Quellcode durchsuchen

Merge remote-tracking branch 'origin/test-merge' into test-merge

LHB vor 1 Tag
Ursprung
Commit
fea3ded3cf

+ 2 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/VolumeDto4.java

@@ -13,4 +13,6 @@ public class VolumeDto4 {
     private Integer filePage;
     //是否已被分卷 0否 1是
     private Integer isCheck=0;
+
+    private Long archiveId;
 }

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/InterimPaymentCertificate.java

@@ -94,6 +94,6 @@ public class InterimPaymentCertificate implements  DataModel{
             BigDecimal payRatioBd = currentPeriodEndPayBd.multiply(new BigDecimal(100)).divide(BaseUtils.str2BigDecimal(this.contractAmount), 2, RoundingMode.HALF_UP);
             this.payRatio = payRatioBd.toString();
         }
-        this.revisedTotal =BaseUtils.str2BigDecimal(revisedAmount).subtract(BaseUtils.str2BigDecimal(contractAmount)).toString();
+        //this.revisedTotal =BaseUtils.str2BigDecimal(revisedAmount).subtract(BaseUtils.str2BigDecimal(contractAmount)).toString();
     }
 }

+ 44 - 12
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -5697,11 +5697,13 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 	public Boolean updateArchivePage(List<Long> archiveIds) {
 		for (Long archiveId : archiveIds) {
 			ArchivesAuto archivesAuto = this.getById(archiveId);
-			List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(archiveId+"", null);
-			archivesAuto.setFileN(files.size());
-			archivesAuto.setPageN(files.stream().mapToInt(ArchiveFile::getFilePage).sum());
-			archivesAuto.setColourStatus(2);
-			baseMapper.updateById(archivesAuto);
+			List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(archiveId+"", "");
+			if(!files.isEmpty()){
+				archivesAuto.setFileN(files.size());
+				archivesAuto.setPageN(files.stream().mapToInt(ArchiveFile::getFilePage).sum());
+				archivesAuto.setColourStatus(2);
+				baseMapper.updateById(archivesAuto);
+			}
 		}
 		return true;
 	}
@@ -5714,7 +5716,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		updateIds.add(archivesAuto.getId());
 		if(!dto.getList().isEmpty()){
 			archivesAuto.setIsVolume(1);
-			archivesAuto.setVolumeIds(null);
+			archivesAuto.setVolumeIds("");
 			for (SaveVolumeDto1 saveVolumeDto1 : dto.getList()) {
 				Long archiveId;
 				if(saveVolumeDto1.getId()==null){
@@ -5727,11 +5729,34 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 					baseMapper.insert(auto);
 				}else {
 					archiveId=saveVolumeDto1.getId();
+					ArchivesAuto auto = this.getById(archiveId);
+					auto.setName(saveVolumeDto1.getArchiveName());
+					baseMapper.updateById(auto);
 				}
 				updateIds.add(archiveId);
-				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = ?, is_volume = 1 WHERE id IN (?)";
-				jdbcTemplate.update(update, archiveId, dto.getArchiveId(), saveVolumeDto1.getFileIds());
+				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = ?, is_volume = 1 WHERE id IN (" + saveVolumeDto1.getFileIds() + ")";
+				jdbcTemplate.update(update, archiveId, dto.getArchiveId());
 				archivesAuto.setVolumeIds(archivesAuto.getVolumeIds()+archiveId+",");
+				List<ArchiveFile> files1 = archiveFileClient.getArchiveFileByArchivesId(archiveId + "", "");
+				if(!files1.isEmpty()){
+					List<Integer> sorts = files1.stream()
+							.map(file -> Optional.ofNullable(file.getSort()).orElse(0))
+							.sorted()
+							.collect(Collectors.toList());
+					List<Integer> sorts1 = files1.stream()
+							.map(file -> Optional.ofNullable(file.getArchiveSort()).orElse(0))
+							.sorted()
+							.collect(Collectors.toList());
+					String[] fileIds = saveVolumeDto1.getFileIds().split(",");
+					if(sorts.size()==fileIds.length){
+						if(fileIds.length>0){
+							for (int i = 0; i < fileIds.length; i++) {
+								String updateSql = "UPDATE u_archive_file SET sort = ? ,archive_sort=? WHERE id = ?";
+								jdbcTemplate.update(updateSql, sorts.get(i), sorts1.get(i),fileIds[i]);
+							}
+						}
+					}
+				}
 			}
 			archivesAuto.setVolumeIds(archivesAuto.getVolumeIds().substring(0,archivesAuto.getVolumeIds().length()-1));
 		}
