Commit a1305698 authored by tianbo's avatar tianbo

refactor(jg): 重构设备注册和转移服务中的ES数据处理逻辑

- 修改EquipClaimServiceImpl中的checkEsData为saveEsData方法 - 重构ESEquipmentCategory的deleteAllWithFallback方法返回类型为void - 重构JgEquipTransferServiceImpl中的ES数据更新和回滚机制 - 重构JgInstallationNoticeServiceImpl中的批量设备ID处理逻辑 - 实现安装通知取消申请时的ES数据回滚功能 - 添加@EnableEsRollback注解支持ES数据操作回滚 - 重构JgReformNoticeServiceImpl中的压力管道数据处理逻辑 - 实现改造通知接受流程中的ES数据保存和删除列表管理
parent f5fb2108
......@@ -113,14 +113,14 @@ public interface ESEquipmentCategory extends PagingAndSortingRepository<ESEquipm
return result.iterator().next();
}
default Iterable<ESEquipmentCategoryDto> deleteAllWithFallback(Iterable<ESEquipmentCategoryDto> dtos) {
default void deleteAllWithFallback(Iterable<ESEquipmentCategoryDto> dtos) {
int batchSize = 2000;
List<ESEquipmentCategoryDto> dtoList = StreamSupport.stream(dtos.spliterator(), false)
.collect(Collectors.toList());
if (dtoList.isEmpty()) {
return Collections.emptyList();
return;
}
log.info("deleteAllWithCache开始处理ES数据,总数量: {}, 批次大小: {}", dtoList.size(), batchSize);
......@@ -160,6 +160,5 @@ public interface ESEquipmentCategory extends PagingAndSortingRepository<ESEquipm
log.info("deleteAllWithCache数据处理完成,总计: 删除{}条", allDeleteData.size());
return dtoList;
}
}
......@@ -923,7 +923,7 @@ public class EquipClaimServiceImpl {
// 技术参数
jgRegisterInfoService.saveOrUpdateEquParams(new LinkedHashMap<>(equipInfo), new LinkedHashMap<>(equipParams), equList, record, timestamp, "edit");
// 更新es
jgRegisterInfoService.checkEsData(record);
jgRegisterInfoService.saveEsData(record);
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(record), EquipCreateOrEditEvent.EquipType.equip));
......
......@@ -32,6 +32,7 @@ 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.ConstructionTypeEnum;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EquipmentCategoryService;
......@@ -500,14 +501,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
* @return record
*/
private ResponseModel pipelineEquipCreateOrUpdate(Map<String, Object> paramMap, CompanyBo company) {
// 获取表单数据并进行类型检查
LinkedHashMap equipmentInfoForm = castToLinkedHashMap(paramMap.get(EQUIP_INFO_FORM_ID));
// 操作类型
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT;
try {
// 获取表单数据并进行类型检查
LinkedHashMap equipmentInfoForm = castToLinkedHashMap(paramMap.get(EQUIP_INFO_FORM_ID));
String submitType = String.valueOf(paramMap.get("submitType"));
return ResponseHelper.buildResponse(batchSubmitOrUpdatePipeline(equipmentInfoForm, submitType, company));
} catch (Exception e) {
log.error("操作失败,数据异常: {}", e.getMessage(), e);
handleError(e, String.valueOf(paramMap.getOrDefault(SEQUENCE_NBR, "")));
handleError(e, String.valueOf(paramMap.getOrDefault(SEQUENCE_NBR, "")), operateType);
return ResponseHelper.buildResponse(null);
}
}
......@@ -906,6 +909,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
LinkedHashMap equipmentClassForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_CLASS_FORM_ID));
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap equipmentParamsForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_PARAMS_FORM_ID));
// 操作类型
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT;
String submitType = String.valueOf(paramMap.get("submitType"));
String record = (String) equipmentInfoForm.get(RECORD);
try {
......@@ -916,7 +921,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 96333码 字段的唯一性校验
check96333Code(equipmentInfoForm);
} catch (Exception e) {
handleError(e, null);
handleError(e, null, null);
}
// 操作类型
try {
......@@ -924,11 +929,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
record = batchSubmitOrUpdate(equipmentClassForm, equipmentInfoForm, equipmentParamsForm, submitType, company);
// 保存Es数据
if (!ObjectUtils.isEmpty(record)) {
checkEsData(record);
saveEsData(record);
}
} catch (Exception e) {
log.error("操作失败,数据异常: " + e.getMessage(), e);
handleError(e, record);
handleError(e, record, operateType);
}
return ResponseHelper.buildResponse(record);
}
......@@ -964,7 +969,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// 历史有使用登记证的场车设备校验车牌号的唯一性
checkCarNumberUniquenessWithHisCC(equipmentInfoForm, record, dataSource);
} catch (Exception e) {
handleError(e, null);
handleError(e, null, null);
}
// 使用登记按照单位办理除外,其余进行编辑校验
......@@ -975,17 +980,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
this.checkForEquipEdit(record);
}
// 操作类型
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT;
try {
// 保存数据
record = batchSubmitOrUpdate(equipmentClassForm, equipmentInfoForm, equipmentParamsForm, submitType, company);
// 保存Es数据
if (!ObjectUtils.isEmpty(record)) {
checkEsData(record);
saveEsData(record);
throw new RuntimeException("保存数据失败");
}
} catch (Exception e) {
log.error("操作失败,数据异常: " + e.getMessage(), e);
handleError(e, record);
handleError(e, record, operateType);
}
return ResponseHelper.buildResponse(record);
}
......@@ -1178,10 +1185,10 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
}
private void handleError(Exception e, String record) {
log.error("处理异常: " + e.getMessage(), e);
private void handleError(Exception e, String record, String operateType) {
log.error("处理设备新增或更新异常: " + e.getMessage(), e);
// 删除数据库数据和ES数据
if (!ObjectUtils.isEmpty(record)) {
if (!ObjectUtils.isEmpty(record) && OPERATESAVE.equals(operateType)) {
List<String> records = new ArrayList<>();
records.add(record);
superviseInfoMapper.deleteDataAll(records);
......@@ -3759,6 +3766,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String companyCode = companyInfoMap.get("creditCode").toString();
constructionInfo.setRecord(record);
constructionInfo.setRecDate(date);
if (!registerInfo.getEquList().equals("5000") && !registerInfo.getEquCategory().equals("4400") && !registerInfo.getEquCategory().equals("2300")) {
constructionInfo.setConstructionType(ConstructionTypeEnum.AZ.getCode());
}
if (companyTypeStr.contains(CompanyTypeEnum.CONSTRUCTION.getCode())) {
constructionInfo.setUscUnitCreditCode(companyCode);
......@@ -4052,14 +4062,10 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
: equipSource;
}
public void checkEsData(String id) {
public void saveEsData(String id) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(id);
categoryOtherInfoMapper.updateEsStatus(id);
ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(id);
if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(id);
}
if (!ObjectUtils.isEmpty(dto)) {
long recTime;
long createTime;
......
......@@ -10,12 +10,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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.service.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransfer;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransferEq;
......@@ -33,10 +37,10 @@ import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.common.api.service.ICompensateFlowDataOfRedis;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgRegisterInfoService;
import com.yeejoin.amos.boot.module.ymt.api.common.BaseException;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
......@@ -60,6 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
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;
......@@ -109,6 +114,9 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
@Autowired
private JgResumeInfoServiceImpl jgResumeInfoService;
@Autowired
private ESEquipmentCategory esEquipmentCategory;
/**
* 保存和保存并提交
*
......@@ -504,6 +512,7 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 6000000)
public void accept(JgEquipTransferDto jgEquipTransferDto, String op) {
List<String> recordList = Lists.newArrayList();
String instanceId = jgEquipTransferDto.getInstanceId();
String nextTaskId = jgEquipTransferDto.getNextTaskId();
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
......@@ -556,13 +565,8 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
}
if (jgEquipTransferEqs != null) {
jgEquipTransferEqs.forEach(equipTransferEq -> {
Map<String, Map<String, Object>> resultMap = MapBuilder.<String, Map<String, Object>>create()
.put(equipTransferEq.getEquId(), MapBuilder.<String, Object>create()
.put("USC_UNIT_NAME", jgEquipTransfer.getInstallUnitName())
.put("USC_UNIT_CREDIT_CODE", jgEquipTransfer.getInstallUnitCreditCode())
.build())
.build();
tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap);
recordList.add(equipTransferEq.getEquId());
updateOldEsEquipment(equipTransferEq, jgEquipTransfer);
updateEsEquipment(equipTransferEq, jgEquipTransfer);
writeUsc2UseInfo(equipTransferEq, jgEquipTransfer);
});
......@@ -603,7 +607,8 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
updateById(jgEquipTransfer);
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgEquipTransfer));
this.delRepeatUseEquipData(jgEquipTransfer.getSequenceNbr(), jgEquipTransfer.getApplyStatus(), jgEquipTransfer.getUseUnitCreditCode());
} catch (InterruptedException e) {
} catch (Exception e) {
this.esRollback(recordList);
e.printStackTrace();
} finally {
if (lock.isHeldByCurrentThread()) {
......@@ -612,6 +617,35 @@ public class JgEquipTransferServiceImpl extends BaseService<JgEquipTransferDto,
}
}
private void updateOldEsEquipment(JgEquipTransferEq equipTransferEq, JgEquipTransfer jgEquipTransfer) {
Optional<ESEquipmentCategoryDto> esOptional = esEquipmentCategory.findById(equipTransferEq.getEquId());
if (esOptional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = esOptional.get();
esEquipmentCategoryDto.setUSC_UNIT_NAME(jgEquipTransfer.getInstallUnitName());
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(jgEquipTransfer.getInstallUnitCreditCode());
esEquipmentCategory.save(esEquipmentCategoryDto);
}
}
private void esRollback(List<String> recordList) {
Iterable<ESEquipmentCategoryDto> esEquipmentCategoryDtos = esEquipmentCategory.findAllById(recordList);
if (!ValidationUtil.isEmpty(esEquipmentCategoryDtos)) {
esEquipmentCategoryDtos.forEach(esEquipmentCategoryDto -> {
esEquipmentCategoryDto.setUSC_UNIT_NAME(null);
esEquipmentCategoryDto.setUSC_UNIT_CREDIT_CODE(null);
});
esEquipmentCategory.saveAll(esEquipmentCategoryDtos);
}
Iterable<ESEquipmentInfo> esEquipmentInfos = esEquipmentDao.findAllById(recordList);
if (!ValidationUtil.isEmpty(esEquipmentInfos)) {
esEquipmentInfos.forEach(esEquipmentInfo -> {
esEquipmentInfo.setUSC_UNIT_NAME(null);
esEquipmentInfo.setUSC_UNIT_CREDIT_CODE(null);
});
esEquipmentDao.saveAll(esEquipmentInfos);
}
}
private void createResume(List<JgEquipTransferEq> equipTransferEqList, JgEquipTransfer equipTransfer, String routePath) {
if(StringUtils.hasText(equipTransfer.getProjectContraptionSeq())){
jgResumeInfoService.saveBatchResume(Collections.singletonList(
......
......@@ -1571,11 +1571,18 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
return tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
}
private IdxBizJgRegisterInfo getIdxBizJgRegisterInfo2(JgInstallationNoticeEq jgRelationEquip) {
LambdaQueryWrapper<IdxBizJgRegisterInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(IdxBizJgRegisterInfo::getRecord, jgRelationEquip.getEquId());
queryWrapper2.select(TzsBaseEntity::getSequenceNbr, IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getEquCodeType);
return tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
private List<IdxBizJgRegisterInfo> getIdxBizJgRegisterInfo2(Set<String> equipIds) {
if (ValidationUtil.isEmpty(equipIds)) {
return Collections.emptyList();
}
List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos = new ArrayList<>();
Lists.partition(Lists.newArrayList(equipIds), 1000).forEach(ids -> {
LambdaQueryWrapper<IdxBizJgRegisterInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(IdxBizJgRegisterInfo::getRecord, ids);
queryWrapper2.select(TzsBaseEntity::getSequenceNbr, IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getEquCodeType);
idxBizJgRegisterInfos.addAll(tzsJgRegistrationInfoMapper.selectList(queryWrapper2));
});
return idxBizJgRegisterInfos;
}
private void genJgCertificateChangeRecord(JgInstallationNotice jgInstallationNotice, Long sequenceNbr, String registrationCode, String equCategory, TaskV2Model taskV2Model1) {
......@@ -1850,6 +1857,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Override
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
@EnableEsRollback
public JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason) {
JgInstallationNotice installationNotice = this.getById(sequenceNbr);
// 0.校验是否做过使用登记,已发起使用登记(非删除状态)则提示不能进行作废
......@@ -1935,21 +1943,22 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, installationNotice.getSequenceNbr());
queryWrapper.select(JgInstallationNoticeEq::getEquipTransferId, BaseEntity::getSequenceNbr, JgInstallationNoticeEq::getEquId);
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
jgInstallationNoticeEqs.forEach(jgRelationEquip -> {
// 1.use_info 回退
this.rollBackUseInfo(jgRelationEquip);
// 2.释放96333码为 未使用状态
this.release96333Code(jgRelationEquip);
// 3.other_info 回退
this.rollBackOtherInfo(jgRelationEquip);
// 4.supervise_info回退
this.rollBackSuperviseInfo(jgRelationEquip);
// 5.设备代码 回退
IdxBizJgRegisterInfo idxBizJgRegisterInfo = getIdxBizJgRegisterInfo2(jgRelationEquip);
this.rollBackRegisterInfo(jgRelationEquip, idxBizJgRegisterInfo);
// 6.es 回退
this.rollBackEsInfo(jgRelationEquip, idxBizJgRegisterInfo);
});
Set<String> equipIds = jgInstallationNoticeEqs.stream()
.map(JgInstallationNoticeEq::getEquId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 1.use_info 回退
this.rollBackUseInfo(equipIds);
// 2.释放96333码为 未使用状态
this.release96333Code(equipIds);
// 3.other_info 回退
this.rollBackOtherInfo(equipIds);
// 4.supervise_info回退
this.rollBackSuperviseInfo(equipIds);
// 5.设备代码 回退
List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos = getIdxBizJgRegisterInfo2(equipIds);
this.rollBackRegisterInfo(idxBizJgRegisterInfos);
// 如果是工业管道,则回滚工程装置表信息
String equCategoryCode = installationNotice.getEquCategoryCode();
if (PipelineEnum.INDUSTRIAL_PIPELINE.getCode().equals(equCategoryCode) || PipelineEnum.LONG_DISTANCE_PIPELINE.getCode().equals(equCategoryCode) || PipelineEnum.COMMON_PIPELINE.getCode().equals(equCategoryCode)) {
......@@ -1963,6 +1972,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (!equipTransferIds.isEmpty()) {
jgResumeInfoService.deleteBatchByBusinessId(equipTransferIds);
}
// 6.es 回退
this.rollBackEsInfo(equipIds, idxBizJgRegisterInfos);
}
/**
......@@ -1988,86 +1999,122 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
/**
* 释放96333码为未使用状态
*
* @param jgRelationEquip jgRelationEquip
* @param equipIds equipIds
*/
private void release96333Code(JgInstallationNoticeEq jgRelationEquip) {
Optional.ofNullable(jgRelationEquip)
.map(JgInstallationNoticeEq::getEquId)
.map(equId -> tzsJgOtherInfoMapper.selectOne(
new LambdaQueryWrapper<OtherInfo>()
.eq(OtherInfo::getRecord, equId)
.select(OtherInfo::getSupervisoryCode)
))
.map(OtherInfo::getSupervisoryCode)
.ifPresent(code -> supervisoryCodeInfoMapper.updateStatus(Collections.singletonList(code)));
}
private void rollBackEsInfo(JgInstallationNoticeEq jgRelationEquip, IdxBizJgRegisterInfo idxBizJgRegisterInfo) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(jgRelationEquip.getEquId());
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setUSE_UNIT_CREDIT_CODE(null);
esEquipmentCategoryDto.setUSE_UNIT_NAME(null);
esEquipmentCategoryDto.setOrgBranchCode(null);
esEquipmentCategoryDto.setORG_BRANCH_NAME(null);
esEquipmentCategoryDto.setSUPERVISORY_CODE(null);
esEquipmentCategoryDto.setCODE96333(null);
esEquipmentCategoryDto.setUSE_PLACE(null);
esEquipmentCategoryDto.setUSE_PLACE_CODE(null);
esEquipmentCategoryDto.setADDRESS(null);
if (EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(idxBizJgRegisterInfo.getEquCodeType())) {
esEquipmentCategoryDto.setEQU_CODE(null);
private void release96333Code(Set<String> equipIds) {
if (ValidationUtil.isEmpty(equipIds)) {
return;
}
List<String> supervisoryCodes = tzsJgOtherInfoMapper.selectList(
new LambdaQueryWrapper<OtherInfo>()
.in(OtherInfo::getRecord, equipIds)
.select(OtherInfo::getSupervisoryCode)
).stream().map(OtherInfo::getSupervisoryCode).collect(Collectors.toList());
if (ValidationUtil.isEmpty(supervisoryCodes)) {
return;
}
Lists.partition(supervisoryCodes, 1000).forEach(codes -> {
supervisoryCodeInfoMapper.updateStatus(codes);
});
}
private void rollBackEsInfo(Set<String> equipIds, List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos) {
if (ValidationUtil.isEmpty(equipIds)) {
return;
}
Iterable<ESEquipmentCategoryDto> esDtos = esEquipmentCategory.findAllById(equipIds);
if (ValidationUtil.isEmpty(esDtos)) {
return;
}
esDtos.forEach(esDto -> {
esDto.setUSE_UNIT_CREDIT_CODE(null);
esDto.setUSE_UNIT_NAME(null);
esDto.setOrgBranchCode(null);
esDto.setORG_BRANCH_NAME(null);
esDto.setSUPERVISORY_CODE(null);
esDto.setCODE96333(null);
esDto.setUSE_PLACE(null);
esDto.setUSE_PLACE_CODE(null);
esDto.setADDRESS(null);
Optional<IdxBizJgRegisterInfo> registerInfoOpt = idxBizJgRegisterInfos.stream()
.filter(r -> r.getRecord().equals(esDto.getSEQUENCE_NBR()))
.findFirst();
if (registerInfoOpt.isPresent() &&
EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(registerInfoOpt.get().getEquCodeType())) {
esDto.setEQU_CODE(null);
}
esEquipmentCategory.save(esEquipmentCategoryDto);
}
});
esEquipmentCategory.saveAllWithFallback(esDtos);
}
private void rollBackRegisterInfo(JgInstallationNoticeEq jgRelationEquip, IdxBizJgRegisterInfo idxBizJgRegisterInfo) {
if (EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(idxBizJgRegisterInfo.getEquCodeType())) {
// 如果设备代码是系统自动生成,回退注册信息表的设备代码字段
private void rollBackRegisterInfo(List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos) {
if (ValidationUtil.isEmpty(idxBizJgRegisterInfos)) {
return;
}
// 如果设备代码是系统自动生成,回退注册信息表的设备代码字段
List<IdxBizJgRegisterInfo> registerInfos = idxBizJgRegisterInfos.stream().filter(info -> info.getEquCodeType().equals(EquCodeTypeEnum.SYSTEM_GENERATED.getCode())).collect(Collectors.toList());
if (ValidationUtil.isEmpty(registerInfos)) {
return;
}
Lists.partition(registerInfos, 1000).forEach(infos -> {
LambdaUpdateWrapper<IdxBizJgRegisterInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgRegisterInfo::getRecord, jgRelationEquip.getEquId());
updateWrapper.in(IdxBizJgRegisterInfo::getRecord, infos.stream().map(IdxBizJgRegisterInfo::getRecord).collect(Collectors.toList()));
updateWrapper.set(IdxBizJgRegisterInfo::getEquCode, null);
tzsJgRegistrationInfoMapper.update(null, updateWrapper);
}
});
}
private void rollBackSuperviseInfo(JgInstallationNoticeEq jgRelationEquip) {
LambdaUpdateWrapper<IdxBizJgSupervisionInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgSupervisionInfo::getRecord, jgRelationEquip.getEquId());
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchCode, null);
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchName, null);
updateWrapper.set(IdxBizJgSupervisionInfo::getCompanyOrgBranchCode, null);
idxBizJgSupervisionInfoMapper.update(null, updateWrapper);
private void rollBackSuperviseInfo(Set<String> equipIds) {
if (ValidationUtil.isEmpty(equipIds)) {
return;
}
Lists.partition(Lists.newArrayList(equipIds), 1000).forEach(ids -> {
LambdaUpdateWrapper<IdxBizJgSupervisionInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(IdxBizJgSupervisionInfo::getRecord, ids);
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchCode, null);
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchName, null);
updateWrapper.set(IdxBizJgSupervisionInfo::getCompanyOrgBranchCode, null);
idxBizJgSupervisionInfoMapper.update(null, updateWrapper);
});
}
private void rollBackOtherInfo(JgInstallationNoticeEq jgRelationEquip) {
LambdaUpdateWrapper<OtherInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AbstractEquipBaseEntity::getRecord, jgRelationEquip.getEquId());
updateWrapper.set(OtherInfo::getCode96333, null);
updateWrapper.set(OtherInfo::getSupervisoryCode, null);
tzsJgOtherInfoMapper.update(null, updateWrapper);
private void rollBackOtherInfo(Set<String> equipIds) {
if (ValidationUtil.isEmpty(equipIds)) {
return;
}
Lists.partition(Lists.newArrayList(equipIds), 1000).forEach(ids -> {
LambdaUpdateWrapper<OtherInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(AbstractEquipBaseEntity::getRecord, ids);
updateWrapper.set(OtherInfo::getCode96333, null);
updateWrapper.set(OtherInfo::getSupervisoryCode, null);
tzsJgOtherInfoMapper.update(null, updateWrapper);
});
}
private void rollBackUseInfo(JgInstallationNoticeEq jgRelationEquip) {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, jgRelationEquip.getEquId()); // 设置更新条件
// 强制更新字段为 NULL
updateWrapper.set(IdxBizJgUseInfo::getUseUnitCreditCode, null);
updateWrapper.set(IdxBizJgUseInfo::getUseUnitName, null);
updateWrapper.set(IdxBizJgUseInfo::getProvince, null);
updateWrapper.set(IdxBizJgUseInfo::getProvinceName, null);
updateWrapper.set(IdxBizJgUseInfo::getCity, null);
updateWrapper.set(IdxBizJgUseInfo::getCityName, null);
updateWrapper.set(IdxBizJgUseInfo::getCounty, null);
updateWrapper.set(IdxBizJgUseInfo::getCountyName, null);
updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null);
updateWrapper.set(IdxBizJgUseInfo::getStreetName, null);
updateWrapper.set(IdxBizJgUseInfo::getIsNotXiXian, null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitCreditCode, null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitName, null);
updateWrapper.set(IdxBizJgUseInfo::getAddress, null);
useInfoService.update(updateWrapper);
private void rollBackUseInfo(Set<String> equipIds) {
if (ValidationUtil.isEmpty(equipIds)) {
return;
}
Lists.partition(Lists.newArrayList(equipIds), 1000).forEach(ids -> {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(IdxBizJgUseInfo::getRecord, Collections.singletonList(ids));
// 强制更新字段为 NULL
updateWrapper.set(IdxBizJgUseInfo::getUseUnitCreditCode, null);
updateWrapper.set(IdxBizJgUseInfo::getUseUnitName, null);
updateWrapper.set(IdxBizJgUseInfo::getProvince, null);
updateWrapper.set(IdxBizJgUseInfo::getProvinceName, null);
updateWrapper.set(IdxBizJgUseInfo::getCity, null);
updateWrapper.set(IdxBizJgUseInfo::getCityName, null);
updateWrapper.set(IdxBizJgUseInfo::getCounty, null);
updateWrapper.set(IdxBizJgUseInfo::getCountyName, null);
updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null);
updateWrapper.set(IdxBizJgUseInfo::getStreetName, null);
updateWrapper.set(IdxBizJgUseInfo::getIsNotXiXian, null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitCreditCode, null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitName, null);
updateWrapper.set(IdxBizJgUseInfo::getAddress, null);
useInfoService.update(updateWrapper);
});
}
......
......@@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.annotation.EnableEsRollback;
import com.yeejoin.amos.boot.biz.common.annotation.ResultFieldMapping;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
......@@ -24,8 +26,11 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.enums.ConstructionTypeEnum;
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.jg.api.common.PipLenCalUtils;
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.entity.JgReformNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNoticeEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgReformNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgReformNoticeMapper;
......@@ -42,14 +47,16 @@ 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.*;
import com.yeejoin.amos.boot.module.jg.api.common.PipLenCalUtils;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
......@@ -932,12 +939,15 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
*/
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 6000000)
@Transactional(rollbackFor = Exception.class)
@EnableEsRollback
public void accept(Map<String, Object> map, String op) {
LinkedHashMap model1 = (LinkedHashMap) map.get("model");
String opinion = (String) map.get("opinion");
String jsonString = JSON.toJSONString(model1);
JgReformNoticeDto jgReformNoticeDto = JSON.parseObject(jsonString, JgReformNoticeDto.class);
jgReformNoticeDto.setRemark(opinion);
List<ESEquipmentCategoryDto> saveEsList = new ArrayList<>();
List<ESEquipmentCategoryDto> deleteEsList = new ArrayList<>();
String instanceId = jgReformNoticeDto.getInstanceId();
String nextTaskId = jgReformNoticeDto.getNextTaskId();
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
......@@ -998,8 +1008,6 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
jgReformNotice.setAcceptDate(new Date());
jgReformNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgReformNotice.setPromoter("");
// 压力管道情况处理
this.YLGDDataPassHandler(jgReformNotice);
TaskV2Model taskV2Model1 = this.updateLastTodo(jgReformNotice, FlowStatusEnum.TO_BE_FINISHED);
this.updateById(jgReformNotice);
this.sendDataRefreshMsg(jgReformNotice, noticeEqs);
......@@ -1007,6 +1015,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
this.createConstruction2Db(jgReformNotice);
// 创建设备履历
this.createResume(noticeEqs, jgReformNotice, taskV2Model1.getRoutePath());
// 压力管道情况处理
this.YLGDDataPassHandler(jgReformNotice, saveEsList, deleteEsList);
} else {
jgReformNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
if (!ObjectUtils.isEmpty(jgReformNotice.getInstanceStatus())) {
......@@ -1036,7 +1046,13 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
}
commonService.saveExecuteFlowData2Redis(instanceId, this.buildInstanceRuntimeData(jgReformNotice));
this.delRepeatUseEquipData(jgReformNotice);
} catch (InterruptedException e) {
if (!ValidationUtil.isEmpty(saveEsList)) {
esEquipmentCategory.saveAllWithFallback(saveEsList);
}
if (!ValidationUtil.isEmpty(deleteEsList)) {
esEquipmentCategory.deleteAllWithFallback(deleteEsList);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (lock.isHeldByCurrentThread()) {
......@@ -1093,7 +1109,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
return JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
}
private void YLGDDataPassHandler(JgReformNotice notice) {
private void YLGDDataPassHandler(JgReformNotice notice, List<ESEquipmentCategoryDto> saveEsList, List<ESEquipmentCategoryDto> deleteEsList) {
if (!EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode())) {
return;
}
......@@ -1106,18 +1122,18 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
List<JSONObject> toUpdatePipData = newPipData.stream().filter(item -> !StringUtils.isEmpty(JSON.parseObject(item.toString()).getString(RECORD))).map(item -> JSON.parseObject(item.toString())).collect(Collectors.toList());
List<JSONObject> toAddPipData = newPipData.stream().filter(item -> StringUtils.isEmpty(JSON.parseObject(item.toString()).getString(RECORD))).map(item -> JSON.parseObject(item.toString())).collect(Collectors.toList());
List<String> toDeletePipRecords = delPipData.stream().map(item -> JSON.parseObject(item.toString()).getString(RECORD)).collect(Collectors.toList());
this.addPipDataWithFlowPass(toAddPipData, notice);
this.addPipDataWithFlowPass(toAddPipData, notice, saveEsList);
this.updatePipDataWithFlowPass(toUpdatePipData);
this.delPipDataWithFlowPass(toDeletePipRecords);
// 1.2更新工程装置中的管道长度
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<IdxBizJgProjectContraption>()
.eq(IdxBizJgProjectContraption::getSequenceNbr, notice.getProjectContraptionId())
.set(IdxBizJgProjectContraption::getPipelineLength, pieLineDataChangeService.calTotalPieLineLength(notice.getProjectContraptionId()))
.set(IdxBizJgProjectContraption::getPipeLengthChanged, notice.getPipeLengthChanged());
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
this.delPipDataWithFlowPass(toDeletePipRecords, deleteEsList);
}
private void delPipDataWithFlowPass(List<String> toDeletePipRecords) {
private void delPipDataWithFlowPass(List<String> toDeletePipRecords, List<ESEquipmentCategoryDto> deleteEsList) {
if (toDeletePipRecords.isEmpty()) {
return;
}
......@@ -1126,8 +1142,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
).collect(Collectors.toList());
// 删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(toDeletePipRecords);
// 删除es中的数据
esEquipmentCategory.deleteAll(esEquipmentCategoryDtoList);
// 收集需要删除es中的数据
deleteEsList.addAll(esEquipmentCategoryDtoList);
}
private void updatePipDataWithFlowPass(List<JSONObject> toUpdatePipData) {
......@@ -1166,18 +1182,17 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
});
}
private void addPipDataWithFlowPass(List<JSONObject> toAddPipData, JgReformNotice notice) {
private void addPipDataWithFlowPass(List<JSONObject> toAddPipData, JgReformNotice notice, List<ESEquipmentCategoryDto> esEquipmentCategoryList) {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionMapper.selectById(notice.getProjectContraptionId());
List<IdxBizJgUseInfo> useInfoList = new ArrayList<>(15);
List<IdxBizJgDesignInfo> designInfoList = new ArrayList<>(15);
List<IdxBizJgConstructionInfo> constructionInfoList = new ArrayList<>(15);
List<IdxBizJgFactoryInfo> factoryInfoList = new ArrayList<>(15);
List<IdxBizJgRegisterInfo> registerInfoList = new ArrayList<>(15);
List<IdxBizJgSupervisionInfo> supervisionInfoList = new ArrayList<>(15);
List<IdxBizJgOtherInfo> otherInfoList = new ArrayList<>(15);
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList = new ArrayList<>(15);
List<IdxBizJgTechParamsPipeline> paramsPipelineList = new ArrayList<>(15);
List<ESEquipmentCategoryDto> esEquipmentCategoryList = new ArrayList<>(15);
// eq关系表
List<JgReformNoticeEq> noticeEqs = new ArrayList<>(15);
// 设备信息
......@@ -1267,9 +1282,9 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
paramsPipelineList.add(pipelineInfo);
}
ESEquipmentCategoryDto esEquipmentDto = JSON.parseObject(toJSONString(pipData), ESEquipmentCategoryDto.class);
esEquipmentDto.setDATA_SOURCE(useInfo.getDataSource());
esEquipmentDto.setCREATE_DATE(System.currentTimeMillis());
esEquipmentDto.setREC_DATE(System.currentTimeMillis());
esEquipmentDto.setSEQUENCE_NBR(record);
esEquipmentDto.setIS_INTO_MANAGEMENT(false);
......@@ -1280,8 +1295,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
esEquipmentDto.setEQU_DEFINE_CODE(projectContraption.getEquDefine());
esEquipmentDto.setEQU_DEFINE(projectContraption.getEquDefineName());
esEquipmentDto.setSTATUS("已认领");
esEquipmentDto.setUSC_UNIT_CREDIT_CODE(projectContraption.getUscUnitCreditCode());
esEquipmentDto.setUSC_UNIT_NAME(projectContraption.getUscUnitName());
esEquipmentDto.setUSC_UNIT_CREDIT_CODE(notice.getInstallUnitCreditCode());
esEquipmentDto.setUSC_UNIT_NAME(notice.getInstallUnitName());
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(projectContraption.getUseUnitCreditCode());
esEquipmentDto.setUSE_UNIT_NAME(projectContraption.getUseUnitName());
esEquipmentDto.setPROJECT_CONTRAPTION(projectContraption.getProjectContraption());
......@@ -1297,7 +1312,6 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
iIdxBizJgSupervisionInfoService.saveBatch(supervisionInfoList);
idxBizJgInspectionDetectionInfoService.saveBatch(inspectionDetectionInfoList);
iIdxBizJgTechParamsPipelineService.saveBatch(paramsPipelineList);
esEquipmentCategory.saveAll(esEquipmentCategoryList);
jgReformNoticeEqService.saveBatch(noticeEqs);
}
......@@ -1378,6 +1392,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
@Override
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
@EnableEsRollback
public JgReformNotice cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgReformNotice reformNotice = this.getById(sequenceNbr);
......@@ -1443,6 +1458,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
if (!EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode())) {
return;
}
List<ESEquipmentCategoryDto> saveEsList = Lists.newArrayList();
List<ESEquipmentCategoryDto> deleteEsList = Lists.newArrayList();
JgRegistrationHistory registrationHistory = jgRegistrationHistoryMapper.selectOne(new LambdaQueryWrapper<JgRegistrationHistory>().eq(JgRegistrationHistory::getCurrentDocumentId, notice.getSequenceNbr()));
JSONObject newData = Optional.ofNullable(JSONObject.parseObject(registrationHistory.getChangeData())).orElse(new JSONObject());
JSONArray alreadyDelPipData = Optional.ofNullable(JSONArray.parseArray(newData.getString(DEL_DEVICE_LIST))).orElse(new JSONArray());
......@@ -1453,13 +1470,19 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
List<String> nowPipDataRecords = idxBizJgProjectContraptionMapper.selectEquipList(notice.getProjectContraptionId()).stream().map(item -> String.valueOf(item.get("record"))).collect(Collectors.toList());
List<JSONObject> toAddPipData = alreadyDelPipData.stream().map(item -> JSON.parseObject(item.toString())).collect(Collectors.toList());
List<String> toDeletePipRecords = nowPipDataRecords.stream().filter(item -> !oldPipDataRecords.contains(item)).collect(Collectors.toList());
this.addPipDataWithFlowPass(toAddPipData, notice);
this.delPipDataWithFlowPass(toDeletePipRecords);
this.addPipDataWithFlowPass(toAddPipData, notice, saveEsList);
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<IdxBizJgProjectContraption>()
.eq(IdxBizJgProjectContraption::getSequenceNbr, notice.getProjectContraptionId())
.set(IdxBizJgProjectContraption::getPipelineLength, oldPipLength)
.set(IdxBizJgProjectContraption::getPipeLengthChanged, 0);
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
this.delPipDataWithFlowPass(toDeletePipRecords, deleteEsList);
if (!ValidationUtil.isEmpty(saveEsList)) {
esEquipmentCategory.saveAllWithFallback(saveEsList);
}
if (!ValidationUtil.isEmpty(deleteEsList)) {
esEquipmentCategory.deleteAllWithFallback(deleteEsList);
}
}
private void finishedTask(JgReformNotice reformNotice) {
......@@ -1482,10 +1505,6 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
*/
private void recordHistoryWhenVoided(JgReformNotice reformNotice) {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(this.queryBySequenceNbr(reformNotice.getSequenceNbr())));
// List<String> equList = getEquList(reformNotice);
// Iterable<ESEquipmentCategoryDto> esEquipmentCategoryDtos = esEquipmentCategory.findAllById(equList);
// List<Map<String, Object>> deviceList = getEquipListMaps(esEquipmentCategoryDtos);
// jsonObject.put("deviceList", deviceList);
this.saveOrUpdateHisData(String.valueOf(reformNotice.getSequenceNbr()), jsonObject, null);
}
......
......@@ -574,7 +574,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
idxBizJgInspectionDetectionInfoService.save(inspectionDetectionInfo);
// 保存es
idxBizJgRegisterInfoService.checkEsData(equRecord);
idxBizJgRegisterInfoService.saveEsData(equRecord);
equRecords.add(equRecord);
// 更新 equList 中的元素
......
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