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

fix(jg):设备履历信息修改

parent e14724af
package com.yeejoin.amos.boot.module.jg.biz.edit.event.listener; package com.yeejoin.amos.boot.module.jg.biz.edit.event.listener;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jg.api.converter.EquDefineConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta; import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
...@@ -11,9 +14,12 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeEqSe ...@@ -11,9 +14,12 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeEqSe
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationManageServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationManageServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
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.IdxBizJgUseInfoMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -28,6 +34,7 @@ import java.util.stream.Collectors; ...@@ -28,6 +34,7 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationManageServiceImpl.*; import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationManageServiceImpl.*;
import static org.apache.commons.lang3.StringUtils.defaultString;
@Component @Component
@Slf4j @Slf4j
...@@ -43,6 +50,7 @@ public class ChangeEquipImpactCertListener { ...@@ -43,6 +50,7 @@ public class ChangeEquipImpactCertListener {
private final JgInstallationNoticeServiceImpl jgInstallationNoticeService; private final JgInstallationNoticeServiceImpl jgInstallationNoticeService;
private final IdxBizJgProjectContraptionServiceImpl jgProjectContraptionService; private final IdxBizJgProjectContraptionServiceImpl jgProjectContraptionService;
private final JgInstallationNoticeEqServiceImpl jgInstallationNoticeEqService; private final JgInstallationNoticeEqServiceImpl jgInstallationNoticeEqService;
private final IdxBizJgUseInfoMapper useInfoMapper;
/** /**
* 事件监听:只把事件放入队列 * 事件监听:只把事件放入队列
...@@ -75,36 +83,93 @@ public class ChangeEquipImpactCertListener { ...@@ -75,36 +83,93 @@ public class ChangeEquipImpactCertListener {
/** /**
* 根据 bizType 路由处理逻辑 * 根据 bizType 路由处理逻辑
*/ */
private JSONObject handleFieldChange(List<FieldChangeMeta> fieldChangeMetaList, JSONObject certificatePrintTag) { private void handleFieldChange(List<FieldChangeMeta> fieldChangeMetaList, JgUseRegistrationManage manage) {
Set<String> keysToJson = fieldChangeMetaList.stream() JSONObject certificatePrintTag = Optional.ofNullable(manage.getCertificatePrintTag())
.filter(v -> ChangeFieldWatchConstants.isWatched(v.getColumnKey())) .map(JSONObject::parseObject)
.peek(v -> log.info("字段 [{}] 是影响字段", v.getColumnKey())) .orElse(new JSONObject());
.flatMap(v -> ChangeFieldWatchConstants.getMatchedCategories(v.getColumnKey()).stream()) Set<String> keysToJson = new HashSet<>();
.flatMap(category -> { for (FieldChangeMeta meta : fieldChangeMetaList) {
String columnKey = meta.getColumnKey();
if (!ChangeFieldWatchConstants.isWatched(columnKey)) {
continue;
}
log.info("字段 [{}] 是影响字段", columnKey);
for (String category : ChangeFieldWatchConstants.getMatchedCategories(columnKey)) {
switch (category) { switch (category) {
case "USE_CERT": case "USE_CERT":
return Stream.of(CERTIFICATE_NORMAL, CERTIFICATE_NESTED); this.updateUseCertField(manage, meta);
keysToJson.addAll(Arrays.asList("CERTIFICATE_NORMAL", "CERTIFICATE_NESTED"));
break;
case "USE_FLAG": case "USE_FLAG":
case "USE_FLAG_VEHICLE": case "USE_FLAG_VEHICLE":
return Stream.of(USE_FLAG_NORMAL, USE_FLAG_NESTED); keysToJson.addAll(Arrays.asList("USE_FLAG_NORMAL", "USE_FLAG_NESTED"));
break;
case "PIPELINE_SUMMARY": case "PIPELINE_SUMMARY":
case "NOTICE": case "NOTICE":
return Stream.of(EXPORT_SUMMARY_TABLE); keysToJson.add("EXPORT_SUMMARY_TABLE");
break;
case "USE_CYLINDER_SUMMARY": case "USE_CYLINDER_SUMMARY":
return Stream.of(CERTIFICATE_NORMAL); keysToJson.add("CERTIFICATE_NORMAL");
break;
default: default:
log.warn("未知分类字段:[{}]", category); log.warn("未知分类字段:[{}]", category);
return Stream.empty();
} }
}) }
.collect(Collectors.toSet()); }
keysToJson.forEach(key -> { for (String key : keysToJson) {
Object value = certificatePrintTag.get(key); Object value = certificatePrintTag.get(key);
if (value instanceof Number && ((Number) value).intValue() == 2) { if (value instanceof Number && ((Number) value).intValue() == 2) {
certificatePrintTag.put(key, 1); certificatePrintTag.put(key, 1);
} }
}); }
return certificatePrintTag; manage.setCertificatePrintTag(JSONObject.toJSONString(certificatePrintTag));
jgUseRegistrationManageService.updateById(manage);
}
private void updateUseCertField(JgUseRegistrationManage manage, FieldChangeMeta meta) {
String columnKey = meta.getColumnKey();
String afterValue = Objects.toString(meta.getColumnNewValue(), null);
if (StringUtils.isBlank(afterValue)) {
return;
}
switch (columnKey) {
case "equDefine":
manage.setEquDefineCode(afterValue);
manage.setEquDefine(EquDefineConverter.getKeyByValue(afterValue));
break;
case "useOrgCode":
manage.setUseRegistrationCode(afterValue);
break;
case "city":
case "county":
case "street":
case "address":
if (!"unit".equals(manage.getManageType())) {
updateEquUseAddressByChangeId(manage, meta.getChangeId());
}
break;
default:
log.warn("未处理的USE_CERT字段:[{}]", columnKey);
break;
}
}
private void updateEquUseAddressByChangeId(JgUseRegistrationManage manage, Object changeId) {
LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda();
lambda.eq(IdxBizJgUseInfo::getRecord, String.valueOf(changeId));
IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(lambda);
if (useInfo != null) {
String fullAddress = String.join("",
defaultString(useInfo.getProvinceName()),
defaultString(useInfo.getCityName()),
defaultString(useInfo.getCountyName()),
defaultString(useInfo.getStreetName()),
defaultString(useInfo.getAddress())
);
manage.setEquUseAddress(fullAddress);
} else {
log.warn("未找到对应的使用信息记录,ChangeId: {}", changeId);
}
} }
/** /**
...@@ -164,11 +229,7 @@ public class ChangeEquipImpactCertListener { ...@@ -164,11 +229,7 @@ public class ChangeEquipImpactCertListener {
.eq(JgUseRegistrationManage::getApplyNo, event.getBizRelationData().getBizId()) .eq(JgUseRegistrationManage::getApplyNo, event.getBizRelationData().getBizId())
.eq(JgUseRegistrationManage::getIsDelete, 0) .eq(JgUseRegistrationManage::getIsDelete, 0)
.one(); .one();
JSONObject certificatePrintTag = Optional.ofNullable(jgUseRegistrationManage.getCertificatePrintTag()) this.handleFieldChange(event.getData(), jgUseRegistrationManage);
.map(JSONObject::parseObject).orElse(new JSONObject());
JSONObject tagJson = this.handleFieldChange(event.getData(), certificatePrintTag);
jgUseRegistrationManage.setCertificatePrintTag(JSONObject.toJSONString(tagJson));
jgUseRegistrationManageService.updateById(jgUseRegistrationManage);
String equId = Stream.concat( String equId = Stream.concat(
Optional.ofNullable(event.getBizRelationData().getProjectContraptionIds()).orElse(Collections.emptySet()).stream(), Optional.ofNullable(event.getBizRelationData().getProjectContraptionIds()).orElse(Collections.emptySet()).stream(),
Optional.ofNullable(event.getBizRelationData().getRecords()).orElse(Collections.emptySet()).stream() Optional.ofNullable(event.getBizRelationData().getRecords()).orElse(Collections.emptySet()).stream()
......
...@@ -108,21 +108,22 @@ public class ChangeLogInsertListener { ...@@ -108,21 +108,22 @@ public class ChangeLogInsertListener {
).findFirst().orElse(null); ).findFirst().orElse(null);
String businessTypeName = BusinessTypeEnum String businessTypeName = BusinessTypeEnum
.findNameByEnumName(changeLog.getBizType()).orElse("设备编辑"); .findNameByEnumName(changeLog.getBizType()).orElse("设备编辑");
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder() JgResumeInfoDto resumeInfoDto = new JgResumeInfoDto();
.applyNo(event.getBizRelationData().getBizId()) resumeInfoDto.setApplyNo(event.getBizRelationData().getBizId());
.businessType(businessTypeName) resumeInfoDto.setBusinessType(businessTypeName);
.businessId(event.getBizRelationData().getBizId()) resumeInfoDto.setBusinessId(event.getBizRelationData().getBizId());
.equId(equId) resumeInfoDto.setEquId(equId);
.resumeType("1") resumeInfoDto.setResumeType("1");
.changeContent("设备编辑") resumeInfoDto.setChangeContent("设备编辑");
.changeLogId(String.valueOf(changeLog.getSequenceNbr())) resumeInfoDto.setChangeLogId(String.valueOf(changeLog.getSequenceNbr()));
.approvalUnit(event.getBizRelationData().getUnitName()) resumeInfoDto.setApprovalUnit(event.getBizRelationData().getUnitName());
.approvalUnitCode(event.getBizRelationData().getUnitCode()) resumeInfoDto.setApprovalUnitCode(event.getBizRelationData().getUnitCode());
.createUserName(event.getBizRelationData().getRecUserName()) resumeInfoDto.setRecDate(new Date());
.createUserId(event.getRequestContext().getExcutedUserId()) resumeInfoDto.setRecUserName(event.getBizRelationData().getRecUserName());
.status("正常") resumeInfoDto.setRecUserId(event.getRequestContext().getExcutedUserId());
.routePath(routePath) resumeInfoDto.setStatus("正常");
.build()); resumeInfoDto.setRoutePath(routePath);
jgResumeInfoService.createWithModel(resumeInfoDto);
} catch (Exception e){ } catch (Exception e){
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
......
...@@ -102,9 +102,13 @@ public class JgBizChangeLogServiceImpl extends BaseService<JgBizChangeLogDto, Jg ...@@ -102,9 +102,13 @@ public class JgBizChangeLogServiceImpl extends BaseService<JgBizChangeLogDto, Jg
if (!ValidationUtil.isEmpty(source.get("columnType")) && !"String".equals(source.get("columnType"))) { if (!ValidationUtil.isEmpty(source.get("columnType")) && !"String".equals(source.get("columnType"))) {
Object before = source.get("beforeData"); Object before = source.get("beforeData");
Object after = source.get("afterData"); Object after = source.get("afterData");
Object displayOldValue = source.get("displayOldValue");
Object displayNewValue = source.get("displayNewValue");
if (Objects.toString(before, "").trim().startsWith("[") && Objects.toString(after, "").trim().startsWith("[")) { if (Objects.toString(before, "").trim().startsWith("[") && Objects.toString(after, "").trim().startsWith("[")) {
source.put("beforeData", JSONObject.parseArray(Objects.toString(before, ""))); source.put("beforeData", JSONObject.parseArray(Objects.toString(before, "")));
source.put("afterData", JSONObject.parseArray(Objects.toString(after, ""))); source.put("afterData", JSONObject.parseArray(Objects.toString(after, "")));
source.put("displayOldValue", JSONObject.parseArray(Objects.toString(displayOldValue, "")));
source.put("displayNewValue", JSONObject.parseArray(Objects.toString(displayNewValue, "")));
} }
} }
list.add(source); list.add(source);
......
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