ソースを参照

Merge remote-tracking branch 'origin/master' into master

yangyj 1 年間 前
コミット
5216610451

+ 5 - 3
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/TaskClient.java

@@ -155,17 +155,19 @@ public interface TaskClient {
     boolean saveFixedFlow(@RequestParam Long fixedFlowId, @RequestParam String fixedName, @RequestParam Long projectId, @RequestParam Long contractId);
 
     @PostMapping(value = "/saveFixedFlowLink")
-    void saveFixedFlowLink(@RequestParam Long fixedFlowId, @RequestParam String name, @RequestParam Integer type, @RequestParam String userIds, @RequestParam Long projectId,
+    void saveFixedFlowLink(@RequestParam Long fixedFlowId, @RequestParam String name, @RequestParam Integer type,
+                           @RequestParam String userIds, @RequestParam Long projectId,
                            @RequestParam Long contractId, @RequestParam Integer sort);
 
     @PostMapping(value = "/updateFixedFlow")
     boolean updateFixedFlow(@RequestParam Long fixedFlowId, @RequestParam String fixedName);
 
     @PostMapping(value = "/updateFixedFlowLink")
-    void updateFixedFlowLink(@RequestParam Long fixedFlowId, @RequestParam String name, @RequestParam Integer type, @RequestParam String userIds, @RequestParam Long projectId,
+    void updateFixedFlowLink(@RequestParam Long fixedFlowId, @RequestParam String name, @RequestParam Integer type,
+                             @RequestParam String userIds, @RequestParam Long projectId,
                              @RequestParam Long contractId, @RequestParam Integer sort);
 
     @PostMapping(value = "/getFixedFlowPage")
-    Page<Map<String, Object>> getFixedFlowPage(@RequestBody org.springblade.meter.dto.PageFixedFlowDTO dto);
+    List<Map<String, Object>> getFixedFlowPage(@RequestBody org.springblade.meter.dto.PageFixedFlowDTO dto);
 
 }

+ 1 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/UpdateFixedFlowDTO.java

@@ -25,7 +25,7 @@ public class UpdateFixedFlowDTO implements Serializable {
     private List<FixedBranch> fixedBranchList;
 
     @Data
-    public class FixedBranch {
+    public static class FixedBranch {
         @ApiModelProperty(value = "流程中的分支任务名称")
         private String name;
         @ApiModelProperty(value = "审批类型,1=垂直、2=平行")

+ 60 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MiddleMeterApplyVO3.java

@@ -0,0 +1,60 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.MiddleMeterApply;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * 中间计量申请表视图实体类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Data
+public class MiddleMeterApplyVO3 {
+
+	@ApiModelProperty(value = "计量单id")
+	private String id;
+
+	@ApiModelProperty(value = "计量单编号")
+	private String meterNumber;
+
+	@ApiModelProperty(value = "工程划分")
+	private String engineerDivide;
+
+	@ApiModelProperty(value = "资料是否齐全:1是0否")
+	private Integer isLinkData;
+
+	@ApiModelProperty(value = "计量金额,应扣回金额就是计量金额")
+	private BigDecimal meterMoney;
+
+	@ApiModelProperty(value = "业务日期")
+	private LocalDate businessDate;
+
+	@ApiModelProperty(value = "距离扣回计量金额日期")
+	private LocalDate deductDate;
+
+
+}

+ 32 - 19
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/TaskClientImpl.java

@@ -206,13 +206,15 @@ public class TaskClientImpl implements TaskClient {
         fixedFlow.setFixedFlowName(fixedName);
         fixedFlow.setProjectId(projectId);
         fixedFlow.setContractId(contractId);
+        fixedFlow.setStatus(1);
+        fixedFlow.setCreateTime(new Date());
         return fixedFlowServiceImpl.save(fixedFlow);
     }
 
     @Override
-    public void saveFixedFlowLink(Long fixedFlowId, String name, Integer type, String userIds, Long projectId, Long contractId, Integer sortBranch) {
+    public void saveFixedFlowLink(Long fixedFlowId, String name, Integer type, String userIds, Long projectId, Long contractId, Integer sort) {
         Map<Long, String> userMap = iUserClient.selectUserAll().stream().filter(f -> ObjectUtil.isNotEmpty(f.getRealName())).collect(Collectors.toMap(User::getId, User::getRealName));
-        int sort = 1;
+        int sortLink = 1;
         for (String userId : userIds.split(",")) {
             FixedFlowLink fixedFlowLink = new FixedFlowLink();
             fixedFlowLink.setFixedFlowId(fixedFlowId);
@@ -221,11 +223,11 @@ public class TaskClientImpl implements TaskClient {
             fixedFlowLink.setFixedFlowLinkUser(Long.parseLong(userId));
             fixedFlowLink.setFixedFlowLinkUserName(userMap.get(Long.parseLong(userId)));
             if (type.equals(1)) {
-                fixedFlowLink.setFixedFlowLinkSort(sort++);
+                fixedFlowLink.setFixedFlowLinkSort(sortLink++);
             }
             fixedFlowLink.setProjectId(projectId);
             fixedFlowLink.setContractId(contractId);
-            fixedFlowLink.setFixedFlowBranchSort(sortBranch);
+            fixedFlowLink.setFixedFlowBranchSort(sort);
             fixedFlowLinkServiceImpl.save(fixedFlowLink);
         }
     }
@@ -236,13 +238,12 @@ public class TaskClientImpl implements TaskClient {
     }
 
     @Override
-    public void updateFixedFlowLink(Long fixedFlowId, String name, Integer type, String userIds, Long projectId, Long contractId, Integer sortBranch) {
-        jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ?", fixedFlowId);
-        this.saveFixedFlowLink(fixedFlowId, name, type, userIds, projectId, contractId, sortBranch);
+    public void updateFixedFlowLink(Long fixedFlowId, String name, Integer type, String userIds, Long projectId, Long contractId, Integer sort) {
+        this.saveFixedFlowLink(fixedFlowId, name, type, userIds, projectId, contractId, sort);
     }
 
     @Override
-    public Page<Map<String, Object>> getFixedFlowPage(PageFixedFlowDTO dto) {
+    public List<Map<String, Object>> getFixedFlowPage(PageFixedFlowDTO dto) {
         Page<FixedFlow> page = new Page<>(dto.getCurrent(), dto.getSize());
         IPage<FixedFlow> fixedFlowsPage = fixedFlowServiceImpl.getBaseMapper().selectPage(page,
                 Wrappers.<FixedFlow>lambdaQuery().eq(FixedFlow::getContractId, dto.getContractId()).eq(FixedFlow::getProjectId, dto.getProjectId()));
@@ -250,29 +251,41 @@ public class TaskClientImpl implements TaskClient {
         List<Long> collect = fixedFlows.stream().map(FixedFlow::getId).collect(Collectors.toList());
         if (collect.size() > 0) {
             List<FixedFlowLink> fixedFlowLinkList = fixedFlowLinkServiceImpl.getBaseMapper().selectList(
-                    Wrappers.<FixedFlowLink>lambdaQuery().in(FixedFlowLink::getFixedFlowId, collect));
-            Map<Long, List<FixedFlowLink>> group = fixedFlowLinkList.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
+                    Wrappers.<FixedFlowLink>lambdaQuery()
+                            .isNotNull(FixedFlowLink::getFixedFlowLink)
+                            .in(FixedFlowLink::getFixedFlowId, collect)
+                            .orderByAsc(FixedFlowLink::getFixedFlowBranchSort)
+                            .orderByAsc(FixedFlowLink::getFixedFlowLinkSort)
+            );
+            Map<Long, List<FixedFlowLink>> group = fixedFlowLinkList.stream()
+                    .collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId,
+                            LinkedHashMap::new,
+                            Collectors.toList()));
+
             List<Map<String, Object>> result = new LinkedList<>();
             for (FixedFlow fixedFlow : fixedFlows) {
                 Map<String, Object> map = new HashMap<>();
                 List<FixedFlowLink> one = group.getOrDefault(fixedFlow.getId(), null);
                 if (one != null) {
-                    Set<String> names = one.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowLink)).keySet();
+                    Set<String> names = one.stream()
+                            .sorted(Comparator.comparingInt(FixedFlowLink::getFixedFlowBranchSort))
+                            .collect(Collectors.toMap(
+                                    FixedFlowLink::getFixedFlowLink,
+                                    FixedFlowLink::getFixedFlowLink,
+                                    (existing, replacement) -> existing,
+                                    LinkedHashMap::new
+                            ))
+                            .keySet();
+
                     map.put("id", fixedFlow.getId());
                     map.put("fixedFlowName", fixedFlow.getFixedFlowName());
                     map.put("linkUserJoinString", StringUtils.join(names, ","));
                 }
                 result.add(map);
             }
-
-            Page<Map<String, Object>> resultMap = new Page<>();
-            resultMap.setCurrent(fixedFlowsPage.getCurrent());
-            resultMap.setSize(fixedFlowsPage.getSize());
-            resultMap.setTotal(fixedFlowsPage.getTotal());
-            resultMap.setRecords(result);
-            return resultMap;
+            return result;
         }
-        return new Page<>();
+        return null;
     }
 
 }

+ 32 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MiddleMeterApplyController.java

@@ -257,4 +257,36 @@ public class MiddleMeterApplyController extends BladeController {
         IPage<WbsFileVO> iPage = middleMeterApplyService.getWbsNodeInfo(dto);
         return R.data(iPage);
     }
+
+    /**
+     * 资料关联台账-分页
+     */
+    @GetMapping("/dataLinkPage")
+    @ApiOperationSupport(order = 14)
+    @ApiOperation(value = "资料关联台账-分页", notes = "传合同id,节点id,计量期id和分页信息")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "contractId", value = "合同id", required = true),
+            @ApiImplicitParam(name = "contractUnitId", value = "节点id", required = true),
+            @ApiImplicitParam(name = "contractPeriodId", value = "合同计量期id", required = true)
+    })
+    public R<IPage<MiddleMeterApplyVO3>> dataLinkPage(MiddleMeterApply middleMeterApply, Query query) {
+        IPage<MiddleMeterApplyVO3> pages = middleMeterApplyService.dataLinkPage(middleMeterApply, query);
+        return R.data(pages);
+    }
+
+    /**
+     * 资料关联台账-关联质检资料
+     */
+    @GetMapping("/dataLinkFile")
+    @ApiOperationSupport(order = 14)
+    @ApiOperation(value = "资料关联台账-关联质检资料", notes = "传合同id,计量单id,选中文件id逗号分隔")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "contractId", value = "合同id", required = true),
+            @ApiImplicitParam(name = "id", value = "计量单id", required = true),
+            @ApiImplicitParam(name = "fileIds", value = "选中文件id逗号分隔(返回数据的selectId,queryInfo的主键)", required = true)
+    })
+    public R<String> dataLinkFile(Long contractId, Long id,String fileIds) {
+        middleMeterApplyService.dataLinkFile(contractId, id,fileIds);
+        return R.success("关联成功");
+    }
 }

