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

fix(jg):暂存功能问题处理

parent 70947d80
......@@ -29,4 +29,5 @@ public class EquipmentInfoDto {
* 属地监管部门:orgCode_名称
*/
private String orgBranchCode;
private String orgBranchName;
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ public class TransferNoticeStrategyHandler implements ToBeSubmitDetailStrategy {
Map<String, Object> basic = new HashMap<>();
basic.put("type", ApplicationFormTypeEnum.YZGZ.getBusinessCode());
basic.put("receiveOrgCreditCode", transferInfo.get("receiveOrgCreditCode"));
basic.put("receiveOrgCreditCode", transferInfo.get("receiveOrgCode"));
basic.put("code", transferInfo.get("EQU_LIST_CODE"));
basic.put("equCategory", transferInfo.get("EQU_CATEGORY_CODE"));
Map<String, Map<String, Object>> result = new HashMap<>();
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.feign.WorkFlowFeignService;
......@@ -11,7 +12,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
......@@ -90,10 +93,44 @@ public class CmWorkflowServiceImpl implements ICmWorkflowService {
throw new LocalBadRequest(devMessage);
} catch (Exception e) {
log.error("调用工作流完成任务接口失败", e);
throw new RuntimeException(e.getMessage());
String responseBody = extractFeignResponseBody(e);
String devMessage = extractDevMessageFromJson(responseBody);
throw new RuntimeException( devMessage != null ? devMessage : "流程处理失败", e);
}
return processTaskDTO;
}
private String extractFeignResponseBody(Exception e) {
if (e instanceof feign.FeignException) {
feign.FeignException fe = (feign.FeignException) e;
try {
return new String(fe.content(), StandardCharsets.UTF_8);
} catch (Exception ex) {
log.warn("读取Feign响应体失败", ex);
}
}
return e.getMessage();
}
private String extractDevMessageFromJson(String jsonStr) {
if (jsonStr == null || jsonStr.trim().isEmpty()) return null;
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> json = mapper.readValue(jsonStr, Map.class);
Object devMessage = json.get("devMessage");
Object message = json.get("message");
if (devMessage != null && !String.valueOf(devMessage).trim().isEmpty()) {
return String.valueOf(devMessage);
} else if (message != null) {
return String.valueOf(message);
}
} catch (Exception ex) {
log.warn("解析响应JSON出错: {}", jsonStr, ex);
}
return null;
}
@Override
public ProcessTaskDTO rollBack(String processInstanceId) {
......
......@@ -960,7 +960,7 @@ public class CommonServiceImpl implements ICommonService {
unitList.stream(),
unitListByType.stream()
).collect(Collectors.toMap(
map -> (String) map.get("useCode"), // 以 unitCode 作为 key
map -> String.valueOf(map.get("useCode")), // 以 unitCode 作为 key
map -> map,
(existing, replacement) -> existing // 如果 key 冲突,保留原有的
)).values());
......
......@@ -39,6 +39,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.biz.config.PressureVesselListener;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.core.BaseService;
import com.yeejoin.amos.boot.module.jg.biz.edit.backup.TechParamsBackupService;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
......@@ -329,6 +330,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
private EventPublisher eventPublisher;
@Autowired
private TechParamsBackupService techParamsBackupService;
public static final String DATA_QUALITY_SCORE = "DATA_QUALITY_SCORE";
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
......@@ -1188,6 +1192,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
equipInfoMap.put("companyLevel", companyLevel);
equipInfoMap.put("type", equIpClassMap.get("type"));
String formType = Optional.ofNullable(equIpClassMap.get("formType"))
.map(Object::toString)
.filter(s -> !s.trim().isEmpty())
.orElse("add");
equipInfoMap.put("formType", formType);
// 设备参数
if (equIpClassMap.containsKey(EQU_LIST) && !ValidationUtil.isEmpty(equIpClassMap.get(EQU_LIST).toString())) {
Map<String, Object> equipParamsMap = this.getEquipParamsMap(record, "", equIpClassMap.get(EQU_LIST).toString());
......@@ -3616,9 +3625,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 八大类技术参数和主要零部件和安全附件表
List<IdxBizJgMainParts> mainPartsList = new ArrayList<>();
List<IdxBizJgProtectionDevices> protectionDevicesList = new ArrayList<>();
// 统一设置所有 SEQ 字段
Object params = techParamsBackupService.getTechParams(equList, record);
// 电梯
if (EquipmentClassifityEnum.DT.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsElevator) {
equipmentParamsForm.put("ELEVATOR_SEQ", ((IdxBizJgTechParamsElevator) params).getSequenceNbr());
}
IdxBizJgTechParamsElevator elevator = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsElevator.class);
if (!ValidationUtil.isEmpty(elevator)) {
elevator.setRecord(record);
......@@ -3629,6 +3643,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 厂车
else if (EquipmentClassifityEnum.CC.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsVehicle) {
equipmentParamsForm.put("VEHICLE_SEQ", ((IdxBizJgTechParamsVehicle) params).getSequenceNbr());
}
IdxBizJgTechParamsVehicle vehicle = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsVehicle.class);
if (!ValidationUtil.isEmpty(vehicle)) {
vehicle.setRecord(record);
......@@ -3646,6 +3663,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 索道
else if (EquipmentClassifityEnum.KYSD.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsRopeway) {
equipmentParamsForm.put("ROPEWAY_SEQ", ((IdxBizJgTechParamsRopeway) params).getSequenceNbr());
}
IdxBizJgTechParamsRopeway ropeway = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsRopeway.class);
if (!ValidationUtil.isEmpty(ropeway)) {
ropeway.setRecord(record);
......@@ -3662,6 +3682,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 游乐设施
else if (EquipmentClassifityEnum.YLSS.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsRides) {
equipmentParamsForm.put("RIDES_SEQ", ((IdxBizJgTechParamsRides) params).getSequenceNbr());
}
IdxBizJgTechParamsRides rides = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsRides.class);
if (!ValidationUtil.isEmpty(rides)) {
rides.setRecord(record);
......@@ -3672,6 +3695,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 锅炉
else if (EquipmentClassifityEnum.GL.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsBoiler) {
equipmentParamsForm.put("BOILER_SEQ", ((IdxBizJgTechParamsBoiler) params).getSequenceNbr());
}
IdxBizJgTechParamsBoiler boiler = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsBoiler.class);
if (!ValidationUtil.isEmpty(boiler)) {
boiler.setRecord(record);
......@@ -3687,6 +3713,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 压力容器
else if (EquipmentClassifityEnum.YLRQ.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsVessel) {
equipmentParamsForm.put("VESSEL_SEQ", ((IdxBizJgTechParamsVessel) params).getSequenceNbr());
}
IdxBizJgTechParamsVessel vessel = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsVessel.class);
if (!ValidationUtil.isEmpty(vessel)) {
vessel.setRecord(record);
......@@ -3710,6 +3739,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
// 压力管道
else if (EquipmentClassifityEnum.YLGD.getCode().equals(equList)) {
if (params instanceof IdxBizJgTechParamsPipeline) {
equipmentParamsForm.put("PIPELINE_SEQ", ((IdxBizJgTechParamsPipeline) params).getSequenceNbr());
}
IdxBizJgTechParamsPipeline pipeline = JSON.parseObject(JSON.toJSONString(equipmentParamsForm), IdxBizJgTechParamsPipeline.class);
if (!ValidationUtil.isEmpty(pipeline)) {
pipeline.setRecord(record);
......@@ -4509,6 +4541,12 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private EquipmentInfoDto createEquipmentInfoDto
(Map<String, Object> equipmentInfoForm, JgVehicleInformationMapper jgVehicleInformationMapper) {
String[] parts = Optional.ofNullable(equipmentInfoForm.get("orgBranchCode"))
.map(Object::toString)
.map(s -> s.split("_", 2))
.orElse(new String[0]);
String orgBranchCode = parts.length > 0 ? parts[0] : "";
String orgBranchName = parts.length > 1 ? parts[1] : "";
EquipmentInfoDto dto = new EquipmentInfoDto();
String equListCode = (String) equipmentInfoForm.get("EQU_LIST");
String equCategoryCode = (String) equipmentInfoForm.get("EQU_CATEGORY");
......@@ -4521,10 +4559,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
dto.setEquDefine(jgVehicleInformationMapper.getEquCategoryNameByCode(equDefineCode));
dto.setDataSource((String) equipmentInfoForm.get("DATA_SOURCE"));
dto.setUseOrgCode((String) equipmentInfoForm.get("USE_ORG_CODE"));
dto.setOrgBranchCode(orgBranchCode);
dto.setOrgBranchName(orgBranchName);
if ("his".equals(equipmentInfoForm.get("DATA_SOURCE"))) {
dto.setReceiveOrgCode(((String) equipmentInfoForm.get("RECEIVE_ORG_CODE")).split("_")[0]);
dto.setReceiveOrgName(((String) equipmentInfoForm.get("RECEIVE_ORG_CODE")).split("_")[1]);
dto.setOrgBranchCode(Optional.ofNullable(equipmentInfoForm.get("orgBranchCode")).map(Object::toString).orElse(""));
dto.setEquState(Optional.ofNullable(equipmentInfoForm.get("EQU_STATE")).map(Object::toString).orElse(""));
}
dto.setPossession(Optional.ofNullable(equipmentInfoForm.get("VEHICLE_APANAGE")).map(Object::toString).orElse(""));
......
......@@ -145,9 +145,10 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
private JgUseRegistrationManageServiceImpl useRegistrationManageService;
@Autowired
private IIdxBizJgOtherInfoService otherInfoService;
@Autowired
private EventPublisher eventPublisher;
@Autowired
private JgVehicleInformationMapper jgVehicleInformationMapper;
/**
* 新增移装变更登记
......@@ -393,7 +394,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
this.flowExecute(oldTransfer.getSequenceNbr(), oldTransfer.getInstanceId(), "0", "", String.valueOf(map.get("nextTaskId")));
} else {
// 如果是新启动的流程开启自动访问
String equipListName = Optional.ofNullable(tableData.get("equListDesc")).orElse("无").toString();
String equipListName = jgVehicleInformationMapper.getEquCategoryNameByCode(Objects.toString(tableData.get("equListCode")));
oldTransfer.setAuditStatus(WorkFlowStatusEnum.TRANSFER_RECEIVE.getPass());
oldTransfer.setStatus(WorkFlowStatusEnum.TRANSFER_RECEIVE.getPass());
oldTransfer.setEquipListName(equipListName);
......
......@@ -34,6 +34,7 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCur
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.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.jg.biz.utils.ObjectCleanerUtils;
import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
......@@ -643,13 +644,15 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
dto.setCreateDate(new Date());
dto.setEquList(jgVehicleInformationMapper.getEquCategoryNameByCode(model.getEquListCode()));
dto.setEquCategory(jgVehicleInformationMapper.getEquCategoryNameByCode(model.getEquCategory()));
dto = ObjectCleanerUtils.removeStringNullFields(dto, JgTransferNotice.class);
list.add(dto);
this.saveOrUpdate(list.get(0));
if (!CollectionUtils.isEmpty(deviceList)){
JgTransferNotice finalDto = dto;
deviceList.forEach(obj -> {
JgTransferNoticeEq jgRelationEquip = new JgTransferNoticeEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipTransferId(dto.getSequenceNbr().toString());
jgRelationEquip.setEquipTransferId(finalDto.getSequenceNbr() +"");
jgRelationEquip.setEquCategory(obj.getOrDefault("EQU_CATEGORY", "").toString());//设备类别
jgRelationEquip.setEquList(String.valueOf(obj.get("EQU_LIST")));//设备种类
jgRelationEquip.setEquListCode(String.valueOf(obj.get("EQU_LIST_CODE")));//设备种类编码
......
......@@ -629,6 +629,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
map.put("safetyManagerId", data[0]);
map.put("safetyManagerName", data[1]);
}
if (map.containsKey("useUnitCreditCode") && map.get("useUnitCreditCode") != null) {
String[] data = String.valueOf(map.getString("useUnitCreditCode")).split("_");
map.put("useUnitCreditCode", data[0]);
}
// 使用单位提交
jgUseRegistration.setUseUnitName(CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType()) ?
company.getCompanyName().split("_")[1] : company.getCompanyName());
......@@ -1241,6 +1245,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 装置更新管道的技术参数、设计信息、安装信息
if (jgProjectContraption != null) {
updatePieLineTechAndInspection(equipmentLists);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
.businessId(jgUseRegistration.getSequenceNbr() + "")
.equId(jgProjectContraption.getSequenceNbr() +"")
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.changeContent(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName() + "业务办理")
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
}
for (int i = 0; i < equipmentLists.size(); i++) {
Map<String, Object> equipment = equipmentLists.get(i);
......@@ -1790,6 +1805,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 新增页面选择无设备代码后,在审批通过后自动生成设备代码
this.justGenerateEquCode(lambda, registerInfo, jgUseRegistration.getReceiveCompanyCode(), mapData, jgRegistrationHistory);
idxBizJgRegisterInfoService.update(lambda);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
.businessId(jgUseRegistration.getSequenceNbr() + "")
.equId((String) mapData.get("equipId"))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.changeContent(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName() + "业务办理")
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
}
}
// 使用信息
......@@ -1804,17 +1830,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
useInfoMapper.updateById(useInfo);
// 更新es
updateEsData(usePlace, mapData, otherInfo, useInfo, jgUseRegistration, jsonObject);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
.businessId(jgUseRegistration.getSequenceNbr() + "")
.equId((String) mapData.get("equipId"))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.changeContent(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName() + "业务办理")
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
}
/**
......
package com.yeejoin.amos.boot.module.jg.biz.utils;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.experimental.UtilityClass;
import java.util.Map;
import java.util.stream.Collectors;
@UtilityClass
public class ObjectCleanerUtils {
public static <T> T removeStringNullFields(T obj, Class<T> clazz) {
if (obj == null) return null;
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = mapper.convertValue(obj, new TypeReference<Map<String, Object>>() {});
Map<String, Object> cleanedMap = map.entrySet().stream()
.filter(e -> {
Object value = e.getValue();
return value != null && !(value instanceof String && "null".equalsIgnoreCase((String) value));
})
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return mapper.convertValue(cleanedMap, clazz);
}
}
\ 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