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);
}
}); });
} }
......
...@@ -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) {
......
...@@ -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