Commit 13c1dd88 authored by 刘林's avatar 刘林

fix(jg):超设计使用年限bug修改

parent 0b6225ae
...@@ -557,13 +557,13 @@ public class CommonController extends BaseController { ...@@ -557,13 +557,13 @@ public class CommonController extends BaseController {
result.forEach(e -> { result.forEach(e -> {
if (e.getOrDefault("dictDataKey", "").equals("2000")) { if (e.getOrDefault("dictDataKey", "").equals("2000")) {
e.put("tips", "变更前需先进行委托检验,在办理变更登记时上传委托检验报告!"); e.put("tips", "变更前需先进行委托检验,在办理变更登记时上传委托检验报告!");
} else { } else {
e.put("tips", "变更前需先进行安全评估,评估结果为改造或重大维修,需办理改造或维修告知,进行监督检验后,再进行变更登记;评估结果为一般维修,需办理定期检验,再进行变更登记!"); e.put("tips", "变更前需先进行安全评估,评估结果为改造或重大维修,需办理改造或维修告知,进行监督检验后,再进行变更登记;评估结果为一般维修,需办理定期检验,再进行变更登记!");
} }
}); });
} else {
result.forEach(e -> e.remove("tips"));
} }
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
...@@ -800,13 +800,13 @@ public class CommonController extends BaseController { ...@@ -800,13 +800,13 @@ public class CommonController extends BaseController {
} }
/** /**
* 使用登记证变更证明 * 超设计使用变更登记变更证明生成
* *
* @param map 参数 * @param map 参数
* @return 变更证明url * @return 变更证明url
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "使用登记变更证明生成", notes = "使用登记变更证明生成") @ApiOperation(httpMethod = "POST", value = "超设计使用变更登记变更证明生成", notes = "超设计使用变更登记变更证明生成")
@PostMapping(value = "/getRegistrationChangeCertificateUrl") @PostMapping(value = "/getRegistrationChangeCertificateUrl")
public ResponseModel<Map<String, Object>> getRegistrationChangeCertificateUrl(@RequestBody JSONObject map) { public ResponseModel<Map<String, Object>> getRegistrationChangeCertificateUrl(@RequestBody JSONObject map) {
JSONObject formData = JSONObject.parseObject(JSONObject.toJSONString(map.get("formData"))); JSONObject formData = JSONObject.parseObject(JSONObject.toJSONString(map.get("formData")));
...@@ -815,6 +815,18 @@ public class CommonController extends BaseController { ...@@ -815,6 +815,18 @@ public class CommonController extends BaseController {
return ResponseHelper.buildResponse(commonService.getRegistrationChangeCertificateUrl(formData)); return ResponseHelper.buildResponse(commonService.getRegistrationChangeCertificateUrl(formData));
} }
/**
* 超设计使用变更登记变更证明生成pdf流生成
* @param response
* @param jsonObject
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "超设计使用变更登记变更证明生成pdf流生成", notes = "超设计使用变更登记变更证明生成pdf流生成")
@PostMapping(value = "/getRegistrationChangeCertificateFormStream")
public void getRegistrationChangeCertificateFormStream(HttpServletResponse response, @RequestBody JSONObject jsonObject) {
commonService.getRegistrationChangeCertificateFormStream(jsonObject, response);
}
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "pdf流生成", notes = "pdf流生成") @ApiOperation(httpMethod = "POST", value = "pdf流生成", notes = "pdf流生成")
@PostMapping(value = "/getRegistrationFormStream") @PostMapping(value = "/getRegistrationFormStream")
......
...@@ -266,4 +266,6 @@ public interface ICommonService { ...@@ -266,4 +266,6 @@ public interface ICommonService {
void getRegistrationFormStream(JSONObject formData,String manageType,HttpServletResponse response); void getRegistrationFormStream(JSONObject formData,String manageType,HttpServletResponse response);
Map<String, Object> getRegistrationChangeCertificateUrl(JSONObject formData); Map<String, Object> getRegistrationChangeCertificateUrl(JSONObject formData);
void getRegistrationChangeCertificateFormStream(JSONObject jsonObject, HttpServletResponse response);
} }
...@@ -73,6 +73,7 @@ import freemarker.template.Configuration; ...@@ -73,6 +73,7 @@ import freemarker.template.Configuration;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.multipdf.PDFMergerUtility; import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.redisson.api.RBucket; import org.redisson.api.RBucket;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
...@@ -1348,9 +1349,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -1348,9 +1349,7 @@ public class CommonServiceImpl implements ICommonService {
JSONObject jsonObject = new JSONObject(noticeObj); JSONObject jsonObject = new JSONObject(noticeObj);
return jgEnableDisableServiceImpl.saveOrUpdate(jsonObject, reginParams); return jgEnableDisableServiceImpl.saveOrUpdate(jsonObject, reginParams);
} else if (type.equals(ApplicationFormTypeEnum.CSJ.getBusinessCode())) { } else if (type.equals(ApplicationFormTypeEnum.CSJ.getBusinessCode())) {
if ("1".equals(uploadMode)) { noticeObj.put("submit", "1".equals(uploadMode) ? "1" : "0");
noticeObj.put("submit", Boolean.TRUE);
}
noticeObj.put("formType", "add"); noticeObj.put("formType", "add");
noticeObj.put("receiveOrgCode", !ObjectUtils.isEmpty(basicObj.get("receiveOrgCreditCode")) ? String.valueOf(basicObj.get("receiveOrgCreditCode")) : String.valueOf(basicObj.get("receiveOrgCreditCode1"))); noticeObj.put("receiveOrgCode", !ObjectUtils.isEmpty(basicObj.get("receiveOrgCreditCode")) ? String.valueOf(basicObj.get("receiveOrgCreditCode")) : String.valueOf(basicObj.get("receiveOrgCreditCode1")));
JSONObject jsonObject = new JSONObject(noticeObj); JSONObject jsonObject = new JSONObject(noticeObj);
...@@ -2476,21 +2475,16 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2476,21 +2475,16 @@ public class CommonServiceImpl implements ICommonService {
throw new BadRequest("压力容器需要先做委托检验后提交!"); throw new BadRequest("压力容器需要先做委托检验后提交!");
} }
} }
if (equips.stream()
boolean hasInvalidDate = equips.stream().anyMatch(info -> { .map(info -> (String) info.get("nextInspectDate"))
String nextInspectDateStr = (String) info.get("nextInspectDate"); .filter(Objects::nonNull)
if (nextInspectDateStr != null) { .anyMatch(dateStr -> {
try { try {
LocalDate nextInspectDate = LocalDate.parse(nextInspectDateStr, DateTimeFormatter.ISO_DATE); return LocalDate.parse(dateStr, DateTimeFormatter.ISO_DATE).isBefore(LocalDate.now());
return nextInspectDate.isBefore(LocalDate.now()); } catch (Exception e) {
} catch (Exception e) { return false;
return false; }
} })) {
}
return false;
});
if (hasInvalidDate) {
throw new BadRequest("委托检验下次检验日期超期,请重新填写后提交!"); throw new BadRequest("委托检验下次检验日期超期,请重新填写后提交!");
} }
if (!CollectionUtils.isEmpty(equips)) { if (!CollectionUtils.isEmpty(equips)) {
...@@ -2664,6 +2658,67 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2664,6 +2658,67 @@ public class CommonServiceImpl implements ICommonService {
} }
} }
@Override
public void getRegistrationChangeCertificateFormStream(JSONObject jsonObject, HttpServletResponse response) {
List<JSONObject> formDataList = buildFileForOverDesign(jsonObject);
String wordPath = "use-registration-change-certificate.ftl";
String filePrefix = "特种设备使用登记变更证明_";
List<File> pdfFiles = new ArrayList<>();
try {
for (int i = 0; i < formDataList.size(); i++) {
String fileName = filePrefix + (i + 1);
File pdfFile = wordToPdf(fileName, wordPath, formDataList.get(i).getInnerMap());
pdfFiles.add(pdfFile);
}
if (pdfFiles.size() == 1) {
exportSinglePdf(pdfFiles.get(0), response);
} else {
File mergedPdf = mergePdfs(filePrefix + "合并.pdf", pdfFiles);
exportSinglePdf(mergedPdf, response);
pdfFiles.add(mergedPdf);
}
} catch (Exception e) {
log.error("PDF 生成或导出失败:{}", e);
throw new RuntimeException("PDF 生成失败", e);
} finally {
// 确保删除所有临时文件
pdfFiles.forEach(file -> {
try {
Files.deleteIfExists(file.toPath());
} catch (Exception e) {
log.error("文件删除失败:{}", e);
}
});
}
}
/**
* 导出单个 PDF
*/
private void exportSinglePdf(File pdfFile, HttpServletResponse response) throws IOException {
byte[] bytes = CommonServiceImpl.file2byte(pdfFile);
FileExporter.exportFile(FileExporter.FileType.pdf, pdfFile.getName(), bytes, response);
}
/**
* 合并多个 PDF
*/
private File mergePdfs(String outputFileName, List<File> pdfFiles) throws Exception {
PDDocument mergedDoc = new PDDocument();
for (File pdfFile : pdfFiles) {
try (PDDocument doc = PDDocument.load(pdfFile)) {
doc.getPages().forEach(mergedDoc::addPage);
}
}
File mergedPdf = new File(outputFileName);
mergedDoc.save(mergedPdf);
mergedDoc.close();
return mergedPdf;
}
/** /**
* 安全删除文件方法 * 安全删除文件方法
*/ */
......
...@@ -57,7 +57,6 @@ import org.redisson.api.RLock; ...@@ -57,7 +57,6 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronization;
...@@ -177,20 +176,16 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -177,20 +176,16 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
if ("2000".equals(Objects.toString(map.get("equListCode"))) && equipmentLists.stream().anyMatch(info -> !"WTJY".equals(info.get("inspectType")))) { if ("2000".equals(Objects.toString(map.get("equListCode"))) && equipmentLists.stream().anyMatch(info -> !"WTJY".equals(info.get("inspectType")))) {
throw new BadRequest("压力容器需要先做委托检验后提交!"); throw new BadRequest("压力容器需要先做委托检验后提交!");
} }
boolean hasInvalidDate = equipmentLists.stream().anyMatch(info -> { if (equipmentLists.stream()
String nextInspectDateStr = (String) info.get("nextInspectDate"); .map(info -> (String) info.get("nextInspectDate"))
if (nextInspectDateStr != null) { .filter(Objects::nonNull)
try { .anyMatch(dateStr -> {
LocalDate nextInspectDate = LocalDate.parse(nextInspectDateStr, DateTimeFormatter.ISO_DATE); try {
return nextInspectDate.isBefore(LocalDate.now()); return LocalDate.parse(dateStr, DateTimeFormatter.ISO_DATE).isBefore(LocalDate.now());
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
} })) {
return false;
});
if (hasInvalidDate) {
throw new BadRequest("委托检验下次检验日期超期,请重新填写后提交!"); throw new BadRequest("委托检验下次检验日期超期,请重新填写后提交!");
} }
List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum( List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum(
...@@ -283,6 +278,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -283,6 +278,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
equipList.add(equip); equipList.add(equip);
overDesignServiceLife.setEquList(Objects.toString(device.get("equList"), "")); overDesignServiceLife.setEquList(Objects.toString(device.get("equList"), ""));
}); });
//保存或更新检验信息
this.updateOrCreateInspectionDetection(equipmentLists);
jgOverDesignServiceLifeEqService.saveBatch(equipList); jgOverDesignServiceLifeEqService.saveBatch(equipList);
} }
if (SUBMIT_TYPE_FLOW.equals(map.get("submit"))) { if (SUBMIT_TYPE_FLOW.equals(map.get("submit"))) {
...@@ -648,7 +645,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -648,7 +645,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
throw new BadRequest("未查询到设备设计信息!"); throw new BadRequest("未查询到设备设计信息!");
} }
// 更新检验检测信息 // 更新检验检测信息
this.updateOrCreateInspectionDetection(equipmentLists); // this.updateOrCreateInspectionDetection(equipmentLists);
this.sendOverDesignMessage(equipmentLists);
this.updateDesignInfo(taskV2Model, jgOverDesignServiceLife, equipmentLists, designInfoList); this.updateDesignInfo(taskV2Model, jgOverDesignServiceLife, equipmentLists, designInfoList);
this.updateRegistrationManage(useOrgCodes); this.updateRegistrationManage(useOrgCodes);
} }
...@@ -693,7 +691,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -693,7 +691,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
)); ));
} }
} }
this.sendOverDesignMessage(equipmentLists);
} }
private void updateDesignInfo(TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife, List<Map<String, Object>> equipmentLists, List<IdxBizJgDesignInfo> designInfoList) { private void updateDesignInfo(TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife, List<Map<String, Object>> equipmentLists, List<IdxBizJgDesignInfo> designInfoList) {
...@@ -876,38 +874,36 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -876,38 +874,36 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr) .eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr)
.eq(JgRegistrationHistory::getIsDelete, false)); .eq(JgRegistrationHistory::getIsDelete, false));
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData()); JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(overDesignServiceLife.getStatus()) && if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(overDesignServiceLife.getStatus()) &&
!ValidationUtil.isEmpty(jsonObject) && !ValidationUtil.isEmpty(jsonObject) &&
!ValidationUtil.isEmpty(overDesignServiceLife)) { !ValidationUtil.isEmpty(overDesignServiceLife)) {
String companyAndOrg = overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName();
Map<String, Object> transferToMap = Bean.BeantoMap(overDesignServiceLife); Map<String, Object> transferToMap = Bean.BeantoMap(overDesignServiceLife);
transferToMap.put("equipmentLists", jsonObject.get("equipmentLists")); resultDataMap.put("equipmentLists", jsonObject.get("equipmentLists"));
transferToMap.put("receiveCompanyCode", companyAndOrg);
transferToMap.put("receiveOrgCode", companyAndOrg);
resultDataMap.putAll(transferToMap); resultDataMap.putAll(transferToMap);
} else if (!ValidationUtil.isEmpty(overDesignServiceLife)) { // 非执行完成状态显示最新设备信息 } else if (!ValidationUtil.isEmpty(overDesignServiceLife)) {
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> records = equipmentLists.stream() List<String> records = equipmentLists.stream()
.map(v -> (String) v.get("record")) .map(v -> (String) v.get("record"))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> ((JSONObject) obj).getString("useOrgCode"))
.collect(Collectors.toList());
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.list();
String companyAndOrg = overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName();
resultDataMap.putAll(Bean.BeantoMap(overDesignServiceLife)); resultDataMap.putAll(Bean.BeantoMap(overDesignServiceLife));
resultDataMap.put("receiveCompanyCode", companyAndOrg);
resultDataMap.put("receiveOrgCode", companyAndOrg);
resultDataMap.put("sequenceNbrs", registrationList.stream()
.map(BaseEntity::getSequenceNbr)
.collect(Collectors.toList()));
List<Map<String, Object>> result = this.getBaseMapper().selectEquipList(records); List<Map<String, Object>> result = this.getBaseMapper().selectEquipList(records);
jsonObject.remove("equipmentLists");
resultDataMap.put("equipmentLists", result); resultDataMap.put("equipmentLists", result);
} }
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> ((JSONObject) obj).getString("useOrgCode"))
.collect(Collectors.toList());
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.list();
String companyAndOrg = overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName();
resultDataMap.put("receiveCompanyCode", companyAndOrg);
resultDataMap.put("receiveOrgCode", companyAndOrg);
resultDataMap.put("sequenceNbrs", registrationList.stream()
.map(BaseEntity::getSequenceNbr)
.collect(Collectors.toList()));
commonService.convertStringToJsonobject(resultDataMap, new String[]{"otherAccessories"}); commonService.convertStringToJsonobject(resultDataMap, new String[]{"otherAccessories"});
commonService.convertStringToJsonobject(resultDataMap, new String[]{"useRegistrationFormFile"}); commonService.convertStringToJsonobject(resultDataMap, new String[]{"useRegistrationFormFile"});
return resultDataMap; return resultDataMap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment