Forráskód Böngészése

电签位置、默认、提示信息同步bug相关,试验自检上报、撤销接口相关

liuyc 2 éve
szülő
commit
2ff80b6b9d
13 módosított fájl, 366 hozzáadás és 237 törlés
  1. 1 1
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java
  2. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSelfInspectionRecordVO2.java
  3. 38 17
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  4. 8 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  5. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  6. 2 2
      blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java
  7. 0 6
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  8. 15 13
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java
  9. 172 137
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  10. 46 17
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java
  11. 59 23
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java
  12. 3 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml
  13. 18 17
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -47,7 +47,7 @@ public interface InformationQueryClient {
                                             @RequestBody List<JSONObject> linkDataList);
 
     @PostMapping(API_PREFIX + "/informationQuerySaveData")
-    void saveData(@RequestParam String nodeId, @RequestParam String projectId, @RequestParam String contractId, @RequestParam String classify, @RequestParam String link, @RequestParam String trialProjectName);
+    void saveData(@RequestParam String id, @RequestParam String projectId, @RequestParam String contractId, @RequestParam String classify, @RequestParam String link, @RequestParam String trialProjectName);
 
     @PostMapping(API_PREFIX + "/updateInformationQuery")
     void updateInformationQuery(@RequestParam String link, @RequestParam String classify, @RequestParam String nodeId, @RequestParam String contractId);

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSelfInspectionRecordVO2.java

@@ -22,6 +22,9 @@ public class TrialSelfInspectionRecordVO2 implements Serializable {
     @ApiModelProperty(value = "工程部位及用途")
     private String projectPosition;
 
+    @ApiModelProperty(value = "工程部位及用途名称")
+    private String projectPositionName;
+
     @ApiModelProperty(value = "报告日期")
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date reportDate;

+ 38 - 17
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -51,6 +51,7 @@ import org.springblade.system.cache.ParamCache;
 import org.springblade.system.entity.DictBiz;
 import org.springblade.system.feign.IDictBizClient;
 import org.springframework.beans.BeanUtils;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -490,7 +491,7 @@ public class InformationWriteQueryController extends BladeController {
         InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify));
         if (businessData != null) {
             //使用批量废除接口
-            return this.batchAbolish(businessData.getId().toString());
+            return this.batchAbolish(businessData.getId().toString(), primaryKeyId);
         }
         return R.data(300, false, "废除失败,未找到业务数据");
     }
