Commit 078d7b81 authored by 刘林's avatar 刘林

fix(jg):超设计使用年限功能开发

parent a5905186
...@@ -25,4 +25,6 @@ public interface JgOverDesignServiceLifeMapper extends BaseMapper<JgOverDesignSe ...@@ -25,4 +25,6 @@ public interface JgOverDesignServiceLifeMapper extends BaseMapper<JgOverDesignSe
@Param("sort") SortVo sortMap, @Param("sort") SortVo sortMap,
@Param("dto") JgOverDesignServiceLifeDto dto , @Param("dto") JgOverDesignServiceLifeDto dto ,
@Param("type") String type); @Param("type") String type);
List<Map<String, Object>> selectEquipList(@Param("records") List<String> records);
} }
...@@ -97,4 +97,28 @@ ...@@ -97,4 +97,28 @@
</if> </if>
ovds.create_date DESC, ovds.apply_no DESC ovds.create_date DESC, ovds.apply_no DESC
</select> </select>
<select id="selectEquipList" resultType="java.util.Map">
select jui.RECORD as SEQUENCE_NBR,
jfi.PRODUCE_UNIT_NAME,
jui.USE_INNER_CODE,
jfi.FACTORY_NUM,
jui.ADDRESS as ADDRESS,
jui.RECORD record,
(SELECT name from tz_equipment_category where code = jri.EQU_DEFINE) as EQU_DEFINE,
jri.PRODUCT_NAME,
jri.EQU_CODE,
jri.USE_ORG_CODE,
(SELECT name from tz_equipment_category where code = jri.EQU_LIST) as EQU_LIST,
(SELECT name from tz_equipment_category where code = jri.EQU_CATEGORY) as EQU_CATEGORY,
(select other.SUPERVISORY_CODE from idx_biz_jg_other_info other where other.RECORD = jui.RECORD) as SUPERVISORY_CODE,
to_char((select NEXT_INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC limit 1), 'YYYY-MM-DD') as NEXT_INSPECT_DATE
FROM idx_biz_jg_use_info jui
LEFT JOIN idx_biz_jg_factory_info jfi on jui.RECORD = jfi.RECORD
LEFT JOIN idx_biz_jg_register_info jri on jui.RECORD = jri.RECORD
WHERE jui.record in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
</select>
</mapper> </mapper>
...@@ -60,6 +60,12 @@ ...@@ -60,6 +60,12 @@
<artifactId>seata-spring-boot-starter</artifactId> <artifactId>seata-spring-boot-starter</artifactId>
<version>1.8.0</version> <version>1.8.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.12</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -17,4 +17,6 @@ public interface IIdxBizJgInspectionDetectionInfoService { ...@@ -17,4 +17,6 @@ public interface IIdxBizJgInspectionDetectionInfoService {
List<IdxBizJgInspectionDetectionInfo> checkInspectionInfo(List<String> records); List<IdxBizJgInspectionDetectionInfo> checkInspectionInfo(List<String> records);
boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList); boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList);
List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record);
} }
...@@ -72,6 +72,7 @@ import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; ...@@ -72,6 +72,7 @@ import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import freemarker.template.Configuration; 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.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;
...@@ -804,7 +805,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -804,7 +805,7 @@ public class CommonServiceImpl implements ICommonService {
while (it.hasNext()) { while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next(); LinkedHashMap e = (LinkedHashMap) it.next();
// 删除非指定的单位类型 // 删除非指定的单位类型
if (!e.get("companyType").toString().contains(companyType)) { if (e.get("companyType") != null && !e.get("companyType").toString().contains(companyType)) {
it.remove(); it.remove();
} }
if (!ObjectUtils.isEmpty(e.get("children"))) { if (!ObjectUtils.isEmpty(e.get("children"))) {
...@@ -2451,47 +2452,54 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2451,47 +2452,54 @@ public class CommonServiceImpl implements ICommonService {
return formData; return formData;
} }
//多个证进行批量生成
public List<JSONObject> buildFileForOverDesign(JSONObject jsonObject) { public List<JSONObject> buildFileForOverDesign(JSONObject jsonObject) {
List<JSONObject> formDataList = new ArrayList<>(); List<JSONObject> formDataList = new ArrayList<>();
JSONObject formData = new JSONObject(); if (jsonObject.containsKey("equipmentLists")) {
formData.putAll(jsonObject); JSONArray equipmentLists = jsonObject.getJSONArray("equipmentLists");
formData.entrySet().removeIf(entry -> entry.getValue() == null);
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
if (formData.containsKey("type")) {
formData.put("registrationType", RegistrationTypeEnum.getNameByType(formData.getString("type")));
}
if (formData.containsKey("equListCode")) {
formData.put("equList", EquipmentClassifityEnum.getNameByCode(formData.getString("equListCode")));
}
//多个证进行批量生成
if (formData.containsKey("equipmentLists")) {
JSONArray equipmentLists = formData.getJSONArray("equipmentLists");
List<Map<String, Object>> equips = equipmentLists.stream() List<Map<String, Object>> equips = equipmentLists.stream()
.filter(obj -> obj instanceof Map) .filter(obj -> obj instanceof Map)
.map(obj -> (Map<String, Object>) obj).collect(Collectors.toList()); .map(obj -> (Map<String, Object>) obj)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(equips)) { if (!CollectionUtils.isEmpty(equips)) {
formData.put("equDefine", equips.get(0).get("EQU_DEFINE")); Map<String, Object> firstEquip = equips.get(0);
formData.put("equCategory", equips.get(0).get("EQU_CATEGORY")); String equDefine = (String) firstEquip.get("EQU_DEFINE");
equips.forEach(v -> { String equCategory = (String) firstEquip.get("EQU_CATEGORY");
String useRegistrationCode = Objects.toString(v.get("USE_ORG_CODE"),""); formDataList = equips.stream().map(v -> {
JSONObject formData = new JSONObject();
formData.put("equDefine", equDefine);
formData.put("equCategory", equCategory);
formData.entrySet().removeIf(entry -> entry.getValue() == null);
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Optional.ofNullable(Objects.toString(jsonObject.get("type"), ""))
.ifPresent(type -> formData.put("registrationType", RegistrationTypeEnum.getNameByType(type)));
Optional.ofNullable(Objects.toString(jsonObject.get("equListCode"), ""))
.ifPresent(code -> formData.put("equList", EquipmentClassifityEnum.getNameByCode(code)));
String useRegistrationCode = Objects.toString(v.get("USE_ORG_CODE"), "");
JgUseRegistrationManage manage = jgUseRegistrationManageService.lambdaQuery() JgUseRegistrationManage manage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode) .eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode)
.eq(JgUseRegistrationManage::getIsDelete, 0) .eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus,CertificateStatusEnum.YIDENGJI.getName()).one(); .eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.one();
formData.put("equCode", v.get("EQU_CODE")); formData.put("equCode", v.get("EQU_CODE"));
formData.put("useRegistrationCode", v.get("USE_ORG_CODE")); formData.put("useRegistrationCode", v.get("USE_ORG_CODE"));
formData.put("produceUnitName", v.get("PRODUCE_UNIT_NAME")); formData.put("produceUnitName", v.get("PRODUCE_UNIT_NAME"));
formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("PRODUCE_DATE")), inputFormatter).format(outputFormatter)); formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("PRODUCE_DATE")), inputFormatter)
.format(outputFormatter));
formData.put("factoryNum", v.get("FACTORY_NUM")); formData.put("factoryNum", v.get("FACTORY_NUM"));
formData.put("productName", v.get("PRODUCT_NAME")); formData.put("productName", v.get("PRODUCT_NAME"));
formData.put("useUnitName", v.get("USE_UNIT_NAME")); formData.put("useUnitName", v.get("USE_UNIT_NAME"));
formData.put("auditPassDate", new SimpleDateFormat("yyyy-MM-dd").format( manage.getAuditPassDate()));
formData.put("receiveCompanyOrgName", manage.getReceiveOrgName()); if (manage != null && manage.getAuditPassDate() != null) {
formData.put("applyNo", manage.getApplyNo()); formData.put("auditPassDate", new SimpleDateFormat("yyyy-MM-dd").format(manage.getAuditPassDate()));
}
formData.put("receiveCompanyOrgName", manage != null ? manage.getReceiveOrgName() : null);
formData.put("applyNo", manage != null ? manage.getApplyNo() : null);
formData.put("cruDate", DateUtils.convertDateToString(new Date(), DateUtils.CHN_DATE_PATTERN)); formData.put("cruDate", DateUtils.convertDateToString(new Date(), DateUtils.CHN_DATE_PATTERN));
formDataList.add(formData); return formData;
}); }).collect(Collectors.toList());
} }
} }
return formDataList; return formDataList;
...@@ -2575,16 +2583,19 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2575,16 +2583,19 @@ public class CommonServiceImpl implements ICommonService {
List<JSONObject> formDataList = buildFileForOverDesign(jsonObject); List<JSONObject> formDataList = buildFileForOverDesign(jsonObject);
String wordPath = "use-registration-change-certificate.ftl"; String wordPath = "use-registration-change-certificate.ftl";
String fileName = "特种设备使用登记变更证明_"; String fileName = "特种设备使用登记变更证明_";
List<String> uploadedUrls = new ArrayList<>();
List<File> generatedFiles = new ArrayList<>(); List<File> generatedFiles = new ArrayList<>();
File mergedPdfFile = null;
try { try {
List<File> pdfFiles = new ArrayList<>();
for (JSONObject formData : formDataList) { for (JSONObject formData : formDataList) {
File pdfFile = wordToPdf(fileName, wordPath, formData); File pdfFile = wordToPdf(fileName, wordPath, formData);
pdfFiles.add(pdfFile);
generatedFiles.add(pdfFile); generatedFiles.add(pdfFile);
uploadedUrls.add(uploadFile(pdfFile, "useRegistrationFormFiles"));
} }
return MapBuilder.<String, Object>create().put("useRegistrationFormUrl", uploadedUrls).build(); mergedPdfFile = mergePdfFiles(pdfFiles, fileName + "合并.pdf");
String uploadedUrl = uploadFile(mergedPdfFile, "useRegistrationFormFiles");
return MapBuilder.<String, Object>create().put("useRegistrationFormUrl", uploadedUrl).build();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
...@@ -2595,7 +2606,25 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2595,7 +2606,25 @@ public class CommonServiceImpl implements ICommonService {
log.error("文件找不到,删除失败:{}", e); log.error("文件找不到,删除失败:{}", e);
} }
} }
if (mergedPdfFile != null) {
try {
Files.deleteIfExists(mergedPdfFile.toPath());
} catch (Exception e) {
log.error("合并 PDF 文件删除失败:{}", e);
}
}
}
}
private File mergePdfFiles(List<File> pdfFiles, String outputFileName) throws IOException {
PDFMergerUtility merger = new PDFMergerUtility();
File outputFile = new File(System.getProperty("java.io.tmpdir"), outputFileName);
merger.setDestinationFileName(outputFile.getAbsolutePath());
for (File pdf : pdfFiles) {
merger.addSource(pdf);
} }
merger.mergeDocuments(null);
return outputFile;
} }
@Override @Override
......
...@@ -12,6 +12,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -12,6 +12,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 安全追溯-检验检测信息表服务实现类 * 安全追溯-检验检测信息表服务实现类
...@@ -57,4 +58,19 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB ...@@ -57,4 +58,19 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB
public boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList) { public boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList) {
return super.saveOrUpdateBatch(inspectionDetectionInfoList); return super.saveOrUpdateBatch(inspectionDetectionInfoList);
} }
@Override
public List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record) {
return list(new QueryWrapper<IdxBizJgInspectionDetectionInfo>()
.lambda()
.eq(IdxBizJgInspectionDetectionInfo::getRecord, record)
.orderByDesc(IdxBizJgInspectionDetectionInfo::getInspectDate))
.stream()
.map(info -> {
IdxBizJgInspectionDetectionInfo result = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(info, result);
return result;
})
.collect(Collectors.toList());
}
} }
\ No newline at end of file
...@@ -29,11 +29,13 @@ import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; ...@@ -29,11 +29,13 @@ import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICompensateFlowDataOfRedis; import com.yeejoin.amos.boot.module.jg.biz.service.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgDesignInfoMapper;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
...@@ -59,6 +61,7 @@ import org.springframework.stereotype.Service; ...@@ -59,6 +61,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -71,12 +74,11 @@ import static java.util.stream.Collectors.toList; ...@@ -71,12 +74,11 @@ import static java.util.stream.Collectors.toList;
* @date 2025-03-06 * @date 2025-03-06
*/ */
@Service @Service
public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesignServiceLife,JgOverDesignServiceLife,JgOverDesignServiceLifeMapper> implements IJgOverDesignServiceLifeService, ICompensateFlowDataOfRedis<JgOverDesignServiceLife> { public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesignServiceLife, JgOverDesignServiceLife, JgOverDesignServiceLifeMapper> implements IJgOverDesignServiceLifeService, ICompensateFlowDataOfRedis<JgOverDesignServiceLife> {
private static final String DEFINITION_KEY = "overDesignServiceLife"; private static final String DEFINITION_KEY = "overDesignServiceLife";
public static final String SUBMIT_TYPE_FLOW = "1"; public static final String SUBMIT_TYPE_FLOW = "1";
public static final String SUBMIT_DATA = "0"; public static final String SUBMIT_DATA = "0";
private static final String TABLE_PAGE_ID = "overDesignServiceLife";
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废"); private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废");
@Autowired @Autowired
private CommonServiceImpl commonService; private CommonServiceImpl commonService;
...@@ -108,6 +110,12 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -108,6 +110,12 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private JgRegistrationHistoryMapper jgRegistrationHistoryMapper; private JgRegistrationHistoryMapper jgRegistrationHistoryMapper;
@Autowired @Autowired
private JgUseRegistrationManageServiceImpl useRegistrationManageService; private JgUseRegistrationManageServiceImpl useRegistrationManageService;
@Autowired
IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
@Autowired
IIdxBizJgInspectionDetectionInfoService iIdxBizJgInspectionDetectionInfoService;
/** /**
* 分页查询 * 分页查询
...@@ -127,9 +135,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -127,9 +135,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
public List<JgOverDesignServiceLife> saveOrUpdate(JSONObject map, ReginParams reginParams) { public List<JgOverDesignServiceLife> saveOrUpdate(JSONObject map, ReginParams reginParams) {
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
try { try {
if(SUBMIT_TYPE_FLOW.equals(map.get("submit"))){ if (SUBMIT_TYPE_FLOW.equals(map.get("submit"))) {
JSONArray useRegistrationFormFile = map.getJSONArray("useRegistrationFormFile"); JSONArray useRegistrationFormFile = map.getJSONArray("useRegistrationFormFile");
if(CollUtil.isEmpty(useRegistrationFormFile)){ if (CollUtil.isEmpty(useRegistrationFormFile)) {
throw new BadRequest("特种设备超设计使用年限变更证明(签章后)为空,请上传后再提交!"); throw new BadRequest("特种设备超设计使用年限变更证明(签章后)为空,请上传后再提交!");
} }
} }
...@@ -137,9 +145,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -137,9 +145,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
Optional.ofNullable(map.get("useRegistrationFormFile")) Optional.ofNullable(map.get("useRegistrationFormFile"))
.map(JSONObject::toJSONString) .map(JSONObject::toJSONString)
.ifPresent(overDesignDto::setUseRegistrationFormFile); .ifPresent(overDesignDto::setUseRegistrationFormFile);
map.put("userName",reginParams.getUserModel().getRealName()); map.put("userName", reginParams.getUserModel().getRealName());
Map<String, Object> overDesign = commonService.getRegistrationFormUrl("vehicle", map); Map<String, Object> overDesign = commonService.getRegistrationFormUrl("overDesign", map);
if(Objects.nonNull(overDesign)){ if (Objects.nonNull(overDesign)) {
overDesignDto.setUseRegistrationFormUrl(String.valueOf(overDesign.get("useRegistrationFormUrl"))); overDesignDto.setUseRegistrationFormUrl(String.valueOf(overDesign.get("useRegistrationFormUrl")));
} }
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists"); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
...@@ -147,7 +155,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -147,7 +155,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
throw new BadRequest("请选择设备信息!"); throw new BadRequest("请选择设备信息!");
} }
if (SUBMIT_TYPE_FLOW.equals(map.get("submit"))) { if (SUBMIT_TYPE_FLOW.equals(map.get("submit"))) {
this.repeatUsedEquipCheck(equipmentLists, this.repeatUsedEquipCheck(equipmentLists,
CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ? company.getCompanyCode().split("_")[1] : company.getCompanyCode()); CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ? company.getCompanyCode().split("_")[1] : company.getCompanyCode());
} }
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList = idxBizJgInspectionDetectionInfoService.checkInspectionInfo( List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList = idxBizJgInspectionDetectionInfoService.checkInspectionInfo(
...@@ -226,10 +234,10 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -226,10 +234,10 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
equip.setEquId(String.valueOf(device.get("record"))); equip.setEquId(String.valueOf(device.get("record")));
equip.setOverDesignId(Objects.toString(overDesignServiceLife.getSequenceNbr())); equip.setOverDesignId(Objects.toString(overDesignServiceLife.getSequenceNbr()));
equip.setDeviceInfo(JSONObject.toJSONString(device)); equip.setDeviceInfo(JSONObject.toJSONString(device));
equip.setUseRegistrationCode(Objects.toString(device.get("USE_ORG_CODE"),"")); equip.setUseRegistrationCode(Objects.toString(device.get("USE_ORG_CODE"), ""));
equip.setEquList(Objects.toString(device.get("EQU_LIST_CODE"),"")); equip.setEquList(Objects.toString(device.get("EQU_LIST_CODE"), ""));
equip.setEquCategory(Objects.toString(device.get("EQU_CATEGORY_CODE"),"")); equip.setEquCategory(Objects.toString(device.get("EQU_CATEGORY_CODE"), ""));
equip.setEquDefine(Objects.toString(device.get("EQU_DEFINE_CODE"),"")); equip.setEquDefine(Objects.toString(device.get("EQU_DEFINE_CODE"), ""));
if (!ObjectUtils.isEmpty(device.get("SAFETY_ASSESSMENT_REPORT"))) { if (!ObjectUtils.isEmpty(device.get("SAFETY_ASSESSMENT_REPORT"))) {
equip.setSafetyAssessmentReport(JSONObject.toJSONString(device.get("SAFETY_ASSESSMENT_REPORT"))); equip.setSafetyAssessmentReport(JSONObject.toJSONString(device.get("SAFETY_ASSESSMENT_REPORT")));
} }
...@@ -278,7 +286,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -278,7 +286,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
commonService.buildTaskModel(list); commonService.buildTaskModel(list);
} }
} }
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.getName(), JSON.parseArray(JSON.toJSONString(equipmentLists)), null, overDesignServiceLife.getSequenceNbr() + ""); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.getName(), map, null, overDesignServiceLife.getSequenceNbr() + "");
return Collections.singletonList(overDesignServiceLife); return Collections.singletonList(overDesignServiceLife);
} catch (BadRequest | LocalBadRequest e) { } catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -333,7 +341,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -333,7 +341,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
LambdaUpdateWrapper<JgOverDesignServiceLifeEq> overDesignServiceLifeEqWrapper = new LambdaUpdateWrapper<JgOverDesignServiceLifeEq>() LambdaUpdateWrapper<JgOverDesignServiceLifeEq> overDesignServiceLifeEqWrapper = new LambdaUpdateWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getEquId, sequenceNbr) .eq(JgOverDesignServiceLifeEq::getEquId, sequenceNbr)
.set(JgOverDesignServiceLifeEq::getIsDelete, true); .set(JgOverDesignServiceLifeEq::getIsDelete, true);
jgOverDesignServiceLifeEqService.getBaseMapper().update(null,overDesignServiceLifeEqWrapper); jgOverDesignServiceLifeEqService.getBaseMapper().update(null, overDesignServiceLifeEqWrapper);
// 删除单子对应历史表数据 // 删除单子对应历史表数据
jgRegistrationHistoryService.getBaseMapper().update(null, jgRegistrationHistoryService.getBaseMapper().update(null,
new LambdaUpdateWrapper<JgRegistrationHistory>() new LambdaUpdateWrapper<JgRegistrationHistory>()
...@@ -351,6 +359,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -351,6 +359,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
/** /**
* 撤回 * 撤回
*
* @param instanceId 流程id * @param instanceId 流程id
* @param nextTaskId 任务id * @param nextTaskId 任务id
* @param manageType 类型 * @param manageType 类型
...@@ -572,20 +581,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -572,20 +581,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
lambdaSelect.eq(JgRegistrationHistory::getIsDelete, false); lambdaSelect.eq(JgRegistrationHistory::getIsDelete, false);
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambdaSelect); JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambdaSelect);
String jsonData = jgRegistrationHistory.getChangeData(); String jsonData = jgRegistrationHistory.getChangeData();
JSONArray jsonArray = JSONArray.parseArray(jsonData); JSONObject jsonObject = JSONObject.parseObject(jsonData);
this.updateEquipMessage(jsonObject);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject mapData = jsonArray.getJSONObject(i);
// 更新设备信息
// this.updateEquipMessage(jgOverDesignServiceLife, mapData, registerInfo, otherInfo);
// // 更新es
// updateEsData(mapData, jgOverDesignServiceLife, otherInfo);
}
// 更新新生成的历史数据的设备代码
jgRegistrationHistory.setChangeData(JSON.toJSONString(jsonArray));
jgRegistrationHistoryService.updateById(jgRegistrationHistory);
// 更新代办状态 // 更新代办状态
HashMap<String, Object> params = new HashMap<>(); HashMap<String, Object> params = new HashMap<>();
params.put("relationId", jgOverDesignServiceLife.getInstanceId()); params.put("relationId", jgOverDesignServiceLife.getInstanceId());
...@@ -602,6 +599,42 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -602,6 +599,42 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
commonService.saveExecuteFlowData2Redis(jgOverDesignServiceLife.getInstanceId(), this.buildInstanceRuntimeData(jgOverDesignServiceLife)); commonService.saveExecuteFlowData2Redis(jgOverDesignServiceLife.getInstanceId(), this.buildInstanceRuntimeData(jgOverDesignServiceLife));
} }
private void updateEquipMessage(JSONObject jsonObject) {
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> ((JSONObject) obj).getString("USE_ORG_CODE"))
.collect(Collectors.toList());
List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum(
equipmentLists.stream().map(v -> (String) v.get("record")).collect(Collectors.toList())
);
if (CollectionUtils.isEmpty(designInfoList)) {
throw new BadRequest("未查询到设备设计信息!");
};
String equListCode = Objects.toString(equipmentLists.get(0).get("EQU_LIST_CODE"));
ZoneId zoneId = ZoneId.systemDefault();
designInfoList.forEach(designInfo -> {
List<IdxBizJgInspectionDetectionInfo> inspectionList =
iIdxBizJgInspectionDetectionInfoService.queryInspectionListByRecord(designInfo.getRecord());
designInfo.setOverDesignRegNum(Math.min(designInfo.getOverDesignRegNum() + 1, 2));
designInfo.setDelayServiceLifeDate(inspectionList.stream()
.filter(info -> "6000".equals(equListCode) || "WTJY".equals(info.getInspectType()))
.findFirst()
.map(info -> "6000".equals(equListCode) ? info.getInspectDate() : info.getNextInspectDate())
.map(date -> date.toInstant().atZone(zoneId).toLocalDate().plusYears("6000".equals(equListCode) ? 4 : 0).toString())
.orElse(null));
});
idxBizJgDesignInfoService.saveOrUpdateBatch(designInfoList);
useRegistrationManageService.lambdaUpdate()
.set(JgUseRegistrationManage::getIsOverDesign, 1)
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
.update();
}
private void buildTask(JgOverDesignServiceLife jgOverDesignServiceLife, WorkflowResultDto workflowResultDto) { private void buildTask(JgOverDesignServiceLife jgOverDesignServiceLife, WorkflowResultDto workflowResultDto) {
// 代办消息 // 代办消息
ArrayList<TaskModelDto> list = new ArrayList<>(); ArrayList<TaskModelDto> list = new ArrayList<>();
...@@ -651,9 +684,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -651,9 +684,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
} }
public String getEquipListCode(String record) { public String getEquipListCode(String record) {
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, record).select(TzsBaseEntity::getSequenceNbr,IdxBizJgRegisterInfo::getEquList)); IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, record).select(TzsBaseEntity::getSequenceNbr, IdxBizJgRegisterInfo::getEquList));
if(registerInfo != null){ if (registerInfo != null) {
return registerInfo.getEquList(); return registerInfo.getEquList();
} }
return null; return null;
} }
...@@ -700,43 +733,49 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -700,43 +733,49 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
Map<String, Object> resultDataMap = new HashMap<>(); Map<String, Object> resultDataMap = new HashMap<>();
JgOverDesignServiceLife overDesignServiceLife = this.getById(sequenceNbr); JgOverDesignServiceLife overDesignServiceLife = this.getById(sequenceNbr);
this.doCompensate(overDesignServiceLife); this.doCompensate(overDesignServiceLife);
JSONArray historyData = commonService.queryHistoryDataObj(sequenceNbr); JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper()
if (ValidationUtil.equals(FlowStatusEnum.TO_BE_FINISHED.getName(), overDesignServiceLife.getStatus())) { .selectOne(new QueryWrapper<JgRegistrationHistory>().lambda()
if (!ValidationUtil.isEmpty(historyData)) { .eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr)
if (!ValidationUtil.isEmpty(overDesignServiceLife)) { .eq(JgRegistrationHistory::getIsDelete, false));
Map<String, Object> transferToMap = Bean.BeantoMap(overDesignServiceLife); JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
transferToMap.put("equipmentLists", JSONArray.parseArray(String.valueOf(historyData))); if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(overDesignServiceLife.getStatus()) &&
transferToMap.put("receiveCompanyCode", overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName()); !ValidationUtil.isEmpty(jsonObject) &&
transferToMap.put("receiveOrgCode", overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName()); !ValidationUtil.isEmpty(overDesignServiceLife)) {
resultDataMap.putAll(transferToMap); String companyAndOrg = overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName();
} Map<String, Object> transferToMap = Bean.BeantoMap(overDesignServiceLife);
} transferToMap.put("equipmentLists", jsonObject.get("equipmentLists"));
} else { transferToMap.put("receiveCompanyCode", companyAndOrg);
if (!ValidationUtil.isEmpty(overDesignServiceLife)) { transferToMap.put("receiveOrgCode", companyAndOrg);
List<String> useRegistrationCodes = historyData.stream() resultDataMap.putAll(transferToMap);
.map(obj -> ((JSONObject) obj).getString("USE_ORG_CODE")) } else if (!ValidationUtil.isEmpty(overDesignServiceLife)) { // 非执行完成状态显示最新设备信息
.collect(Collectors.toList()); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> records = equipmentLists.stream()
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery() .map(v -> (String) v.get("record"))
.in(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCodes) .collect(Collectors.toList());
.list(); List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> ((JSONObject) obj).getString("USE_ORG_CODE"))
resultDataMap.putAll(Bean.BeantoMap(overDesignServiceLife)); .collect(Collectors.toList());
resultDataMap.put("receiveCompanyCode", overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName()); List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
resultDataMap.put("receiveOrgCode", overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName()); .in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
resultDataMap.put("sequenceNbrs", registrationList.stream() .list();
.map(BaseEntity::getSequenceNbr) String companyAndOrg = overDesignServiceLife.getReceiveCompanyCode() + "_" + overDesignServiceLife.getReceiveOrgName();
.collect(Collectors.toList())); resultDataMap.putAll(Bean.BeantoMap(overDesignServiceLife));
resultDataMap.put("equipmentLists", JSONArray.parseArray(String.valueOf(historyData))); 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);
resultDataMap.put("equipmentLists", result);
} }
commonService.convertStringToJsonobject(resultDataMap, new String[]{"otherAccessories"}); commonService.convertStringToJsonobject(resultDataMap, new String[]{"otherAccessories"});
commonService.convertStringToJsonobject(resultDataMap, new String[]{"useRegistrationFormFile"});
return resultDataMap; return resultDataMap;
} }
@Override @Override
public boolean beforeCheck(JgOverDesignServiceLife overDesignServiceLife) { public boolean beforeCheck(JgOverDesignServiceLife overDesignServiceLife) {
return overDesignServiceLife.getInstanceId() != null && !overDesignServiceLife.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) &&!overDesignServiceLife.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()); return overDesignServiceLife.getInstanceId() != null && !overDesignServiceLife.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) && !overDesignServiceLife.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName());
} }
@Override @Override
......
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
"type": "120", "type": "120",
"pageType": "look", "pageType": "look",
"name": "超设计使用年限变更", "name": "超设计使用年限变更",
"url": "/mixuap?appId=1742358052905971713&id=1897575052807794690&roleIds={roleIds}&userId={userId}&pageType=look" "url": "/mixuap?appId=1742358052905971713&id=1897575343384981506&roleIds={roleIds}&userId={userId}&pageType=look"
}, },
{ {
"type": "121", "type": "121",
......
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