+ 173 - 103
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -56,6 +56,7 @@ import org.springblade.meter.vo.*;
 import org.springblade.producer.bean.PushMessage;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
@@ -85,6 +86,7 @@ public class TaskController extends BladeController {
     private final JdbcTemplate jdbcTemplate;
     private final BladeRedis bladeRedis;
     private final TaskClient taskClient;
+    private final IUserClient iUserClient;
     private final ArchiveFileTaskClient archiveFileTaskClient;
     private final ContractMeterPeriodServiceImpl contractMeterPeriodService;
     private final MeterPeriodServiceImpl periodService;
@@ -602,9 +604,17 @@ public class TaskController extends BladeController {
             }
 
         } else {
+
             /*2.预设流程*/
-            int sort = 1;
+            Set<Integer> sortList = new HashSet<>();
             for (Map.Entry<String, List<FixedFlowLink>> stringListEntry : sortedMap.entrySet()) {
+                int maxSort;
+                if (sortList.isEmpty()) {
+                    maxSort = 1;
+                } else {
+                    maxSort = Collections.max(sortList) + 1;
+                }
+
                 String sortStr = stringListEntry.getKey();
                 String branchType = sortStr.split("@@@")[1];
 
@@ -630,7 +640,8 @@ public class TaskController extends BladeController {
                         taskParallel.setStatus(1);
                         taskParallel.setIsDeleted(0);
 
-                        taskParallel.setSort(sort++); //sort累加
+                        sortList.add(maxSort);
+                        taskParallel.setSort(maxSort++);
 
                         taskClient.saveTaskParallel(taskParallel);
 
@@ -657,7 +668,8 @@ public class TaskController extends BladeController {
                         taskParallel.setStatus(1);
                         taskParallel.setIsDeleted(0);
 
-                        taskParallel.setSort(sort); //sort固定
+                        sortList.add(maxSort);
+                        taskParallel.setSort(maxSort);
 
                         taskClient.saveTaskParallel(taskParallel);
 
@@ -742,6 +754,15 @@ public class TaskController extends BladeController {
                 List<TaskParallel> taskParallels = jdbcTemplate.query("SELECT * FROM u_task_parallel WHERE process_instance_id = '" + processInstanceId + "' ORDER BY sort", new BeanPropertyRowMapper<>(TaskParallel.class));
                 List<String> taskParallelsUserIds = taskParallels.stream().map(TaskParallel::getTaskUser).collect(Collectors.toList());
                 List<String> name = new ArrayList<>();
+
+                /*平行签废除,首先排除相同sort,只判断自己的顺序*/
+                TaskParallel current = taskParallels.stream().filter(f -> f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
+                if (current == null) {
+                    throw new ServiceException("获取当前用户任务信息失败");
+                }
+                Integer currentSort = current.getSort();
+                taskParallels.removeIf(f -> f.getSort().equals(currentSort) && !f.getTaskUser().equals(SecureUtil.getUserId().toString()));
+
                 for (TaskParallel parallel : taskParallels) {
                     if (parallel.getTaskUser().equals(SecureUtil.getUserId().toString())) {
                         break;
@@ -1305,11 +1326,11 @@ public class TaskController extends BladeController {
                 MaterialMeterFormTask materialMeterFormTask = materialMeterFormServiceTask.getById(dataId);
                 MaterialMeterFormTaskVO materialMeterFormTaskVO = BeanUtil.copyProperties(materialMeterFormTask, MaterialMeterFormTaskVO.class);
                 if (materialMeterFormTaskVO != null) {
-                    if(materialMeterFormTaskVO.getMaterialConform()!=null){
-                        materialMeterFormTaskVO.setMaterialConformName( materialMeterFormTaskVO.getMaterialConform().equals(0) ? "不符合" : "符合");
+                    if (materialMeterFormTaskVO.getMaterialConform() != null) {
+                        materialMeterFormTaskVO.setMaterialConformName(materialMeterFormTaskVO.getMaterialConform().equals(0) ? "不符合" : "符合");
                     }
-                    if(materialMeterFormTaskVO.getStorageConform()!=null){
-                        materialMeterFormTaskVO.setStorageConformName(materialMeterFormTaskVO.getStorageConform()==0 ? "不符合" : "符合");
+                    if (materialMeterFormTaskVO.getStorageConform() != null) {
+                        materialMeterFormTaskVO.setStorageConformName(materialMeterFormTaskVO.getStorageConform() == 0 ? "不符合" : "符合");
                     }
                     vo.setBasicsInfo(materialMeterFormTaskVO);
                 }
@@ -2147,7 +2168,7 @@ public class TaskController extends BladeController {
                     data.setStatementName("材料预付款--" + me.getPeriodName());
 
                     //计量任务类型 1=中间计量申请,2=材料计量单,3=开工预付款计量单,4=变更令
-                    if(task.getMeterTaskType()==2){
+                    if (task.getMeterTaskType() == 2) {
                         data.setType(1);
                     }
                     materialStartStatementService.addOrUpdate(data);
@@ -2156,7 +2177,7 @@ public class TaskController extends BladeController {
                     reportId = materialS.getId();
                 }
                 /**计量公式执行 0中间,1材料,2开工*/
-                meterPdfInfo(reportId+"",1);
+                meterPdfInfo(reportId + "", 1);
 
                 /*复制业务数据状态>主任务状态>替换数据*/
                 updateCopyDataApproveStatus(task, dto).updateTaskStatus(task).displace(task, dto);
@@ -2187,6 +2208,14 @@ public class TaskController extends BladeController {
         //是否为最后一个审批人
         boolean isCurrentUserLastApprover = false;
 
+        /*平行签审批,首先排除相同sort,只判断自己的顺序*/
+        TaskParallel current = taskParallels.stream().filter(f -> f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
+        if (current == null) {
+            throw new ServiceException("获取当前用户任务信息失败");
+        }
+        Integer currentSort = current.getSort();
+        taskParallels.removeIf(f -> f.getSort().equals(currentSort) && !f.getTaskUser().equals(SecureUtil.getUserId().toString()));
+
         for (TaskParallel parallel : taskParallels) {
             if (parallel.getTaskUser().equals(SecureUtil.getUserId().toString())) {
                 if (parallel.getStatus().equals(2)) {
@@ -2538,9 +2567,8 @@ public class TaskController extends BladeController {
         return R.fail("操作失败");
     }
 
-
     @GetMapping("/meterPdfInfoOld")
-    @ApiOperationSupport(order = 20)
+    @ApiOperationSupport(order = 22)
     @ApiOperation(value = "计量生成Pdf", notes = "计量生成Pdf")
     public R meterPdfInfo(@RequestParam String ContractId, @RequestParam String FormDataId, @RequestParam Integer type) {
         String file_path = CollectionUtils.getSysLocalFileUrl();
@@ -2664,14 +2692,14 @@ public class TaskController extends BladeController {
     }
 
     @GetMapping("/meterPdfInfo")
-    @ApiOperationSupport(order = 20)
+    @ApiOperationSupport(order = 22)
     @ApiOperation(value = "计量生成Pdf", notes = "计量生成Pdf")
-    public R meterPdfInfo( @RequestParam String reportId, @RequestParam Integer type){
-          return R.data(calculate(reportId,type));
+    public R meterPdfInfo(@RequestParam String reportId, @RequestParam Integer type) {
+        return R.data(calculate(reportId, type));
     }
 
-    public R<String> calculate(String reportId, Integer type){
-        if(BaseUtils.isNumber(reportId)&& BaseUtils.isNumber(type)) {
+    public R<String> calculate(String reportId, Integer type) {
+        if (BaseUtils.isNumber(reportId) && BaseUtils.isNumber(type)) {
             Report report = generateReport(Long.parseLong(reportId), type);
             return generateReportsPdf(report);
         }
@@ -2679,7 +2707,7 @@ public class TaskController extends BladeController {
     }
 
     /*中期支付证书报表、开工、材料手册报表*/
-    public R<String> generateReportsPdf(Report report){
+    public R<String> generateReportsPdf(Report report) {
         /*报表记录新增或者重算的时候会调用当前方法,生成PDF*/
         /*保存两类PDF,一每种表独立一份用于浏览,二合成表用于电签*/
         /*数据完全独立互不影响,可以并发生成,预估PDF的总大小来决定是否全部在内存中生成PDF*/
@@ -2687,30 +2715,30 @@ public class TaskController extends BladeController {
         /*如果数据没有变化,则各表的PDF可以不用更新*/
         List<ReportResult> reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType());
         String fileUrl = null;
-        if(Func.isNotEmpty(reportResults)){
+        if (Func.isNotEmpty(reportResults)) {
             /*List<String> dataListPdf = new ArrayList<>();*/
             String file_path = CollectionUtils.getSysLocalFileUrl();
-           Map<String,Object> projectMap=jdbcTemplate.queryForMap("select b.project_name projectName from m_contract_info a  join  m_project_info b on a.p_id=b.id where a.id= "+report.getContractId());
-            String projectName = projectMap.getOrDefault("projectName",StringPool.EMPTY).toString();
-          /*  String fileUrl = "";*/
-            List<Map<String,Object>> excelInfo=jdbcTemplate.queryForList("SELECT id,file_url from m_excel_tab where id in("+reportResults.stream().map(ReportResult::getExcelId).distinct().map(Objects::toString).collect(Collectors.joining(","))+")");
-            if(Func.isNotEmpty(excelInfo)){
+            Map<String, Object> projectMap = jdbcTemplate.queryForMap("select b.project_name projectName from m_contract_info a  join  m_project_info b on a.p_id=b.id where a.id= " + report.getContractId());
+            String projectName = projectMap.getOrDefault("projectName", StringPool.EMPTY).toString();
+            /*  String fileUrl = "";*/
+            List<Map<String, Object>> excelInfo = jdbcTemplate.queryForList("SELECT id,file_url from m_excel_tab where id in(" + reportResults.stream().map(ReportResult::getExcelId).distinct().map(Objects::toString).collect(Collectors.joining(",")) + ")");
+            if (Func.isNotEmpty(excelInfo)) {
                 /*所有的Excel地址映射*/
-                Map<String,String> fileUrlMapping = excelInfo.stream().collect(Collectors.toMap(m->m.get("id").toString(),m->m.get("file_url").toString(),(v1,v2)->v1));
+                Map<String, String> fileUrlMapping = excelInfo.stream().collect(Collectors.toMap(m -> m.get("id").toString(), m -> m.get("file_url").toString(), (v1, v2) -> v1));
                 /*把Excel缺失的移除*/
-                reportResults.removeIf(rs->!fileUrlMapping.containsKey(rs.getExcelId().toString()));
+                reportResults.removeIf(rs -> !fileUrlMapping.containsKey(rs.getExcelId().toString()));
                 /*准备*/
-                reportResults.forEach(rs->{
+                reportResults.forEach(rs -> {
                     /*初始化路径*/
-                     rs.pathInit(file_path);
-                     rs.setExcelUrl(fileUrlMapping.get(rs.getExcelId().toString()));
+                    rs.pathInit(file_path);
+                    rs.setExcelUrl(fileUrlMapping.get(rs.getExcelId().toString()));
                     /*删除已经存在的PDF*/
                     File tabPdf;
                     try {
                         tabPdf = ResourceUtil.getFile(rs.getPdfPath());
                         if (tabPdf.exists()) {
-                            if(tabPdf.delete()){
-                                System.out.println(rs.getPdfPath()+"删除成功");
+                            if (tabPdf.delete()) {
+                                System.out.println(rs.getPdfPath() + "删除成功");
                             }
                         }
                     } catch (FileNotFoundException e) {
@@ -2719,24 +2747,24 @@ public class TaskController extends BladeController {
                 });
                 /*每种表生成一份pdf*/
                 StringBuffer sb = new StringBuffer();
-                reportResults.parallelStream().forEach(rs->{
+                reportResults.parallelStream().forEach(rs -> {
                     try {
                         byte[] excelByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(rs.getExcelUrl()));
                         PdfReader reader = null;
                         Document doc = new Document();
-                        PdfCopy  pdfCopy = new PdfCopy(doc, new FileOutputStream(rs.getPdfPath()));
+                        PdfCopy pdfCopy = new PdfCopy(doc, new FileOutputStream(rs.getPdfPath()));
                         int pageCount;
                         doc.open();
-                        String tile=rs.getName().contains("封面")?projectName:projectName+StringPool.DASH+rs.getName();
+                        String tile = rs.getName().contains("封面") ? projectName : projectName + StringPool.DASH + rs.getName();
                         /*把公共部分内容释放到每一页*/
                         rs.putCommon();
-                        for(Map<String,Object> dataMap:rs.getData()){
+                        for (Map<String, Object> dataMap : rs.getData()) {
                             try {
-                                Workbook workbook  = WorkbookFactory.create(new ByteArrayInputStream(excelByte));
+                                Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(excelByte));
                                 //获取工作表
                                 Sheet sheet = workbook.getSheetAt(0);
                                 sheet.setForceFormulaRecalculation(true);
-                                if(Func.isNotEmpty(dataMap)) {
+                                if (Func.isNotEmpty(dataMap)) {
                                     for (String keys : dataMap.keySet()) {
                                         int y1 = Func.toInt(keys.split("_")[0]);
                                         int x1 = Func.toInt(keys.split("_")[1]);
@@ -2752,7 +2780,7 @@ public class TaskController extends BladeController {
                                     }
                                 }
                                 /*设置表头*/
-                                setTitle(sheet,tile);
+                                setTitle(sheet, tile);
                                 //去掉表格虚线
                                 sheet.setPrintGridlines(false);
                                 //设置 整个工作表为一页
@@ -2761,7 +2789,7 @@ public class TaskController extends BladeController {
                                 ByteArrayOutputStream out = new ByteArrayOutputStream();
                                 workbook.write(out);
                                 workbook.write(new FileOutputStream(rs.getExcelPath()));
-                                com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook( new ByteArrayInputStream(out.toByteArray()));
+                                com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(new ByteArrayInputStream(out.toByteArray()));
                                 out.reset();
                                 wb.save(out, SaveFormat.PDF);
                                 reader = new PdfReader(new ByteArrayInputStream(out.toByteArray()));
@@ -2771,47 +2799,45 @@ public class TaskController extends BladeController {
                                 }
                                 out.close();
                                 workbook.close();
-                            }catch (Exception e){
+                            } catch (Exception e) {
                                 e.printStackTrace();
                             }
                         }
                         pdfCopy.flush();
                         pdfCopy.close();
-                        if(reader!=null)reader.close();
+                        if (reader != null) reader.close();
                         doc.close();
-                        rs.setPdfOssPath(CompletableFuture.supplyAsync(()->{
-                            BladeFile bladeFile = newIOSSClient.uploadFile(rs.getName()+SnowFlakeUtil.getId() + ".pdf", rs.getPdfPath());
-                            String url=bladeFile.getLink();
-                            if(Func.isEmpty(url)){
-                                url="无效链接";
+                        rs.setPdfOssPath(CompletableFuture.supplyAsync(() -> {
+                            BladeFile bladeFile = newIOSSClient.uploadFile(rs.getName() + SnowFlakeUtil.getId() + ".pdf", rs.getPdfPath());
+                            String url = bladeFile.getLink();
+                            if (Func.isEmpty(url)) {
+                                url = "无效链接";
                             }
                             return url;
                         }));
-                    }catch (Exception e){
+                    } catch (Exception e) {
                         sb.append("【").append(rs.getName()).append("】");
                         e.printStackTrace();
                     }
                 });
-                if(sb.length()>0){
+                if (sb.length() > 0) {
                     sb.append("生成异常");
                     return R.fail(sb.toString());
                 }
                 /*合并所有表*/
-                fileUrl=report.getReportPdf(file_path,reportResults);
+                fileUrl = report.getReportPdf(file_path, reportResults);
             }
         }
-       return R.data(fileUrl);
+        return R.data(fileUrl);
     }
 
-
-
-    public void setTitle(Sheet sheet,String name){
+    public void setTitle(Sheet sheet, String name) {
         Row row = sheet.getRow(0);
         Cell cell = row.getCell(0);
         if (cell != null) {
-           /* Workbook workbook = sheet.getWorkbook();*/
-           /* Font font = workbook.createFont();*/
-            CellStyle style=cell.getCellStyle();
+            /* Workbook workbook = sheet.getWorkbook();*/
+            /* Font font = workbook.createFont();*/
+            CellStyle style = cell.getCellStyle();
 /*            font.setFontName("黑体"); // 设置字体名称
             font.setFontHeightInPoints((short) 20); // 设置字号为20*/
             /*CellStyle style = workbook.createCellStyle();*/
@@ -2824,38 +2850,46 @@ public class TaskController extends BladeController {
     }
 
     @Data
-    class Report{
-        public final String[] REPORT_TYPE=new String[]{"s_interim_pay_certificate","s_material_start_statement","s_material_start_statement"};
-        public final String[] PERIOD_TYPE=new String[]{"s_contract_meter_period","s_meter_period","s_meter_period"};
-        /**报表记录id*/
+    class Report {
+        public final String[] REPORT_TYPE = new String[]{"s_interim_pay_certificate", "s_material_start_statement", "s_material_start_statement"};
+        public final String[] PERIOD_TYPE = new String[]{"s_contract_meter_period", "s_meter_period", "s_meter_period"};
+        /**
+         * 报表记录id
+         */
         private Long id;
-        /**报表PDF地址*/
+        /**
+         * 报表PDF地址
+         */
         private String pdfUrl;
         /*报表对应计量期Id*/
         private Long periodId;
-        /**计量期ID*/
+        /**
+         * 计量期ID
+         */
         private Long contractId;
-        /**计量类型,0中间计量 1材料,2开工动员*/
+        /**
+         * 计量类型,0中间计量 1材料,2开工动员
+         */
         private Integer type;
 
-       /*上传并关联PDF,然后返回合并后的PDF链接*/
-        public String getReportPdf(String file_path,List<ReportResult> reportResults){
+        /*上传并关联PDF,然后返回合并后的PDF链接*/
+        public String getReportPdf(String file_path, List<ReportResult> reportResults) {
             Long dataId = SnowFlakeUtil.getId();
             String lasPdf = file_path + "/pdf//" + dataId + "_last.pdf";
             CollectionUtils.mergePdfPublicMethods(reportResults.stream().map(ReportResult::getPdfPath).collect(Collectors.toList()), lasPdf);
             BladeFile bladeFile = newIOSSClient.uploadFile(dataId + "_last.pdf", lasPdf);
-            this.pdfUrl=bladeFile.getLink();
-            Map<String,String> fileListMap = reportResults.stream().collect(Collectors.toMap(ReportResult::getName, rs-> {
+            this.pdfUrl = bladeFile.getLink();
+            Map<String, String> fileListMap = reportResults.stream().collect(Collectors.toMap(ReportResult::getName, rs -> {
                 try {
                     return rs.getPdfOssPath().get();
                 } catch (InterruptedException | ExecutionException e) {
                     e.printStackTrace();
                     return "无效地址";
                 }
-            },(v1,v2)->v1,LinkedHashMap::new));
-            String upSql = "update "+REPORT_TYPE[this.type]+" set raw_url=?,file_url_list=? where id="+this.id;
-            jdbcTemplate.update(upSql,this.pdfUrl , JSON.toJSONString(fileListMap));
-            return  this.pdfUrl;
+            }, (v1, v2) -> v1, LinkedHashMap::new));
+            String upSql = "update " + REPORT_TYPE[this.type] + " set raw_url=?,file_url_list=? where id=" + this.id;
+            jdbcTemplate.update(upSql, this.pdfUrl, JSON.toJSONString(fileListMap));
+            return this.pdfUrl;
         }
 
         public Report(Long id, Integer type) {
@@ -2864,28 +2898,33 @@ public class TaskController extends BladeController {
         }
     }
 
-   public Report generateReport(Long reportId,Integer type){
-        Report report =new Report(reportId,type);
-        Map<String,Object> map;
-        if(type==0){
-            map = this.jdbcTemplate.queryForMap("select id,contract_id ,contract_period_id period_id from s_interim_pay_certificate where id = "+reportId);
-        }else{
-            map = this.jdbcTemplate.queryForMap("select id,contract_id,meter_period_id period_id  from s_material_start_statement where id = "+reportId);
+    public Report generateReport(Long reportId, Integer type) {
+        Report report = new Report(reportId, type);
+        Map<String, Object> map;
+        if (type == 0) {
+            map = this.jdbcTemplate.queryForMap("select id,contract_id ,contract_period_id period_id from s_interim_pay_certificate where id = " + reportId);
+        } else {
+            map = this.jdbcTemplate.queryForMap("select id,contract_id,meter_period_id period_id  from s_material_start_statement where id = " + reportId);
         }
         report.setContractId(Long.parseLong(map.get("contract_id").toString()));
         report.setPeriodId(Long.parseLong(map.get("period_id").toString()));
         return report;
-   }
+    }
 
-    @GetMapping("/getFixedFlowPage")
-    @ApiOperationSupport(order = 21)
+    @PostMapping("/getFixedFlowPage")
+    @ApiOperationSupport(order = 23)
     @ApiOperation(value = "计量预设流程分页", notes = "传入dto")
     public R<Page<Map<String, Object>>> getFixedFlowPage(@RequestBody PageFixedFlowDTO dto) {
-        return R.data(taskClient.getFixedFlowPage(dto));
+        Page<Map<String, Object>> resultMap = new Page<>();
+        resultMap.setCurrent(dto.getCurrent());
+        resultMap.setSize(dto.getSize());
+        resultMap.setTotal(jdbcTemplate.queryForObject("SELECT count(1) FROM u_fixed_flow WHERE is_deleted = 0 AND project_id = ? AND contract_id = ?", Long.class, dto.getProjectId(), dto.getContractId()));
+        resultMap.setRecords(taskClient.getFixedFlowPage(dto));
+        return R.data(resultMap);
     }
 
     @PostMapping("/saveFixedFlow")
-    @ApiOperationSupport(order = 22)
+    @ApiOperationSupport(order = 24)
     @ApiOperation(value = "计量新增预设流程", notes = "传入dto")
     public R<Object> saveFixedFlow(@RequestBody SaveFixedFlowDTO dto) {
         if (ObjectUtil.isEmpty(dto.getFixedBranchList()) || dto.getFixedBranchList().size() == 0) {
@@ -2903,13 +2942,31 @@ public class TaskController extends BladeController {
                 String[] userIdArray = userIds.split(",");
                 for (String userId : userIdArray) {
                     if (!allUserIds.add(userId)) {
-                        //如果添加失败,说明这个userId已经存在,表示有重复
                         duplicateUserIds.add(userId);
                     }
                 }
             }
             if (!duplicateUserIds.isEmpty()) {
-                throw new ServiceException("存在重复的用户ID:" + String.join(",", duplicateUserIds));
+                if (duplicateUserIds.contains("")) {
+                    throw new ServiceException("操作异常,userIds不能为null");
+                }
+                Map<Long, String> userMap = iUserClient.selectUserAll().stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getRealName())).collect(Collectors.toMap(User::getId, User::getRealName));
+                List<String> names = new LinkedList<>();
+                for (String duplicateUserId : duplicateUserIds) {
+                    String orDefault = userMap.getOrDefault(Long.parseLong(duplicateUserId), null);
+                    names.add(orDefault);
+                }
+                throw new ServiceException("每个任务人只能归属于一个任务中,以下任务人重复:" + String.join("、", names));
+            }
+
+            /*检查签字证书信息*/
+            List<String> userIds = dto.getFixedBranchList().stream().map(SaveFixedFlowDTO.FixedBranch::getUserIds).collect(Collectors.toList());
+            if (userIds.size() > 0) {
+                String resultString = StringUtils.join(userIds, ",");
+                R<Object> objectR = archiveFileTaskClient.checkTaskUserCertificateInfo(resultString);
+                if (!objectR.isSuccess()) {
+                    throw new ServiceException("预设流程选择的任务人没有签字证书信息");
+                }
             }
 
             Long fixedFlowId = SnowFlakeUtil.getId();
@@ -2929,20 +2986,23 @@ public class TaskController extends BladeController {
     }
 
     @GetMapping("/getFixedFlow")
-    @ApiOperationSupport(order = 23)
+    @ApiOperationSupport(order = 25)
     @ApiOperation(value = "计量获取预设流程信息", notes = "传入预设流程id")
-    public R<FixedFlowVO> getFixedFlow(@RequestBody String id) {
+    public R<FixedFlowVO> getFixedFlow(@RequestParam String id) {
         FixedFlow fixedFlow = jdbcTemplate.query("SELECT * FROM u_fixed_flow WHERE is_deleted = 0 AND id = ?", new Object[]{id}, new BeanPropertyRowMapper<>(FixedFlow.class)).stream().findAny().orElse(null);
         if (fixedFlow != null) {
-            List<FixedFlowLink> fixedFlowLinkList = jdbcTemplate.query("SELECT * FROM u_fixed_flow_link WHERE is_deleted = 0 AND fixed_flow_id = ?", new Object[]{fixedFlow.getId()}, new BeanPropertyRowMapper<>(FixedFlowLink.class));
+            List<FixedFlowLink> fixedFlowLinkList = jdbcTemplate.query("SELECT * FROM u_fixed_flow_link WHERE is_deleted = 0 AND fixed_flow_id = ? ORDER BY fixed_flow_branch_sort,fixed_flow_link_sort", new Object[]{fixedFlow.getId()}, new BeanPropertyRowMapper<>(FixedFlowLink.class));
             if (fixedFlowLinkList.size() > 0) {
-                Map<String, List<FixedFlowLink>> group = fixedFlowLinkList.stream().collect(Collectors.groupingBy(obj -> obj.getFixedFlowLink() + "@@@" + obj.getFixedFlowLinkType()));
+                Map<String, List<FixedFlowLink>> group = fixedFlowLinkList.stream()
+                        .collect(Collectors.groupingBy(obj -> obj.getFixedFlowLink() + "@@@" + obj.getFixedFlowLinkType(),
+                                LinkedHashMap::new,
+                                Collectors.toList()));
 
                 FixedFlowVO vo = new FixedFlowVO();
                 vo.setFixedFlowId(fixedFlow.getId());
                 vo.setFixedFlowName(fixedFlow.getFixedFlowName());
 
-                List<FixedFlowVO.FixedBranchVO> fixedBranchVOList = new ArrayList<>();
+                List<FixedFlowVO.FixedBranchVO> fixedBranchVOList = new LinkedList<>();
                 for (Map.Entry<String, List<FixedFlowLink>> listEntry : group.entrySet()) {
 
                     String nameAndType = listEntry.getKey();
@@ -2977,7 +3037,7 @@ public class TaskController extends BladeController {
     }
 
     @PostMapping("/updateFixedFlow")
-    @ApiOperationSupport(order = 24)
+    @ApiOperationSupport(order = 26)
     @ApiOperation(value = "计量修改预设流程", notes = "传入dto")
     public R<Object> updateFixedFlow(@RequestBody UpdateFixedFlowDTO dto) {
         if (ObjectUtil.isEmpty(dto.getFixedBranchList()) || dto.getFixedBranchList().size() == 0) {
@@ -2993,17 +3053,35 @@ public class TaskController extends BladeController {
                 String[] userIdArray = userIds.split(",");
                 for (String userId : userIdArray) {
                     if (!allUserIds.add(userId)) {
-                        //如果添加失败,说明这个userId已经存在,表示有重复
                         duplicateUserIds.add(userId);
                     }
                 }
             }
             if (!duplicateUserIds.isEmpty()) {
-                throw new ServiceException("存在重复的用户ID:" + String.join(",", duplicateUserIds));
+                if (duplicateUserIds.contains("")) {
+                    throw new ServiceException("操作异常,userIds不能为null");
+                }
+                Map<Long, String> userMap = iUserClient.selectUserAll().stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getRealName())).collect(Collectors.toMap(User::getId, User::getRealName));
+                List<String> names = new LinkedList<>();
+                for (String duplicateUserId : duplicateUserIds) {
+                    String orDefault = userMap.getOrDefault(Long.parseLong(duplicateUserId), null);
+                    names.add(orDefault);
+                }
+                throw new ServiceException("每个任务人只能归属于一个任务中,以下任务人重复:" + String.join("、", names));
             }
 
-            if (taskClient.updateFixedFlow(dto.getFixedFlowId(), dto.getFixedName())) {
+            /*检查签字证书信息*/
+            List<String> userIds = dto.getFixedBranchList().stream().map(UpdateFixedFlowDTO.FixedBranch::getUserIds).collect(Collectors.toList());
+            if (userIds.size() > 0) {
+                String resultString = StringUtils.join(userIds, ",");
+                R<Object> objectR = archiveFileTaskClient.checkTaskUserCertificateInfo(resultString);
+                if (!objectR.isSuccess()) {
+                    throw new ServiceException("预设流程选择的任务人没有签字证书信息");
+                }
+            }
 
+            if (taskClient.updateFixedFlow(dto.getFixedFlowId(), dto.getFixedName())) {
+                jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ?", dto.getFixedFlowId());
                 int sort = 1;
                 for (UpdateFixedFlowDTO.FixedBranch fixedBranch : dto.getFixedBranchList()) {
                     taskClient.updateFixedFlowLink(dto.getFixedFlowId(), fixedBranch.getName(), fixedBranch.getType(),
@@ -3016,21 +3094,13 @@ public class TaskController extends BladeController {
         return R.fail("操作失败");
     }
 
-    @PostMapping("/deleteFixedFlowBranch")
-    @ApiOperationSupport(order = 25)
-    @ApiOperation(value = "计量刪除预设流程分支", notes = "传入预设流程id、分支名称")
-    public R<Object> deleteFixedFlowBranch(@RequestParam String id, @RequestParam String name) {
-        jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ? AND fixed_flow_link = ?", new Object[]{id, name});
-        return R.fail("操作成功");
-    }
-
     @PostMapping("/deleteFixedFlow")
-    @ApiOperationSupport(order = 26)
+    @ApiOperationSupport(order = 27)
     @ApiOperation(value = "计量刪除预设流程", notes = "传入预设流程id")
     public R<Object> deleteFixedFlow(@RequestParam String id) {
         jdbcTemplate.update("DELETE FROM u_fixed_flow WHERE id = ?", new Object[]{id});
         jdbcTemplate.update("DELETE FROM u_fixed_flow_link WHERE fixed_flow_id = ?", new Object[]{id});
-        return R.fail("操作成功");
+        return R.success("操作成功");
     }
 
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/InventoryFormApplyMapper.java

@@ -35,5 +35,5 @@ public interface InventoryFormApplyMapper extends BaseMapper<InventoryFormApply>
 
     void deleteByMiddleId(@Param("id") Long id);
 
-    List<InventoryFormApplyVO> getByMeterIdAndFormId(@Param("vo") ChangeFormVO2 vo2);
+    List<InventoryFormApplyVO> getByMeterIdAndFormId(@Param("ids")List<Long> ids);
 }

+ 4 - 2
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/InventoryFormApplyMapper.xml

@@ -24,8 +24,10 @@
     </delete>
     <select id="getByMeterIdAndFormId" resultType="org.springblade.meter.vo.InventoryFormApplyVO">
         select * from s_inventory_form_apply
-        where is_deleted = 0 and contract_id = #{vo.contractId} and contract_form_id = #{vo.id}
-        and contract_meter_id = #{vo.contractMeterId}
+        where is_deleted = 0 and id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
     </select>
 
 </mapper>

+ 2 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.java

@@ -53,6 +53,8 @@ public interface MiddleMeterApplyMapper extends BaseMapper<MiddleMeterApply> {
     IPage<MiddleMeterApplyVO> page2(IPage<MiddleMeterApplyVO> iPage,@Param("apply") MiddleMeterApply middleMeterApply);
     //根据部位排序
     IPage<MiddleMeterApplyVO> page3(IPage<MiddleMeterApplyVO> iPage,@Param("apply") MiddleMeterApply middleMeterApply,@Param("ids") List<Long> ids);
+    //和page3相同,只是返回字段不同
+    IPage<MiddleMeterApplyVO3> dataLinkPage(IPage<MiddleMeterApplyVO3> iPage,@Param("apply") MiddleMeterApply middleMeterApply,@Param("ids") List<Long> ids);
 
     List<MeterInventoryDetailVO> meterPeriodAllForm(@Param("apply") MiddleMeterApply apply);
 

+ 15 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -298,6 +298,21 @@
         group by id
         order by sort,create_time
     </select>
+    <select id="dataLinkPage" resultType="org.springblade.meter.vo.MiddleMeterApplyVO3">
+        SELECT id,meter_number,engineer_divide,is_link_data,meter_money,business_date
+        FROM s_middle_meter_apply mma
+        WHERE contract_id = #{apply.contractId} and is_deleted = 0 and contract_period_id = #{apply.contractPeriodId}
+        and contract_unit_id in (
+        <foreach collection="ids" item="id"  separator=",">
+            #{id}
+        </foreach>
+        )
+        order by FIELD(contract_unit_id,
+        <foreach collection="ids" item="id"  separator=",">
+            #{id}
+        </foreach>
+        )
+    </select>
 
 
 </mapper>

+ 10 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IMiddleMeterApplyService.java

@@ -70,4 +70,14 @@ public interface IMiddleMeterApplyService extends BaseService<MiddleMeterApply>
     List<MeterInventoryVO> getCurrentNodeAllForm(MiddleMeterApply middleMeterApply);
 
     IPage<WbsFileVO> getWbsNodeInfo(WbsNodeDTO dto);
+
+    /**
+     * 资料关联台账-分页
+     */
+    IPage<MiddleMeterApplyVO3> dataLinkPage(MiddleMeterApply middleMeterApply, Query query);
+
+    /**
+     * 资料关联台账-关联质检资料
+     */
+    void dataLinkFile(Long contractId, Long id, String fileIds);
 }

+ 21 - 16
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/InventoryFormApplyServiceImpl.java

@@ -17,6 +17,8 @@
 package org.springblade.meter.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.meter.entity.InventoryFormApply;
 import org.springblade.meter.mapper.InventoryFormApplyMapper;
 import org.springblade.meter.service.IInventoryFormApplyService;
@@ -59,23 +61,26 @@ public class InventoryFormApplyServiceImpl extends BaseServiceImpl<InventoryForm
         List<InventoryFormApply> needUpdateData = new ArrayList<>();
         //目前先这样查询,后期优化
         for (ChangeFormVO2 vo2 : allForm) {
-            //查询指定节点,指定清单,在中间计量申请和清单中间表的数据,结果为多个计量期
-            List<InventoryFormApplyVO> vos = baseMapper.getByMeterIdAndFormId(vo2);
-            //不存在则跳过
-            if (vos.size() == 0){
-                continue;
-            }
-            //循环修改
-            BigDecimal total = vo2.getNewestChangeTotal().add(vo2.getCurrentChangeTotal());
-            for (InventoryFormApplyVO vo : vos) {
-                InventoryFormApply apply = new InventoryFormApply();
-                apply.setId(vo.getId());
-                if (total.compareTo(BigDecimal.ZERO) == 0) {
-                    apply.setPayRatio(BigDecimal.ZERO);
-                }else {
-                    apply.setPayRatio(vo.getCurrentMeterTotal().divide(total,2, RoundingMode.HALF_UP));
+            if (StringUtils.isNotBlank(vo2.getApplyIds())) {
+                //查询指定节点,指定清单,在中间计量申请和清单中间表的数据,结果为多个计量期
+                List<Long> ids = Func.toLongList(vo2.getApplyIds());
+                List<InventoryFormApplyVO> vos = baseMapper.getByMeterIdAndFormId(ids);
+                //不存在则跳过
+                if (vos.size() == 0) {
+                    continue;
+                }
+                //循环修改
+                BigDecimal total = vo2.getNewestChangeTotal().add(vo2.getCurrentChangeTotal());
+                for (InventoryFormApplyVO vo : vos) {
+                    InventoryFormApply apply = new InventoryFormApply();
+                    apply.setId(vo.getId());
+                    if (total.compareTo(BigDecimal.ZERO) == 0) {
+                        apply.setPayRatio(BigDecimal.ZERO);
+                    } else {
+                        apply.setPayRatio(vo.getCurrentMeterTotal().divide(total, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
+                    }
+                    needUpdateData.add(apply);
                 }
-                needUpdateData.add(apply);
             }
         }
         this.updateBatchById(needUpdateData);

+ 34 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -812,6 +812,40 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
         return iPage;
     }
 
+    /**
+     * 资料关联台账-分页
+     */
+    @Override
+    public IPage<MiddleMeterApplyVO3> dataLinkPage(MiddleMeterApply middleMeterApply, Query query) {
+        IPage<MiddleMeterApplyVO3> iPage = new Page<>(query.getCurrent(),query.getSize());
+        //根据部位分页,先查出部位
+        List<NodeSortVO> vos = baseMapper.getLowestNodeBySort(middleMeterApply.getContractId(),middleMeterApply.getContractUnitId());
+        //转换为树
+        Long l1 = System.currentTimeMillis();
+        List<NodeSortVO> list = ForestNodeMerger.merge(vos);
+        Long l2 = System.currentTimeMillis();
+        System.out.println(l2-l1);
+        //递归循环树,存在子节点就深入,不存在子节点就add后返回上一层
+        List<Long> ids = new ArrayList<>();
+        gatherSortNode(list,ids);
+        if (ids.size() != 0){
+            Long l3 = System.currentTimeMillis();
+            iPage = baseMapper.dataLinkPage(iPage,middleMeterApply,ids);
+            Long l4 = System.currentTimeMillis();
+            System.out.println(l4-l3);
+            iPage.getRecords().forEach(l->l.setDeductDate(l.getBusinessDate().plusMonths(3)));
+        }
+        return iPage;
+    }
+
+    /**
+     * 资料关联台账-关联质检资料
+     */
+    @Override
+    public void dataLinkFile(Long contractId, Long id, String fileIds) {
+
+    }
+
     //递归方法
     private void gatherSortNode(List<NodeSortVO> list,List<Long> ids){
         for (NodeSortVO vo : list) {