@@ -5755,12 +5780,18 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				}else {
 					auto.setVolumeIds(auto.getVolumeIds().replace(volumeId+",",""));
 				}
-				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = '', is_volume = 0 WHERE archive_id = ?";
+				if(auto.getVolumeIds().startsWith(",")){
+					auto.setVolumeIds(auto.getVolumeIds().substring(1));
+				}
+				if(auto.getVolumeIds().endsWith(",")){
+					auto.setVolumeIds(auto.getVolumeIds().substring(0,auto.getVolumeIds().length()-1));
+				}
+				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = null, is_volume = 0 WHERE archive_id = ?";
 				jdbcTemplate.update(update, archiveId, volumeId);
 			}
 			baseMapper.updateById(auto);
 			this.deleteLogic(Arrays.asList(volumeId));
-			this.updateArchivePage(Arrays.asList(archiveId));
+			this.updateArchivePage(Arrays.asList(archiveId,volumeId));
 		}
 		return true;
 	}
@@ -5768,7 +5799,8 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 	@Override
 	public boolean backVolume(Long fileId){
 		ArchiveFile archiveFile = archiveFileClient.getArchiveFileById(fileId);
-		List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(archiveFile.getArchiveId()+"",null);
+		Long id=archiveFile.getArchiveId();
+		List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(archiveFile.getArchiveId()+"","");
 		if(files.size()<=1){
 			throw new ServiceException("回退失败");
 		}
@@ -5776,7 +5808,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 			archiveFile.setArchiveId(archiveFile.getOldArchiveId());
 			archiveFile.setIsVolume(0);
 			archiveFileClient.updateById2(archiveFile);
-			this.updateArchivePage(Arrays.asList(archiveFile.getArchiveId(),archiveFile.getOldArchiveId()));
+			this.updateArchivePage(Arrays.asList(id,archiveFile.getArchiveId()));
 		}
 		return true;
 	}

+ 16 - 22
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -515,28 +515,22 @@
         WHERE uaa.project_id = #{projectId} and uaa.is_deleted = 0
     </select>
     <select id="getAllArchiveFileByContractTypeSummary" resultType="java.util.Map">
