Commit 9e9766f2 authored by 刘林's avatar 刘林

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

parent 269cb894
......@@ -3,48 +3,47 @@
<mapper namespace="com.yeejoin.amos.boot.module.jg.api.mapper.JgOverDesignServiceLifeMapper">
<select id="queryForFlowingEquipList" resultType="com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto">
select a.use_unit_credit_code as companyCode,
GROUP_CONCAT(b.equ_id) as records
from TZS_JG_OVER_DESIGN_SERVICE_LIFE a,
TZS_JG_OVER_DESIGN_SERVICE_LIFE_EQ b
where a.sequence_nbr = b.over_design_id
and a.status in ('待受理')
SELECT a.use_unit_credit_code AS companyCode,
GROUP_CONCAT(b.equ_id) AS records
FROM tzs_jg_over_design_service_life a,
tzs_jg_over_design_service_life_eq b
WHERE a.sequence_nbr = b.over_design_id
AND a.status IN ('待受理')
GROUP BY a.use_unit_credit_code
</select>
<sql id="page_list">
<sql id="pageList">
WITH crteq_limited AS (
SELECT *,ROW_NUMBER() OVER (PARTITION BY over_design_id ORDER BY rec_date desc) as rn
FROM TZS_JG_OVER_DESIGN_SERVICE_LIFE_EQ)
SELECT *,ROW_NUMBER() OVER (PARTITION BY over_design_id ORDER BY rec_date desc) AS rn
FROM tzs_jg_over_design_service_life_eq)
SELECT
ovds.sequence_nbr as sequenceNbr,
DATE_FORMAT(ovds.rec_date,'%Y-%m-%d') as regDate,
DATE_FORMAT(ovds.create_date,'%Y-%m-%d') as createDate,
ovds.sequence_nbr AS sequenceNbr,
DATE_FORMAT(ovds.rec_date,'%Y-%m-%d') AS regDate,
DATE_FORMAT(ovds.create_date,'%Y-%m-%d') AS createDate,
ovds.status,
ovds.receive_org_name as receiveOrgName,
ovds.apply_no as applyNo,
ovds.receive_org_name AS receiveOrgName,
ovds.apply_no AS applyNo,
ovds.next_execute_ids AS nextExecuteIds,
ovds.promoter,
DATE_FORMAT(ovds.rec_date,'%Y-%m-%d') as recDate,
ovds.instance_id as instanceId,
ovds.use_registration_code as useRegistrationCode,
ovds.next_execute_user_ids as nextExecuteUserIds,
ovds.create_user_id as createUserId,
ovds.next_task_id as nextTaskId,
ovds.USE_UNIT_NAME as useUnitName,
jri.PRODUCT_NAME as productName,
jri.EQU_CODE as equCode,
concat(use."PROVINCE_NAME", '', use."CITY_NAME", '', use."COUNTY_NAME", '', use."STREET_NAME") as allAddress,
(SELECT name from tz_equipment_category WHERE code = jri.EQU_LIST) AS equList,
(SELECT name from tz_equipment_category where code = jri.EQU_CATEGORY) as equCategory,
(SELECT name from tz_equipment_category where code = jri.EQU_DEFINE) as equDefine
FROM TZS_JG_OVER_DESIGN_SERVICE_LIFE ovds
DATE_FORMAT(ovds.rec_date,'%Y-%m-%d') AS recDate,
ovds.instance_id AS instanceId,
ovds.use_registration_code AS useRegistrationCode,
ovds.next_execute_user_ids AS nextExecuteUserIds,
ovds.create_user_id AS createUserId,
ovds.next_tASk_id AS nextTASkId,
ovds.USE_UNIT_NAME AS useUnitName,
jri.PRODUCT_NAME AS productName,
jri.EQU_CODE AS equCode,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_LIST) AS equList,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_CATEGORY) AS equCategory,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_DEFINE) AS equDefine
FROM tzs_jg_over_design_service_life ovds
LEFT JOIN crteq_limited ovdseq ON ovds.sequence_nbr = ovdseq.over_design_id AND ovdseq.rn = 1
LEFT JOIN idx_biz_jg_register_info jri on ovdseq.equ_id = jri.RECORD
LEFT JOIN idx_biz_jg_use_info use on ovdseq.equ_id = use.RECORD
LEFT JOIN idx_biz_jg_register_info jri ON ovdseq.equ_id = jri.RECORD
LEFT JOIN idx_biz_jg_use_info use ON ovdseq.equ_id = use.RECORD
</sql>
<select id="getListPage" resultType="java.util.Map">
<include refid="page_list"/>
<include refid="pageList"/>
<where>
and ovds.is_delete = 0
<if test="dto.equCategory != null and dto.equCategory != ''">
......@@ -99,34 +98,32 @@
</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,
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 name from tz_equipment_category where code = jri.EQU_DEFINE) as EQU_DEFINE,
jri.EQU_LIST as EQU_LIST_CODE,
jri.EQU_CATEGORY as EQU_CATEGORY_CODE,
jri.EQU_DEFINE as EQU_DEFINE_CODE,
jfi.PRODUCE_DATE,
(select SEQUENCE_NBR from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) jySeq,
(select INSPECT_ORG_NAME from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) INSPECT_ORG_NAME,
(select INSPECT_ORG_CODE from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) INSPECT_ORG_CODE,
(select INSPECT_REPORT_NO from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) INSPECT_REPORT_NO,
(select INSPECT_CONCLUSION from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) INSPECT_CONCLUSION_CODE,
(select name from cb_data_dictionary where type = 'JYJL' and code = (select INSPECT_CONCLUSION from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1)) INSPECT_CONCLUSION,
to_char((select NEXT_INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1), 'YYYY-MM-DD') NEXT_INSPECT_DATE,
(select INSPECT_REPORT from idx_biz_jg_inspection_detection_info where "RECORD" = jui."RECORD" AND INSPECT_TYPE = 'WTJY' ORDER BY INSPECT_DATE DESC limit 1) INSPECT_REPORT
SELECT jui.RECORD AS sequenceNbr,
jfi.PRODUCE_UNIT_NAME AS produceUnitName,
jfi.FACTORY_NUM AS factoryNum,
jui.RECORD AS record,
jri.PRODUCT_NAME AS productName,
jri.EQU_CODE AS equCode,
jri.USE_ORG_CODE AS useOrgCode,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_LIST) AS equList,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_CATEGORY) AS equCategory,
(SELECT name FROM tz_equipment_category WHERE code = jri.EQU_DEFINE) AS equDefine,
jri.EQU_LIST AS equListCode,
jri.EQU_CATEGORY AS equCategoryCode,
jri.EQU_DEFINE AS equDefineCode,
jfi.PRODUCE_DATE AS produceDate,
(SELECT SEQUENCE_NBR FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) jySeq,
(SELECT INSPECT_ORG_NAME FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) inspectOrgName,
(SELECT INSPECT_ORG_CODE FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) inspectOrgCode,
(SELECT INSPECT_REPORT_NO FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) inspectReportNo,
(SELECT INSPECT_CONCLUSION FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) inspectConclusionCode,
(SELECT NAME FROM cb_data_dictionary WHERE type = 'JYJL' and code = (SELECT INSPECT_CONCLUSION FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1)) inspectConclusion,
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') nextInspectDate,
(SELECT INSPECT_REPORT FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = jui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1) inspectReport
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
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>
......
......@@ -1449,7 +1449,7 @@
select
count(1) as inUseNumber
from
"tzs_jg_use_registration_eq" ae
tzs_jg_use_registration_eq ae
JOIN tzs_jg_use_registration A ON A.sequence_nbr = ae.equip_transfer_id
JOIN "tzs_jg_equip_transfer_eq" tjete ON ae.equ_id = tjete."equ_id"
JOIN tzs_jg_equip_transfer tjet ON tjete."equip_transfer_id" = tjet."sequence_nbr"
......@@ -1461,11 +1461,11 @@
select
count(1) as inUseNumber
from
"TZS_JG_OVER_DESIGN_SERVICE_LIFE_EQ" ae
JOIN TZS_JG_OVER_DESIGN_SERVICE_LIFE a ON a.sequence_nbr = ae.over_design_id
tzs_jg_over_design_service_life_eq ae
JOIN tzs_jg_over_design_service_life a ON a.sequence_nbr = ae.over_design_id
where a.use_registration_code LIKE CONCAT('%',#{code},'%')
AND a.is_delete = 0
AND a.status != '已作废'
)x
)
</select>
</mapper>
......@@ -230,19 +230,6 @@ public class IdxBizJgProjectContraptionController extends BaseController {
return ResponseHelper.buildResponse(idxBizJgProjectContraptionServiceImpl.getNewInspectionDetailByRecord(record));
}
/**
* 获取最新检验信息详情
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getNewWTJYInspectionDetailByRecord")
@ApiOperation(httpMethod = "GET", value = "获取最新检验信息详情", notes = "获取最新检验信息详情")
public ResponseModel<Map<String, Object>> getNewWTJYInspectionDetailByRecord(@RequestParam("record") String record,
@RequestParam("equListCode") String equListCode) {
return ResponseHelper.buildResponse(idxBizJgProjectContraptionServiceImpl.getNewWTJYInspectionDetailByRecord(record,equListCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/summaryBasicInfo/export")
@ApiOperation(httpMethod = "GET", value = "导出基本信息汇总表(长输/公用管道)", notes = "导出基本信息汇总表(长输/公用管道)")
......
......@@ -164,4 +164,17 @@ public class JgOverDesignServiceLifeController extends BaseController {
public ResponseModel<JgOverDesignServiceLife> invalid(@RequestBody JgOverDesignServiceLifeDto dto) {
return ResponseHelper.buildResponse(jgOverDesignServiceLifeServiceImpl.invalid(dto.getSequenceNbr(), dto.getCancelReason()));
}
/**
* 获取最新检验信息详情
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getNewWTJYInspectionDetailByRecord")
@ApiOperation(httpMethod = "GET", value = "获取最新检验信息详情", notes = "获取最新检验信息详情")
public ResponseModel<Map<String, Object>> getNewWTJYInspectionDetailByRecord(@RequestParam("record") String record,
@RequestParam("equListCode") String equListCode) {
return ResponseHelper.buildResponse(jgOverDesignServiceLifeServiceImpl.getNewWTJYInspectionDetailByRecord(record,equListCode));
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.CaseFormat;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
......@@ -20,7 +21,6 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
......@@ -260,6 +260,43 @@ public class JgUseRegistrationManageController extends BaseController {
}
/**
* 根据证id批量查询证下面所有设备
* @param current
* @param size
* @param enableType
* @param sequenceNbrs
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/queryEquForPageByCertificateSeqList")
@ApiOperation(httpMethod = "GET", value = "根据证id批量查询证下面所有设备", notes = "根据证id批量查询证下面所有设备")
public ResponseModel<Page<JSONObject>> queryEquForPageByCertificateSeqList(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "enableType", required = false) String enableType,
@RequestParam(value = "sequenceNbrs", required = false) String sequenceNbrs) {
if (ObjectUtils.isEmpty(sequenceNbrs)) {
throw new BadRequest("请先选择使用登记证");
}
List<Long> collect = Arrays.stream(sequenceNbrs.split(","))
.map(Long::parseLong)
.collect(Collectors.toList());
Page<JSONObject> result = jgUseRegistrationManageServiceImpl.queryEquForPageByCertificateSeqList(enableType, collect, current, size);
result.setRecords(result.getRecords().stream().map(this::convertKeysToCamelCase).collect(Collectors.toList()));
return ResponseHelper.buildResponse(result);
}
/**
* 将 JSON 对象的 Key 由 UPPER_UNDERSCORE 转换为 lowerCamelCase
*/
private JSONObject convertKeysToCamelCase(JSONObject jsonObject) {
JSONObject newJson = new JSONObject();
jsonObject.forEach((key, value) ->
newJson.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, key), value)
);
return newJson;
}
/**
* 证的 相关打印
* @param response 响应
* @param printType certificateNormalPrint:使用登记证 普打
......
......@@ -81,6 +81,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -93,7 +94,6 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.PostConstruct;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
......@@ -2456,7 +2456,6 @@ public class CommonServiceImpl implements ICommonService {
return formData;
}
//多个证进行批量生成
public List<JSONObject> buildFileForOverDesign(JSONObject jsonObject) {
List<JSONObject> formDataList = new ArrayList<>();
if (jsonObject.containsKey("equipmentLists")) {
......@@ -2467,8 +2466,8 @@ public class CommonServiceImpl implements ICommonService {
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(equips)) {
Map<String, Object> firstEquip = equips.get(0);
String equDefine = (String) firstEquip.get("EQU_DEFINE");
String equCategory = (String) firstEquip.get("EQU_CATEGORY");
String equDefine = Objects.toString(firstEquip.get("equDefine"),"--");
String equCategory = Objects.toString(firstEquip.get("equCategory"),"");
formDataList = equips.stream().map(v -> {
JSONObject formData = new JSONObject();
formData.putAll(jsonObject);
......@@ -2481,27 +2480,25 @@ public class CommonServiceImpl implements ICommonService {
.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"), "");
String useRegistrationCode = Objects.toString(v.get("useOrgCode"), "");
JgUseRegistrationManage manage = jgUseRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode)
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.one();
formData.put("equCode", v.get("EQU_CODE"));
formData.put("useRegistrationCode", v.get("USE_ORG_CODE"));
formData.put("produceUnitName", v.get("PRODUCE_UNIT_NAME"));
formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("PRODUCE_DATE")), inputFormatter)
formData.put("equCode", v.get("equCode"));
formData.put("useRegistrationCode", v.get("useOrgCode"));
formData.put("produceUnitName", v.get("produceUnitName"));
formData.put("produceDate", LocalDateTime.parse(Objects.toString(v.get("produceDate")), inputFormatter)
.format(outputFormatter));
formData.put("factoryNum", v.get("FACTORY_NUM"));
formData.put("productName", v.get("PRODUCT_NAME"));
formData.put("useUnitName", v.get("USE_UNIT_NAME"));
formData.put("factoryNum", v.get("factoryNum"));
formData.put("productName", v.get("productName"));
formData.put("useUnitName", v.get("useUnitName"));
if (manage != null && manage.getAuditPassDate() != null) {
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("applyNo", jsonObject.get("applyNo"));
formData.put("cruDate", DateUtils.convertDateToString(new Date(), DateUtils.CHN_DATE_PATTERN));
return formData;
}).collect(Collectors.toList());
......@@ -2585,7 +2582,18 @@ public class CommonServiceImpl implements ICommonService {
@Override
public Map<String, Object> getRegistrationChangeCertificateUrl(JSONObject jsonObject) {
String applyNo = jsonObject.getString("applyNo");
if (StringUtils.isEmpty(applyNo)) {
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.CSJ.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
throw new BadRequest("超设计使用年限变更申请单单号获取失败!");
}
applyNo = listResponseModel.getResult().get(0);
}
jsonObject.put("applyNo", applyNo);
List<JSONObject> formDataList = buildFileForOverDesign(jsonObject);
Map<String, Object> result = new HashMap<>();
String wordPath = "use-registration-change-certificate.ftl";
String fileName = "特种设备使用登记变更证明_";
List<File> generatedFiles = new ArrayList<>();
......@@ -2594,31 +2602,33 @@ public class CommonServiceImpl implements ICommonService {
try {
List<File> pdfFiles = formDataList.stream()
.map(formData -> {
File pdfFile = null;
try {
pdfFile = wordToPdf(fileName, wordPath, formData);
File pdfFile = wordToPdf(fileName, wordPath, formData);
if (pdfFile != null && pdfFile.exists()) generatedFiles.add(pdfFile);
return pdfFile;
} catch (Exception e) {
throw new RuntimeException(e);
}
if (pdfFile != null && pdfFile.exists()) {
generatedFiles.add(pdfFile);
log.error("PDF 生成失败", e);
return null;
}
return pdfFile;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!pdfFiles.isEmpty()) {
mergedPdfFile = mergePdfFiles(pdfFiles, fileName + "合并.pdf");
if (mergedPdfFile.exists()) {
generatedFiles.add(mergedPdfFile);
}
if (mergedPdfFile.exists()) generatedFiles.add(mergedPdfFile);
}
String uploadedUrl = uploadFile(mergedPdfFile, "useRegistrationFormFiles");
return Collections.singletonMap("useRegistrationFormUrl", uploadedUrl);
result.put("useRegistrationFormUrl", uploadedUrl);
result.put("applyNo", applyNo);
return result;
} catch (Exception e) {
log.error("生成或上传文件失败", e);
throw new RuntimeException("文件处理失败", e);
} finally {
System.gc();
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
generatedFiles.forEach(this::deleteFileSafely);
}
}
......
......@@ -748,22 +748,4 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
result.put("jySeq", info.getSequenceNbr());
return result;
}
public Map<String, Object> getNewWTJYInspectionDetailByRecord(String record, String equListCode) {
return detectionInfoService.queryInspectionListByRecord(record).stream()
.filter(v -> "6000".equals(equListCode) || "WTJY".equals(v.getInspectType()))
.findFirst()
.map(info -> {
Map<String, Object> result = new HashMap<>(Bean.BeantoMap(info));
result.put("inspectReport", JSON.parseArray(info.getInspectReport()));
result.put("inspectConclusionCode", info.getInspectConclusion());
result.put("inspectConclusion",
Optional.ofNullable(dataDictionaryServiceImpl.getByCode(info.getInspectConclusion(), "JYJL"))
.map(DataDictionary::getName)
.orElse(""));
result.put("jySeq", info.getSequenceNbr());
return result;
})
.orElse(Collections.emptyMap());
}
}
\ No newline at end of file
......@@ -14,15 +14,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgOverDesignServiceLife;
import com.yeejoin.amos.boot.module.jg.api.entity.JgOverDesignServiceLifeEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgOverDesignServiceLifeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgOverDesignServiceLifeMapper;
......@@ -51,6 +50,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
......@@ -71,6 +72,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;
import java.util.*;
......@@ -85,53 +87,36 @@ import static java.util.stream.Collectors.toList;
* @author system_generator
* @date 2025-03-06
*/
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesignServiceLife, JgOverDesignServiceLife, JgOverDesignServiceLifeMapper> implements IJgOverDesignServiceLifeService, ICompensateFlowDataOfRedis<JgOverDesignServiceLife> {
private static final String DEFINITION_KEY = "overDesignServiceLife";
public static final String SUBMIT_TYPE_FLOW = "1";
public static final String SUBMIT_DATA = "0";
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废", "已完成");
@Autowired
private CommonServiceImpl commonService;
@Autowired
private JgOverDesignServiceLifeEqServiceImpl jgOverDesignServiceLifeEqService;
@Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
private RedissonClient redissonClient;
@Autowired
private CommonServiceImpl commonServiceImpl;
@Autowired
private RedisUtils redisUtils;
@Autowired
private CmWorkflowServiceImpl cmWorkflowService;
@Autowired
private JgOverDesignServiceLifeEqMapper jgOverDesignServiceLifeEqMapper;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
private TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
private ICmWorkflowService workflowService;
@Autowired
private IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoServiceImpl;
@Autowired
private JgUseRegistrationManageServiceImpl useRegistrationManageService;
@Autowired
private IIdxBizJgInspectionDetectionInfoService iIdxBizJgInspectionDetectionInfoService;
@Autowired
private JgResumeInfoServiceImpl jgResumeInfoService;
@Autowired
private InspectionDetectionInfoMapper inspectionDetectionInfoMapper;
@Autowired
private SnowflakeIdUtil sequence;
@Autowired
private EventPublisher eventPublisher;
@Autowired
private EmqKeeper emqKeeper;
private final CommonServiceImpl commonService;
private final JgOverDesignServiceLifeEqServiceImpl jgOverDesignServiceLifeEqService;
private final JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
private final RedissonClient redissonClient;
private final CommonServiceImpl commonServiceImpl;
private final RedisUtils redisUtils;
private final CmWorkflowServiceImpl cmWorkflowService;
private final JgOverDesignServiceLifeEqMapper jgOverDesignServiceLifeEqMapper;
private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
private final IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
private final TzsServiceFeignClient tzsServiceFeignClient;
private final ICmWorkflowService workflowService;
private final IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoServiceImpl;
private final JgUseRegistrationManageServiceImpl useRegistrationManageService;
private final IIdxBizJgInspectionDetectionInfoService iIdxBizJgInspectionDetectionInfoService;
private final JgResumeInfoServiceImpl jgResumeInfoService;
private final InspectionDetectionInfoMapper inspectionDetectionInfoMapper;
private final SnowflakeIdUtil sequence;
private final EventPublisher eventPublisher;
private final EmqKeeper emqKeeper;
private final DataDictionaryServiceImpl dataDictionaryServiceImpl;
/**
* 分页查询
......@@ -179,25 +164,34 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.map(v -> (String) v.get("record"))
.collect(Collectors.toList())
);
if (equipmentLists.stream().anyMatch(info -> info.get("safetyAssessmentReport") == null || "".equals(info.get("safetyAssessmentReport")))) {
throw new BadRequest("请补充设备安全评估报告信息后提交!");
}
if (inspectionDetectionInfoList.stream().anyMatch(info ->
ObjectUtils.isEmpty(info) || ObjectUtils.isEmpty(info.getInspectType()) ||
ObjectUtils.isEmpty(info.getInspectConclusion()) || ObjectUtils.isEmpty(info.getInspectOrgCode()))) {
throw new BadRequest("请补充设备检验检测信息后提交!");
}
if (inspectionDetectionInfoList.stream().anyMatch(info ->
"2000".equals(map.get("equListCode")) && !"WTJY".equals(info.getInspectType()))) {
throw new BadRequest("压力容器需要先做委托检验后提交!!");
}
List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum(
equipmentLists.stream()
.map(v -> (String) v.get("record"))
.collect(Collectors.toList())
);
if (designInfoList.stream().anyMatch(info -> info.getOverDesignRegNum() >= 2)) {
throw new BadRequest("请补充设备检验检测信息后提交!");
log.error("超设计使用年限变更登记设备最多延期两次, 设备record: {}", designInfoList.stream().filter(info -> info.getOverDesignRegNum() >= 2)
.map(IdxBizJgDesignInfo::getRecord).collect(Collectors.joining(",")));
throw new BadRequest("超设计使用年限变更登记设备最多延期两次!");
}
overDesignDto.setCreateDate(new Date());
overDesignDto.setPromoter(reginParams.getUserModel().getUserId());
List<String> registrationNoList = equipmentLists.stream()
.map(objectMap -> objectMap.get("USE_ORG_CODE"))
.map(objectMap -> objectMap.get("useOrgCode"))
.filter(Objects::nonNull)
.map(Object::toString)
.collect(Collectors.toList());
......@@ -230,16 +224,18 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.findFirst()
.map(e -> Objects.toString(e.get(key), ""))
.orElse("");
overDesignServiceLife.setEquList(getFirstValue.apply("EQU_LIST"));
overDesignServiceLife.setEquCategory(getFirstValue.apply("EQU_CATEGORY"));
overDesignServiceLife.setEquList(getFirstValue.apply("equList"));
overDesignServiceLife.setEquCategory(getFirstValue.apply("equCategory"));
boolean hasId = StringUtils.isEmpty(overDesignDto.getSequenceNbr());
//新增
if (hasId) {
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.CSJ.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
throw new BadRequest("超设计使用年限变更申请单单号获取失败!");
String applyNo = Objects.toString(map.get("applyNo"), null);
if (StringUtils.isEmpty(applyNo)) {
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.BZDJ.getCode(), 1);
if (!listResponseModel.getResult().isEmpty()) {
applyNo = listResponseModel.getResult().get(0);
}
}
String applyNo = listResponseModel.getResult().get(0);
overDesignServiceLife.setApplyNo(applyNo);
overDesignServiceLife.setStatus(SUBMIT_DATA.equals(map.get("submit")) ? WorkFlowStatusEnum.USE_SUBMIT.getPass() : WorkFlowStatusEnum.USE_RECEIVE.getPass());
this.save(overDesignServiceLife);
......@@ -256,14 +252,20 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
equip.setEquId(String.valueOf(device.get("record")));
equip.setOverDesignId(Objects.toString(overDesignServiceLife.getSequenceNbr()));
equip.setDeviceInfo(JSONObject.toJSONString(device));
equip.setUseRegistrationCode(Objects.toString(device.get("USE_ORG_CODE"), ""));
equip.setEquList(Objects.toString(device.get("EQU_LIST_CODE"), ""));
equip.setEquCategory(Objects.toString(device.get("EQU_CATEGORY_CODE"), ""));
equip.setEquDefine(Objects.toString(device.get("EQU_DEFINE_CODE"), ""));
if (!ObjectUtils.isEmpty(device.get("SAFETY_ASSESSMENT_REPORT"))) {
equip.setSafetyAssessmentReport(JSONObject.toJSONString(device.get("SAFETY_ASSESSMENT_REPORT")));
equip.setUseRegistrationCode(Objects.toString(device.get("useOrgCode"), ""));
equip.setEquList(Objects.toString(device.get("equListCode"), ""));
equip.setEquCategory(Objects.toString(device.get("equCategoryCode"), ""));
equip.setEquDefine(Objects.toString(device.get("equDefineCode"), ""));
equip.setSafetyAssessmentName(Objects.toString(device.get("safetyAssessmentName"), ""));
equip.setSafetyAssessmentCreditCode(Objects.toString(device.get("safetyAssessmentCreditCode"), ""));
equip.setSafetyAssessmentResult(Objects.toString(device.get("safetyAssessmentResult"), ""));
equip.setSafetyAssessmentDate(castDate2TimeStr(Objects.toString(device.get("safetyAssessmentDate"), null)));
equip.setSafetyAssessmentName(Objects.toString(device.get("equListCode"), ""));
if (!ObjectUtils.isEmpty(device.get("safetyAssessmentReport"))) {
equip.setSafetyAssessmentReport(JSONObject.toJSONString(device.get("safetyAssessmentReport")));
}
equipList.add(equip);
overDesignServiceLife.setEquList(Objects.toString(device.get("equList"), ""));
});
jgOverDesignServiceLifeEqService.saveBatch(equipList);
}
......@@ -299,7 +301,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
BeanUtil.copyProperties(overDesignServiceLife, taskMessageDto);
taskMessageDto.setEquipId(String.valueOf(map.get("equipId")));
dto.setModel(taskMessageDto);
dto.setTaskContent(String.format("来自%s的业务办理,【申请单号:%s】",ObjectUtils.isEmpty(overDesignServiceLife.getEquList()) ? "" : overDesignServiceLife.getEquList(),
dto.setTaskContent(String.format("来自%s的业务办理,【申请单号:%s】", ObjectUtils.isEmpty(overDesignServiceLife.getEquList()) ? "" : overDesignServiceLife.getEquList(),
overDesignServiceLife.getApplyNo()));
dto.setTaskCode(overDesignServiceLife.getApplyNo());
dto.setTaskType(String.valueOf(BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.getCode()));
......@@ -620,7 +622,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private void updateEquipMessage(JSONObject jsonObject, TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife) {
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> Objects.toString(obj.get("USE_ORG_CODE"), ""))
.map(obj -> Objects.toString(obj.get("useOrgCode"), ""))
.collect(Collectors.toList());
List<String> records = equipmentLists.stream()
.map(v -> Objects.toString(v.get("record"), ""))
......@@ -646,9 +648,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private void updateOrCreateInspectionDetection(List<Map<String, Object>> equipmentLists) {
for (Map<String, Object> equipment : equipmentLists) {
equipment.remove("recDate");
InspectionDetectionInfo inspectionDetectionInfo = new InspectionDetectionInfo();
equipment.put("NEXT_INSPECT_DATE", this.castDate2TimeStr(Objects.toString(equipment.get("NEXT_INSPECT_DATE"))));
equipment.put("INSPECT_DATE", this.castDate2TimeStr(Objects.toString(equipment.get("INSPECT_DATE"))));
BeanUtil.copyProperties(equipment, inspectionDetectionInfo);
// 处理jySeq更新逻辑
String jySeq = Objects.toString(equipment.get("jySeq"), "");
......@@ -680,33 +681,43 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
}
private void updateDesignInfo(TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife, List<Map<String, Object>> equipmentLists, List<IdxBizJgDesignInfo> designInfoList) {
String equListCode = Objects.toString(equipmentLists.get(0).get("EQU_LIST_CODE"), "");
String equListCode = Objects.toString(equipmentLists.get(0).get("equListCode"), "");
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 -> {
Date targetDate = "6000".equals(equListCode) ? info.getInspectDate() : info.getNextInspectDate();
return targetDate.toInstant().atZone(zoneId).toLocalDate().plusYears("6000".equals(equListCode) ? 4 : 0).toString();
})
.orElse(null)
);
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = inspectionList.stream()
.filter(info -> "6000".equals(equListCode) || "WTJY".equals(info.getInspectType()))
.findFirst()
.orElse(null);
if (inspectionDetectionInfo != null) {
boolean is6000 = "6000".equals(equListCode);
Date targetDate = is6000 ? inspectionDetectionInfo.getInspectDate() : inspectionDetectionInfo.getNextInspectDate();
if (targetDate != null) {
// 将 targetDate 转换为 Instant,再转换为 LocalDate,避免解析错误
String resultDate = targetDate.toInstant() // 将 Date 转换为 Instant
.atZone(zoneId) // 转为 ZoneDateTime
.toLocalDate() // 转为 LocalDate
.plusYears(is6000 ? 4 : 0) // 根据条件加上年份
.toString(); // 转换为 String 类型
designInfo.setDelayServiceLifeDate(resultDate);
}
}
idxBizJgDesignInfoServiceImpl.saveOrUpdateBatch(designInfoList);
this.saveResumeInfo(taskV2Model, jgOverDesignServiceLife, designInfo);
});
}
/**
* 发送超设计使用年限消息
*
* @param equipmentLists 设备信息
*/
private void sendOverDesignMessage(List<Map<String, Object>> equipmentLists) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(equipmentLists));
if (CollectionUtil.isNotEmpty(jsonArray)){
if (CollectionUtil.isNotEmpty(jsonArray)) {
try {
emqKeeper.getMqttClient().publish(SafetyProblemTypeEnum.SJNXDJ.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
......@@ -782,7 +793,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private void setEquListCode2Json(JgOverDesignServiceLife jgOverDesignServiceLife, JSONObject jsonObject) {
TaskMessageDto taskMessageDto = new TaskMessageDto();
this.setEquListForWorkSpace(jgOverDesignServiceLife, taskMessageDto);
jsonObject.put("EQU_LIST_CODE", taskMessageDto.getEQU_LIST_CODE());
jsonObject.put("equListCode", taskMessageDto.getEQU_LIST_CODE());
}
private void setEquListForWorkSpace(JgOverDesignServiceLife jgOverDesignServiceLife, TaskMessageDto taskMessageDto) {
......@@ -864,7 +875,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.map(v -> (String) v.get("record"))
.collect(Collectors.toList());
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> ((JSONObject) obj).getString("USE_ORG_CODE"))
.map(obj -> ((JSONObject) obj).getString("useOrgCode"))
.collect(Collectors.toList());
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
......@@ -933,7 +944,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private List<String> getEquList(JgOverDesignServiceLife overDesignServiceLife) {
return jgOverDesignServiceLifeEqMapper.selectList(new LambdaQueryWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLife.getSequenceNbr()))
.eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLife.getSequenceNbr()))
.stream()
.map(JgOverDesignServiceLifeEq::getEquId)
.collect(toList());
......@@ -991,7 +1002,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.collect(Collectors.toList());
List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum(records);
designInfoList.forEach(designInfo -> {
designInfo.setOverDesignRegNum(Math.max(designInfo.getOverDesignRegNum() -1,0));
designInfo.setOverDesignRegNum(Math.max(designInfo.getOverDesignRegNum() - 1, 0));
designInfo.setDelayServiceLifeDate("");
jgResumeInfoService.deleteByBusinessId(String.valueOf(overDesignServiceLife.getSequenceNbr()));
});
......@@ -1011,4 +1022,36 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
taskMap.put("model", taskMessageDto);
commonServiceImpl.updateTaskModel(taskMap);
}
public Map<String, Object> getNewWTJYInspectionDetailByRecord(String record, String equListCode) {
JgOverDesignServiceLifeEq overDesignServiceLifeEq = jgOverDesignServiceLifeEqMapper.selectOne(
new LambdaQueryWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getEquId, record)
.orderByDesc(JgOverDesignServiceLifeEq::getRecDate)
.last("LIMIT 1"));
return iIdxBizJgInspectionDetectionInfoService.queryInspectionListByRecord(record).stream()
.filter(v -> "6000".equals(equListCode) || "WTJY".equals(v.getInspectType()))
.findFirst()
.map(info -> {
Map<String, Object> result = new HashMap<>(Bean.BeantoMap(info));
result.put("inspectReport", JSON.parseArray(info.getInspectReport()));
result.put("inspectConclusionCode", info.getInspectConclusion());
result.put("inspectConclusion",
Optional.ofNullable(dataDictionaryServiceImpl.getByCode(info.getInspectConclusion(), "JYJL"))
.map(DataDictionary::getName)
.orElse(""));
result.put("jySeq", info.getSequenceNbr());
if (overDesignServiceLifeEq != null) {
result.put("safetyAssessmentName", overDesignServiceLifeEq.getSafetyAssessmentName());
result.put("safetyAssessmentCreditCode", overDesignServiceLifeEq.getSafetyAssessmentCreditCode());
result.put("safetyAssessmentReport", overDesignServiceLifeEq.getSafetyAssessmentReport());
result.put("safetyAssessmentResult", overDesignServiceLifeEq.getSafetyAssessmentResult());
result.put("safetyAssessmentDate", overDesignServiceLifeEq.getSafetyAssessmentDate());
}
commonService.convertStringToJsonobject(result, new String[]{"safetyAssessmentReport"});
return result;
})
.orElse(Collections.emptyMap());
}
}
\ No newline at end of file
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