|
@@ -10,11 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.spire.xls.*;
|
|
import com.spire.xls.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
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;
|
|
|
|
-import org.springblade.business.dto.TrialSelfInspectionRecordPageDTO;
|
|
|
|
|
|
+import org.springblade.business.dto.*;
|
|
import org.springblade.business.entity.*;
|
|
import org.springblade.business.entity.*;
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
import org.springblade.business.mapper.TrialMaterialMobilizationMapper;
|
|
import org.springblade.business.mapper.TrialMaterialMobilizationMapper;
|
|
@@ -126,8 +122,14 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
record.setProjectPositionName(name);
|
|
record.setProjectPositionName(name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ //关联取样ids
|
|
|
|
+ String sql = "select sampling_id from u_trial_self_sample where self_id = " + record.getId();
|
|
|
|
+ List<Long> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfSample.class)).stream().map(TrialSelfSample::getSamplingId).collect(Collectors.toList());
|
|
|
|
+ if (query.size() > 0) {
|
|
|
|
+ record.setSampleIds(org.apache.commons.lang.StringUtils.join(query, ","));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return trialSelfInspectionRecordVOIPage.setRecords(records);
|
|
return trialSelfInspectionRecordVOIPage.setRecords(records);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -212,103 +214,196 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<TrialSelfInspectionRecordVO2> getRawMaterialInfo(String nodeId, String contractId) {
|
|
|
|
- List<TrialSelfInspectionRecord> result = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().eq(TrialSelfInspectionRecord::getNodeId, nodeId).eq(TrialSelfInspectionRecord::getContractId, contractId).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
|
- 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());
|
|
|
|
|
|
+ public List<TrialSelfInspectionRecordVO2> getRawMaterialInfo(String nodeId, String contractId, String id) {
|
|
|
|
+ List<TrialSelfInspectionRecordVO2> recordVO2s;
|
|
|
|
+ //编辑
|
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
|
+ //获取nodeId节点下的记录信息(排除当前id记录)
|
|
|
|
+ List<TrialSelfInspectionRecord> result = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getNodeId, nodeId)
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getContractId, contractId)
|
|
|
|
+ .ne(TrialSelfInspectionRecord::getId, id)
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
|
+
|
|
|
|
+ recordVO2s = BeanUtil.copyProperties(result, TrialSelfInspectionRecordVO2.class);
|
|
|
|
+
|
|
|
|
+ if (recordVO2s.size() > 0) {
|
|
|
|
+ //获取当前记录所关联的记录raw_material_record_id
|
|
|
|
+ String sql = "select raw_material_record_id from u_trial_raw_material_self_record where self_record_id = " + id;
|
|
|
|
+ List<TrialRawMaterialSelfRecord> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
|
+
|
|
|
|
+ //是否关联过
|
|
|
|
+ for (TrialRawMaterialSelfRecord record : list) {
|
|
|
|
+ for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
|
|
|
|
+ if (record.getRawMaterialRecordId().equals(recordVO2.getId())) {
|
|
|
|
+ recordVO2.setIsRawMaterialRelation(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //新增
|
|
|
|
+ List<TrialSelfInspectionRecord> result = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getNodeId, nodeId)
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getContractId, contractId)
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
|
+
|
|
|
|
+ recordVO2s = BeanUtil.copyProperties(result, TrialSelfInspectionRecordVO2.class);
|
|
}
|
|
}
|
|
- for (Object id : idsRecord) {
|
|
|
|
|
|
+
|
|
|
|
+ //工程部位信息
|
|
|
|
+ if (recordVO2s.size() > 0) {
|
|
for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
|
|
for (TrialSelfInspectionRecordVO2 recordVO2 : recordVO2s) {
|
|
- if (id.equals(recordVO2.getId())) {
|
|
|
|
- recordVO2.setIsRawMaterialRelation(1);
|
|
|
|
|
|
+ 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() >= 2) {
|
|
|
|
+ recordVO2.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
|
|
|
|
+ } else {
|
|
|
|
+ recordVO2.setProjectPositionName(name);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
return recordVO2s;
|
|
return recordVO2s;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
|
|
public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
- throw new ServiceException("请先保存填报数据后再关联原材检测报告!");
|
|
|
|
- }
|
|
|
|
- //删除关系
|
|
|
|
- String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
|
-
|
|
|
|
- List<String> strings = Func.toStrList(dto.getIds());
|
|
|
|
- //新增关系
|
|
|
|
- for (String s : strings) {
|
|
|
|
- String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + s + ")";
|
|
|
|
- jdbcTemplate.execute(sql2);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //获取ids、id下的PDF
|
|
|
|
- List<String> ids = new ArrayList<>(strings);
|
|
|
|
- ids.add(dto.getId());
|
|
|
|
- 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);
|
|
|
|
|
|
+ throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
|
|
|
|
+ } else {
|
|
|
|
+ TrialSelfInspectionRecord objMain = this.getBaseMapper().selectById(dto.getId());
|
|
|
|
+ if (ObjectUtil.isNotEmpty(objMain) && (("已审批").equals(objMain.getTaskStatus()) || ("待审批").equals(objMain.getTaskStatus()))) {
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //当前记录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 {
|
|
} else {
|
|
- informationQueryClient.saveData(dto.getNodeId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), bladeFile.getLink(), trialProjectName);
|
|
|
|
|
|
+ //删除关系,恢复当前记录的原始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 true;
|
|
|
|
- } else {
|
|
|
|
- //删除关系
|
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String selfPrintPdf(String ids) throws FileNotFoundException {
|
|
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<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());
|
|
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;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -354,50 +449,59 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
public void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) throws FileNotFoundException {
|
|
public void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) throws FileNotFoundException {
|
|
for (TaskApprovalVO taskApprovalVO : obj) {
|
|
for (TaskApprovalVO taskApprovalVO : obj) {
|
|
if (ObjectUtil.isNotEmpty(taskApprovalVO.getParallelProcessInstanceId())) {
|
|
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,88 +642,91 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- /*@Transactional(rollbackFor = Exception.class)*/
|
|
|
|
- public boolean selfSubmit(TrialSelfInspectionRecordDTO dto) throws Exception {
|
|
|
|
|
|
+ public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws Exception {
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
//构建记录表编号、报告单编号
|
|
//构建记录表编号、报告单编号
|
|
this.buildNumber(dto);
|
|
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);
|
|
|
|
- }*/
|
|
|
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getId())) {
|
|
|
|
+ //获取当前最新的试验记录信息
|
|
|
|
+ TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
|
|
|
- //关联新增或修改了表信息
|
|
|
|
- if (this.saveOrUpdate(dto)) {
|
|
|
|
try {
|
|
try {
|
|
//保存实体表数据、记录信息、生成pdf
|
|
//保存实体表数据、记录信息、生成pdf
|
|
- String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), dto.getTableIds());
|
|
|
|
- //返回合并pdfURL
|
|
|
|
|
|
+ assert obj != null;
|
|
|
|
+ String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
if (StringUtils.isNotEmpty(pdfURL)) {
|
|
if (StringUtils.isNotEmpty(pdfURL)) {
|
|
- LambdaUpdateWrapper<TrialSelfInspectionRecord> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
- updateWrapper.set(TrialSelfInspectionRecord::getPdfUrl, pdfURL);
|
|
|
|
- updateWrapper.eq(TrialSelfInspectionRecord::getId, dto.getId());
|
|
|
|
- this.update(null, updateWrapper);
|
|
|
|
|
|
+ //修改合并pdf
|
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
|
|
|
|
+ .set(TrialSelfInspectionRecord::getPdfUrl, pdfURL)
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ throw new ServiceException("保存实体表数据生成pdf时发生异常 " + e.getMessage());
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getId())) {
|
|
|
|
- //关联样品信息
|
|
|
|
- this.recordSample(dto);
|
|
|
|
|
|
|
|
- //关联工程部位及用途信息
|
|
|
|
- this.recordProjectPosition(dto);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtils.isNotEmpty(dto.getDeviceUseIds())) {
|
|
|
|
//新增设备使用记录信息
|
|
//新增设备使用记录信息
|
|
- trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
|
|
|
+ this.trialDeviceUseService.addDeviceUseInfo(dto);
|
|
}
|
|
}
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ return dto.getId().toString();
|
|
}
|
|
}
|
|
|
|
|
|
- private void recordSample(TrialSelfInspectionRecordDTO dto) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean recordSampleSubmit(RecordSampleSubmitDTO dto) {
|
|
|
|
+ if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
|
+ throw new ServiceException("请先保存填报数据后,再关联取样信息");
|
|
|
|
+ }
|
|
|
|
+ //删除关联信息
|
|
|
|
+ baseMapper.delSelfSample(dto.getId());
|
|
if (StringUtils.isNotEmpty(dto.getSampleIds())) {
|
|
if (StringUtils.isNotEmpty(dto.getSampleIds())) {
|
|
- baseMapper.delSelfSample(dto.getId()); //删除关联信息
|
|
|
|
List<String> ids = Func.toStrList(dto.getSampleIds());
|
|
List<String> ids = Func.toStrList(dto.getSampleIds());
|
|
- for (String id : ids) { //新增关联信息
|
|
|
|
|
|
+ for (String id : ids) {
|
|
|
|
+ //新增关联信息
|
|
baseMapper.saveSelfSample(SnowFlakeUtil.getId(), dto.getId(), id);
|
|
baseMapper.saveSelfSample(SnowFlakeUtil.getId(), dto.getId(), id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- private void recordProjectPosition(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean recordProjectPosition(SelfProjectPositionSubmitDTO dto) throws FileNotFoundException {
|
|
|
|
+ if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
|
+ throw new ServiceException("请先保存填报数据后,再关联工程部位及用途信息");
|
|
|
|
+ }
|
|
|
|
+ //已审批记录关联
|
|
if (StringUtils.isNotEmpty(dto.getProjectPosition())) {
|
|
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);
|
|
|
|
- }
|
|
|
|
|
|
+ TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
|
+ if (("已审批").equals(obj.getTaskStatus())) {
|
|
|
|
+ //删除关联信息
|
|
|
|
+ baseMapper.delSelfQuality(dto.getId());
|
|
|
|
+
|
|
|
|
+ List<String> ids = Func.toStrList(dto.getProjectPosition());
|
|
|
|
+ //新增关联信息
|
|
|
|
+ for (String id : ids) {
|
|
|
|
+ baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), dto.getId(), id);
|
|
|
|
+ }
|
|
|
|
|
|
- //已审批填报记录
|
|
|
|
- if (("已审批").equals(dto.getTaskStatus())) {
|
|
|
|
//把当前试验的PDF合并关联到质检树节点下
|
|
//把当前试验的PDF合并关联到质检树节点下
|
|
- List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(String.valueOf(dto.getId()));
|
|
|
|
-
|
|
|
|
- for (String id : contractNodePKeyIds) {
|
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(id);
|
|
|
|
|
|
+ List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(String.valueOf(dto.getId())); //获取合同段质检树的节点PkeyId
|
|
|
|
+ for (String pKeyId : contractNodePKeyIds) {
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(pKeyId);
|
|
if (wbsTreeContract != null) {
|
|
if (wbsTreeContract != null) {
|
|
List<String> pdfUrlList = new ArrayList<>();
|
|
List<String> pdfUrlList = new ArrayList<>();
|
|
String classify;
|
|
String classify;
|
|
@@ -628,29 +735,40 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
} else {
|
|
} else {
|
|
classify = "2";
|
|
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
|
|
//质检节点合并pdfUrl
|
|
- pdfUrlList.add(pdfUrlAll);
|
|
|
|
|
|
+ pdfUrlList.add(pdfUrlNodeAll);
|
|
//试验pdfUrl
|
|
//试验pdfUrl
|
|
- pdfUrlList.add(ObjectUtil.isNotEmpty(dto.getPdfUrl()) ? dto.getPdfUrl() : "");
|
|
|
|
|
|
+ pdfUrlList.add(obj.getPdfUrl());
|
|
|
|
|
|
//合并PDF
|
|
//合并PDF
|
|
String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
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);
|
|
File tabPDF = ResourceUtil.getFile(listPdf);
|
|
if (tabPDF.exists()) {
|
|
if (tabPDF.exists()) {
|
|
tabPDF.delete();
|
|
tabPDF.delete();
|
|
}
|
|
}
|
|
FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
|
|
FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
|
|
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
|
|
if (bladeFile != null) {
|
|
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("当前试验记录任务未上报审批,关联工程部位及用途信息失败");
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ //删除关联信息
|
|
|
|
+ baseMapper.delSelfQuality(dto.getId());
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
private void buildNumber(TrialSelfInspectionRecordDTO dto) {
|
|
private void buildNumber(TrialSelfInspectionRecordDTO dto) {
|
|
@@ -932,5 +1050,4 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|