Commit ae80aae0 authored by suhuiguang's avatar suhuiguang

fix(设备创建) :es双写优化

1.写es移动到最后执行
parent 5ba6d6ed
...@@ -639,6 +639,9 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -639,6 +639,9 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
taskModelDto.setModel(conveterTaskMessageDTO(jgChangeRegistrationReform)); taskModelDto.setModel(conveterTaskMessageDTO(jgChangeRegistrationReform));
commonServiceImpl.buildTaskModel(Collections.singletonList(taskModelDto)); commonServiceImpl.buildTaskModel(Collections.singletonList(taskModelDto));
} }
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationReform));
this.getBaseMapper().updateById(jgChangeRegistrationReform);
} else { } else {
jgChangeRegistrationReform.setAuditPassDate(new Date()); jgChangeRegistrationReform.setAuditPassDate(new Date());
jgChangeRegistrationReform.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName()); jgChangeRegistrationReform.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
...@@ -672,11 +675,24 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -672,11 +675,24 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
// 创建设备履历 // 创建设备履历
this.createResume(jgChangeRegistrationReform, taskV2Model.getRoutePath()); this.createResume(jgChangeRegistrationReform, taskV2Model.getRoutePath());
} }
this.sendDataRefreshMsg(jgChangeRegistrationReform);
}
// redis流程实时数据更新 // redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationReform)); commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationReform));
this.getBaseMapper().updateById(jgChangeRegistrationReform); this.getBaseMapper().updateById(jgChangeRegistrationReform);
// 清除施工单位信息
this.clearUscInfoEs(jgChangeRegistrationReform);
this.sendDataRefreshMsg(jgChangeRegistrationReform);
}
}
private void clearUscInfoEs(JgChangeRegistrationReform reform) {
// es
List<JgChangeRegistrationReformEq> reformEqs = jgChangeRegistrationReformEqMapper.selectList(new LambdaQueryWrapper<JgChangeRegistrationReformEq>().eq(JgChangeRegistrationReformEq::getEquipTransferId, reform.getSequenceNbr()));
Iterable<ESEquipmentCategoryDto> esEquipmentCategoryDtos = esEquipmentCategory.findAllById(reformEqs.stream().map(JgChangeRegistrationReformEq::getEquId).collect(Collectors.toList()));
esEquipmentCategoryDtos.forEach(esEquipmentCategoryDto -> {
esEquipmentCategoryDto.setUSC_UNIT_NAME(null);
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(null);
});
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
} }
/** /**
...@@ -747,17 +763,6 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -747,17 +763,6 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
.set(IdxBizJgProjectContraption::getUscUnitCreditCode, null) .set(IdxBizJgProjectContraption::getUscUnitCreditCode, null)
.set(IdxBizJgProjectContraption::getUscUnitName, null) .set(IdxBizJgProjectContraption::getUscUnitName, null)
.update(); .update();
// es
List<JgChangeRegistrationReformEq> reformEqs = jgChangeRegistrationReformEqMapper.selectList(new LambdaQueryWrapper<JgChangeRegistrationReformEq>().eq(JgChangeRegistrationReformEq::getEquipTransferId, reform.getSequenceNbr()));
reformEqs.forEach(reformEq -> {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(reformEq.getEquId());
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setUSC_UNIT_NAME(null);
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(null);
esEquipmentCategory.save(esEquipmentCategoryDto);
}
});
} }
private void clearUscWInfo(JgChangeRegistrationReform reform) { private void clearUscWInfo(JgChangeRegistrationReform reform) {
...@@ -769,14 +774,6 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -769,14 +774,6 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
updateWrapper.set(IdxBizJgUseInfo::getUSC_UNIT_CREDIT_CODE, null); updateWrapper.set(IdxBizJgUseInfo::getUSC_UNIT_CREDIT_CODE, null);
updateWrapper.set(IdxBizJgUseInfo::getUSC_UNIT_NAME, null); updateWrapper.set(IdxBizJgUseInfo::getUSC_UNIT_NAME, null);
idxBizJgUseInfoService.update(updateWrapper); idxBizJgUseInfoService.update(updateWrapper);
// es清空
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(reformEq.getEquId());
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setUSC_UNIT_NAME(null);
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(null);
esEquipmentCategory.save(esEquipmentCategoryDto);
}
}); });
} }
......
...@@ -18,6 +18,8 @@ import com.yeejoin.amos.boot.biz.common.enums.TcmUnitTypeEnum; ...@@ -18,6 +18,8 @@ import com.yeejoin.amos.boot.biz.common.enums.TcmUnitTypeEnum;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; 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.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil; 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.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.enums.ReginStepEnum; import com.yeejoin.amos.boot.module.common.api.enums.ReginStepEnum;
import com.yeejoin.amos.boot.module.common.api.service.ICompensateFlowDataOfRedis; import com.yeejoin.amos.boot.module.common.api.service.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent; import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
...@@ -51,6 +53,7 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO; ...@@ -51,6 +53,7 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO; import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import io.seata.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
...@@ -83,6 +86,7 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistration ...@@ -83,6 +86,7 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistration
* @date 2023-12-20 * @date 2023-12-20
*/ */
@Service @Service
@Slf4j
public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChangeRegistrationTransferDto, JgChangeRegistrationTransfer, JgChangeRegistrationTransferMapper> implements IJgChangeRegistrationTransferService, ICompensateFlowDataOfRedis<JgChangeRegistrationTransfer> { public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChangeRegistrationTransferDto, JgChangeRegistrationTransfer, JgChangeRegistrationTransferMapper> implements IJgChangeRegistrationTransferService, ICompensateFlowDataOfRedis<JgChangeRegistrationTransfer> {
private static final String PROCESS_DEFINITION_KEY = "changeRegistrationTransfer"; private static final String PROCESS_DEFINITION_KEY = "changeRegistrationTransfer";
private static final String TABLE_PAGE_ID = "changeRegistrationTransfer"; private static final String TABLE_PAGE_ID = "changeRegistrationTransfer";
...@@ -152,7 +156,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -152,7 +156,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
JgResumeInfoServiceImpl jgResumeInfoService; JgResumeInfoServiceImpl jgResumeInfoService;
@Autowired @Autowired
private CommonMapper commonMapper; private ESEquipmentCategory esEquipmentCategory;
/** /**
* 新增移装变更登记 * 新增移装变更登记
...@@ -527,9 +531,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -527,9 +531,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
//执行流程 //执行流程
ProcessTaskDTO complete = icmWorkflowService.completeOrReject(taskId, dto, operate); ProcessTaskDTO complete = icmWorkflowService.completeOrReject(taskId, dto, operate);
workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(complete)).get(0); workflowResult = commonService.buildWorkFlowInfo(Collections.singletonList(complete)).get(0);
delRepeatUseEquipData(transfer);
// 更新下一步执行人 // 更新下一步执行人
this.updateExecuteIds(instanceId, transfer, operate, workflowResult); this.updateExecuteIds(instanceId, transfer, operate, workflowResult);
delRepeatUseEquipData(transfer);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
...@@ -730,11 +734,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -730,11 +734,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
private void repeatUsedEquipCheck(List<Long> equipList, String companyCode) {
equipList.forEach(equipMap -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
.registrationRepeatUsedCheck(String.valueOf(equipMap), companyCode));
}
/** /**
* 删除 redis校验重复引用设备的数据 * 删除 redis校验重复引用设备的数据
*/ */
...@@ -752,6 +751,11 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -752,6 +751,11 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
} }
private void repeatUsedEquipCheck(List<Long> equipList, String companyCode) {
equipList.forEach(equipMap -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
.registrationRepeatUsedCheck(String.valueOf(equipMap), companyCode));
}
private void rollBackForDelRedisData() { private void rollBackForDelRedisData() {
FlowingEquipRedisContext.getContext().forEach( FlowingEquipRedisContext.getContext().forEach(
e -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY) e -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
...@@ -851,6 +855,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -851,6 +855,9 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
commonService.buildTaskModel(Collections.singletonList(taskModelDto)); commonService.buildTaskModel(Collections.singletonList(taskModelDto));
} }
} }
// redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationTransfer));
this.getBaseMapper().updateById(jgChangeRegistrationTransfer);
} else { } else {
jgChangeRegistrationTransfer.setAuditPassDate(new Date()); jgChangeRegistrationTransfer.setAuditPassDate(new Date());
jgChangeRegistrationTransfer.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName()); jgChangeRegistrationTransfer.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
...@@ -862,7 +869,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -862,7 +869,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
JgRegistrationHistory historyData = jgRegistrationHistoryMapper.selectOne(new LambdaQueryWrapper<JgRegistrationHistory>() JgRegistrationHistory historyData = jgRegistrationHistoryMapper.selectOne(new LambdaQueryWrapper<JgRegistrationHistory>()
.eq(JgRegistrationHistory::getCurrentDocumentId, jgChangeRegistrationTransfer.getApplyNo()) .eq(JgRegistrationHistory::getCurrentDocumentId, jgChangeRegistrationTransfer.getApplyNo())
.eq(JgRegistrationHistory::getIsDelete, false)); .eq(JgRegistrationHistory::getIsDelete, false));
this.updateByFlowEnd(jgChangeRegistrationTransfer.getSequenceNbr().toString(), historyData); List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = this.updateByFlowEnd(jgChangeRegistrationTransfer.getSequenceNbr().toString(), historyData);
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
...@@ -877,10 +884,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -877,10 +884,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
this.sendDataRefreshMsg(jgChangeRegistrationTransfer); this.sendDataRefreshMsg(jgChangeRegistrationTransfer);
// 创建设备履历 // 创建设备履历
this.createResume( jgChangeRegistrationTransfer, taskV2Model.getRoutePath()); this.createResume( jgChangeRegistrationTransfer, taskV2Model.getRoutePath());
}
// redis流程实时数据更新 // redis流程实时数据更新
commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationTransfer)); commonServiceImpl.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgChangeRegistrationTransfer));
this.getBaseMapper().updateById(jgChangeRegistrationTransfer); this.getBaseMapper().updateById(jgChangeRegistrationTransfer);
if(!esEquipmentCategoryDtos.isEmpty()){
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
}
} }
private void createResume(JgChangeRegistrationTransfer jgChangeRegistrationTransfer, String routePath) { private void createResume(JgChangeRegistrationTransfer jgChangeRegistrationTransfer, String routePath) {
...@@ -1019,14 +1029,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1019,14 +1029,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* *
* @param sequenceNbr 移装变更单Id * @param sequenceNbr 移装变更单Id
*/ */
public void updateByFlowEnd(String sequenceNbr, JgRegistrationHistory historyData) { public List<ESEquipmentCategoryDto> updateByFlowEnd(String sequenceNbr, JgRegistrationHistory historyData) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
JgChangeRegistrationTransfer transfer = this.getBaseMapper().selectById(sequenceNbr); JgChangeRegistrationTransfer transfer = this.getBaseMapper().selectById(sequenceNbr);
LambdaQueryWrapper<JgChangeRegistrationTransferEq> lambda = new QueryWrapper<JgChangeRegistrationTransferEq>().lambda(); LambdaQueryWrapper<JgChangeRegistrationTransferEq> lambda = new QueryWrapper<JgChangeRegistrationTransferEq>().lambda();
lambda.eq(JgChangeRegistrationTransferEq::getEquipTransferId, sequenceNbr); lambda.eq(JgChangeRegistrationTransferEq::getEquipTransferId, sequenceNbr);
List<JgChangeRegistrationTransferEq> transferEqList = jgChangeRegistrationTransferEqService.getBaseMapper().selectList(lambda); List<JgChangeRegistrationTransferEq> transferEqList = jgChangeRegistrationTransferEqService.getBaseMapper().selectList(lambda);
List<String> useRegistrationCodeList = new ArrayList<>(Collections.emptyList()); List<String> useRegistrationCodeList = new ArrayList<>(Collections.emptyList());
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
if (!CollectionUtils.isEmpty(transferEqList)) { if (!CollectionUtils.isEmpty(transferEqList)) {
AtomicReference<String> useRegistrationCode = new AtomicReference<>(""); AtomicReference<String> useRegistrationCode = new AtomicReference<>("");
AtomicBoolean isUpdateRegistrationCode = new AtomicBoolean(false); AtomicBoolean isUpdateRegistrationCode = new AtomicBoolean(false);
...@@ -1067,7 +1077,8 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1067,7 +1077,8 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
//替换历史数据表和设备使用表 //替换历史数据表和设备使用表
this.replacementHistoryData(device.getEquId(), transfer, historyData, supervisoryCode, code96333); this.replacementHistoryData(device.getEquId(), transfer, historyData, supervisoryCode, code96333);
//更新使用注册登记证编号及ES中的信息 //更新使用注册登记证编号及ES中的信息
this.updateRegisterInfoAndEsData(device.getEquId(), historyData, useRegistrationCode.get(), supervisoryCode, code96333, isUpdateRegistrationCode); ESEquipmentCategoryDto equipmentCategoryDto = this.updateRegisterInfoAndEsData(device.getEquId(), historyData, useRegistrationCode.get(), supervisoryCode, code96333, isUpdateRegistrationCode);
esEquipmentCategoryDtos.add(equipmentCategoryDto);
//修改各类告知列表,置为废弃 //修改各类告知列表,置为废弃
this.updateInvalidStatusByHistory(device.getEquId(), device.getEquipTransferId()); this.updateInvalidStatusByHistory(device.getEquId(), device.getEquipTransferId());
//修改证管理表数据 //修改证管理表数据
...@@ -1085,6 +1096,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1085,6 +1096,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
transfer.setRegPersonName(reginParams.getUserModel().getUserName()); transfer.setRegPersonName(reginParams.getUserModel().getUserName());
transfer.setUseRegistrationCode(String.join(",", useRegistrationCodeList)); transfer.setUseRegistrationCode(String.join(",", useRegistrationCodeList));
this.updateTransferByBaseInfo(transfer); this.updateTransferByBaseInfo(transfer);
return esEquipmentCategoryDtos;
} }
private void updateUseRegistrationManage(JgChangeRegistrationTransferEq device, JgChangeRegistrationTransfer transfer, JgRegistrationHistory historyData, String useRegistrationCode, boolean isUpdateRegistrationCode) { private void updateUseRegistrationManage(JgChangeRegistrationTransferEq device, JgChangeRegistrationTransfer transfer, JgRegistrationHistory historyData, String useRegistrationCode, boolean isUpdateRegistrationCode) {
...@@ -1334,7 +1346,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1334,7 +1346,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* @param useRegistrationCode 使用注册登记证编号 * @param useRegistrationCode 使用注册登记证编号
* @param isUpdateRegistrationCode 是否更新使用登记证编号 * @param isUpdateRegistrationCode 是否更新使用登记证编号
*/ */
public void updateRegisterInfoAndEsData(String equId, JgRegistrationHistory newData, String useRegistrationCode, public ESEquipmentCategoryDto updateRegisterInfoAndEsData(String equId, JgRegistrationHistory newData, String useRegistrationCode,
String supervisoryCode, String code96333, AtomicBoolean isUpdateRegistrationCode) { String supervisoryCode, String code96333, AtomicBoolean isUpdateRegistrationCode) {
//更新使用注册登记证编号 //更新使用注册登记证编号
if (isUpdateRegistrationCode.get()) { if (isUpdateRegistrationCode.get()) {
...@@ -1418,8 +1430,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1418,8 +1430,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
map1.put("CODE96333", code96333); map1.put("CODE96333", code96333);
} }
resultMap.put(equId, map1); Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(equId);
tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap); if(optional.isPresent()){
ESEquipmentCategoryDto categoryDto = optional.get();
BeanUtil.copyProperties(map1, categoryDto, true);
return categoryDto;
}
log.error("办理业务的设备: {},在es中不存在", equId);
throw new BadRequest("设备数据不存在");
} }
//更新移装变更基本信息 //更新移装变更基本信息
......
...@@ -53,6 +53,7 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper; ...@@ -53,6 +53,7 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.Workflow; import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.*; import com.yeejoin.amos.feign.workflow.model.*;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -82,6 +83,7 @@ import static java.util.stream.Collectors.toSet; ...@@ -82,6 +83,7 @@ import static java.util.stream.Collectors.toSet;
* @date 2023-12-25 * @date 2023-12-25
*/ */
@Service @Service
@Slf4j
public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, JgEnableDisable, JgEnableDisableMapper> implements IJgEnableDisableService, ICompensateFlowDataOfRedis<JgEnableDisable> { public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, JgEnableDisable, JgEnableDisableMapper> implements IJgEnableDisableService, ICompensateFlowDataOfRedis<JgEnableDisable> {
...@@ -587,7 +589,7 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -587,7 +589,7 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
// 执行工作流并返回组装好的工作流信息 // 执行工作流并返回组装好的工作流信息
WorkflowResultDto workflowResultDto = getWorkflowResultDto(operate, comment, jgEnableDisable); WorkflowResultDto workflowResultDto = getWorkflowResultDto(operate, comment, jgEnableDisable);
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
jgEnableDisable.setPromoter(reginParams.getUserModel().getUserId()); jgEnableDisable.setPromoter(reginParams.getUserModel().getUserId());
TaskV2Model taskV2Model = new TaskV2Model(); TaskV2Model taskV2Model = new TaskV2Model();
if ("0".equals(operate)) { if ("0".equals(operate)) {
...@@ -606,7 +608,7 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -606,7 +608,7 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
BeanUtils.copyProperties(jgEnableDisable, taskMessageDto); BeanUtils.copyProperties(jgEnableDisable, taskMessageDto);
taskMap.put("model", jgEnableDisable); taskMap.put("model", jgEnableDisable);
// 更新业务数据 // 更新业务数据
updateInfoOther(jgEnableDisable); esEquipmentCategoryDtos = updateInfoOther(jgEnableDisable);
// 保存json历史数据 // 保存json历史数据
commonService.saveOrUpdateHistory(this.getRegistrationClass(jgEnableDisable), map, null, jgEnableDisable.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(this.getRegistrationClass(jgEnableDisable), map, null, jgEnableDisable.getSequenceNbr().toString());
TaskV2Model taskV2Model1 = commonService.updateTaskModel(taskMap); TaskV2Model taskV2Model1 = commonService.updateTaskModel(taskMap);
...@@ -679,6 +681,9 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -679,6 +681,9 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
// redis流程实时数据更新 // redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgEnableDisable)); commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgEnableDisable));
this.delRepeatUseEquipData(jgEnableDisable); this.delRepeatUseEquipData(jgEnableDisable);
if(!esEquipmentCategoryDtos.isEmpty()){
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
...@@ -731,7 +736,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -731,7 +736,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
eventPublisher.publish(new DataRefreshEvent(this, records, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE)); eventPublisher.publish(new DataRefreshEvent(this, records, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE));
} }
private void updateInfoOther(JgEnableDisable jgEnableDisable) { private List<ESEquipmentCategoryDto> updateInfoOther(JgEnableDisable jgEnableDisable) {
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
// 1.更新设备的使用信息:启用->停用,停用->启用 // 1.更新设备的使用信息:启用->停用,停用->启用
LambdaQueryWrapper<JgEnableDisableEq> lambdaEq = new QueryWrapper<JgEnableDisableEq>().lambda(); LambdaQueryWrapper<JgEnableDisableEq> lambdaEq = new QueryWrapper<JgEnableDisableEq>().lambda();
lambdaEq.eq(JgEnableDisableEq::getEnableDisableApplyId, jgEnableDisable.getSequenceNbr()); lambdaEq.eq(JgEnableDisableEq::getEnableDisableApplyId, jgEnableDisable.getSequenceNbr());
...@@ -749,7 +755,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -749,7 +755,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
wrapper.eq(IdxBizJgUseInfo::getRecord, jgEnableDisableEq.getEquId()); wrapper.eq(IdxBizJgUseInfo::getRecord, jgEnableDisableEq.getEquId());
idxBizJgUseInfoMapper.update(idxBizJgUseInfo, wrapper); idxBizJgUseInfoMapper.update(idxBizJgUseInfo, wrapper);
// 2.更新设备的es数据的状态:启用->停用,停用->启用 // 2.更新设备的es数据的状态:启用->停用,停用->启用
updateEquipEsData(jgEnableDisableEq, idxBizJgUseInfo); ESEquipmentCategoryDto equipmentCategoryDto = updateEquipEsData(jgEnableDisableEq, idxBizJgUseInfo);
esEquipmentCategoryDtos.add(equipmentCategoryDto);
}); });
String useRegistrationCodeStr = jgEnableDisable.getUseRegistrationCode(); String useRegistrationCodeStr = jgEnableDisable.getUseRegistrationCode();
List<String> useRegistrationCodeList = Optional.ofNullable(useRegistrationCodeStr) List<String> useRegistrationCodeList = Optional.ofNullable(useRegistrationCodeStr)
...@@ -765,18 +772,19 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto, ...@@ -765,18 +772,19 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
.in(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCodeList) .in(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCodeList)
.update(); .update();
} }
return esEquipmentCategoryDtos;
} }
private void updateEquipEsData(JgEnableDisableEq jgScrapCancelEq, IdxBizJgUseInfo idxBizJgUseInfo) { private ESEquipmentCategoryDto updateEquipEsData(JgEnableDisableEq jgScrapCancelEq, IdxBizJgUseInfo idxBizJgUseInfo) {
Map<String, Map<String, Object>> resultMap = new HashMap<>(); Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(jgScrapCancelEq.getEquId());
Map<String, Object> map1 = new HashMap<>(); if(optional.isPresent()){
map1.put("EQU_STATE", idxBizJgUseInfo.getEquState()); ESEquipmentCategoryDto dto = optional.get();
resultMap.put(jgScrapCancelEq.getEquId(), map1); dto.setEQU_STATE(Integer.parseInt(idxBizJgUseInfo.getEquState()));
try { return dto;
tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap);
} catch (Exception e) {
log.error("更新es失败", e.getCause());
} }
log.error("办理使用登记的设备{},在es中不存在", jgScrapCancelEq.getEquId());
throw new BadRequest("设备数据不存在");
} }
......
...@@ -73,6 +73,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -73,6 +73,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
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;
import java.util.stream.StreamSupport;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
...@@ -1032,11 +1033,13 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -1032,11 +1033,13 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
// 执行流程 // 执行流程
ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate); ProcessTaskDTO processTaskDTO = cmWorkflowService.completeOrReject(taskId, dto, operate);
// 更新下一步执行人、创建待办 // 更新下一步执行人、创建待办
updateExecuteIds(equList, instanceId, id, operate, processTaskDTO); List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = updateExecuteIds(equList, instanceId, id, operate, processTaskDTO);
// redis流程实时数据更新 // redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgScrapCancel)); commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgScrapCancel));
this.delRepeatUseEquipData(jgScrapCancel); this.delRepeatUseEquipData(jgScrapCancel);
if(!esEquipmentCategoryDtos.isEmpty()){
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} catch (BadRequest e) { } catch (BadRequest e) {
...@@ -1058,7 +1061,8 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -1058,7 +1061,8 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
.build(); .build();
} }
public void updateExecuteIds(String equList, String instanceId, Long sequenceNbr, String operate, ProcessTaskDTO processTaskDTO) { public List<ESEquipmentCategoryDto> updateExecuteIds(String equList, String instanceId, Long sequenceNbr, String operate, ProcessTaskDTO processTaskDTO) {
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
List<String> roleListNext = new ArrayList<>(); List<String> roleListNext = new ArrayList<>();
List<String> roleListAll = new ArrayList<>(); List<String> roleListAll = new ArrayList<>();
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName(); String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
...@@ -1107,13 +1111,28 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -1107,13 +1111,28 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
// 更新代办 // 更新代办
TaskV2Model taskV2Model = updateTaskModel(scrapCancelDto, operate); TaskV2Model taskV2Model = updateTaskModel(scrapCancelDto, operate);
// 修改业务信息 // 修改业务信息
updateInfoOther(jgScrapCancel, taskV2Model.getRoutePath()); List<String> records = updateInfoOther(jgScrapCancel, taskV2Model.getRoutePath());
esEquipmentCategoryDtos = this.buildEsData(records, jgScrapCancel);
// 发送数据变更消息 // 发送数据变更消息
this.sendDataRefreshMsg(jgScrapCancel); this.sendDataRefreshMsg(jgScrapCancel);
// 创建设备履历 // 创建设备履历
this.createResume(jgScrapCancel, taskV2Model.getRoutePath()); this.createResume(jgScrapCancel, taskV2Model.getRoutePath());
} }
this.getBaseMapper().updateById(jgScrapCancel); this.getBaseMapper().updateById(jgScrapCancel);
return esEquipmentCategoryDtos;
}
private List<ESEquipmentCategoryDto> buildEsData(List<String> records, JgScrapCancel jgScrapCancel) {
Iterable<ESEquipmentCategoryDto> equipmentCategoryDtos = esEquipmentCategory.findAllById(records);
Integer equState;
if (CancelTypeEnum.SCRAPPED.getCode().equals(jgScrapCancel.getCancelType())) {
equState = EquipmentEnum.BAOFEI.getCode();
} else {
equState = EquipmentEnum.ZHUXIAO.getCode();
}
Integer finalEquState = equState;
equipmentCategoryDtos.forEach(e-> e.setEQU_STATE(finalEquState));
return StreamSupport.stream(equipmentCategoryDtos.spliterator(), false).collect(Collectors.toList());
} }
private void createResume(JgScrapCancel jgScrapCancel, String routePath) { private void createResume(JgScrapCancel jgScrapCancel, String routePath) {
...@@ -1142,7 +1161,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -1142,7 +1161,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
eventPublisher.publish(new DataRefreshEvent(this, records, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE)); eventPublisher.publish(new DataRefreshEvent(this, records, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE));
} }
private void updateInfoOther(JgScrapCancel jgScrapCancel, String routePath) { private List<String> updateInfoOther(JgScrapCancel jgScrapCancel, String routePath) {
LambdaQueryWrapper<JgScrapCancelEq> lambdaEq = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JgScrapCancelEq> lambdaEq = new LambdaQueryWrapper<>();
lambdaEq.eq(JgScrapCancelEq::getEquipTransferId, jgScrapCancel.getSequenceNbr()); lambdaEq.eq(JgScrapCancelEq::getEquipTransferId, jgScrapCancel.getSequenceNbr());
lambdaEq.select(JgScrapCancelEq::getEquId, JgScrapCancelEq::getUseRegistrationCode); lambdaEq.select(JgScrapCancelEq::getEquId, JgScrapCancelEq::getUseRegistrationCode);
...@@ -1233,6 +1252,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -1233,6 +1252,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
} }
jgScrapCancel.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName()); jgScrapCancel.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgScrapCancel.setAuditPassDate(new Date()); jgScrapCancel.setAuditPassDate(new Date());
return equipIds;
} }
private void updateProjectContraption(String projectContraptionId) { private void updateProjectContraption(String projectContraptionId) {
......
...@@ -1240,6 +1240,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1240,6 +1240,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
buildTask(jgUseRegistration, workflowResultDto); buildTask(jgUseRegistration, workflowResultDto);
} }
} }
this.getBaseMapper().updateById(jgUseRegistration);
commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration));
} else { } else {
// 流程结束 // 流程结束
jgUseRegistration.setStatus(taskCode); jgUseRegistration.setStatus(taskCode);
...@@ -1334,6 +1336,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1334,6 +1336,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
List<String> records = new ArrayList<>(); List<String> records = new ArrayList<>();
List<JgResumeInfoDto> resumeList = new ArrayList<>(); List<JgResumeInfoDto> resumeList = new ArrayList<>();
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
if (!CollectionUtils.isEmpty(equipmentLists)) { if (!CollectionUtils.isEmpty(equipmentLists)) {
// 装置更新管道的技术参数、设计信息、安装信息 // 装置更新管道的技术参数、设计信息、安装信息
if (jgProjectContraption != null) { if (jgProjectContraption != null) {
...@@ -1365,7 +1368,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1365,7 +1368,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
} }
// 批量收集的结果 // 批量收集的结果
HashMap<String, Map<String, Object>> allEsData = new HashMap<>();
List<JgCertificateChangeRecordEq> jgCertificateChangeRecordEqBatchList = new ArrayList<>(); List<JgCertificateChangeRecordEq> jgCertificateChangeRecordEqBatchList = new ArrayList<>();
for (int i = 0; i < equipmentLists.size(); i++) { for (int i = 0; i < equipmentLists.size(); i++) {
Map<String, Object> equipment = equipmentLists.get(i); Map<String, Object> equipment = equipmentLists.get(i);
...@@ -1391,9 +1393,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1391,9 +1393,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// equipment.put("inspectOrgName", mapData.getOrDefault("inspectOrgName", "")); // equipment.put("inspectOrgName", mapData.getOrDefault("inspectOrgName", ""));
// equipment.put("inspectConclusion", inspectConclusionName); // equipment.put("inspectConclusion", inspectConclusionName);
// 更新设备信息 && 生成使用登记证编号 && 同步es // 更新设备信息 && 生成使用登记证编号 && 同步es
HashMap<String, Map<String, Object>> esDataMap = this.processMapData(sequenceNbr, mapData, jgUseRegistration, jgRegistrationHistory, registerInfo, otherInfo, taskV2Model, ESEquipmentCategoryDto esData = this.processMapData(sequenceNbr, mapData, jgUseRegistration, jgRegistrationHistory, registerInfo, otherInfo, taskV2Model,
jsonObject, flag.get(), useRegistrationCode, equipment, isMerge); jsonObject, flag.get(), useRegistrationCode, equipment, isMerge);
allEsData.putAll(esDataMap); esEquipmentCategoryDtos.add(esData);
// 查询设备制造信息 // 查询设备制造信息
LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>();
factoryInfoWrapper.eq(IdxBizJgFactoryInfo::getRecord, equId); factoryInfoWrapper.eq(IdxBizJgFactoryInfo::getRecord, equId);
...@@ -1406,10 +1408,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1406,10 +1408,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
changeRecordEq.setProductCode(idxBizJgFactoryInfo.getFactoryNum());//产品编号 changeRecordEq.setProductCode(idxBizJgFactoryInfo.getFactoryNum());//产品编号
jgCertificateChangeRecordEqBatchList.add(changeRecordEq); jgCertificateChangeRecordEqBatchList.add(changeRecordEq);
} }
// 循环结束后,统一批量更新ES
if (!allEsData.isEmpty()) {
tzsServiceFeignClient.commonUpdateEsDataByIds(allEsData);
}
if (!jgCertificateChangeRecordEqBatchList.isEmpty()){ if (!jgCertificateChangeRecordEqBatchList.isEmpty()){
jgCertificateChangeRecordEqMapper.insertBatchSomeColumn(jgCertificateChangeRecordEqBatchList,BATCH_SIZE); jgCertificateChangeRecordEqMapper.insertBatchSomeColumn(jgCertificateChangeRecordEqBatchList,BATCH_SIZE);
} }
...@@ -1440,10 +1438,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1440,10 +1438,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 更新历史表:下次检验日期、检验机构名称、检验结论在压力管道、气瓶时更新子表单的数据 // 更新历史表:下次检验日期、检验机构名称、检验结论在压力管道、气瓶时更新子表单的数据
jgRegistrationHistory.setChangeData(JSON.toJSONString(mapData)); jgRegistrationHistory.setChangeData(JSON.toJSONString(mapData));
jgRegistrationHistoryService.updateById(jgRegistrationHistory); jgRegistrationHistoryService.updateById(jgRegistrationHistory);
this.publish2CalGrade(jgUseRegistration, records);
}
this.getBaseMapper().updateById(jgUseRegistration); this.getBaseMapper().updateById(jgUseRegistration);
this.publish2CalGrade(jgUseRegistration, records);
commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration)); commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration));
// 循环结束后,统一批量更新ES
if (!esEquipmentCategoryDtos.isEmpty()) {
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
}
} }
/** /**
...@@ -1823,6 +1825,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1823,6 +1825,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
buildTask(jgUseRegistration, workflowResultDto); buildTask(jgUseRegistration, workflowResultDto);
} }
} }
this.getBaseMapper().updateById(jgUseRegistration);
commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration));
} else { } else {
//如果是特殊的历史设备需要更新安装信息和维保信息 //如果是特殊的历史设备需要更新安装信息和维保信息
String dataSource = jsonObject.getString("DATA_SOURCE"); String dataSource = jsonObject.getString("DATA_SOURCE");
...@@ -1859,10 +1863,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1859,10 +1863,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 更新代办 // 更新代办
TaskV2Model taskV2Model = updateAgency(jgUseRegistration); TaskV2Model taskV2Model = updateAgency(jgUseRegistration);
HashMap<String, Map<String, Object>> esDataMap = processMapData(sequenceNbr, mapData, jgUseRegistration, jgRegistrationHistory, registerInfo, otherInfo, taskV2Model,
jsonObject, Boolean.FALSE, null, mapData, Boolean.FALSE);
tzsServiceFeignClient.commonUpdateEsDataByIds(esDataMap);
Optional.ofNullable(registerInfo).ifPresent(info -> { Optional.ofNullable(registerInfo).ifPresent(info -> {
// 生成证书管理表记录 // 生成证书管理表记录
generateRegistrationManage(jgUseRegistration, registerInfo, Boolean.FALSE, null); generateRegistrationManage(jgUseRegistration, registerInfo, Boolean.FALSE, null);
...@@ -1881,10 +1881,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1881,10 +1881,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
certificateChangeRecordEqService.save(changeRecordEq); certificateChangeRecordEqService.save(changeRecordEq);
this.createResume(jgUseRegistration, registerInfo.getRecord(), taskV2Model.getRoutePath()); this.createResume(jgUseRegistration, registerInfo.getRecord(), taskV2Model.getRoutePath());
}); });
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_USAGE_REGISTRATION.name(), Sets.newHashSet(registerInfo.getRecord()), EquipCreateOrEditEvent.EquipType.equip));
}
this.getBaseMapper().updateById(jgUseRegistration); this.getBaseMapper().updateById(jgUseRegistration);
commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration)); commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration));
// 更新es
ESEquipmentCategoryDto esData = processMapData(sequenceNbr, mapData, jgUseRegistration, jgRegistrationHistory, registerInfo, otherInfo, taskV2Model, jsonObject, Boolean.FALSE, null, mapData, Boolean.FALSE);
esEquipmentCategory.save(esData);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_USAGE_REGISTRATION.name(), Sets.newHashSet(registerInfo.getRecord()), EquipCreateOrEditEvent.EquipType.equip));
}
return jgUseRegistration; return jgUseRegistration;
} }
...@@ -1902,7 +1905,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1902,7 +1905,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.build()); .build());
} }
private HashMap<String, Map<String, Object>> processMapData(Long sequenceNbr, JSONObject mapData, JgUseRegistration jgUseRegistration, private ESEquipmentCategoryDto processMapData(Long sequenceNbr, JSONObject mapData, JgUseRegistration jgUseRegistration,
JgRegistrationHistory jgRegistrationHistory, IdxBizJgRegisterInfo registerInfo, IdxBizJgOtherInfo otherInfo, JgRegistrationHistory jgRegistrationHistory, IdxBizJgRegisterInfo registerInfo, IdxBizJgOtherInfo otherInfo,
TaskV2Model taskV2Model, JSONObject jsonObject, Boolean flag, String useRegistrationCode, TaskV2Model taskV2Model, JSONObject jsonObject, Boolean flag, String useRegistrationCode,
Map<String, Object> equipment, boolean isMerge) { Map<String, Object> equipment, boolean isMerge) {
...@@ -2051,8 +2054,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2051,8 +2054,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return codeUtil.generateEquipmentCode(codeGenerateDto); return codeUtil.generateEquipmentCode(codeGenerateDto);
} }
public HashMap<String, Map<String, Object>> updateEsData(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo, IdxBizJgUseInfo useInfo, public ESEquipmentCategoryDto updateEsData(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo, IdxBizJgUseInfo useInfo,
JgUseRegistration jgUseRegistration, JSONObject jsonObject) { JgUseRegistration jgUseRegistration, JSONObject jsonObject) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById((String) dataMap.get("equipId"));
if(optional.isPresent()){
// 更新es // 更新es
HashMap<String, Map<String, Object>> objMap = new HashMap<>(); HashMap<String, Map<String, Object>> objMap = new HashMap<>();
HashMap<String, Object> param = new HashMap<>(); HashMap<String, Object> param = new HashMap<>();
...@@ -2087,14 +2092,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2087,14 +2092,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if((!ObjectUtils.isEmpty(carNumber))) { if((!ObjectUtils.isEmpty(carNumber))) {
param.put("CAR_NUMBER", dataMap.get("carNumber")); param.put("CAR_NUMBER", dataMap.get("carNumber"));
} }
objMap.put((String) dataMap.get("equipId"), param); ESEquipmentCategoryDto categoryDto = optional.get();
// tzsServiceFeignClient.commonUpdateEsDataByIds(objMap); BeanUtil.copyProperties(param, categoryDto, true);
return objMap; return categoryDto;
}
log.error("办理使用登记的设备{},在es中不存在", dataMap.get("equipId"));
throw new BadRequest("设备数据不存在");
} }
public void updateEsData2(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo, IdxBizJgUseInfo useInfo, public ESEquipmentCategoryDto updateEsData2(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo, IdxBizJgUseInfo useInfo,
JgUseRegistration jgUseRegistration, JSONObject jsonObject) { JgUseRegistration jgUseRegistration, JSONObject jsonObject) {
if (otherInfo != null) { Optional<ESEquipmentCategoryDto> op = esEquipmentCategory.findById((String) dataMap.get("equipId"));
if(op.isPresent()){
// 更新es // 更新es
HashMap<String, Map<String, Object>> objMap = new HashMap<>(); HashMap<String, Map<String, Object>> objMap = new HashMap<>();
HashMap<String, Object> param = new HashMap<>(); HashMap<String, Object> param = new HashMap<>();
...@@ -2129,9 +2138,12 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2129,9 +2138,12 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
param.put("USE_ORG_CODE", jgUseRegistration.getUseRegistrationCode()); param.put("USE_ORG_CODE", jgUseRegistration.getUseRegistrationCode());
param.put("CYLINDER_CATEGORY", dataMap.get("cylinderCategory")); param.put("CYLINDER_CATEGORY", dataMap.get("cylinderCategory"));
param.put("FACTORY_NUM", MapUtil.getStr(dataMap, "factoryNum")); param.put("FACTORY_NUM", MapUtil.getStr(dataMap, "factoryNum"));
objMap.put((String) dataMap.get("equipId"), param); ESEquipmentCategoryDto categoryDto = op.get();
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap); BeanUtil.copyProperties(param, categoryDto, true);
return categoryDto;
} }
log.error("办理使用登记的设备{},在es中不存在", dataMap.get("equipId"));
throw new BadRequest("设备数据不存在");
} }
private Long castDate2TimeStr(String nextInspectDate) { private Long castDate2TimeStr(String nextInspectDate) {
...@@ -4360,6 +4372,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -4360,6 +4372,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JgUseRegistrationEq jgUseRegistrationEq = new JgUseRegistrationEq(); JgUseRegistrationEq jgUseRegistrationEq = new JgUseRegistrationEq();
jgUseRegistrationEq.setEquId(equipId); jgUseRegistrationEq.setEquId(equipId);
jgRelationEquipMapper.update(jgUseRegistrationEq, lambda); jgRelationEquipMapper.update(jgUseRegistrationEq, lambda);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(equipId), EquipCreateOrEditEvent.EquipType.equip));
return this.baseMapper.getDetailById(jgUseRegistration.getSequenceNbr());
} else { } else {
//新增暂存 //新增暂存
if(!Arrays.asList("tempSubmit", "tempEdit").contains(submitType)){ if(!Arrays.asList("tempSubmit", "tempEdit").contains(submitType)){
...@@ -4546,7 +4560,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -4546,7 +4560,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
this.createCode(map, jgUseRegistration, registerInfo, useInfo, otherInfo); this.createCode(map, jgUseRegistration, registerInfo, useInfo, otherInfo);
map.put("equCode", equCode); map.put("equCode", equCode);
// 更新es // 更新es
this.updateEsData2(usePlace, map, otherInfo, useInfo, jgUseRegistration, map); ESEquipmentCategoryDto equipmentCategoryDto = this.updateEsData2(usePlace, map, otherInfo, useInfo, jgUseRegistration, map);
this.updateById(jgUseRegistration); this.updateById(jgUseRegistration);
// 设备安装信息更新 // 设备安装信息更新
...@@ -4573,9 +4587,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -4573,9 +4587,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理") .changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理")
.build()); .build());
} }
} esEquipmentCategory.save(equipmentCategoryDto);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(equipId), EquipCreateOrEditEvent.EquipType.equip)); eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(equipId), EquipCreateOrEditEvent.EquipType.equip));
return this.baseMapper.getDetailById(jgUseRegistration.getSequenceNbr()); return this.baseMapper.getDetailById(jgUseRegistration.getSequenceNbr());
}
} catch (BadRequest | LocalBadRequest e) { } catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
this.rollBackForDelRedisData(); this.rollBackForDelRedisData();
......
...@@ -2178,6 +2178,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2178,6 +2178,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
} }
} }
List<ESEquipmentCategoryDto> esEquipmentCategoryDtos = new ArrayList<>();
// 更新关联气瓶信息 // 更新关联气瓶信息
if (!CollectionUtils.isEmpty(equipmentLists)) { if (!CollectionUtils.isEmpty(equipmentLists)) {
List<JgVehicleInformationEq> equipList = new ArrayList<>(); List<JgVehicleInformationEq> equipList = new ArrayList<>();
...@@ -2239,7 +2240,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2239,7 +2240,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
if(!Arrays.asList("temp", "tempEdit").contains(submitType)){ if(!Arrays.asList("temp", "tempEdit").contains(submitType)){
this.updateEquipInfo(vehicleInformation, registerInfo, otherInfo, String.valueOf(x.get("record"))); this.updateEquipInfo(vehicleInformation, registerInfo, otherInfo, String.valueOf(x.get("record")));
// 更新es // 更新es
this.updateEquipEsData(vehicleInformation, otherInfo, registerInfo, String.valueOf(x.get("record")), useInfo); ESEquipmentCategoryDto equipmentCategoryDto = this.updateEquipEsData(vehicleInformation, otherInfo, registerInfo, String.valueOf(x.get("record")), useInfo);
esEquipmentCategoryDtos.add(equipmentCategoryDto);
} }
// 查询设备制造信息 // 查询设备制造信息
LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizJgFactoryInfo> factoryInfoWrapper = new LambdaQueryWrapper<>();
...@@ -2261,6 +2263,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2261,6 +2263,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
Set<String> recordSet = equipmentLists.stream() Set<String> recordSet = equipmentLists.stream()
.map(v -> (String) v.get("record")) .map(v -> (String) v.get("record"))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if(!esEquipmentCategoryDtos.isEmpty()){
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip)); eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return Collections.singletonList(vehicleInformation); return Collections.singletonList(vehicleInformation);
} }
...@@ -2572,15 +2577,16 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2572,15 +2577,16 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
this.createCode(jgVehicleInformation, registerInfo, otherInfo); this.createCode(jgVehicleInformation, registerInfo, otherInfo);
} }
private void updateEquipEsData(JgVehicleInformation jgVehicleInformation, IdxBizJgOtherInfo otherInfo, private ESEquipmentCategoryDto updateEquipEsData(JgVehicleInformation jgVehicleInformation, IdxBizJgOtherInfo otherInfo,
IdxBizJgRegisterInfo registerInfo, String equId ,IdxBizJgUseInfo useInfo) { IdxBizJgRegisterInfo registerInfo, String equId ,IdxBizJgUseInfo useInfo) {
Optional<ESEquipmentCategoryDto> op = esEquipmentCategory.findById((String) equId);
if(op.isPresent()){
// 更新es // 更新es
HashMap<String, Map<String, Object>> objMap = new HashMap<>(); HashMap<String, Map<String, Object>> objMap = new HashMap<>();
HashMap<String, Object> param = new HashMap<>(); HashMap<String, Object> param = new HashMap<>();
param.put("SUPERVISORY_CODE", otherInfo.getSupervisoryCode()); param.put("SUPERVISORY_CODE", otherInfo.getSupervisoryCode());
param.put("USE_UNIT_CREDIT_CODE", jgVehicleInformation.getUseUnitCreditCode()); param.put("USE_UNIT_CREDIT_CODE", jgVehicleInformation.getUseUnitCreditCode());
param.put("USE_UNIT_NAME", jgVehicleInformation.getUseUnitName()); param.put("USE_UNIT_NAME", jgVehicleInformation.getUseUnitName());
//param.put("ADDRESS", otherInfo.get);
param.put("USE_PLACE", jgVehicleInformation.getUseUnitAddress()); param.put("USE_PLACE", jgVehicleInformation.getUseUnitAddress());
param.put("STATUS", "已认领"); param.put("STATUS", "已认领");
param.put("EQU_STATE", Optional.ofNullable(useInfo.getEquState()) param.put("EQU_STATE", Optional.ofNullable(useInfo.getEquState())
...@@ -2590,8 +2596,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2590,8 +2596,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
param.put("ORG_BRANCH_NAME", jgVehicleInformation.getOrgBranchName()); param.put("ORG_BRANCH_NAME", jgVehicleInformation.getOrgBranchName());
param.put("EQU_CODE", registerInfo.getEquCode()); param.put("EQU_CODE", registerInfo.getEquCode());
param.put("USE_ORG_CODE", jgVehicleInformation.getUseRegistrationCode()); param.put("USE_ORG_CODE", jgVehicleInformation.getUseRegistrationCode());
objMap.put(equId, param); ESEquipmentCategoryDto categoryDto = op.get();
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap); BeanUtil.copyProperties(param, categoryDto, true);
return categoryDto;
}
log.error("办理车用使用登记的设备{},在es中不存在", equId);
throw new BadRequest("设备数据不存在");
} }
@Override @Override
......
...@@ -398,10 +398,19 @@ public class CommonServiceImpl { ...@@ -398,10 +398,19 @@ public class CommonServiceImpl {
return "no"; return "no";
} }
public void updateEquipNextInspectDate(JyjcInspectionResultModel model, String record) {
updateEsInspectDate(record, model.getNextInspectionDate()); public void updateEquipNextInspectDateBatch(Date nextInspectionDate, List<String> records) {
if (nextInspectionDate != null) {
Iterable<ESEquipmentCategoryDto> equipmentCategoryDtos = esEquipmentCategory.findAllById(records);
equipmentCategoryDtos.forEach(esEquipmentCategoryDto->{
esEquipmentCategoryDto.setNEXT_INSPECT_DATE(nextInspectionDate.getTime());
});
esEquipmentCategory.saveAll(equipmentCategoryDtos);
}
} }
public void updateEquipNextInspectDate(JyjcInspectionResult model, String record) { public void updateEquipNextInspectDate(JyjcInspectionResult model, String record) {
updateEsInspectDate(record, model.getNextInspectionDate()); updateEsInspectDate(record, model.getNextInspectionDate());
} }
......
...@@ -372,8 +372,6 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR ...@@ -372,8 +372,6 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
} }
// 3.更新使用信息表,最新检验信息 // 3.更新使用信息表,最新检验信息
useInfoMapper.updateByRecord(record, model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo()); useInfoMapper.updateByRecord(record, model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo());
// 4.更新es下次检验日期
commonService.updateEquipNextInspectDate(model, record);
}); });
// 更新装置的汇总的管道长度 // 更新装置的汇总的管道长度
calAndWriteTotalPipelineLength(model.getEquipUnicode()); calAndWriteTotalPipelineLength(model.getEquipUnicode());
...@@ -405,10 +403,10 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR ...@@ -405,10 +403,10 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
} }
// 3.更新使用信息表最新的检验信息 // 3.更新使用信息表最新的检验信息
useInfoMapper.updateByRecord(model.getEquipUnicode(), model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo()); useInfoMapper.updateByRecord(model.getEquipUnicode(), model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo());
// 4.es更新下次检验日期
commonService.updateEquipNextInspectDate(model, model.getEquipUnicode());
records.add(model.getEquipUnicode()); records.add(model.getEquipUnicode());
} }
// 4.es更新下次检验日期
commonService.updateEquipNextInspectDateBatch(model.getNextInspectionDate(), new ArrayList<>(records));
return records; return records;
} }
......
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