Commit 039a3022 authored by tianbo's avatar tianbo

feat(jg): 实现超设计使用年限业务流程优化

- 新增 OverDesignDataChangeHandler 和 OverDesignEditUpdateService 处理器处理单据查看设备履历功能 - 超设计使用年限变更通过后,修改设备状态为在用状态、证状态为已登记 - 调整使用登记证查询逻辑,按记录日期降序取最新一条数据
parent 48fd74f2
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.overDesign;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.biz.event.CommonPublisher;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.dto.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgOverDesignServiceLife;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* 设备停用启用编辑处理器
*/
@Component
public class OverDesignDataChangeHandler extends DefaultBizDataChangeHandler<BaseBizDataChangeEvent> {
private final OverDesignEditUpdateService overDesignEditUpdateService;
protected OverDesignDataChangeHandler(CommonPublisher routerEventPublisher, ApplicationContext applicationContext, OverDesignEditUpdateService overDesignEditUpdateService) {
super(routerEventPublisher, applicationContext);
this.overDesignEditUpdateService = overDesignEditUpdateService;
}
@Override
public String canHandleBizType() {
return BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.name();
}
@Override
public List<FieldChangeMeta> postSave(String bizId, String applyNo, ModelType model, Map<String, Object> changeData, List<FieldChangeMeta> allChangeColumns, Map<String, List<PipelineChangeItemDto>> pipelineChangeItemMap) {
return Collections.emptyList();
}
@Override
public Boolean beforeCheck(String bizId, String applyNo, ModelType model, Map<String, Object> changeData) {
return Boolean.TRUE;
}
@Override
public Set<String> getEqs(String applyNo) {
return overDesignEditUpdateService.getEqsByApplyNo(applyNo);
}
/**
* 管道专用-判断数据是实时落库,还是先存到json
*
* @param applyNo 单据号
* @return 是否需要临时存储
*/
@Override
public Boolean requiresTemporarySave(String applyNo) {
return false;
}
@Override
public Boolean bizIsFinished(String applyNo) {
JgOverDesignServiceLife overDesignServiceLife = overDesignEditUpdateService.getOverDesignServiceLifeService().getOne(new LambdaQueryWrapper<JgOverDesignServiceLife>().eq(JgOverDesignServiceLife::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr, JgOverDesignServiceLife::getStatus));
return overDesignServiceLife.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName());
}
@Override
public Set<String> getProjectContraptionIds(String applyNo) {
return new HashSet<>();
}
@Override
public void preSave(String bizId, String applyNo, ModelType model, Map<String, Object> changeData) {
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.overDesign;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
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.biz.service.impl.JgOverDesignServiceLifeEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgOverDesignServiceLifeServiceImpl;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Getter
public class OverDesignEditUpdateService {
private final JgOverDesignServiceLifeServiceImpl overDesignServiceLifeService;
private final JgOverDesignServiceLifeEqServiceImpl overDesignServiceLifeEqService;
public Set<String> getEqsByApplyNo(String applyNo) {
JgOverDesignServiceLife overDesignServiceLifeServiceOne = overDesignServiceLifeService.getOne(new LambdaQueryWrapper<JgOverDesignServiceLife>().eq(JgOverDesignServiceLife::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr));
List<JgOverDesignServiceLifeEq> eqs = overDesignServiceLifeEqService.list(new LambdaQueryWrapper<JgOverDesignServiceLifeEq>().eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLifeServiceOne.getSequenceNbr()).select(JgOverDesignServiceLifeEq::getEquId, BaseEntity::getSequenceNbr));
return eqs.stream().map(JgOverDesignServiceLifeEq::getEquId).collect(Collectors.toSet());
}
public JgOverDesignServiceLife getOneByApplyNo(String applyNo) {
return overDesignServiceLifeService.getOne(new LambdaQueryWrapper<JgOverDesignServiceLife>().eq(JgOverDesignServiceLife::getApplyNo, applyNo));
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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;
......@@ -20,13 +21,17 @@ 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.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.common.api.service.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
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;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgResumeInfoEqMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgOverDesignServiceLifeService;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
......@@ -35,12 +40,13 @@ import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
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.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.common.api.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.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.InspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.InspectionDetectionInfoMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
......@@ -74,6 +80,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.LocalDate;
import java.time.format.DateTimeFormatter;
......@@ -82,7 +89,6 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationNameServiceImpl.DB_BATCH_SIZE;
import static java.util.stream.Collectors.toList;
/**
......@@ -122,6 +128,9 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private final DataDictionaryServiceImpl dataDictionaryServiceImpl;
private final JgCertificateChangeRecordServiceImpl jgCertificateChangeRecordService;
private final JgCertificateChangeRecordEqServiceImpl jgCertificateChangeRecordEqService;
private final IdxBizJgUseInfoServiceImpl jgUseInfoService;
private final ESEquipmentCategory esEquipmentCategory;
private final EsEquipmentDao esEquipmentDao;
/**
* 分页查询
......@@ -635,10 +644,6 @@ 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("useOrgCode"), ""))
.distinct()
.collect(Collectors.toList());
List<String> records = equipmentLists.stream()
.map(v -> Objects.toString(v.get("record"), ""))
.collect(Collectors.toList());
......@@ -650,7 +655,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
// this.updateOrCreateInspectionDetection(equipmentLists);
this.sendOverDesignMessage(equipmentLists);
this.updateDesignInfo(taskV2Model, jgOverDesignServiceLife, equipmentLists, designInfoList);
this.updateRegistrationManage(useOrgCodes, jgOverDesignServiceLife, designInfoList, taskV2Model);
this.updateRegistrationManage(jgOverDesignServiceLife, records, taskV2Model);
}
private Date castDate2TimeStr(String date) {
......@@ -782,29 +787,28 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
}
}
private void updateRegistrationManage(List<String> useOrgCodes, JgOverDesignServiceLife jgOverDesignServiceLife, List<IdxBizJgDesignInfo> designInfoList, TaskV2Model taskV2Model) {
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
private void updateRegistrationManage(JgOverDesignServiceLife jgOverDesignServiceLife, List<String> equipRecords, TaskV2Model taskV2Model) {
JgUseRegistrationManage registrationManage = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, jgOverDesignServiceLife.getUseRegistrationCode())
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.list();
.orderByDesc(JgUseRegistrationManage::getRecDate)
.last("limit 1")
.one();
if (!CollectionUtils.isEmpty(registrationList)) {
registrationList.forEach(v -> {
v.setIsOverDesign("1");
v.setVersion(v.getVersion() + 1);
});
useRegistrationManageService.updateBatchById(registrationList);
}
if (!ValidationUtil.isEmpty(registrationManage)) {
registrationManage.setIsOverDesign("1");
registrationManage.setVersion(registrationManage.getVersion() + 1);
registrationManage.setAuditPassDate(new Date());
// 注销的证改为已登记
registrationManage.setCertificateStatus(CertificateStatusEnum.YIDENGJI.getName());
useRegistrationManageService.updateById(registrationManage);
FeignClientResult<AgencyUserModel> agencyUserResult = Privilege.agencyUserClient.queryByUserId(jgOverDesignServiceLife.getCreateUserId());
String realName = agencyUserResult.getResult().getRealName();
List<JgCertificateChangeRecord> certificateChangeRecords = new ArrayList<>();
List<JgCertificateChangeRecordEq> certificateChangeRecordEqs = new ArrayList<>();
Date now = new Date();
for (JgUseRegistrationManage v : registrationList) {
JgCertificateChangeRecord record = new JgCertificateChangeRecord();
record.setApplyNo(jgOverDesignServiceLife.getApplyNo());
record.setReceiveOrgName(jgOverDesignServiceLife.getReceiveOrgName());
......@@ -820,27 +824,36 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
record.setCreateDate(now);
record.setCreateUserId(jgOverDesignServiceLife.getCreateUserId());
record.setUseRegistrationCode(jgOverDesignServiceLife.getUseRegistrationCode());
record.setCertificateNo(v.getCertificateNo());
record.setCertificateNo(registrationManage.getCertificateNo());
record.setUseUnitCreditCode(jgOverDesignServiceLife.getUseUnitCreditCode());
record.setUseUnitName(jgOverDesignServiceLife.getUseUnitName());
record.setEquCategory(jgOverDesignServiceLife.getEquCategoryName());
record.setReceiveCompanyCode(jgOverDesignServiceLife.getReceiveOrgCode());
record.setRoutePath(taskV2Model.getRoutePath());
certificateChangeRecords.add(record);
}
jgCertificateChangeRecordService.save(record);
jgCertificateChangeRecordService.saveBatch(certificateChangeRecords);
for (JgCertificateChangeRecord record : certificateChangeRecords) {
List<JgCertificateChangeRecordEq> eqs = designInfoList.stream()
.map(p -> {
if (!ValidationUtil.isEmpty(equipRecords)) {
equipRecords.forEach(r -> {
JgCertificateChangeRecordEq eq = new JgCertificateChangeRecordEq();
eq.setEquId(p.getRecord());
eq.setEquId(r);
eq.setChangeRecordId(record.getSequenceNbr().toString());
return eq;
}).collect(toList());
certificateChangeRecordEqs.addAll(eqs);
}
certificateChangeRecordEqs.add(eq);
});
jgCertificateChangeRecordEqService.saveBatch(certificateChangeRecordEqs);
// 注销的设备状态改为在用
jgUseInfoService.update(new UpdateWrapper<IdxBizJgUseInfo>().lambda()
.in(IdxBizJgUseInfo::getRecord, equipRecords)
.set(IdxBizJgUseInfo::getEquState, String.valueOf(EquipmentEnum.ZAIYONG.getCode())));
// 更新es设备状态字段
Iterable<ESEquipmentCategoryDto> jgAllEsDtos = esEquipmentCategory.findAllById(equipRecords);
jgAllEsDtos.forEach(dto -> dto.setEQU_STATE(EquipmentEnum.ZAIYONG.getCode()));
esEquipmentCategory.saveAll(jgAllEsDtos);
Iterable<ESEquipmentInfo> newEsDtos = esEquipmentDao.findAllById(equipRecords);
newEsDtos.forEach(dto -> dto.setEQU_STATE(EquipmentEnum.ZAIYONG.getCode()));
esEquipmentDao.saveAll(newEsDtos);
}
}
}
private void buildTask(JgOverDesignServiceLife jgOverDesignServiceLife, WorkflowResultDto workflowResultDto) {
......@@ -974,7 +987,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
useRegistrationManageService.lambdaQuery()
.eq(JgUseRegistrationManage::getUseRegistrationCode, useOrgCode)
.eq(JgUseRegistrationManage::getIsDelete, 0)
.eq(JgUseRegistrationManage::getCertificateStatus, CertificateStatusEnum.YIDENGJI.getName())
.orderByDesc(JgUseRegistrationManage::getRecDate)
.last("limit 1")
.one();
if (registration == null) {
throw new BadRequest("未查询到使用登记信息");
......@@ -1132,7 +1146,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
Optional.ofNullable(dataDictionaryServiceImpl.getByCode(info.getInspectConclusion(), "JYJL"))
.map(DataDictionary::getName)
.orElse(""));
result.put("inspectReport", Optional.ofNullable(info.getInspectReport()).orElse("{}"));
result.put("inspectReport", Optional.ofNullable(info.getInspectReport()).orElse("[]"));
result.put("jySeq", info.getSequenceNbr());
if (overDesignServiceLifeEq != null) {
result.put("safetyAssessmentName", overDesignServiceLifeEq.getSafetyAssessmentName());
......
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