-        select sum(a.key1 + a.key11) key1,sum(a.key2 + a.key12) key2,sum(a.key3 +a.key13) key3 ,a.key4,a.key5,a.key6 from (
-          SELECT
-              sum(uaf.source_type = 1 and matc.tree_code is null) key4,
-              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code is null) key3,
-              sum(uaf.source_type = 1 and matc.tree_code = 'S') key5,
-              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code = 'S') key2,
-              sum(uaf.source_type = 1 and matc.tree_code = 'C') key6,
-              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code = 'C') key1,
-              sum(mci.id is not null and mci.contract_type = 1) key11,
-              sum(mci.id is not null and mci.contract_type = 2) key12,
-              sum(mci.id is not null and mci.contract_type not in(1,2)) key13
-
-          FROM
-              u_archive_file uaf
-                  LEFT JOIN m_archive_tree_contract matc ON uaf.node_id = matc.id
-                  left join m_contract_info mci on matc.tree_code = mci.id and mci.is_deleted = 0
-          WHERE
-              uaf.project_id = #{projectId}
-            AND matc.is_deleted = 0
-            AND uaf.is_deleted = 0
-            AND ( uaf.is_auto_file IS NULL OR uaf.is_auto_file != 1 )
-      ) a
+        SELECT
+            sum(uaf.source_type = 1 and ((matc.tree_code is null or matc.tree_code = 'null') or (mci.id is not null and mci.contract_type not in(1,2)))) key4,
+            sum((uaf.source_type != 1 or uaf.source_type is null ) and ((matc.tree_code is null or matc.tree_code = 'null') or (mci.id is not null and mci.contract_type not in(1,2))) ) key3,
+            sum(uaf.source_type = 1 and (matc.tree_code = 'S' or (mci.id is not null and mci.contract_type = 2))) key5,
+            sum((uaf.source_type != 1 or uaf.source_type is null ) and (matc.tree_code = 'S' or (mci.id is not null and mci.contract_type = 2)) ) key2,
+            sum(uaf.source_type = 1 and (matc.tree_code = 'C' or (mci.id is not null and mci.contract_type = 1)) ) key6,
+            sum((uaf.source_type != 1 or uaf.source_type is null ) and (matc.tree_code = 'C' or (mci.id is not null and mci.contract_type = 1))) key1
+        FROM
+            u_archive_file uaf
+                LEFT JOIN m_archive_tree_contract matc ON uaf.node_id = matc.id
+                left join m_contract_info mci on matc.tree_code = mci.id and mci.is_deleted = 0
+        WHERE
+            uaf.project_id = #{projectId}
+          AND matc.is_deleted = 0
+          AND uaf.is_deleted = 0
+          AND ( uaf.is_auto_file IS NULL OR uaf.is_auto_file != 1 )
     </select>
     <select id="getAllArchiveFileByContractTypeCount" resultType="java.lang.Integer">
         SELECT count(0) `count`

