|
@@ -204,11 +204,19 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
public boolean selfCopy(List<Long> ids) {
|
|
|
List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectBatchIds(ids);
|
|
|
for (TrialSelfInspectionRecord trialSelfInspectionRecord : trialSelfInspectionRecords) {
|
|
|
- TrialSelfInspectionRecordDTO trialSelfInspectionRecordDTO = BeanUtil.copyProperties(trialSelfInspectionRecord, TrialSelfInspectionRecordDTO.class);
|
|
|
- assert trialSelfInspectionRecordDTO != null;
|
|
|
- trialSelfInspectionRecordDTO.setId(SnowFlakeUtil.getId()); //主键id
|
|
|
- this.buildNumber(trialSelfInspectionRecordDTO); //重构编号
|
|
|
- this.save(trialSelfInspectionRecordDTO); //复制新增
|
|
|
+ TrialSelfInspectionRecordDTO dto = BeanUtil.copyProperties(trialSelfInspectionRecord, TrialSelfInspectionRecordDTO.class);
|
|
|
+ assert dto != null;
|
|
|
+ dto.setId(SnowFlakeUtil.getId());
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRecordNo())) {
|
|
|
+ dto.setTableType("1");
|
|
|
+ } else if (StringUtils.isNotEmpty(dto.getReportNo())) {
|
|
|
+ dto.setTableType("2");
|
|
|
+ } else if (StringUtils.isNotEmpty(dto.getReportNo()) && StringUtils.isNotEmpty(dto.getRecordNo())) {
|
|
|
+ dto.setTableType("1,2");
|
|
|
+ }
|
|
|
+ //重构编号
|
|
|
+ this.buildNumber(dto);
|
|
|
+ this.save(dto);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -642,8 +650,8 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws Exception {
|
|
|
- if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
+ public String selfSubmit(TrialSelfInspectionRecordDTO dto) {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getId()) && StringUtils.isNotEmpty(dto.getTableType())) {
|
|
|
//构建记录表编号、报告单编号
|
|
|
this.buildNumber(dto);
|
|
|
|
|
@@ -667,9 +675,17 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
//获取当前最新的试验记录信息
|
|
|
TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
|
|
|
+ //如果新增时不是两种类型表都填报过,那么有一项编号为Null,所以编辑时生成记录表编号或报告单编号
|
|
|
+ if (StringUtils.isEmpty(obj.getRecordNo()) && dto.getTableType().contains("1")) {
|
|
|
+ this.buildNumber(dto);
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ } else if (StringUtils.isEmpty(obj.getReportNo()) && dto.getTableType().contains("2")) {
|
|
|
+ this.buildNumber(dto);
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
- //保存实体表数据、记录信息、生成pdf
|
|
|
- assert obj != null;
|
|
|
+ //保存实体表数据、试验记录信息、生成pdf
|
|
|
String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
|
if (StringUtils.isNotEmpty(pdfURL)) {
|
|
|
//修改合并pdf
|
|
@@ -817,66 +833,158 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
private void buildNumber(TrialSelfInspectionRecordDTO dto) {
|
|
|
StringSPUtils spUtils = new StringSPUtils();
|
|
|
List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectAll(dto.getNodeId(), dto.getContractId());
|
|
|
- //获取记录表最大编号
|
|
|
- List<String> recordNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList());
|
|
|
- String maxRecordNo;
|
|
|
- if (recordNos.size() == 0 || ObjectUtil.isEmpty(recordNos)) {
|
|
|
- maxRecordNo = "0001";
|
|
|
- } else {
|
|
|
- List<String> numberRecordNos = new ArrayList<>();
|
|
|
- for (String recordNo : recordNos) {
|
|
|
- String number = recordNo.split("-")[recordNo.split("-").length - 1];
|
|
|
- numberRecordNos.add(number);
|
|
|
+
|
|
|
+ //两种类型同时生成
|
|
|
+ if (dto.getTableType().contains("1,2") || dto.getTableType().contains("2,1")) {
|
|
|
+ String maxRecordNo = "";
|
|
|
+ if (StringUtils.isEmpty(dto.getRecordNo())) {
|
|
|
+ //获取记录表最大编号
|
|
|
+ List<String> recordNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList());
|
|
|
+ if (recordNos.size() == 0 || ObjectUtil.isEmpty(recordNos)) {
|
|
|
+ maxRecordNo = "0001";
|
|
|
+ } else {
|
|
|
+ List<String> numberRecordNos = new ArrayList<>();
|
|
|
+ for (String recordNo : recordNos) {
|
|
|
+ String number = recordNo.split("-")[recordNo.split("-").length - 1];
|
|
|
+ numberRecordNos.add(number);
|
|
|
+ }
|
|
|
+ int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
|
|
|
+ if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
|
|
|
+ maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
|
|
|
- if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
|
|
|
- maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
|
|
|
+
|
|
|
+ String maxReportNo = "";
|
|
|
+ if (StringUtils.isEmpty(dto.getReportNo())) {
|
|
|
+ //获取报告单最大编号
|
|
|
+ List<String> reportNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList());
|
|
|
+ if (reportNos.size() == 0 || ObjectUtil.isEmpty(reportNos)) {
|
|
|
+ maxReportNo = "0001";
|
|
|
+ } else {
|
|
|
+ List<String> numberReportNo = new ArrayList<>();
|
|
|
+ for (String reportNo : reportNos) {
|
|
|
+ String number = reportNo.split("-")[reportNo.split("-").length - 1];
|
|
|
+ numberReportNo.add(number);
|
|
|
+ }
|
|
|
+ int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
|
|
|
+ if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
|
|
|
+ maxReportNo = spUtils.buildSerial(maxReportNo1, 4);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
|
|
|
+ ContractInfo contract = contractClient.getContractById(dto.getContractId());
|
|
|
+ int year = LocalDateTimeUtil.now().getYear();
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ throw new ServiceException("未找到当前节点信息,操作失败!");
|
|
|
} else {
|
|
|
- throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ //记录表
|
|
|
+ if (StringUtils.isNotEmpty(maxRecordNo)) {
|
|
|
+ String str1 = "JL" +
|
|
|
+ "-" + contract.getContractNumber() +
|
|
|
+ "-" + year +
|
|
|
+ "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
+ "-" + maxRecordNo;
|
|
|
+ dto.setRecordNo(str1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //报告单
|
|
|
+ if (StringUtils.isNotEmpty(maxReportNo)) {
|
|
|
+ String str2 = "BG" +
|
|
|
+ "-" + contract.getContractNumber() +
|
|
|
+ "-" + year +
|
|
|
+ "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
+ "-" + maxReportNo;
|
|
|
+ dto.setReportNo(str2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取报告单最大编号
|
|
|
- List<String> reportNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList());
|
|
|
- String maxReportNo;
|
|
|
- if (reportNos.size() == 0 || ObjectUtil.isEmpty(reportNos)) {
|
|
|
- maxReportNo = "0001";
|
|
|
- } else {
|
|
|
- List<String> numberReportNo = new ArrayList<>();
|
|
|
- for (String reportNo : reportNos) {
|
|
|
- String number = reportNo.split("-")[reportNo.split("-").length - 1];
|
|
|
- numberReportNo.add(number);
|
|
|
- }
|
|
|
- int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
|
|
|
- if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
|
|
|
- maxReportNo = spUtils.buildSerial(maxReportNo1, 4);
|
|
|
- } else {
|
|
|
- throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ //记录表
|
|
|
+ if (("1").equals(dto.getTableType())) {
|
|
|
+ if (StringUtils.isEmpty(dto.getRecordNo())) {
|
|
|
+ //获取记录表最大编号
|
|
|
+ List<String> recordNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList());
|
|
|
+ String maxRecordNo;
|
|
|
+ if (recordNos.size() == 0 || ObjectUtil.isEmpty(recordNos)) {
|
|
|
+ maxRecordNo = "0001";
|
|
|
+ } else {
|
|
|
+ List<String> numberRecordNos = new ArrayList<>();
|
|
|
+ for (String recordNo : recordNos) {
|
|
|
+ String number = recordNo.split("-")[recordNo.split("-").length - 1];
|
|
|
+ numberRecordNos.add(number);
|
|
|
+ }
|
|
|
+ int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
|
|
|
+ if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
|
|
|
+ maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
|
|
|
+ ContractInfo contract = contractClient.getContractById(dto.getContractId());
|
|
|
+ int year = LocalDateTimeUtil.now().getYear();
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ throw new ServiceException("未找到当前节点信息,操作失败!");
|
|
|
+ } else {
|
|
|
+ //记录表
|
|
|
+ String str1 = "JL" +
|
|
|
+ "-" + contract.getContractNumber() +
|
|
|
+ "-" + year +
|
|
|
+ "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
+ "-" + maxRecordNo;
|
|
|
+ dto.setRecordNo(str1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
|
|
|
- WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
|
|
|
- ContractInfo contract = contractClient.getContractById(dto.getContractId());
|
|
|
- int year = LocalDateTimeUtil.now().getYear();
|
|
|
- if (wbsTreePrivate == null) {
|
|
|
- throw new ServiceException("未找到当前节点信息,操作失败!");
|
|
|
- } else {
|
|
|
- //记录表
|
|
|
- String str1 = "JL" +
|
|
|
- "-" + contract.getContractNumber() +
|
|
|
- "-" + year +
|
|
|
- "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
- "-" + maxRecordNo;
|
|
|
- dto.setRecordNo(str1);
|
|
|
-
|
|
|
- //报告单
|
|
|
- String str2 = "BG" +
|
|
|
- "-" + contract.getContractNumber() +
|
|
|
- "-" + year +
|
|
|
- "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
- "-" + maxReportNo;
|
|
|
- dto.setReportNo(str2);
|
|
|
+ //报告单
|
|
|
+ if (("2").equals(dto.getTableType())) {
|
|
|
+ if (StringUtils.isEmpty(dto.getReportNo())) {
|
|
|
+ //获取报告单最大编号
|
|
|
+ List<String> reportNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList());
|
|
|
+ String maxReportNo;
|
|
|
+ if (reportNos.size() == 0 || ObjectUtil.isEmpty(reportNos)) {
|
|
|
+ maxReportNo = "0001";
|
|
|
+ } else {
|
|
|
+ List<String> numberReportNo = new ArrayList<>();
|
|
|
+ for (String reportNo : reportNos) {
|
|
|
+ String number = reportNo.split("-")[reportNo.split("-").length - 1];
|
|
|
+ numberReportNo.add(number);
|
|
|
+ }
|
|
|
+ int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
|
|
|
+ if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
|
|
|
+ maxReportNo = spUtils.buildSerial(maxReportNo1, 4);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前编号已达到最大值9999,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
|
|
|
+ ContractInfo contract = contractClient.getContractById(dto.getContractId());
|
|
|
+ int year = LocalDateTimeUtil.now().getYear();
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ throw new ServiceException("未找到当前节点信息,操作失败!");
|
|
|
+ } else {
|
|
|
+ //报告单
|
|
|
+ String str2 = "BG" +
|
|
|
+ "-" + contract.getContractNumber() +
|
|
|
+ "-" + year +
|
|
|
+ "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
|
|
|
+ "-" + maxReportNo;
|
|
|
+ dto.setReportNo(str2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|