From 07a2f9c762efb3be3a29e2e8cc7004d4164cc9d8 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 22 十二月 2025 20:15:58 +0800
Subject: [PATCH] 修改了对应代码
---
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 261 insertions(+), 14 deletions(-)
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
index e2b02f4..90cc40f 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -2,26 +2,34 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ArchiveCategory;
import com.ruoyi.domain.ArchiveRecords;
-import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.domain.DocumentMaterials;
-import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.*;
import com.ruoyi.mapper.DocumentMaterialsMapper;
-import com.ruoyi.service.IArchiveCategoryService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.util.ErrorcodeExceptionextends;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
-
+/**
+ * 銆愭枃浠舵潗鏂欑患鍚堜俊鎭�慡ervice涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2025-07-26
+ */
@Service
public class DocumentMaterialsServiceImpl extends ServiceImpl<DocumentMaterialsMapper, DocumentMaterials> implements IDocumentMaterialsService {
private LambdaQueryWrapper<DocumentMaterials> buildCondition(DocumentMaterials documentMaterials){
@@ -35,9 +43,14 @@
.like(!StringUtils.isEmpty(documentMaterials.getPublicity()), DocumentMaterials::getPublicity, documentMaterials.getPublicity())
.like(!StringUtils.isEmpty(documentMaterials.getRetentionPeriod()), DocumentMaterials::getRetentionPeriod, documentMaterials.getRetentionPeriod())
.like(!StringUtils.isEmpty(documentMaterials.getSecurityLevel()), DocumentMaterials::getSecurityLevel, documentMaterials.getSecurityLevel())
+ .like(!StringUtils.isEmpty(documentMaterials.getTitle()), DocumentMaterials::getTitle, documentMaterials.getTitle())
+
+
.eq(documentMaterials.getDate()!=null, DocumentMaterials::getDate, documentMaterials.getDate())
- .eq(documentMaterials.getRecordId()!=null, DocumentMaterials::getRecordId, documentMaterials.getRecordId());
-// .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber())
+ .eq(documentMaterials.getRecordId()!=null, DocumentMaterials::getRecordId, documentMaterials.getRecordId())
+ .eq(documentMaterials.getPageNumber()!=null, DocumentMaterials::getPageNumber, documentMaterials.getPageNumber());
+
+ // .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber())
// .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber())
// .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId());
// // .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation())
@@ -104,6 +117,17 @@
}
@Override
+ public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id) {
+
+ return this.baseMapper.getDocumentMaterialsvoLarge(Math.toIntExact(id));
+ }
+
+ @Override
+ public List<DocumentMaterialsFileList> selectDocumentMaterialsFileList(Long id) {
+ return this.baseMapper.getDocumentMaterialsFileList(Math.toIntExact(id));
+ }
+
+ @Override
public int insertDocumentMaterials(DocumentMaterials documentMaterials) {
LocalDateTime time = LocalDateTime.now();
@@ -130,9 +154,66 @@
}
@Override
- public int updateDocumentMaterials(DocumentMaterials documentMaterials) {
+ public List<DocumentMaterials> selectDocumentMaterialsByIds(Long[] ids) {
+ // 鑾峰彇褰撳墠鐢ㄦ埛ID
+ Long userid = SecurityUtils.getUserId();
- boolean result = updateById(documentMaterials);
+ // 鍒涘缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+
+ // 鏍规嵁ids鏌ヨ
+ lambdaQueryWrapper.in(DocumentMaterials::getMaterialId, Arrays.asList(ids));
+ lambdaQueryWrapper.orderByAsc(DocumentMaterials::getPageNumber);
+ // 濡傛灉涓嶆槸绠$悊鍛橈紝闇�瑕佽�冭檻鏉冮檺杩囨护锛堝彲鏍规嵁瀹為檯鏉冮檺闇�姹傝皟鏁达級
+ if (userid != 1) {
+ // 杩欓噷鍙互娣诲姞鏉冮檺鐩稿叧鐨勮繃婊ゆ潯浠�
+ }
+
+ List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper);
+ return beanRecords;
+ }
+
+ @Override
+ public int updateDocumentMaterials(DocumentMaterials documentMaterials) {
+ boolean result = false;
+ try {
+ // 浣跨敤LambdaUpdateWrapper鏋勯�犳洿鏂版潯浠讹紝纭繚null鍊间篃鑳芥洿鏂板埌鏁版嵁搴�
+ LambdaUpdateWrapper<DocumentMaterials> updateWrapper = new LambdaUpdateWrapper<>();
+ updateWrapper.eq(DocumentMaterials::getMaterialId, documentMaterials.getMaterialId());
+
+ // 鏄庣‘璁剧疆闇�瑕佹洿鏂扮殑瀛楁
+ updateWrapper.set(DocumentMaterials::getFileNumber, documentMaterials.getFileNumber());
+ updateWrapper.set(DocumentMaterials::getDocumentNumber, documentMaterials.getDocumentNumber());
+ updateWrapper.set(DocumentMaterials::getCreator, documentMaterials.getCreator());
+ updateWrapper.set(DocumentMaterials::getTitle, documentMaterials.getTitle());
+ updateWrapper.set(DocumentMaterials::getDate, documentMaterials.getDate());
+ updateWrapper.set(DocumentMaterials::getPageNumber, documentMaterials.getPageNumber()); // 鍏佽鏇存柊涓簄ull
+ updateWrapper.set(DocumentMaterials::getPageOrder, documentMaterials.getPageOrder());
+ updateWrapper.set(DocumentMaterials::getStage, documentMaterials.getStage());
+ updateWrapper.set(DocumentMaterials::getPublicity, documentMaterials.getPublicity());
+ updateWrapper.set(DocumentMaterials::getIsAttachment, documentMaterials.getIsAttachment());
+ updateWrapper.set(DocumentMaterials::getIsDiagram, documentMaterials.getIsDiagram());
+ updateWrapper.set(DocumentMaterials::getRetentionPeriod, documentMaterials.getRetentionPeriod());
+ updateWrapper.set(DocumentMaterials::getSecurityLevel, documentMaterials.getSecurityLevel());
+ updateWrapper.set(DocumentMaterials::getIsSensitive, documentMaterials.getIsSensitive());
+ updateWrapper.set(DocumentMaterials::getIsCanceled, documentMaterials.getIsCanceled());
+ updateWrapper.set(DocumentMaterials::getFormat, documentMaterials.getFormat());
+ updateWrapper.set(DocumentMaterials::getSizeType, documentMaterials.getSizeType());
+ updateWrapper.set(DocumentMaterials::getHorizontalResolution, documentMaterials.getHorizontalResolution());
+ updateWrapper.set(DocumentMaterials::getVerticalResolution, documentMaterials.getVerticalResolution());
+ updateWrapper.set(DocumentMaterials::getWidth, documentMaterials.getWidth());
+ updateWrapper.set(DocumentMaterials::getHeight, documentMaterials.getHeight());
+ updateWrapper.set(DocumentMaterials::getFileSize, documentMaterials.getFileSize());
+ updateWrapper.set(DocumentMaterials::getAttachmentHistoryNumbers, documentMaterials.getAttachmentHistoryNumbers());
+ updateWrapper.set(DocumentMaterials::getRemarks, documentMaterials.getRemarks());
+ updateWrapper.set(DocumentMaterials::getVisible, documentMaterials.getVisible());
+ updateWrapper.set(DocumentMaterials::getFileStyle, documentMaterials.getFileStyle());
+ // 鎵ц鏇存柊鎿嶄綔
+ result = update(updateWrapper);
+ } catch (Exception e) {
+ System.out.println(e);
+ throw new ErrorcodeExceptionextends(500, "鍚屼竴涓鍗峰唴锛屼笉鍏佽椤电爜閲嶅锛�");
+ }
if(result)
return 1;
else
@@ -154,27 +235,30 @@
}
@Override
- public Long getFiNum(Long pageNumber) {
- return this.baseMapper.getFileNumber(pageNumber);
+ public Long getFiNum(Long pageNumber, Long recordId) {
+ return this.baseMapper.getFileNumber(pageNumber, recordId)+1;
}
@Override
- public int updateByPageNumber(Long pageNumber, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format) {
+ public int updateByPageNumber(Long pageNumber, String sizeType, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format, Long recordId) {
//鏍规嵁pageNumber鎷垮埌title锛岀劧鍚庤绠梡ageOrder
LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(recordId!=null, DocumentMaterials::getRecordId, recordId);
lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber);
List<DocumentMaterials> records = list(lqw);
+
+ //璁$畻pageOrder
Long pageOrder = 1L;
if(pageNumber.equals(1))
pageOrder = 1L;
else {
- Long maxPOrder = this.baseMapper.getMaxPageOrder(records.get(0).getTitle(), pageNumber, records.get(0).getStage());
+ Long maxPOrder = this.baseMapper.getMaxPageOrder(records.get(0).getTitle(), pageNumber, records.get(0).getStage(), recordId);
if (maxPOrder != null)
pageOrder = maxPOrder + 1;
}
- this.baseMapper.updateInfoByPageNumber(pageNumber, fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format);
+ this.baseMapper.updateInfoByPageNumber(pageNumber, sizeType,fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format, recordId);
return 0;
}
@@ -183,4 +267,167 @@
public List<DocumentMaterialsVo> findArchMInfo(String recordId) {
return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId));
}
+
+ @Override
+ public List<DocumentMaterialFileStyle> findFileStyleInfo(int recordId) {
+ return this.baseMapper.getFileStyleInfo(recordId);
+ }
+
+ @Override
+ public AjaxResult importExcel(MultipartFile file, String recordId) {
+ ExcelUtil<DocumentMaterialFileSmallVo> util = new ExcelUtil<>(DocumentMaterialFileSmallVo.class);
+ List<DocumentMaterialFileSmallVo> dataList = null;
+ try {
+ dataList = util.importExcel(file.getInputStream());
+ } catch (Exception e) {
+ throw new RuntimeException("娌℃湁鎸夌収瑙勫垯瀵煎叆鏁版嵁");
+ }
+
+ assert dataList != null;
+
+ for (DocumentMaterialFileSmallVo archiveCategory : dataList) {
+ // physcialService.mySave(physcial);
+ DocumentMaterials documentMaterials = new DocumentMaterials();
+ BeanUtils.copyProperties(archiveCategory, documentMaterials);
+ documentMaterials.setRecordId(Long.parseLong(recordId));
+ documentMaterials.setVisible(1);
+ this.insertDocumentMaterials(documentMaterials);
+ }
+
+ return AjaxResult.success(); }
+
+ @Override
+ public DocumentMaterials selectByPageNumber(Long pageNumber, Integer recordId) {
+ LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber);
+ lqw.eq(recordId!=null, DocumentMaterials::getRecordId, recordId);
+ List<DocumentMaterials> ls = list(lqw);
+ if(!ls.isEmpty())
+ return ls.get(0);
+ else
+ return null;
+ }
+
+ @Override
+ public boolean isPageNumberIslegal(Integer recordId) {
+ return this.baseMapper.isPageNumberLegal(recordId);
+ }
+
+ @Override
+ public int getFileCount(Integer recordId) {
+ return this.baseMapper.getCount(recordId);
+ }
+
+ @Override
+ public AjaxResult addMiddleRecordsByPageNumbers(Long recordId, Long maxPageNumber) {
+ try {
+ // 鑾峰彇鎸囧畾recordId涓嬬殑鎵�鏈夎褰曪紝鎸夐〉鍙峰崌搴忔帓鍒�
+ LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(DocumentMaterials::getRecordId, recordId);
+ lqw.ne(DocumentMaterials::getFileStyle, "鍏朵粬鏉愭枡");
+ lqw.orderByAsc(DocumentMaterials::getPageNumber);
+ List<DocumentMaterials> records = this.list(lqw);
+
+ if (records == null || records.isEmpty()) {
+ return AjaxResult.success("娌℃湁鎵惧埌鎸囧畾璁板綍");
+ }
+
+ List<DocumentMaterials> middleRecords = new ArrayList<>();
+
+ // 閬嶅巻璁板綍锛屾壘鍑洪渶瑕佹坊鍔犱腑闂撮〉鍙风殑浣嶇疆
+ for (int i = 0; i < records.size() - 1; i++) {
+ DocumentMaterials currentRecord = records.get(i);
+ DocumentMaterials nextRecord = records.get(i + 1);
+
+ long currentPage = currentRecord.getPageNumber();
+ long nextPage = nextRecord.getPageNumber();
+
+ // 濡傛灉褰撳墠椤靛彿鍜屼笅涓�椤靛彿涔嬮棿鏈夐棿闅�
+ if (nextPage - currentPage > 1) {
+ // 娣诲姞涓棿椤靛彿鐨勮褰曪紝淇℃伅涓庡綋鍓嶈褰曚繚鎸佷竴鑷�
+ for (long page = currentPage + 1; page < nextPage; page++) {
+ DocumentMaterials newRecord = new DocumentMaterials();
+ // 澶嶅埗褰撳墠璁板綍鐨勬墍鏈夊睘鎬�
+ BeanUtils.copyBeanProp(newRecord, currentRecord);
+ // 璁剧疆鏂扮殑椤靛彿
+ newRecord.setPageNumber(page);
+ // 娓呴櫎ID锛岀‘淇濇槸鏂拌褰�
+ newRecord.setMaterialId(null);
+ // 璁剧疆鍒涘缓鏃堕棿
+ newRecord.setCreatedAt(new Date());
+ // 閲嶇疆鏂囦欢鏉愭枡搴忓彿涓簄ull锛岃绯荤粺鑷姩鐢熸垚
+ newRecord.setFileNumber(null);
+ // 閲嶇疆椤垫涓簄ull锛岃绯荤粺鑷姩鐢熸垚
+ newRecord.setPageOrder(null);
+ // 閲嶇疆鍥惧儚鐩稿叧瀛楁锛屼互渚夸笂浼犳枃浠舵椂鏇存柊
+ newRecord.setSizeType(null);
+ newRecord.setWidth(null);
+ newRecord.setHeight(null);
+ newRecord.setHorizontalResolution(null);
+ newRecord.setVerticalResolution(null);
+ newRecord.setFileSize(null);
+ newRecord.setFormat(null);
+ newRecord.setUrl(null);
+ //涓嶅湪鍓嶇鏄剧ず
+ newRecord.setVisible(0);
+ // 娣诲姞鍒颁腑闂磋褰曞垪琛�
+ middleRecords.add(newRecord);
+ }
+ }
+ }
+
+ // 澶勭悊鏈�鍚庝竴鏉¤褰曞埌maxPageNumber涔嬮棿鐨勯棿闅�
+ DocumentMaterials lastRecord = records.get(records.size() - 1);
+ long lastPage = lastRecord.getPageNumber();
+
+ if (maxPageNumber > lastPage) {
+ // 娣诲姞浠巐astPage+1鍒癿axPageNumber涔嬮棿鐨勪腑闂磋褰�
+ for (long page = lastPage + 1; page <= maxPageNumber; page++) {
+ DocumentMaterials newRecord = new DocumentMaterials();
+ // 澶嶅埗鏈�鍚庝竴鏉¤褰曠殑鎵�鏈夊睘鎬�
+ BeanUtils.copyBeanProp(newRecord, lastRecord);
+ // 璁剧疆鏂扮殑椤靛彿
+ newRecord.setPageNumber(page);
+ // 娓呴櫎ID锛岀‘淇濇槸鏂拌褰�
+ newRecord.setMaterialId(null);
+ // 璁剧疆鍒涘缓鏃堕棿
+ newRecord.setCreatedAt(new Date());
+ // 閲嶇疆鏂囦欢鏉愭枡搴忓彿涓簄ull锛岃绯荤粺鑷姩鐢熸垚
+ newRecord.setFileNumber(null);
+ // 閲嶇疆椤垫涓簄ull锛岃绯荤粺鑷姩鐢熸垚
+ newRecord.setPageOrder(null);
+ // 閲嶇疆鍥惧儚鐩稿叧瀛楁锛屼互渚夸笂浼犳枃浠舵椂鏇存柊
+ newRecord.setSizeType(null);
+ newRecord.setWidth(null);
+ newRecord.setHeight(null);
+ newRecord.setHorizontalResolution(null);
+ newRecord.setVerticalResolution(null);
+ newRecord.setFileSize(null);
+ newRecord.setFormat(null);
+ newRecord.setUrl(null);
+ // 娣诲姞鍒颁腑闂磋褰曞垪琛�
+ middleRecords.add(newRecord);
+ }
+ }
+
+ // 鎵归噺淇濆瓨涓棿璁板綍
+ if (!middleRecords.isEmpty()) {
+ this.saveBatch(middleRecords);
+ return AjaxResult.success("鎴愬姛娣诲姞涓棿璁板綍", "娣诲姞鏁伴噺锛�" + middleRecords.size());
+ } else {
+ return AjaxResult.success("娌℃湁闇�瑕佹坊鍔犵殑涓棿璁板綍");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return AjaxResult.error("娣诲姞涓棿璁板綍澶辫触锛�" + e.getMessage());
+ }
+ }
+
+ @Override
+ public Boolean judgeInfo(int recordId) {
+
+ return this.baseMapper.judgeArchiveInfo(recordId);
+ }
}
+
+
--
Gitblit v1.9.1