+ 14 - 18
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -438,7 +438,7 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
     public List<VolumeDto1> selectVolumeAfter(Long archiveId) {
         List<VolumeDto1> list = new ArrayList<>();
         ArchivesAuto archivesAuto = archiveAutoClient.getArchiveById(archiveId);
-        if(archivesAuto.getIsVolume()==1&&StringUtils.isEmpty(archivesAuto.getVolumeIds())){
+        if(archivesAuto.getIsVolume()==1&&StringUtils.isNotEmpty(archivesAuto.getVolumeIds())){
             String volumeIds = archivesAuto.getVolumeIds();
             String[] archivesAutoIds = volumeIds.split(",");
             for (String autoId : archivesAutoIds) {
@@ -468,30 +468,26 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
     public VolumeDto3 selectVolumeBefore(Long archiveId,Integer type) {
         ArchivesAuto auto = archiveAutoClient.getArchiveById(archiveId);
         VolumeDto3 dto=new VolumeDto3();
-        if(auto.getIsVolume()==1&&StringUtils.isEmpty(auto.getVolumeIds())){
-            String volumeIds = auto.getVolumeIds();
-            String[] archivesAutoIds = volumeIds.split(",");
+        //查询原案卷
+        if(type==1){
             String sql="select id,file_number,file_name,file_time,duty_user,file_page from u_archive_file where archive_id="+auto.getId()+" and is_deleted=0 order by archive_sort,sort,sort_num,create_time";
             List<VolumeDto4> dto2s = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(VolumeDto4.class));
-            dto.getList().addAll(dto2s);
-            if(type==2){
-                for (String autoId : archivesAutoIds) {
-                    String sql1="select id,file_number,file_name,file_time,duty_user,file_page from u_archive_file where archive_id="+autoId+" and is_deleted=0 order by archive_sort,sort,sort_num,create_time";
-                    List<VolumeDto4> dto2s1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(VolumeDto4.class));
-                    dto2s1.stream().forEach(dto2 -> dto2.setIsCheck(1));
-                    dto.getList().addAll(dto2s);
-                }
-            }
             dto.setId(auto.getId());
             dto.setName(auto.getName());
             dto.setTotal(auto.getPageN());
+            dto.setList(dto2s);
         }else {
-            dto.setId(auto.getId());
-            dto.setName(auto.getName());
-            String sql="select id,file_number,file_name,file_time,duty_user,file_page from u_archive_file where archive_id="+auto.getId()+" and is_deleted=0 order by archive_sort,sort,sort_num,create_time";
+            String archiveIds=auto.getId().toString();
+            //查询所有案卷
+            if(StringUtils.isNotEmpty(auto.getVolumeIds())){
+                archiveIds=archiveIds+","+auto.getVolumeIds();
+            }
+            String sql="select id,file_number,file_name,file_time,duty_user,file_page,archive_id from u_archive_file where archive_id in ("+archiveIds+") and is_deleted=0 order by archive_sort,sort,sort_num,create_time";
             List<VolumeDto4> dto2s = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(VolumeDto4.class));
-            dto.setList(dto2s);
-            dto.setTotal(auto.getPageN());
+            if(StringUtils.isNotEmpty(auto.getVolumeIds())){
+                dto2s.stream().filter(item ->auto.getVolumeIds().contains(item.getArchiveId().toString())).forEach(item ->item.setIsCheck(1));
+            }
+           dto.setList(dto2s);
         }
         return dto;
     }

+ 61 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/InformationImportRecordController.java

@@ -5,10 +5,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.spire.xls.CellRange;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Shape;
+import org.apache.poi.ss.util.CellAddress;
+import org.apache.poi.xssf.usermodel.XSSFComment;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jetbrains.annotations.NotNull;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -51,10 +59,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
+import java.io.*;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -195,6 +200,7 @@ public class InformationImportRecordController extends BladeController {
             String path = base + id + filename.substring(filename.lastIndexOf("."));
 
             Files.write(Paths.get(path), IOUtils.toByteArray(is));
+            String name = getFileNameBySheet(path);
 
             // 创建记录
             InformationImportRecord record = new InformationImportRecord();
@@ -202,10 +208,11 @@ public class InformationImportRecordController extends BladeController {
             record.setNodeId(nodeId);
             record.setContractId(contractId);
             record.setClassify(classify);
-            record.setFileName(filename.substring(0, filename.lastIndexOf(".")));
+            record.setFileName(name == null ? filename.substring(0, filename.lastIndexOf(".")) : name);
             record.setFilePath(path);
             record.setCreateTime(now);
             record.setCreateUser(AuthUtil.getUserId());
+            record.setRemark("::" + filename);
             records.add(record);
         }
         informationImportRecordService.saveBatch(records);
@@ -213,6 +220,29 @@ public class InformationImportRecordController extends BladeController {
         return R.data(true);
     }
 
+    private static String getFileNameBySheet(String excelPath) {
+        // 解析excel, 读取excel中的批注
+        try (InputStream is = Files.newInputStream(Paths.get(excelPath));XSSFWorkbook workbook = new XSSFWorkbook(is);) {
+            for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
+                XSSFSheet sheet = workbook.getSheetAt(i);
+                Map<CellAddress, XSSFComment> map = sheet.getCellComments();
+                for (Map.Entry<CellAddress, XSSFComment> entry : map.entrySet()) {
+                    XSSFComment value = entry.getValue();
+                    if (value != null && value.getString() != null) {
+                        String string = value.getString().getString();
+                        if (string != null && string.contains("》")) {
+                            return string.replaceAll("\r\n", "");
+                        }
+                    }
+                }
+            }
+            return null;
+        } catch (Exception e) {
+            logger.error("获取文件名失败", e);
+            return null;
+        }
+    }
+
     /**
      * 初始化: 匹配节点,创建子节点
      * @param id 记录ID
@@ -282,20 +312,42 @@ public class InformationImportRecordController extends BladeController {
                 }
             }
             if (record.getTargetId() != null && record.getTargetId() > 0) {
-                informationImportRecordService.updateProcess(record.getId(), 20, 1, null, record.getUpdateTime());
+                informationImportRecordService.update(Wrappers.<InformationImportRecord>lambdaUpdate().eq(InformationImportRecord::getId, record.getId())
+                        .set(InformationImportRecord::getTargetId, record.getTargetId()).set(InformationImportRecord::getProcess, 20));
                 return;
             }
         }
 
-        List<WbsTreePrivate> query = jdbcTemplate.query("select * from m_wbs_tree_private where is_deleted = 0 and node_type = 6 and project_id = " + target.getProjectId() + " and node_name like '" + lastName + "' limit 1",
+        List<WbsTreePrivate> query = jdbcTemplate.query("select * from m_wbs_tree_private where is_deleted = 0 and project_id = " + target.getProjectId() + " and node_name like '" + lastName + "'",
                 new BeanPropertyRowMapper<>(WbsTreePrivate.class));
         if (query.isEmpty()) {
             informationImportRecordService.updateProcess(record.getId(), null, 3, "节点未找到-后管::" + target.getFullName(), record.getUpdateTime());
             return;
         }
+        WbsTreePrivate wbsTreePrivate = null;
+        List<WbsTreePrivate> tables = null;
+        for (WbsTreePrivate treePrivate : query) {
+            tables = jdbcTemplate.query("select * from m_wbs_tree_private where is_deleted = 0 and type in (2,10) and p_id = " + treePrivate.getPKeyId(), new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+            if (tables.isEmpty()) {
+                tables = jdbcTemplate.query("select * from m_wbs_tree_private where is_deleted = 0 and type in (2,10) and parent_id = " + treePrivate.getId() + " and project_id = " + target.getProjectId(), new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+            }
+            if (!tables.isEmpty()) {
+                wbsTreePrivate = treePrivate;
+                break;
+            }
+            if (treePrivate.getNodeType() != null && treePrivate.getNodeType() == 6) {
+                wbsTreePrivate = treePrivate;
+            }
+        }
+        if (wbsTreePrivate == null) {
+            informationImportRecordService.updateProcess(record.getId(), null, 3, "节点未找到-后管::" + target.getFullName(), record.getUpdateTime());
+            return;
+        }
+        if (tables.isEmpty()) {
+            informationImportRecordService.updateProcess(record.getId(), null, 3, "表单未找到-后管::" + wbsTreePrivate.getNodeName(), record.getUpdateTime());
+            return;
+        }
         informationImportRecordService.updateProcess(record.getId(), 7, 1, null, record.getUpdateTime());
-        WbsTreePrivate wbsTreePrivate = query.get(0);
-        List<WbsTreePrivate> tables = jdbcTemplate.query("select * from m_wbs_tree_private where is_deleted = 0 and p_id = " + wbsTreePrivate.getPKeyId(), new BeanPropertyRowMapper<>(WbsTreePrivate.class));
 
         // 在target节点下创建子节点及表单
         Long parentPKeyId = SnowFlakeUtil.getId();

+ 34 - 14
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -16,7 +16,7 @@ import lombok.SneakyThrows;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xssf.usermodel.*;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -633,6 +633,13 @@ public class WbsTreeContractController extends BladeController {
             if(originalFileName.startsWith("》")){
                 originalFileName=originalFileName.substring(1);
             }
+            XSSFSheet sheetAt = mainWorkbook.getSheetAt(0);
+            if (sheetAt != null) {
+                XSSFRow row = sheetAt.createRow(0);
+                XSSFCell cell = row.createCell(0);
+                // 设置批注
+                setCommentToFirstCell(mainWorkbook, sheetAt, cell, originalFileName);
+            }
             try {
                 // 1. 先编码所有字符
                 String fullyEncoded = URLEncoder.encode(originalFileName, StandardCharsets.UTF_8.name());
@@ -643,25 +650,19 @@ public class WbsTreeContractController extends BladeController {
                         .replaceAll("%2B", "+")       // 解码+号
                         .replaceAll("%2F", "/")       // 解码/号
                         .replaceAll("%23", "#")       // 解码#号
-                        .replaceAll("%7E", "~")       // 解码~号
-                        // - 号不需要处理,URL编码不会编码-
-                        ;
+                        .replaceAll("%7E", "~");      // 解码~号
 
                 // 3. 设置响应头
                 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                 response.setHeader("Content-Disposition",
-                        "attachment; filename=\"" + partiallyDecoded + "\"; ");
+                        "attachment; filename=\"" + partiallyDecoded + "\"; filename*=UTF-8''" + fullyEncoded);
 
             } catch (Exception e) {
-                // 备用方案:简单清理
-                String safeFileName = originalFileName
-                        .replaceAll("[\\\\:*?\"<>|]", "_")
-                        .trim();
+                // 备用方案
+                String safeFileName = originalFileName.replaceAll("[\\\\:*?\"<>|]", "_").trim();
                 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-                response.setHeader("Content-Disposition",
-                        "attachment; filename=\"" + safeFileName + "\"");
+                response.setHeader("Content-Disposition", "attachment; filename=\"" + safeFileName + "\"");
             }
-
             // 写入输出流
             try (ServletOutputStream outputStream = response.getOutputStream()) {
                 mainWorkbook.write(outputStream);
@@ -677,8 +678,27 @@ public class WbsTreeContractController extends BladeController {
             }
         }
     }
-
-
+    public static void setCommentToFirstCell(XSSFWorkbook workbook, XSSFSheet sheet,
+                                             XSSFCell cell, String commentText) {
+        // 创建绘图对象
+        XSSFDrawing drawing = sheet.createDrawingPatriarch();
+
+        // 创建锚点,定位批注框
+        ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();
+        anchor.setCol1(cell.getColumnIndex());      // 起始列
+        anchor.setCol2(cell.getColumnIndex() + 3);  // 结束列(控制宽度)
+        anchor.setRow1(cell.getRowIndex());         // 起始行
+        anchor.setRow2(cell.getRowIndex() + 2);     // 结束行(控制高度)
+
+        // 创建批注
+        Comment comment = drawing.createCellComment(anchor);
+
+        // 设置批注内容
+        comment.setString(new XSSFRichTextString(commentText));
+
+        // 将批注关联到单元格
+        cell.setCellComment(comment);
+    }
     private void addDefaultValue(org.apache.poi.ss.usermodel.Workbook singleSheetWorkbook, String initTableName,String htmlContent,Long pId) {
         if (singleSheetWorkbook == null || initTableName == null) {
             return;

+ 12 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -1236,6 +1236,7 @@ public class ExecutorMeter extends FormulaExecutor {
             //上期期数ID
             Long prePeriodId = null;
             List<ContractMeterPeriod> contractMeterPeriodList =FormEndPayUtil.selectList(contractId);
+            List<Long> idList=new ArrayList<>();
             if(contractMeterPeriodList.size()>0){
                 OptionalInt index=IntStream.range(0, contractMeterPeriodList.size())
                     .filter(i -> contractMeterPeriodList.get(i).getId().equals(periodId))
@@ -1246,6 +1247,11 @@ public class ExecutorMeter extends FormulaExecutor {
                     if(j>0){
                         prePeriodId=contractMeterPeriodList.get(j-1).getId();
                     }
+                    // 获取从开始到目标索引(包含)的所有元素
+                    idList= IntStream.rangeClosed(0, j)
+                            .mapToObj(contractMeterPeriodList::get)
+                            .map(ContractMeterPeriod::getId)
+                            .collect(Collectors.toList());
                 }
             }
             Long finalPrePeriodId = prePeriodId;
@@ -1342,6 +1348,12 @@ public class ExecutorMeter extends FormulaExecutor {
                         }
                          /*计算其它属性值*/
                          ipc.calculate();
+                         //重新计算 合同价及变更总金额_变更总金额,合同价及变更总金额_变更后总金额
+                         //合同价及变更总金额_变更总金额 = 2-8的值累加
+                         BigDecimal sumChangeMoney =InventoryUCUtil.selectChangeMoney(idList,k);
+                         ipc.setRevisedTotal(sumChangeMoney+"");
+                         //合同价及变更总金额_变更后总金额 =合同价及变更总金额_变更总金额+合同价及变更总金额_合同金额
+                         ipc.setRevisedAmount(sumChangeMoney.add(new BigDecimal(ipc.getContractAmount())).toString());
                          //dataList.add(ipc);
                          paymentCertificateMap.put(ch,ipc);
                      }

+ 16 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1401,6 +1401,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 int index = 0;
                 if (resultFormData != null && resultFormData.getValues() != null) {
                     List<ElementData> values = resultFormData.getValues();
+                    if (values.size() == 1 && relyList.size() == 1) {
+                        index = -1;
+                    }
                     int x = 0, y = 0;
                     if (split1.length > 1 && split1[1].contains("_")) {
                         String[] point = split1[1].split("_");
@@ -1421,7 +1424,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 }
                             }
                             resultData = value;
-                            index = i;
+                            if (index > -1) {
+                                index = i;
+                            }
                             break;
                         }
                     }
