|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.spire.xls.*;
|
|
|
import io.swagger.models.auth.In;
|
|
|
+import jdk.nashorn.internal.scripts.JD;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springblade.business.dto.*;
|
|
@@ -59,9 +60,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
-public class TrialSelfInspectionRecordServiceImpl
|
|
|
- extends BaseServiceImpl<TrialSelfInspectionRecordMapper, TrialSelfInspectionRecord>
|
|
|
- implements ITrialSelfInspectionRecordService {
|
|
|
+public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialSelfInspectionRecordMapper, TrialSelfInspectionRecord> implements ITrialSelfInspectionRecordService {
|
|
|
|
|
|
private final TrialSampleInfoMapper trialSampleInfoMapper;
|
|
|
private final TrialMaterialMobilizationMapper trialMaterialMobilizationMapper;
|
|
@@ -81,70 +80,109 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
|
|
|
@Override
|
|
|
public IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException {
|
|
|
- QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
- if (StringUtils.isNotEmpty(dto.getQueryValue())) {
|
|
|
- queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue());
|
|
|
- }
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
- String endTime = dto.getEndTime();
|
|
|
- endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
- queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
|
|
|
- }
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryName())) {
|
|
|
- queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialUserName, dto.getQueryName());
|
|
|
- }
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
|
|
|
- queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
|
|
|
- }
|
|
|
- IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
|
|
|
- IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
|
|
|
- List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
|
|
|
- Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
|
|
|
+ //获取当前选择节点所有的子级节点pKeyIds
|
|
|
+ WbsTreePrivate selectedNode = jdbcTemplate.query("select id,project_id from m_wbs_tree_private where p_key_id = " + dto.getNodeId(), new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
+ if (selectedNode != null) {
|
|
|
+ List<WbsTreePrivate> ziNodePKeyIds = jdbcTemplate.query("select p_key_id from m_wbs_tree_private where type = 1 and is_deleted = 0 and project_id = " + selectedNode.getProjectId() + " and find_in_set('" + selectedNode.getId() + "',ancestors)", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
+ if (ziNodePKeyIds.size() > 0) {
|
|
|
+ dto.setNodeId(null);
|
|
|
+ List<Long> pIds = ziNodePKeyIds.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
+ queryWrapper.lambda().in(TrialSelfInspectionRecord::getNodeId, pIds);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getQueryValue())) {
|
|
|
+ queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue());
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
+ String endTime = dto.getEndTime();
|
|
|
+ endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
+ queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryName())) {
|
|
|
+ queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialUserName, dto.getQueryName());
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
|
|
|
+ queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
|
|
|
+ }
|
|
|
|
|
|
- for (TrialSelfInspectionRecordVO record : records) {
|
|
|
- record.setIsUploadCertificateName((new Integer(1)).equals(record.getIsUploadCertificate()) ? "是" : "否");
|
|
|
- record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "不合格");
|
|
|
+ IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
|
|
|
+ IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
|
|
|
+ List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
|
|
|
+ Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
|
|
|
- Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
|
|
|
- if (dict != null) {
|
|
|
- record.setDetectionCategoryName(dict.getDictValue());
|
|
|
+ for (TrialSelfInspectionRecordVO record : records) {
|
|
|
+ record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "");
|
|
|
+ if (StringUtils.isNotEmpty(record.getDetectionResultName())) {
|
|
|
+ record.setDetectionResult(1);
|
|
|
+ } else {
|
|
|
+ record.setDetectionResult(0);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //工程部位及用途名称
|
|
|
- if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
|
|
|
- List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
|
|
|
- List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
|
|
|
- List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
|
- String name = projectPositionNames.stream().findAny().orElse(null);
|
|
|
- if (projectPositionNames.size() > 1) {
|
|
|
- record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
|
|
|
+ if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
|
|
|
+ Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
|
|
|
+ if (dict != null) {
|
|
|
+ record.setDetectionCategoryName(dict.getDictValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //工程部位及用途名称
|
|
|
+ if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
|
|
|
+ List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
|
|
|
+ List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
|
|
|
+ List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
|
+ String name = projectPositionNames.stream().findAny().orElse(null);
|
|
|
+ if (projectPositionNames.size() > 1) {
|
|
|
+ record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
|
|
|
+ } else {
|
|
|
+ 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, ","));
|
|
|
+ this.getIsUploadCertificateStatus(record.getSampleIds(), record);
|
|
|
} else {
|
|
|
- record.setProjectPositionName(name);
|
|
|
+ record.setIsUploadCertificate(-1);
|
|
|
+ record.setIsUploadCertificateName(""); //没关联材料显示null
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //关联取样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, ","));
|
|
|
- }
|
|
|
+ //原材料检测报告ids
|
|
|
+ String sql1 = "select raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + record.getId();
|
|
|
+ List<TrialRawMaterialSelfRecord> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
+ if (query1.size() > 0) {
|
|
|
+ List<Long> ids = query1.stream().map(TrialRawMaterialSelfRecord::getRawMaterialRecordId).collect(Collectors.toList());
|
|
|
+ record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
|
|
|
+ }
|
|
|
|
|
|
- //原材料检测报告ids
|
|
|
- String sql1 = "select raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + record.getId();
|
|
|
- List<TrialRawMaterialSelfRecord> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
- if (query1.size() > 0) {
|
|
|
- List<Long> ids = query1.stream().map(TrialRawMaterialSelfRecord::getRawMaterialRecordId).collect(Collectors.toList());
|
|
|
- record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
|
|
|
+ //合并的pdfUrl
|
|
|
+ String pdf = this.getMergePdfToTrial(record.getContractId(), record.getId());
|
|
|
+ record.setPdfUrl(pdf);
|
|
|
}
|
|
|
|
|
|
- //合并的pdfUrl
|
|
|
- String pdf = this.getMergePdfToTrial(record.getContractId(), record.getId());
|
|
|
- record.setPdfUrl(pdf);
|
|
|
+ return trialSelfInspectionRecordVOIPage.setRecords(records);
|
|
|
}
|
|
|
- return trialSelfInspectionRecordVOIPage.setRecords(records);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getIsUploadCertificateStatus(String sampleIds, TrialSelfInspectionRecordVO record) {
|
|
|
+ List<TrialSamplingRecord> mobilizationIds = jdbcTemplate.query("select mobilization_id from u_trial_sampling_record where sample_info_id in(" + sampleIds + ")", new BeanPropertyRowMapper<>(TrialSamplingRecord.class));
|
|
|
+ if (mobilizationIds.size() > 0) {
|
|
|
+ List<Long> collect = mobilizationIds.stream().map(TrialSamplingRecord::getMobilizationId).collect(Collectors.toList());
|
|
|
+ String join = org.apache.commons.lang.StringUtils.join(collect, ",");
|
|
|
+ List<TrialMaterialMobilization> mobilizations = jdbcTemplate.query("select production_certificate from u_trial_material_mobilization where id in(" + join + ")", new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
|
|
|
+ List<TrialMaterialMobilization> notUpdate = mobilizations.stream().filter(f -> ObjectUtils.isEmpty(f.getProductionCertificate())).collect(Collectors.toList());
|
|
|
+ if (notUpdate.size() != 0) {
|
|
|
+ record.setIsUploadCertificate(1);
|
|
|
+ record.setIsUploadCertificateName("是");
|
|
|
+ } else {
|
|
|
+ record.setIsUploadCertificate(0);
|
|
|
+ record.setIsUploadCertificateName("否");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private String getMergePdfToTrial(Long contractId, Long nodeId) throws FileNotFoundException {
|
|
@@ -224,12 +262,20 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
for (Attach attach : query) {
|
|
|
if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
|
|
|
sampleAncillaryDocumentsVO.setOtherAccessoriesName(attach.getOriginalName());
|
|
|
+ } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && !sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
|
|
|
+ sampleAncillaryDocumentsVO.setOtherAccessoriesName(sampleAncillaryDocumentsVO.getOtherAccessories());
|
|
|
}
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
|
|
|
sampleAncillaryDocumentsVO.setProductionCertificateName(attach.getOriginalName());
|
|
|
+ } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && !sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
|
|
|
+ sampleAncillaryDocumentsVO.setProductionCertificateName(sampleAncillaryDocumentsVO.getProductionCertificate());
|
|
|
}
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
|
|
|
sampleAncillaryDocumentsVO.setQualityInspectionReportName(attach.getOriginalName());
|
|
|
+ } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && !sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
|
|
|
+ sampleAncillaryDocumentsVO.setQualityInspectionReportName(sampleAncillaryDocumentsVO.getQualityInspectionReport());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -272,14 +318,146 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
} else if (StringUtils.isNotEmpty(dto.getReportNo()) && StringUtils.isNotEmpty(dto.getRecordNo())) {
|
|
|
dto.setTableType("1,2");
|
|
|
}
|
|
|
+
|
|
|
//重构编号
|
|
|
this.buildNumber(dto);
|
|
|
+ this.reNumberNo(trialSelfInspectionRecord, dto);
|
|
|
+
|
|
|
+ dto.setCreateTime(new Date());
|
|
|
+ dto.setTaskStatus("未上报");
|
|
|
+ dto.setId(SnowFlakeUtil.getId());
|
|
|
this.save(dto);
|
|
|
+
|
|
|
+ //复制表数据、表附件文件
|
|
|
+ String tableIds = trialSelfInspectionRecord.getTableIds();
|
|
|
+ if (StringUtils.isNotEmpty(tableIds)) {
|
|
|
+ //获取表的数据源
|
|
|
+ List<String> pKeyIds = Func.toStrList(tableIds);
|
|
|
+ for (String pKeyId : pKeyIds) {
|
|
|
+ WbsTreePrivate tab = wbsTreePrivateClient.getNodeByPrimaryKeyId(pKeyId);
|
|
|
+ //复制数据
|
|
|
+ List<Map<String, Object>> oneTabData = wbsTreePrivateClient.getTrialDataInfo(pKeyId, trialSelfInspectionRecord.getId());
|
|
|
+ if (oneTabData.size() >= 1) {
|
|
|
+ Map<String, Object> dataMap2 = oneTabData.get(0);
|
|
|
+
|
|
|
+ dataMap2.remove("id");
|
|
|
+ dataMap2.remove("p_key_id");
|
|
|
+ dataMap2.remove("group_id");
|
|
|
+
|
|
|
+ //sql组装
|
|
|
+ String sqlInfo = "";
|
|
|
+ sqlInfo = "INSERT INTO " + tab.getInitTableName() + " (";
|
|
|
+ StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
|
|
|
+ StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + pKeyId + "," + dto.getId() + ",");
|
|
|
+ for (String keys : dataMap2.keySet()) {
|
|
|
+ if (!(dataMap2.get(keys) + "").equals("null")) {
|
|
|
+ String keysResult = keys.split("__")[0];
|
|
|
+ String keysResult2 = keys.split("__")[1];
|
|
|
+ keyStr.append(keysResult).append(",");
|
|
|
+ Object value = dataMap2.get(keys);
|
|
|
+
|
|
|
+ //替换报告单号、记录编号
|
|
|
+ if (String.valueOf(value).contains("JL-")) {
|
|
|
+ value = StringUtils.isNotEmpty(dto.getRecordNo()) ? dto.getRecordNo() : null;
|
|
|
+ }
|
|
|
+ if (String.valueOf(value).contains("BG-")) {
|
|
|
+ value = StringUtils.isNotEmpty(dto.getReportNo()) ? dto.getReportNo() : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String values = value + "_^_" + keysResult2;
|
|
|
+ valStr.append("'").append(values).append("',");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
|
|
|
+ valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
|
|
|
+ sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
+ //新增
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //复制附件文件
|
|
|
+ List<TableFile> oldFiles = jdbcTemplate.query("select domain_url,name,extension,type,is_deleted,domain_pdf_url,status from m_table_file where is_deleted = 0 and tab_id = '" + pKeyId + "' and trial_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TableFile.class));
|
|
|
+ List<TableFile> newFiles = new ArrayList<>();
|
|
|
+ for (TableFile oldFile : oldFiles) {
|
|
|
+ TableFile obj = BeanUtil.copyProperties(oldFile, TableFile.class);
|
|
|
+ if (obj != null) {
|
|
|
+ obj.setId(SnowFlakeUtil.getId());
|
|
|
+ obj.setTabId(pKeyId + ""); //表pKeyId
|
|
|
+ obj.setTrialRecordId(dto.getId()); //当前记录id
|
|
|
+ newFiles.add(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tableFileClient.saveBatch(newFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //复制试验记录关联相关信息:工程部位、原材料检测报告、取样信息
|
|
|
+ //1、工程部位与projectPosition字段绑定,在审批时建立关联关系
|
|
|
+
|
|
|
+ //2、原材料检测报告
|
|
|
+ List<TrialRawMaterialSelfRecord> query = jdbcTemplate.query("select self_record_id,raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
+ for (TrialRawMaterialSelfRecord record : query) {
|
|
|
+ //新增关系
|
|
|
+ jdbcTemplate.execute("insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values (" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + record.getRawMaterialRecordId() + "," + (StringUtils.isNotEmpty(record.getOldPdfUrl()) ? record.getOldPdfUrl() : null) + ")");
|
|
|
+ }
|
|
|
+
|
|
|
+ //3、取样信息
|
|
|
+ List<TrialSelfSample> qyInfo = jdbcTemplate.query("select sampling_id from u_trial_self_sample where self_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TrialSelfSample.class));
|
|
|
+ for (TrialSelfSample trialSelfSample : qyInfo) {
|
|
|
+ //新增关系
|
|
|
+ jdbcTemplate.execute("insert into u_trial_self_sample(id,self_id,sampling_id) values (" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + trialSelfSample.getSamplingId() + ")");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private void reNumberNo(TrialSelfInspectionRecord trialSelfInspectionRecord, TrialSelfInspectionRecordDTO dto) {
|
|
|
+ StringSPUtils spUtils = new StringSPUtils();
|
|
|
+ List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
|
|
|
+ .select(TrialSelfInspectionRecord::getReportNo, TrialSelfInspectionRecord::getRecordNo)
|
|
|
+ .and(obj -> obj.like(TrialSelfInspectionRecord::getReportNo, "BG-").or().like(TrialSelfInspectionRecord::getRecordNo, "JL-"))
|
|
|
+ .eq(TrialSelfInspectionRecord::getContractId, trialSelfInspectionRecord.getContractId()).eq(TrialSelfInspectionRecord::getNodeId, trialSelfInspectionRecord.getNodeId()));
|
|
|
+
|
|
|
+ List<TrialSelfInspectionRecord> bg = recordList.stream().filter(f -> f.getReportNo().contains("BG-")).collect(Collectors.toList());
|
|
|
+ List<TrialSelfInspectionRecord> jl = recordList.stream().filter(f -> f.getRecordNo().contains("JL-")).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (jl.size() > 0) {
|
|
|
+ List<String> numberRecordNos = new ArrayList<>();
|
|
|
+ for (String recordNo : jl.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList())) {
|
|
|
+ String number = recordNo.split("-")[recordNo.split("-").length - 1];
|
|
|
+ numberRecordNos.add(number);
|
|
|
+ }
|
|
|
+ int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
|
|
|
+ if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
|
|
|
+ String recordNo = dto.getRecordNo();
|
|
|
+ String substring = recordNo.substring(recordNo.length() - 4);
|
|
|
+ String s = spUtils.buildSerial(maxRecordNo1, 4);
|
|
|
+ String replace = recordNo.replace(substring, s);
|
|
|
+ dto.setRecordNo(replace);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bg.size() > 0) {
|
|
|
+ List<String> numberReportNos = new ArrayList<>();
|
|
|
+ for (String reportNo : bg.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList())) {
|
|
|
+ String number = reportNo.split("-")[reportNo.split("-").length - 1];
|
|
|
+ numberReportNos.add(number);
|
|
|
+ }
|
|
|
+ int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNos)) + 1;
|
|
|
+ if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
|
|
|
+ String reportNo = dto.getReportNo();
|
|
|
+ String substring = reportNo.substring(reportNo.length() - 4);
|
|
|
+ String s = spUtils.buildSerial(maxReportNo1, 4);
|
|
|
+ String replace = reportNo.replace(substring, s);
|
|
|
+ dto.setReportNo(replace);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<TrialSelfInspectionRecordVO2> getRawMaterialInfo(String nodeId, String contractId, String id) {
|
|
|
List<TrialSelfInspectionRecordVO2> recordVO2s;
|
|
@@ -407,64 +585,62 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
- public void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, List<TaskApprovalVO> obj) throws FileNotFoundException {
|
|
|
- for (TaskApprovalVO taskApprovalVO : obj) {
|
|
|
- if (ObjectUtil.isNotEmpty(taskApprovalVO.getParallelProcessInstanceId())) {
|
|
|
- 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);
|
|
|
- if (taskParallel != null && 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()) ? "已审批" : "已废除")
|
|
|
- .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
|
|
|
- .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
|
|
|
- );
|
|
|
-
|
|
|
- TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
|
|
|
- //此时的record.getPdfUrl()为电签后的pdf信息
|
|
|
- if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
|
|
|
- /**
|
|
|
- * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
|
|
|
- */
|
|
|
- if (StringUtils.isNotEmpty(record.getProjectPosition())) {
|
|
|
- //有pdf的节点
|
|
|
- String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
|
|
|
- List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
|
|
|
- if (collect.size() > 0) {
|
|
|
- //删除当前记录关联记录
|
|
|
- baseMapper.delSelfQuality(record.getId());
|
|
|
- for (Long pKeyId : collect) {
|
|
|
- //新增当前记录关联信息
|
|
|
- baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
|
|
|
-
|
|
|
- //获取当前工程部位节点最新的关联试验记录ids
|
|
|
- List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
|
|
|
-
|
|
|
- //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
|
|
|
- if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
|
|
|
- //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
|
|
|
- baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //如果当前工程部位节点的关联试验记录id有多条,那么合并
|
|
|
- List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
|
|
|
- List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
-
|
|
|
- String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
- String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
|
|
|
- File tabPDF = ResourceUtil.getFile(listPdf);
|
|
|
- if (tabPDF.exists()) {
|
|
|
- tabPDF.delete();
|
|
|
- }
|
|
|
-
|
|
|
- FileUtils.mergePdfPublicMethods(pdfS, listPdf);
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
|
|
|
- if (bladeFile != null) {
|
|
|
- //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
|
|
|
- baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
|
|
|
- }
|
|
|
+ public void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, TaskApprovalVO obj) throws FileNotFoundException {
|
|
|
+ if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
|
|
|
+ String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
|
|
|
+ TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
|
|
|
+ if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
|
|
|
+ String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
|
|
|
+ if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
|
|
|
+ .set(TrialSelfInspectionRecord::getTaskStatus, "已审批")
|
|
|
+ .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
|
|
|
+ .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
|
|
|
+ );
|
|
|
+
|
|
|
+ TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
|
|
|
+ //此时的record.getPdfUrl()为电签后的pdf信息
|
|
|
+ if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
|
|
|
+ /**
|
|
|
+ * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
|
|
|
+ */
|
|
|
+ if (StringUtils.isNotEmpty(record.getProjectPosition())) {
|
|
|
+ //有pdf的节点
|
|
|
+ String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
|
|
|
+ List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ //删除当前记录关联记录
|
|
|
+ baseMapper.delSelfQuality(record.getId());
|
|
|
+ for (Long pKeyId : collect) {
|
|
|
+ //新增当前记录关联信息
|
|
|
+ baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
|
|
|
+
|
|
|
+ //获取当前工程部位节点最新的关联试验记录ids
|
|
|
+ List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
|
|
|
+
|
|
|
+ //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
|
|
|
+ if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
|
|
|
+ //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
|
|
|
+ baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果当前工程部位节点的关联试验记录id有多条,那么合并
|
|
|
+ List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
|
|
|
+ List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
+
|
|
|
+ String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
|
|
|
+ File tabPDF = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabPDF.exists()) {
|
|
|
+ tabPDF.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfS, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
|
|
|
+ if (bladeFile != null) {
|
|
|
+ //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
|
|
|
+ baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -476,8 +652,26 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String
|
|
|
- projectId, String classify, String id, String tableType) throws Exception {
|
|
|
+ public void updateTrialSelfInspectionRecordStatusFC(TaskApprovalVO obj) {
|
|
|
+ if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
|
|
|
+ String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
|
|
|
+ TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
|
|
|
+ if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
|
|
|
+ String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
|
|
|
+ if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
|
|
|
+ .set(TrialSelfInspectionRecord::getTaskStatus, "已废除")
|
|
|
+ .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
|
|
|
+ );
|
|
|
+ //废除后修改电签为null
|
|
|
+ jdbcTemplate.execute("update u_information_query set e_visa_pdf_url = null where wbs_id = " + trialSelfInspectionRecordId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String projectId, String classify, String id, String tableType) throws Exception {
|
|
|
R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
BladeFile bladeFile1 = bladeFile.getData();
|
|
|
TableFile tableFile = new TableFile();
|
|
@@ -610,12 +804,12 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
|
|
|
@Override
|
|
|
public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
|
|
|
+ //------初始当前填报的表pKeyIds------
|
|
|
+ this.initTrialTabIds(dto);
|
|
|
+
|
|
|
//------初始编号信息------
|
|
|
this.initBuildNumber(dto);
|
|
|
|
|
|
- //------初始当前填报的表------
|
|
|
- this.initTrialTabIds(dto);
|
|
|
-
|
|
|
//------新增或编辑------
|
|
|
this.saveOrUpdate(dto);
|
|
|
|
|
@@ -623,7 +817,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
//------获取最新试验记录------
|
|
|
TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
|
|
|
- //------编辑时生成为Null的记录表编号或报告单编号------
|
|
|
+ //------编辑时记录表编号或报告单编号为Null的重新生成------
|
|
|
this.reBuildNumber(obj, dto);
|
|
|
|
|
|
//------保存实体表数据、试验记录信息、生成PDF------
|
|
@@ -635,7 +829,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
//------关联取样信息------
|
|
|
this.recordSampleSubmit(dto, obj);
|
|
|
|
|
|
- //------新增设备使用记录信息------
|
|
|
+ //------关联新增设备使用记录信息------
|
|
|
this.trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
}
|
|
|
return dto.getId().toString();
|
|
@@ -659,41 +853,6 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
List<String> ids = tableIds.stream().distinct().collect(Collectors.toList());
|
|
|
String join = org.apache.commons.lang.StringUtils.join(ids, ",");
|
|
|
dto.setTableIds(join);
|
|
|
-
|
|
|
- // TODO 如果前端处理了隐藏表入参的情况(即:隐藏表单pKeyId不传),那么接口就不处理
|
|
|
- /*//获取按钮状态,是否为隐藏表单,移除隐藏表单(编辑时)
|
|
|
- if (ObjectUtils.isNotEmpty(dto.getId())) {
|
|
|
- List<TrialSelfDataRecord> tabStatus = jdbcTemplate.query("select is_buss_show,tab_id from u_trial_self_data_record where record_id = " + dto.getId(), new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
|
|
|
- if (tabStatus.size() > 0) {
|
|
|
- Map<Long, TrialSelfDataRecord> collect = tabStatus.stream().collect(Collectors.toMap(TrialSelfDataRecord::getTabId, Function.identity()));
|
|
|
- List<Long> pKeyIds = Func.toLongList(dto.getTableIds());
|
|
|
- List<Long> addPkeyIds = new ArrayList<>();
|
|
|
- for (Long pId : pKeyIds) {
|
|
|
- TrialSelfDataRecord record = collect.get(pId);
|
|
|
- if (record != null) {
|
|
|
- //隐藏的不添加
|
|
|
- if (!new Integer(2).equals(record.getIsBussShow())) {
|
|
|
- addPkeyIds.add(pId);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //未生成记录的添加进去
|
|
|
- addPkeyIds.add(pId);
|
|
|
- }
|
|
|
- }
|
|
|
- //重新赋值
|
|
|
- String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
|
|
|
- dto.setTableIds(joinNew);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //获取按钮状态,是否为隐藏表单,移除隐藏表单(新增时)
|
|
|
- String tablePkeyIds = dto.getTableIds();
|
|
|
- List<WbsTreePrivate> tableList = jdbcTemplate.query("select is_buss_show,p_key_id from m_wbs_tree_private where status = 1 and p_key_id in(" + tablePkeyIds + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
- List<Long> addPkeyIds = tableList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getIsBussShow()) && !(new Integer(2).equals(f.getIsBussShow()))).map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
-
|
|
|
- //重新赋值
|
|
|
- String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
|
|
|
- dto.setTableIds(joinNew);
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
private void reBuildNumber(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
@@ -709,7 +868,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
@Async
|
|
|
public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
|
try {
|
|
|
- String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
|
+ String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
|
if (StringUtils.isNotEmpty(pdfURL)) {
|
|
|
this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
}
|