@@ -556,12 +557,12 @@ public class InformationWriteQueryController extends BladeController {
      */
     @PostMapping("/queryNodeStatus-trial")
     @ApiOperationSupport(order = 23)
-    @ApiOperation(value = "/查询节点状态-试验")
-    public R<String> queryNodeStatusTrial(@RequestParam String primaryKeyId, @RequestParam String classify) {
+    @ApiOperation(value = "/查询节点状态-试验", notes = "当前记录id、所属方classify")
+    public R<String> queryNodeStatusTrial(@RequestParam String classify, @RequestParam String id) {
         //记录状态
         String status = "1";
         //查询填报状态
-        InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).ne(InformationQuery::getType, 3));
+        InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, id).eq(InformationQuery::getClassify, classify).ne(InformationQuery::getType, 3));
         if (businessData != null) {
             switch (businessData.getStatus()) {
                 case 0:
@@ -578,10 +579,11 @@ public class InformationWriteQueryController extends BladeController {
                     //如果不匹配,默认为未填报
                     status = "1";
                     //查询表格
-                    List<WbsTreePrivate> tableList = this.wbsTreePrivateClient.queryChildByParent(this.wbsTreePrivateClient.getNodeByPrimaryKeyId(primaryKeyId), "queryTable", classify);
-                    if (tableList != null && tableList.size() > 0) {
-                        for (WbsTreePrivate table : tableList) {
-                            if (new Integer("2").equals(table.getIsTabPdf())) {
+                    String sql = "select is_tab_pdf from u_trial_self_data_record where record_id = " + id;
+                    List<TrialSelfDataRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+                    if (query.size() > 0) {
+                        for (TrialSelfDataRecord info : query) {
+                            if (new Integer("2").equals(info.getIsTabPdf())) {
                                 //这些表格中,但凡有一个能够预览,就开放预览
                                 status = "2";
                                 break;
@@ -592,10 +594,11 @@ public class InformationWriteQueryController extends BladeController {
             }
         } else {
             //查询表格
-            List<WbsTreePrivate> tableList = this.wbsTreePrivateClient.queryChildByParent(this.wbsTreePrivateClient.getNodeByPrimaryKeyId(primaryKeyId), "queryTable", classify);
-            if (tableList != null && tableList.size() > 0) {
-                for (WbsTreePrivate table : tableList) {
-                    if (new Integer("2").equals(table.getIsTabPdf())) {
+            String sql = "select is_tab_pdf from u_trial_self_data_record where record_id = " + id;
+            List<TrialSelfDataRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+            if (query.size() > 0) {
+                for (TrialSelfDataRecord info : query) {
+                    if (new Integer("2").equals(info.getIsTabPdf())) {
                         //这些表格中,但凡有一个能够预览,就开放预览
                         status = "2";
                         break;
@@ -739,8 +742,8 @@ public class InformationWriteQueryController extends BladeController {
      */
     @PostMapping("/batchAbolish")
     @ApiOperationSupport(order = 18)
-    @ApiOperation(value = "批量废除")
-    public R<Boolean> batchAbolish(@RequestParam String ids) {
+    @ApiOperation(value = "批量废除", notes = "质检的ids,试验的记录ids")
+    public R<Boolean> batchAbolish(@RequestParam String ids, String primaryKeyId) {
         //获取所有相关任务记录
         List<Task> taskList = this.taskClient.queryTaskListByFormDataId(ids);
         if (taskList != null && taskList.size() > 0) {
@@ -880,6 +883,18 @@ public class InformationWriteQueryController extends BladeController {
                         e.printStackTrace();
                     }
                 }
+
+                //修改试验任务状态为未上报
+                String sql;
+                if (StringUtils.isNotEmpty(primaryKeyId)) {
+                    //单个废除
+                    sql = "update u_trial_self_inspection_record set task_status = '未上报' where id in(" + primaryKeyId + ")";
+                } else {
+                    //批量废除直接调的该接口,primaryKeyId为null,ids=当前试验记录的ids
+                    sql = "update u_trial_self_inspection_record set task_status = '未上报' where id in(" + ids + ")";
+                }
+                jdbcTemplate.execute(sql);
+
                 return R.data(true, "废除成功");
             } catch (Exception e) {
                 e.printStackTrace();
@@ -911,7 +926,7 @@ public class InformationWriteQueryController extends BladeController {
                         if (taskVO.getUserTasks() != null && taskVO.getUserTasks().size() > 0) {
                             //标记为自定义流程
                             taskVO.setFixedFlowId(Long.parseLong("0"));
-                        }else{
+                        } else {
                             //标记固定流程
                             taskVO.setFixedFlowId(startTaskVO.getFixedFlowId());
                         }
@@ -941,6 +956,12 @@ public class InformationWriteQueryController extends BladeController {
 
                             //修改记录
                             this.informationQueryService.update(wrappers);
+
+                            //修改试验记录上报任务状态
+                            if (ObjectUtil.isNotEmpty(startTaskVO.getTrialSelfInspectionRecordId())) {
+                                String sql = "update u_trial_self_inspection_record set task_status = '待审批' where id = " + startTaskVO.getTrialSelfInspectionRecordId();
+                                jdbcTemplate.execute(sql);
+                            }
                         }
                     }
                 } catch (Exception e) {
@@ -1132,9 +1153,9 @@ public class InformationWriteQueryController extends BladeController {
                     //重塑primaryKeyId
                     newData.setPKeyId(SnowFlakeUtil.getId());
                     //设置旧ID
-                    if(StringUtils.isNotEmpty(node.getOldId())){
+                    if (StringUtils.isNotEmpty(node.getOldId())) {
                         newData.setOldId(node.getOldId().toString());
-                    }else{
+                    } else {
                         newData.setOldId(node.getId().toString());
                     }
 

+ 8 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -76,8 +76,11 @@ public class TaskController extends BladeController {
 	private final ITaskService iTaskService;
 
 	private final WebSocket webSocket;
+
 	private final CommonFileClient commonFileClient;
 
+	private final ITrialSelfInspectionRecordService iTrialSelfInspectionRecordService;
+
 	/**
 	 * 记录短信验证码超时时间
 	 */
@@ -282,6 +285,11 @@ public class TaskController extends BladeController {
 
 				taskApprovalVOS.add(approvalVO);
 			}
+
+			//修改试验填报状态
+			this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(taskApprovalVOS);
+
+			//审批
 			this.taskService.batchCompleteApprovalTask(taskApprovalVOS,AuthUtil.getUserId());
 
 			//通过WebSocket推送数量条数

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -209,7 +209,7 @@ public class TrialDetectionController extends BladeController {
         return R.data(recordVO2s);
     }
 
-    @PostMapping("/self/raw-material/submit-relation")
+    @PostMapping("/self/raw-material/submit")
     @ApiOperationSupport(order = 21)
     @ApiOperation(value = "关联原材检测报告保存或修改", notes = "传入RawMaterialSubmitRelationDTO")
     public R<Object> rawMaterialSubmitRelation(@RequestBody RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java

@@ -46,10 +46,10 @@ public class InformationQueryClientImpl implements InformationQueryClient {
     }
 
     @Override
-    public void saveData(String nodeId, String projectId, String contractId, String classify, String link,String trialProjectName) {
+    public void saveData(String id, String projectId, String contractId, String classify, String link,String trialProjectName) {
         InformationQuery obj = new InformationQuery();
         obj.setId(SnowFlakeUtil.getId());
-        obj.setWbsId(Long.valueOf(nodeId));
+        obj.setWbsId(Long.valueOf(id));
         obj.setProjectId(Long.valueOf(projectId));
         obj.setContractId(Long.valueOf(contractId));
         obj.setClassify(Integer.valueOf(classify));

+ 0 - 6
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -89,9 +89,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 
     private final ITaskBatchService taskBatchService;
 
-    private final ITrialSelfInspectionRecordService iTrialSelfInspectionRecordService;
-
-
     @Override
     public List<TaskParallel> queryApprovalUser(String formDataIds) {
         //返回结果
@@ -378,9 +375,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             this.checkIsExsitTaskBatch(taskApprovalVOS, taskBatch.getId().toString());
         }
 
-        //修改试验填报状态
-        this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(taskApprovalVOS);
-
     }
 
     private void checkIsExsitTaskBatch(List<TaskApprovalVO> taskApprovalVOS, String batchId) {

+ 15 - 13
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java

@@ -306,21 +306,23 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
     }
 
     public void addDeviceUseInfo(TrialSelfInspectionRecordDTO dto) {
-        //获取进场记录
-        List<TrialDeviceInfo> deviceInfos = trialDeviceInfoMapper.selectList(Wrappers.<TrialDeviceInfo>lambdaQuery().in(TrialDeviceInfo::getId, dto.getDeviceUseIds()));
-
-        //构造使用记录
-        List<TrialDeviceUse> list = new ArrayList<>();
-        for (TrialDeviceInfo deviceInfo : deviceInfos) {
-            TrialDeviceUse trialDeviceUses = BeanUtil.copyProperties(deviceInfo, TrialDeviceUse.class);
-            if (trialDeviceUses != null) {
-                trialDeviceUses.setNodeId(dto.getNodeId());
-                trialDeviceUses.setDeviceInfoId(deviceInfo.getId());
-                trialDeviceUses.setId(SnowFlakeUtil.getId());
-                list.add(trialDeviceUses);
+        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(dto.getDeviceUseIds())) {
+            //获取进场记录
+            List<TrialDeviceInfo> deviceInfos = trialDeviceInfoMapper.selectList(Wrappers.<TrialDeviceInfo>lambdaQuery().in(TrialDeviceInfo::getId, dto.getDeviceUseIds()));
+
+            //构造使用记录
+            List<TrialDeviceUse> list = new ArrayList<>();
+            for (TrialDeviceInfo deviceInfo : deviceInfos) {
+                TrialDeviceUse trialDeviceUses = BeanUtil.copyProperties(deviceInfo, TrialDeviceUse.class);
+                if (trialDeviceUses != null) {
+                    trialDeviceUses.setNodeId(dto.getNodeId());
+                    trialDeviceUses.setDeviceInfoId(deviceInfo.getId());
+                    trialDeviceUses.setId(SnowFlakeUtil.getId());
+                    list.add(trialDeviceUses);
+                }
             }
+            this.saveBatch(list, 1000);
         }
-        this.saveBatch(list, 1000);
     }
 
 }

+ 172 - 137
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.spire.xls.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.time.DateUtils;
-import org.apache.poi.hssf.record.DVALRecord;
 import org.springblade.business.dto.RawMaterialSubmitRelationDTO;
 import org.springblade.business.dto.TrialFileSubmitDTO;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
@@ -217,28 +216,46 @@ public class TrialSelfInspectionRecordServiceImpl
         List<TrialSelfInspectionRecordVO2> recordVO2s = BeanUtil.copyProperties(result, TrialSelfInspectionRecordVO2.class);
         List<Long> collect = result.stream().map(TrialSelfInspectionRecord::getId).collect(Collectors.toList());
         String ids = org.apache.commons.lang.StringUtils.join(collect, ",");
-        String sql = "select raw_material_record_id from u_trial_raw_material_self_record where self_record_id in(" + ids + ")";
-        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
-        List<Object> idsRecord = new ArrayList<>();
-        for (Map<String, Object> map : maps) {
-            for (Map.Entry<String, Object> obj : map.entrySet()) {
-                idsRecord.add(obj.getValue());
+        if (StringUtils.isNotEmpty(ids)) {
+            String sql = "select raw_material_record_id from u_trial_raw_material_self_record where self_record_id in (" + ids + ")";
+            List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+            List<Object> idsRecord = new ArrayList<>();
+
+            for (Map<String, Object> map : maps) {
+                for (Map.Entry<String, Object> obj : map.entrySet()) {
+                    idsRecord.add(obj.getValue());
+                }
+            }
+            for (Object id : idsRecord) {
+                for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
+                    if (id.equals(recordVO2.getId())) {
+                        recordVO2.setIsRawMaterialRelation(1);
+                    }
+                }
             }
         }
-        for (Object id : idsRecord) {
-            for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
-                if (id.equals(recordVO2.getId())) {
-                    recordVO2.setIsRawMaterialRelation(1);
+
+        for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
+            if (StringUtils.isNotEmpty(recordVO2.getProjectPosition())) {
+                List<String> idsP = Func.toStrList(recordVO2.getProjectPosition()); //关联的工程部位ids
+                List<WbsTreeContract> resultNode = baseMapper.selectWbsTreeContractListByPKeyIds(idsP); //查询工程部位节点名称信息
+                List<String> projectPositionNames = resultNode.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                String name = projectPositionNames.stream().findAny().orElse(null);
+                if (projectPositionNames.size() > 1) {
+                    recordVO2.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
+                } else {
+                    recordVO2.setProjectPositionName(name);
                 }
             }
         }
+
         return recordVO2s;
     }
 
     @Override
     public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
         if (ObjectUtil.isEmpty(dto.getId())) {
-            throw new ServiceException("请先保存填报数据后再关联原材检测报告");
+            throw new ServiceException("请先保存填报数据后再关联原材检测报告");
         }
         //删除关系
         String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
@@ -257,58 +274,63 @@ public class TrialSelfInspectionRecordServiceImpl
         List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
         List<String> listPDFURL = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
 
-        //合并PDF
-        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-        String listPdf = filePath + "/pdf/" + dto.getNodeId() + ".pdf";
-        File tabPDF = ResourceUtil.getFile(listPdf);
-        if (tabPDF.exists()) {
-            tabPDF.delete();
-        }
-        FileUtils.mergePdfPublicMethods(listPDFURL, listPdf);
-        BladeFile bladeFile = this.newIOSSClient.uploadFile(dto.getNodeId() + ".pdf", listPdf);
-
-        //获取试验记录id的试验项目名称
-        List<String> collect = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getTrialProjectName).collect(Collectors.toList());
-        String oneName = collect.stream().findAny().orElse(null);
-        String trialProjectName = "";
-        if (StringUtils.isNotEmpty(oneName)) {
-            trialProjectName = oneName + "等" + collect.size() + "个文件";
-        }
-
-        if (ObjectUtil.isNotEmpty(bladeFile)) {
-            //修改pdfURL
-            String querySql = "select * from u_information_query where classify='" + dto.getType() + "' and wbs_id='" + dto.getNodeId() + "' and contract_id ='" + dto.getContractId() + "'";
-            List<Map<String, Object>> resultSQL = jdbcTemplate.queryForList(querySql);
-            if (resultSQL.size() > 0) {
-                String sql3 = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name = '" + trialProjectName + "' where classify= '" + dto.getType() + "' and wbs_id='" + dto.getNodeId() + "' and contract_id ='" + dto.getContractId() + "'";
-                jdbcTemplate.execute(sql3);
+        if (listPDFURL.size() > 0) {
+            //合并PDF
+            String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+            String listPdf = filePath + "/pdf/" + dto.getNodeId() + ".pdf";
+            File tabPDF = ResourceUtil.getFile(listPdf);
+            if (tabPDF.exists()) {
+                tabPDF.delete();
+            }
+            FileUtils.mergePdfPublicMethods(listPDFURL, listPdf);
+            BladeFile bladeFile = this.newIOSSClient.uploadFile(dto.getNodeId() + ".pdf", listPdf);
+
+            //获取试验记录id的试验项目名称
+            List<String> collect = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getTrialProjectName).collect(Collectors.toList());
+            String oneName = collect.stream().findAny().orElse(null);
+            String trialProjectName = "";
+            if (StringUtils.isNotEmpty(oneName)) {
+                trialProjectName = oneName + "等" + collect.size() + "个文件";
+            }
+
+            if (ObjectUtil.isNotEmpty(bladeFile)) {
+                //修改pdfURL
+                String querySql = "select * from u_information_query where classify='" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
+                List<Map<String, Object>> resultSQL = jdbcTemplate.queryForList(querySql);
+                if (resultSQL.size() > 0) {
+                    String sql3 = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name = '" + trialProjectName + "' where classify= '" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
+                    jdbcTemplate.execute(sql3);
+                } else {
+                    informationQueryClient.saveData(dto.getId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), bladeFile.getLink(), trialProjectName);
+                }
+                return true;
             } else {
-                informationQueryClient.saveData(dto.getNodeId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), bladeFile.getLink(), trialProjectName);
+                //删除关系
+                jdbcTemplate.execute(sql1);
+                return false;
             }
-            return true;
-        } else {
-            //删除关系
-            jdbcTemplate.execute(sql1);
-            return false;
         }
+        return false;
     }
 
     @Override
     public String selfPrintPdf(String ids) throws FileNotFoundException {
         List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
         List<String> listPdfUrl = recordList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
-        //合并PDF
-        Long id = SnowFlakeUtil.getId();
-        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-        String listPdf = filePath + "/pdf/" + id + ".pdf";
-        File tabPDF = ResourceUtil.getFile(listPdf);
-        if (tabPDF.exists()) {
-            tabPDF.delete();
-        }
-        FileUtils.mergePdfPublicMethods(listPdfUrl, listPdf);
-        BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
-        if (bladeFile != null) {
-            return bladeFile.getLink();
+        if (listPdfUrl.size() > 0) {
+            //合并PDF
+            Long id = SnowFlakeUtil.getId();
+            String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+            String listPdf = filePath + "/pdf/" + id + ".pdf";
+            File tabPDF = ResourceUtil.getFile(listPdf);
+            if (tabPDF.exists()) {
+                tabPDF.delete();
+            }
+            FileUtils.mergePdfPublicMethods(listPdfUrl, listPdf);
+            BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
+            if (bladeFile != null) {
+                return bladeFile.getLink();
+            }
         }
         return null;
     }
@@ -354,50 +376,59 @@ public class TrialSelfInspectionRecordServiceImpl
     public void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) throws FileNotFoundException {
         for (TaskApprovalVO taskApprovalVO : obj) {
             if (ObjectUtil.isNotEmpty(taskApprovalVO.getParallelProcessInstanceId())) {
-                String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskApprovalVO.getParallelProcessInstanceId());
-                if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
-                    LambdaUpdateWrapper<TrialSelfInspectionRecord> updateWrapper = new LambdaUpdateWrapper<>();
-                    updateWrapper.set(TrialSelfInspectionRecord::getTaskStatus, "OK".equals(taskApprovalVO.getFlag()) ? "已审批" : "已废除");
-                    updateWrapper.eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId);
-                    baseMapper.update(null, updateWrapper);
-
-                    TrialSelfInspectionRecord entity = updateWrapper.getEntity();
-
-                    //把当前试验的PDF合并关联到质检树节点下
-                    if (ObjectUtil.isNotEmpty(entity) && ("已审批").equals(entity.getTaskStatus())) {
-                        List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(trialSelfInspectionRecordId);
-
-                        for (String id : contractNodePKeyIds) {
-                            WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(id);
-                            if (wbsTreeContract != null) {
-                                List<String> pdfUrlList = new ArrayList<>();
-                                String classify;
-                                if (wbsTreeContract.getTableOwner().contains("1") || wbsTreeContract.getTableOwner().contains("2") || wbsTreeContract.getTableOwner().contains("3")) {
-                                    classify = "1";
-                                } else {
-                                    classify = "2";
-                                }
-                                String pdfUrlAll = baseMapper.selectInformationQuery(id, wbsTreeContract.getContractId(), classify);
-                                //质检节点合并pdfUrl
-                                pdfUrlList.add(pdfUrlAll);
-                                //试验pdfUrl
-                                pdfUrlList.add(ObjectUtil.isNotEmpty(entity.getPdfUrl()) ? entity.getPdfUrl() : "");
-
-                                //合并PDF
-                                String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                                String listPdf = filePath + "/pdf/" + id + ".pdf";
-                                File tabPDF = ResourceUtil.getFile(listPdf);
-                                if (tabPDF.exists()) {
-                                    tabPDF.delete();
+                String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + taskApprovalVO.getParallelProcessInstanceId() + "'";
+                TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
+                assert taskParallel != null;
+                if (ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
+                    String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
+                    if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(TrialSelfInspectionRecord::getTaskStatus, "OK".equals(taskApprovalVO.getFlag()) ? "已审批" : "已废除")
+                                .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
+                        );
+
+                        /*TrialSelfInspectionRecord entity = this.baseMapper.selectById(trialSelfInspectionRecordId);
+                        //把当前试验的PDF合并关联到质检树节点下
+                        if (ObjectUtil.isNotEmpty(entity) && ("已审批").equals(entity.getTaskStatus())) {
+                            List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(trialSelfInspectionRecordId);
+
+                            for (String id : contractNodePKeyIds) {
+                                if (StringUtils.isEmpty(entity.getPdfUrl())) {
+                                    continue;
                                 }
-                                FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
-                                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
-                                if (bladeFile != null) {
-                                    //修改质检合并pdfURL
-                                    baseMapper.updateInformationQuery(id, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
+
+                                WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(id);
+                                if (wbsTreeContract != null) {
+                                    List<String> pdfUrlList = new ArrayList<>();
+                                    String classify;
+                                    if (wbsTreeContract.getTableOwner().contains("1") || wbsTreeContract.getTableOwner().contains("2") || wbsTreeContract.getTableOwner().contains("3")) {
+                                        classify = "1";
+                                    } else {
+                                        classify = "2";
+                                    }
+                                    String pdfUrlAll = baseMapper.selectInformationQuery(id, wbsTreeContract.getContractId(), classify);
+                                    //质检节点合并pdfUrl
+                                    pdfUrlList.add(pdfUrlAll);
+                                    //试验pdfUrl
+                                    pdfUrlList.add(entity.getPdfUrl());
+
+                                    //合并PDF
+                                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                                    String listPdf = filePath + "/pdf/" + id + ".pdf";
+                                    File tabPDF = ResourceUtil.getFile(listPdf);
+                                    if (tabPDF.exists()) {
+                                        tabPDF.delete();
+                                    }
+                                    FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
+                                    BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
+                                    if (bladeFile != null) {
+                                        //修改质检合并pdfURL
+                                        baseMapper.updateInformationQuery(trialSelfInspectionRecordId, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
+                                    }
                                 }
                             }
-                        }
+                        }*/
+
                     }
                 }
             }
@@ -538,35 +569,35 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
-    /*@Transactional(rollbackFor = Exception.class)*/
     public boolean selfSubmit(TrialSelfInspectionRecordDTO dto) throws Exception {
         if (ObjectUtil.isEmpty(dto.getId())) {
             //构建记录表编号、报告单编号
             this.buildNumber(dto);
 
-            //任务流程状态初始化
-            dto.setTaskStatus("待审批");
-        }
+            //任务流程状态初始化未上报
+            dto.setTaskStatus("未上报");
 
-        JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
-        List<String> tableIds = new ArrayList<>();
-        for (int i = 0; i < dataArray.size(); i++) {
-            String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
-            tableIds.add(pkeyId);
+            //初始化tabIds
+            JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
+            List<String> tableIds = new ArrayList<>();
+            for (int i = 0; i < dataArray.size(); i++) {
+                String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
+                tableIds.add(pkeyId);
+            }
+            String join = org.apache.commons.lang.StringUtils.join(tableIds, ",");
+            dto.setTableIds(join);
         }
-        String join = org.apache.commons.lang.StringUtils.join(tableIds, ",");
-        dto.setTableIds(join);
-
-        /*//只修改基础信息,未修改表信息
-        if (dataArray.size() == 0) {
-            return this.saveOrUpdate(dto);
-        }*/
 
         //关联新增或修改了表信息
-        if (this.saveOrUpdate(dto)) {
+        this.saveOrUpdate(dto);
+
+        if (ObjectUtil.isNotEmpty(dto.getId())) {
+            //获取obj
+            TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
+
             try {
                 //保存实体表数据、记录信息、生成pdf
-                String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), dto.getTableIds());
+                String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
                 //返回合并pdfURL
                 if (StringUtils.isNotEmpty(pdfURL)) {
                     LambdaUpdateWrapper<TrialSelfInspectionRecord> updateWrapper = new LambdaUpdateWrapper<>();
@@ -575,19 +606,15 @@ public class TrialSelfInspectionRecordServiceImpl
                     this.update(null, updateWrapper);
                 }
             } catch (Exception e) {
-                e.printStackTrace();
+                throw new ServiceException("保存实体表数据生成pdf时发生异常 " + e.getMessage());
             }
-        }
 
-        if (ObjectUtil.isNotEmpty(dto.getId())) {
             //关联样品信息
             this.recordSample(dto);
 
-            //关联工程部位及用途信息
-            this.recordProjectPosition(dto);
-        }
+            //已审批任务,关联到工程部位及用途信息
+            this.recordProjectPosition(dto, obj);
 
-        if (StringUtils.isNotEmpty(dto.getDeviceUseIds())) {
             //新增设备使用记录信息
             trialDeviceUseService.addDeviceUseInfo(dto);
         }
@@ -605,21 +632,22 @@ public class TrialSelfInspectionRecordServiceImpl
         }
     }
 
-    private void recordProjectPosition(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
+    private void recordProjectPosition(TrialSelfInspectionRecordDTO dto, TrialSelfInspectionRecord obj) throws FileNotFoundException {
         if (StringUtils.isNotEmpty(dto.getProjectPosition())) {
-            baseMapper.delSelfQuality(dto.getId()); //删除关联信息
-            List<String> ids = Func.toStrList(dto.getProjectPosition());
-            for (String id : ids) { //新增关联信息
-                baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), dto.getId(), id);
-            }
-
+            dto.setTaskStatus(obj.getTaskStatus());
             //已审批填报记录
             if (("已审批").equals(dto.getTaskStatus())) {
+                baseMapper.delSelfQuality(dto.getId()); //删除关联信息
+                List<String> ids = Func.toStrList(dto.getProjectPosition());
+                for (String id : ids) { //新增关联信息
+                    baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), dto.getId(), id);
+                }
+
                 //把当前试验的PDF合并关联到质检树节点下
                 List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(String.valueOf(dto.getId()));
 
-                for (String id : contractNodePKeyIds) {
-                    WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(id);
+                for (String pKeyId : contractNodePKeyIds) {
+                    WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(pKeyId);
                     if (wbsTreeContract != null) {
                         List<String> pdfUrlList = new ArrayList<>();
                         String classify;
@@ -628,27 +656,34 @@ public class TrialSelfInspectionRecordServiceImpl
                         } else {
                             classify = "2";
                         }
-                        String pdfUrlAll = baseMapper.selectInformationQuery(id, wbsTreeContract.getContractId(), classify);
+                        String pdfUrlNodeAll = baseMapper.selectInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify);
+
+                        if (StringUtils.isEmpty(pdfUrlNodeAll) || StringUtils.isEmpty(obj.getPdfUrl())) {
+                            continue;
+                        }
+
                         //质检节点合并pdfUrl
-                        pdfUrlList.add(pdfUrlAll);
+                        pdfUrlList.add(pdfUrlNodeAll);
                         //试验pdfUrl
-                        pdfUrlList.add(ObjectUtil.isNotEmpty(dto.getPdfUrl()) ? dto.getPdfUrl() : "");
+                        pdfUrlList.add(obj.getPdfUrl());
 
                         //合并PDF
                         String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                        String listPdf = filePath + "/pdf/" + id + ".pdf";
+                        String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
                         File tabPDF = ResourceUtil.getFile(listPdf);
                         if (tabPDF.exists()) {
                             tabPDF.delete();
                         }
                         FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
-                        BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
+                        BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
                         if (bladeFile != null) {
-                            //修改质检合并pdfURL
-                            baseMapper.updateInformationQuery(id, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
+                            //修改质检合并后的pdfURL
+                            baseMapper.updateInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
                         }
                     }
                 }
+            } else {
+                throw new ServiceException("当前试验记录任务未审批,关联工程部位及用途信息失败");
             }
         }
     }

+ 46 - 17
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.manager.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -39,11 +40,10 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
-import org.springblade.manager.entity.WbsFormElement;
-import org.springblade.manager.entity.WbsTreeContract;
-import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.manager.entity.*;
 import org.springblade.manager.excel.WbsExcelBatchUtil;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
+import org.springblade.manager.service.impl.WbsTreeContractServiceImpl;
 import org.springblade.manager.service.impl.WbsTreePrivateServiceImpl;
 import org.springblade.manager.utils.CopyUtil;
 import org.springblade.manager.vo.TextdictBy345VO;
@@ -54,7 +54,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.vo.TextdictInfoVO;
 import org.springblade.manager.service.ITextdictInfoService;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -84,6 +83,7 @@ public class TextdictInfoController extends BladeController {
     private final ITextdictInfoService textdictInfoService;
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
     private final WbsTreePrivateServiceImpl wbsTreePrivateService;
+    private final WbsTreeContractServiceImpl wbsTreeContractService;
 
     private final JdbcTemplate jdbcTemplate;
 
@@ -432,8 +432,21 @@ public class TextdictInfoController extends BladeController {
         String replace = str1.replace("\\", "\\\\");
 
         //修改所有节点的htmlUrl
-        String updateSql = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (" + ids + ")";
-        jdbcTemplate.execute(updateSql);
+        String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (" + ids + ")";
+        jdbcTemplate.execute(updateSqlP);
+
+        //修改对应合同段的htmlUrl,当前项目下对应合同段的节点
+        List<Long> cIdsList = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getId).distinct().collect(Collectors.toList());
+        List<Long> cPkeyIds = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>lambdaQuery()
+                .eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreeContract::getExcelId, wbsTreePrivate.getExcelId())
+                .eq(WbsTreeContract::getStatus, 1)
+                .in(WbsTreeContract::getId, cIdsList)
+        ).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
+
+        String cPkeyIdsStr = StringUtils.join(cPkeyIds, ",");
+        String updateSqlC = "update m_wbs_tree_contract set html_url = '" + replace + "' where p_key_id in (" + cPkeyIdsStr + ")";
+        jdbcTemplate.execute(updateSqlC);
 
         return R.success("操作成功");
     }
@@ -481,9 +494,9 @@ public class TextdictInfoController extends BladeController {
                 .eq(TextdictInfo::getTabId, textdictInfo.getTableId())
                 .eq(TextdictInfo::getType, textdictInfo.getType()));
 
+        List<TextdictInfo> textDictInfosNewAll = new ArrayList<>();
         for (Long pKeyId : pKeyIds) {
-
-            List<TextdictInfo> textDictInfosNew = CommonUtil.deepCopy(textDictInfosOld);
+            List<TextdictInfo> textDictInfosNew = JSON.parseArray(JSON.toJSONString(textDictInfosOld), TextdictInfo.class);
 
             TextdictInfo textDictBean = new TextdictInfo();
             textDictBean.setColKey(id);
@@ -509,15 +522,18 @@ public class TextdictInfoController extends BladeController {
                     obj.setName("提示信息");
                 }
             }
+            textDictInfosNewAll.addAll(textDictInfosNew);
+        }
 
-            //删除当前类型
-            textdictInfoService.getBaseMapper().delete(Wrappers.<TextdictInfo>query().lambda()
-                    .eq(TextdictInfo::getTabId, pKeyId)
-                    .eq(TextdictInfo::getType, textdictInfo.getType()));
+        //删除当前类型
+        List<String> collect = textDictInfosNewAll.stream().map(TextdictInfo::getTabId).distinct().collect(Collectors.toList());
+        this.textdictInfoService.getBaseMapper().delete(Wrappers.<TextdictInfo>query().lambda()
+                .eq(TextdictInfo::getType, textdictInfo.getType())
+                .in(TextdictInfo::getTabId, collect)
+        );
 
-            //批量新增
-            textdictInfoService.saveBatch(textDictInfosNew);
-        }
+        //批量新增
+        this.textdictInfoService.saveBatch(textDictInfosNewAll);
 
         if (textdictInfo.getType() == 5) { // 提示语
             String lastHtml = "";
@@ -535,8 +551,21 @@ public class TextdictInfoController extends BladeController {
         String replace = str1.replace("\\", "\\\\");
 
         //修改所有节点的htmlUrl
-        String updateSql = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (" + ids + ")";
-        jdbcTemplate.execute(updateSql);
+        String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (" + ids + ")";
+        jdbcTemplate.execute(updateSqlP);
+
+        //修改对应合同段的htmlUrl,当前项目下对应合同段的节点
+        List<Long> cIdsList = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getId).distinct().collect(Collectors.toList());
+        List<Long> cPkeyIds = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>lambdaQuery()
+                .eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreeContract::getExcelId, wbsTreePrivate.getExcelId())
+                .eq(WbsTreeContract::getStatus, 1)
+                .in(WbsTreeContract::getId, cIdsList)
+        ).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
+
+        String cPkeyIdsStr = StringUtils.join(cPkeyIds, ",");
+        String updateSqlC = "update m_wbs_tree_contract set html_url = '" + replace + "' where p_key_id in (" + cPkeyIdsStr + ")";
+        jdbcTemplate.execute(updateSqlC);
 
         return R.success("操作成功");
     }

+ 59 - 23
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -3,16 +3,29 @@ package org.springblade.manager.feign;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.AllArgsConstructor;
+import org.springblade.business.entity.InformationQuery;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
+import org.springblade.business.feign.InformationQueryClient;
+import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.entity.TrialSelfDataRecord;
 import org.springblade.manager.service.IExcelTabService;
+import org.springblade.manager.utils.FileUtils;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.system.cache.ParamCache;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.File;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @AllArgsConstructor
@@ -20,6 +33,8 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
     private final IExcelTabService excelTabService;
     private final JdbcTemplate jdbcTemplate;
+    private final NewIOSSClient newIOSSClient;
+    private final InformationQueryClient informationQueryClient;
 
     @Override
     public ExcelTab getById(String id) {
@@ -38,35 +53,57 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
         String pdfUrl = "";
 
-        //单表PDF保存
-        if (isBatchSave == 0) {
-            //保存数据到数据库-试验,当前记录id作为groupId
-            this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
-            try {
-                //公式填充
-                this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId));
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
+        //保存数据到数据库-试验,当前记录id作为groupId
+        this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
+        try {
+            //公式填充
+            this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
-            //单表PDF
+        if (isBatchSave == 0) {
+            //单表PDF保存
             TableInfo tableInfo = tableInfoList.stream().findAny().orElse(null);
             assert tableInfo != null;
-            if (tableInfo.getPkeyId().equals(tabIds)) {
+            if (tabIds.contains(tableInfo.getPkeyId())) {
+
                 excelTabService.getBussPDFTrial(Long.valueOf(tableInfo.getPkeyId()), contractId, id);
-            }
 
-        } else if (isBatchSave == 1) { //多表PDF保存
-            //保存数据到数据库-试验,当前记录id作为groupId
-            this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
-            try {
-                //公式填充
-                this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId));
-            } catch (Exception e) {
-                e.printStackTrace();
+                //重新合并pdf
+                String sql = "select * from u_trial_self_data_record where record_id = " + id;
+                List<TrialSelfDataRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+                List<String> pdfList = query.stream().map(TrialSelfDataRecord::getPdfUrl).collect(Collectors.toList());
+
+                String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                String pdfPath2 = file_path + "/pdf//" + id + "_2.pdf";
+                File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+                if (tabPdf2.exists()) {
+                    tabPdf2.delete();
+                }
+                FileUtils.mergePdfPublicMethods(pdfList, pdfPath2);
+                BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath2);
+
+                String sqlUpdate = "update u_trial_self_inspection_record set pdf_url = '" + bladeFile.getLink() + "' where id = " + id;
+                jdbcTemplate.execute(sqlUpdate);
+
+                //获取试验记录id的试验项目名称
+                String sql2 = "select trial_project_name from u_trial_self_inspection_record where id = " + id;
+                TrialSelfInspectionRecord obj = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
+                assert obj != null;
+                //合并PDF集合(解决单表保存后上报找不到题名问题)
+                String querySql = "select * from u_information_query where classify ='" + type + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'";
+                List<InformationQuery> query2 = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(InformationQuery.class));
+                if (query2.size() > 0) {
+                    String updateSql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + obj.getTrialProjectName() + "'  where classify='" + type + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
+                    jdbcTemplate.execute(updateSql);
+                } else {
+                    informationQueryClient.saveData(id.toString(), projectId, contractId, type.toString(), bladeFile.getLink(), obj.getTrialProjectName());
+                }
             }
 
-            //多表合并PDF
+        } else if (isBatchSave == 1) {
+            //多表PDF保存
             pdfUrl = excelTabService.getBussPDFSTrial(nodeId,
                     tableType, //tableType=表类型 1=记录表 2=报告单
                     String.valueOf(type), //type=所属方 1=施工质检 2=监理抽检
@@ -76,7 +113,6 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                     tabIds //新增的表的pKeyIds
             );
         }
-
         return pdfUrl;
     }
 

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml

@@ -396,11 +396,11 @@
 
     <select id="updateAllNodeTabById" resultType="org.springblade.manager.entity.WbsTreeContract">
         update m_wbs_tree_contract
-        set excel_id=#{aPrivate.excelId},
+        set excel_id= #{aPrivate.excelId},
             node_name = #{aPrivate.nodeName},
             full_name = #{aPrivate.fullName},
-            is_link_table=2,
-            html_url=#{aPrivate.htmlUrl}
+            is_link_table = 2,
+            html_url = #{aPrivate.htmlUrl}
         where type = 2
           and project_id = #{aPrivate.projectId}
           and id = #{aPrivate.id};

+ 18 - 17
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

@@ -168,7 +168,7 @@
         update m_wbs_tree_private
         set tenant_id       = #{wbsTP.tenantId},
             parent_id       = #{wbsTP.parentId},
-            node_type   = #{wbsTP.nodeType},
+            node_type       = #{wbsTP.nodeType},
             node_name       = #{wbsTP.nodeName},
             full_name       = #{wbsTP.nodeName},
             ancestors       = #{wbsTP.ancestors},
@@ -180,6 +180,7 @@
             create_time     = #{wbsTP.createTime},
             update_user     = #{wbsTP.updateUser},
             update_time     = #{wbsTP.updateTime},
+            mix_ratio_test_ids = #{wbsTP.mixRatioTestIds},
             status          = 1,
             is_deleted      = 0
         where p_key_id = #{pKeyId}
@@ -483,34 +484,34 @@
         SELECT * FROM m_wbs_tree_private
         WHERE
         (
-            type = 1
+        type = 1
         <if test="id != null and id != ''">
             AND id = #{id}
         </if>
-            AND project_id = #{referencePrivateWbsProjectId}
-            AND wbs_id = #{wbsId}
-            AND STATUS = 1
-            AND is_deleted = 0
+        AND project_id = #{referencePrivateWbsProjectId}
+        AND wbs_id = #{wbsId}
+        AND STATUS = 1
+        AND is_deleted = 0
         )
         OR
         (
-            type = 2
+        type = 2
         <if test="id != null and id != ''">
             parent_id = #{id}
         </if>
-            AND project_id = #{referencePrivateWbsProjectId}
-            AND wbs_id = #{wbsId}
-            AND STATUS = 1
-            AND is_deleted = 0
+        AND project_id = #{referencePrivateWbsProjectId}
+        AND wbs_id = #{wbsId}
+        AND STATUS = 1
+        AND is_deleted = 0
         )
         OR
         (
-            type = 10
-            AND project_id = #{referencePrivateWbsProjectId}
-            AND wbs_id is null
-            AND parent_id = -10
-            AND STATUS = 1
-            AND is_deleted = 0
+        type = 10
+        AND project_id = #{referencePrivateWbsProjectId}
+        AND wbs_id is null
+        AND parent_id = -10
+        AND STATUS = 1
+        AND is_deleted = 0
         )
     </select>