瀏覽代碼

解决试验自检re-sign会丢失记录表或者报告表pdf的bug

lvy 1 月之前
父節點
當前提交
d28246e15f

+ 41 - 6
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -1144,7 +1144,12 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             //------初始编号信息------
             this.initBuildNumber(dto);
         }
+        String tableIds = dto.getTableIds();
+        if (ObjectUtil.isNotEmpty(dto.getId())) {
+            dto.setTableIds(null);
+        }
         this.saveOrUpdate(dto);
+        dto.setTableIds(tableIds);
         if (ObjectUtil.isNotEmpty(dto.getId())) {
             //------获取最新试验记录------
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
@@ -1198,6 +1203,35 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         }
         return dto.getId().toString();
     }
+    private String saveTrialRecordTableIds(TrialSelfInspectionRecord obj, String tableIds , boolean isRecord){
+        if (obj.getTableIds() ==  null || obj.getTableIds().trim().isEmpty()) {
+            return tableIds;
+        }
+        List<WbsTreePrivate> query = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id in (" + obj.getTableIds() + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+        List<String> recordIds = new ArrayList<>();
+        List<String> reportIds = new ArrayList<>();
+        for (WbsTreePrivate treePrivate : query) {
+            Integer type = treePrivate.getTableType();
+            if (type == null) {
+                continue;
+            }
+            if (type == 1 || type == 9) {
+                recordIds.add(treePrivate.getPKeyId() + "");
+            } else if (type == 2 || type == 10) {
+                reportIds.add(treePrivate.getPKeyId() + "");
+            }
+        }
+        if (isRecord) {
+            if (!reportIds.isEmpty()) {
+                tableIds = tableIds + "," + String.join(",", reportIds);
+            }
+        } else {
+            if (!recordIds.isEmpty()) {
+                tableIds = tableIds + "," + String.join(",", recordIds);
+            }
+        }
+        return tableIds;
+    }
 
     /**
      * 取到传入的表单中的报告编号或者记录编号 修改记录表中相应字段的值
@@ -1396,14 +1430,15 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             String updateSql = null;
             if (recordDataTable && !reportDataTable) {
                 //单独保存记录表 查询报告单pdf是否有值 如果有值就合并 合并存到pdf_url
-                updateSql = getUpdateSql(dto, pdfURL, listPdf, snowId, "report_pdf_url", 1, "record_pdf_url");
-
+                String tableIds = saveTrialRecordTableIds(obj, dto.getTableIds(), true);
+                updateSql = getUpdateSql(dto, pdfURL, listPdf, snowId, "report_pdf_url", 1, "record_pdf_url", tableIds);
             } else if (!recordDataTable && reportDataTable) {
                 //单独保存报告表 查询记录表pdf是否有值 如果有值就合并 合并存到pdf_url
-                updateSql = getUpdateSql(dto, pdfURL, listPdf, snowId, "record_pdf_url", 2, "report_pdf_url");
+                String tableIds = saveTrialRecordTableIds(obj, dto.getTableIds(), false);
+                updateSql = getUpdateSql(dto, pdfURL, listPdf, snowId, "record_pdf_url", 2, "report_pdf_url", tableIds);
             } else {
                 //一起保存的数据  只改变pdf_url
-                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).set(TrialSelfInspectionRecord::getTaskStatus, "未上报").eq(TrialSelfInspectionRecord::getId, dto.getId()));
+                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getTableIds, dto.getTableIds()).set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).set(TrialSelfInspectionRecord::getTaskStatus, "未上报").eq(TrialSelfInspectionRecord::getId, dto.getId()));
             }
             if (ObjectUtil.isNotEmpty(updateSql)) {
                 jdbcTemplate.execute(updateSql);
@@ -1415,7 +1450,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @NotNull
-    private String getUpdateSql(TrialSelfInspectionRecordDTO dto, String pdfURL, String listPdf, Long snowId, String param1, int type, String param2) {
+    private String getUpdateSql(TrialSelfInspectionRecordDTO dto, String pdfURL, String listPdf, Long snowId, String param1, int type, String param2, String tableIds) {
         String updateSql;
         String sqlForAntherPDF = "SELECT " + param1 + " from u_trial_self_inspection_record where id =  " + dto.getId() + " and is_deleted = 0";
         String AntherPDFUrl = jdbcTemplate.queryForObject(sqlForAntherPDF, new SingleColumnRowMapper<String>(String.class));
@@ -1428,7 +1463,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             }
 
             BladeFile bladeFile = this.newIOSSClient.uploadFile(snowId + ".pdf", listPdf);
-            updateSql = "update u_trial_self_inspection_record set pdf_url = '" + bladeFile.getLink() + "'," + param2 + "= '" + pdfURL + "' ,task_status='未上报' where id='" + dto.getId() + "'";
+            updateSql = "update u_trial_self_inspection_record set pdf_url = '" + bladeFile.getLink() + "'," + param2 + "= '" + pdfURL + "' ,task_status='未上报', table_ids = '" + tableIds +"' where id='" + dto.getId() + "'";
             //合并后更新queryInfo表的pdfurl
             String updateForQurtyInfo = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' where classify='" + dto.getType() + "' and  wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "' ";
             jdbcTemplate.execute(updateForQurtyInfo);