@@ -1431,6 +1436,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     relyList.forEach(rely -> {
                         FormData formData = map.get(rely);
                         if (formData != null && formData.getValues() != null) {
+                            if (tempIndex == -1) {
+                                for (int i = 0; i < formData.getValues().size(); i++) {
+                                    ElementData elementData = formData.getValues().get(i);
+                                    if ((elementData ==  null || StringUtil.isBlank(elementData.stringValue())) && formData.getInitial() != null && formData.getInitial().size() > i ) {
+                                        elementData = formData.getInitial().get(i);
+                                    }
+                                    data.append(elementData == null || elementData.getValue() == null ? "" : elementData.getValue().toString() + " ,");
+                                }
+                                return;
+                            }
                             if (formData.getValues().size() > tempIndex) {
                                 ElementData elementData = formData.getValues().get(tempIndex);
                                 if ((elementData ==  null || StringUtil.isBlank(elementData.stringValue())) && formData.getInitial() != null && formData.getInitial().size() > tempIndex ) {

+ 19 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/InventoryUCUtil.java

@@ -12,7 +12,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 @Component
@@ -120,6 +124,21 @@ public class InventoryUCUtil {
         return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ChangeInventoryForm.class));
     }
 
+    public static BigDecimal selectChangeMoney(List<Long> idList, String k) {
+        if (idList == null || idList.isEmpty()) {
+            return BigDecimal.ZERO;
+        }
+        String placeholders = String.join(",", Collections.nCopies(idList.size(), "?"));
+        String sql = "select sum(change_money) from s_change_inventory_form where period_id in (" + placeholders + ") and inventory_num=?";
+        List<Object> params = new ArrayList<>();
+        params.addAll(idList);
+        params.add(k);
+        List<BigDecimal> result = jdbcTemplate.query(sql, params.toArray(), (rs, rowNum) -> rs.getBigDecimal(1));
+        BigDecimal sum = result.isEmpty() || result.get(0) == null ? BigDecimal.ZERO : result.get(0);
+        // 四舍五入保留整数
+        return sum.setScale(0, RoundingMode.HALF_UP);
+    }
+
     @Autowired
     public  void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
         InventoryUCUtil.jdbcTemplate = jdbcTemplate;