|
@@ -276,107 +276,112 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
|
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(dto.getIds())) { //新增关系,合并pdf
|
|
|
- List<String> idsList = Func.toStrList(dto.getIds());
|
|
|
- //获取ids、id下的pdfUrl
|
|
|
- List<String> ids = new ArrayList<>();
|
|
|
- ids.add(dto.getId());
|
|
|
- ids.addAll(idsList);
|
|
|
- List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
- TrialSelfInspectionRecord oldObj = recordList.stream().filter(f -> f.getId().equals(Long.parseLong(dto.getId()))).findAny().orElse(null);
|
|
|
- List<TrialSelfInspectionRecord> oldOther = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
|
|
|
-
|
|
|
- //获取原始pdfUrl
|
|
|
- String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
- TrialRawMaterialSelfRecord recordOld = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
|
|
|
- if (recordOld != null) {
|
|
|
- assert oldObj != null;
|
|
|
- oldObj.setPdfUrl(recordOld.getOldPdfUrl());
|
|
|
+ } else {
|
|
|
+ TrialSelfInspectionRecord objMain = this.getBaseMapper().selectById(dto.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(objMain) && (("已审批").equals(objMain.getTaskStatus()) || ("待审批").equals(objMain.getTaskStatus()))) {
|
|
|
+ throw new ServiceException("当前填报数据已上报,无法进行关联操作");
|
|
|
}
|
|
|
-
|
|
|
- //当前记录pdfUrl置顶
|
|
|
- List<TrialSelfInspectionRecord> recordList2 = new ArrayList<>();
|
|
|
- recordList2.add(oldObj);
|
|
|
- recordList2.addAll(oldOther);
|
|
|
- List<String> listPdfUrl = recordList2.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
-
|
|
|
- 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 = recordList.stream().map(TrialSelfInspectionRecord::getTrialProjectName).collect(Collectors.toList());
|
|
|
- String name = collect.stream().findAny().orElse(null);
|
|
|
- String trialProjectName;
|
|
|
- if (collect.size() > 1) {
|
|
|
- trialProjectName = name + "等" + collect.size() + "个文件";
|
|
|
- } else {
|
|
|
- trialProjectName = name;
|
|
|
- }
|
|
|
-
|
|
|
- //删除当前记录关系信息
|
|
|
- String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
- //新增当前记录关系信息
|
|
|
- for (String s : idsList) {
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIds())) { //新增关系,合并pdf
|
|
|
+ List<String> idsList = Func.toStrList(dto.getIds());
|
|
|
+ //获取ids、id下的pdfUrl
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+ ids.add(dto.getId());
|
|
|
+ ids.addAll(idsList);
|
|
|
+ List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
+ TrialSelfInspectionRecord oldObj = recordList.stream().filter(f -> f.getId().equals(Long.parseLong(dto.getId()))).findAny().orElse(null);
|
|
|
+ List<TrialSelfInspectionRecord> oldOther = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取原始pdfUrl
|
|
|
+ String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
+ TrialRawMaterialSelfRecord recordOld = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
|
|
|
+ if (recordOld != null) {
|
|
|
assert oldObj != null;
|
|
|
- String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + s + ",'" + oldObj.getPdfUrl() + "')";
|
|
|
- jdbcTemplate.execute(sql2);
|
|
|
+ oldObj.setPdfUrl(recordOld.getOldPdfUrl());
|
|
|
}
|
|
|
|
|
|
- if (ObjectUtil.isNotEmpty(bladeFile)) {
|
|
|
+ //当前记录pdfUrl置顶
|
|
|
+ List<TrialSelfInspectionRecord> recordList2 = new ArrayList<>();
|
|
|
+ recordList2.add(oldObj);
|
|
|
+ recordList2.addAll(oldOther);
|
|
|
+ List<String> listPdfUrl = recordList2.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
+
|
|
|
+ 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 = recordList.stream().map(TrialSelfInspectionRecord::getTrialProjectName).collect(Collectors.toList());
|
|
|
+ String name = collect.stream().findAny().orElse(null);
|
|
|
+ String trialProjectName;
|
|
|
+ if (collect.size() > 1) {
|
|
|
+ trialProjectName = name + "等" + collect.size() + "个文件";
|
|
|
+ } else {
|
|
|
+ trialProjectName = name;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除当前记录关系信息
|
|
|
+ String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
+ jdbcTemplate.execute(sql1);
|
|
|
+ //新增当前记录关系信息
|
|
|
+ for (String s : idsList) {
|
|
|
+ assert oldObj != null;
|
|
|
+ String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + s + ",'" + oldObj.getPdfUrl() + "')";
|
|
|
+ jdbcTemplate.execute(sql2);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改当前记录pdfUrl
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, bladeFile.getLink()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
+
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ //删除关系
|
|
|
+ jdbcTemplate.execute(sql1);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //删除关系,恢复当前记录的原始pdfUrl
|
|
|
+ TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
+ String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
+ TrialRawMaterialSelfRecord record = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
|
|
|
+ if (record != null) {
|
|
|
//修改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() + "'";
|
|
|
+ String sql3 = "update u_information_query set pdf_url ='" + record.getOldPdfUrl() + "', name = '" + obj.getTrialProjectName() + "' 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);
|
|
|
+ informationQueryClient.saveData(dto.getId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), record.getOldPdfUrl(), obj.getTrialProjectName());
|
|
|
}
|
|
|
|
|
|
//修改当前记录pdfUrl
|
|
|
- this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, bladeFile.getLink()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, record.getOldPdfUrl()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- //删除关系
|
|
|
+ //删除当前记录关系信息
|
|
|
+ String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
jdbcTemplate.execute(sql1);
|
|
|
- return false;
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
- } else {
|
|
|
- //删除关系,恢复当前记录的原始pdfUrl
|
|
|
- TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
- String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
- TrialRawMaterialSelfRecord record = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
|
|
|
- if (record != null) {
|
|
|
- //修改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 ='" + record.getOldPdfUrl() + "', name = '" + obj.getTrialProjectName() + "' 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()), record.getOldPdfUrl(), obj.getTrialProjectName());
|
|
|
- }
|
|
|
-
|
|
|
- //修改当前记录pdfUrl
|
|
|
- this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, record.getOldPdfUrl()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
-
|
|
|
- //删除当前记录关系信息
|
|
|
- String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
- }
|
|
|
- return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|