|
@@ -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.*;
|
|
@@ -317,14 +318,146 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
} 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;
|
|
@@ -538,8 +671,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String
|
|
|
- projectId, String classify, String id, String tableType) throws Exception {
|
|
|
+ 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();
|
|
@@ -685,7 +817,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
//------获取最新试验记录------
|
|
|
TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
|
|
|
- //------编辑时生成为Null的记录表编号或报告单编号------
|
|
|
+ //------编辑时记录表编号或报告单编号为Null的重新生成------
|
|
|
this.reBuildNumber(obj, dto);
|
|
|
|
|
|
//------保存实体表数据、试验记录信息、生成PDF------
|
|
@@ -697,7 +829,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
//------关联取样信息------
|
|
|
this.recordSampleSubmit(dto, obj);
|
|
|
|
|
|
- //------新增设备使用记录信息------
|
|
|
+ //------关联新增设备使用记录信息------
|
|
|
this.trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
}
|
|
|
return dto.getId().toString();
|
|
@@ -881,13 +1013,6 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId());
|
|
|
List<TrialSelfInspectionRecord> trialSelfInspectionRecords = result.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
- //解决如果当前类型没有表,那么不生成编号
|
|
|
- /*String tableIds = dto.getTableIds();
|
|
|
- List<WbsTreePrivate> recordTab = jdbcTemplate.query("select table_type from m_wbs_tree_private where table_type is not null and p_key_id in (" + tableIds + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
- List<Integer> collect = recordTab.stream().map(WbsTreePrivate::getTableType).distinct().collect(Collectors.toList());
|
|
|
- String tabType = org.apache.commons.lang.StringUtils.join(collect, ",");
|
|
|
- dto.setTableType(tabType);*/
|
|
|
-
|
|
|
//两种类型同时生成
|
|
|
if (dto.getTableType().contains("1,2") || dto.getTableType().contains("2,1")) {
|
|
|
String maxRecordNo = "";
|