Commit 62be67c6 authored by 韩桐桐's avatar 韩桐桐

fix(jg):BUG 26887

parent e46930ca
...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; ...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent; import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo; 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.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
...@@ -40,7 +41,7 @@ public class CancellationEventListener { ...@@ -40,7 +41,7 @@ public class CancellationEventListener {
private final ESEquipmentCategory esEquipmentCategoryDao; private final ESEquipmentCategory esEquipmentCategoryDao;
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper; private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService; private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
...@@ -76,24 +77,28 @@ public class CancellationEventListener { ...@@ -76,24 +77,28 @@ public class CancellationEventListener {
Boolean inUsed = commonService.checkEquipIsUsed(record); Boolean inUsed = commonService.checkEquipIsUsed(record);
// 无引用则进行修改纳管状态为未纳管 // 无引用则进行修改纳管状态为未纳管
if (!inUsed) { if (!inUsed) {
// 更新已纳管为未纳管-数据库 // 更新已纳管为未纳管 - 数据库
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>(); idxBizJgUseInfoService.lambdaUpdate()
updateWrapper.eq(IdxBizJgUseInfo::getRecord, record); .eq(IdxBizJgUseInfo::getRecord, record)
updateWrapper.set(IdxBizJgUseInfo::getIsIntoManagement, false); .set(IdxBizJgUseInfo::getIsIntoManagement, false)
idxBizJgUseInfoMapper.update(null, updateWrapper); .update();
// 清除系统自动生成的设备代码
idxBizJgRegisterInfoService.lambdaUpdate() // 清除系统自动生成的设备代码`equCode`
boolean isRegisterUpdated = idxBizJgRegisterInfoService.lambdaUpdate()
.eq(IdxBizJgRegisterInfo::getRecord, record) .eq(IdxBizJgRegisterInfo::getRecord, record)
.eq(IdxBizJgRegisterInfo::getEquCodeType, "2") .eq(IdxBizJgRegisterInfo::getEquCodeType, "2")
.set(IdxBizJgRegisterInfo::getEquCode, null) .set(IdxBizJgRegisterInfo::getEquCode, null)
.update(); .update();
// 更新已纳管为未纳管-es
// 同步修改ES数据
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategoryDao.findById(record); Optional<ESEquipmentCategoryDto> optional = esEquipmentCategoryDao.findById(record);
if (optional.isPresent()) { optional.ifPresent(esEquipmentCategoryDto -> {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(false); esEquipmentCategoryDto.setIS_INTO_MANAGEMENT(false);
if (isRegisterUpdated) {
esEquipmentCategoryDto.setEQU_CODE(null);
}
esEquipmentCategoryDao.save(esEquipmentCategoryDto); esEquipmentCategoryDao.save(esEquipmentCategoryDto);
} });
} }
} }
} }
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