Commit b4eb682d authored by suhuiguang's avatar suhuiguang

feat(大编辑):管道增减功能开发

1.改造告知增加装置查询
parent f788f847
...@@ -6,5 +6,5 @@ import java.util.List; ...@@ -6,5 +6,5 @@ import java.util.List;
public interface DataBackupManager { public interface DataBackupManager {
void backup(String key); void backup(String key);
void restore(String key); Boolean restore(String key);
} }
...@@ -21,9 +21,9 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager { ...@@ -21,9 +21,9 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager {
handler.backup2Db(getBizType(), bizId, getRecords(bizId)); handler.backup2Db(getBizType(), bizId, getRecords(bizId));
} }
public void restore(String bizId) { public Boolean restore(String bizId) {
EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class); EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class);
handler.restoreFormBackup(getBizType(), bizId); return handler.restoreFormBackup(getBizType(), bizId);
} }
public void updateLastOne(String bizId, List<FieldChangeMeta> changeMetas) { public void updateLastOne(String bizId, List<FieldChangeMeta> changeMetas) {
...@@ -39,7 +39,7 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager { ...@@ -39,7 +39,7 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager {
public List<IdxBizJgPipelineOperationHist> listAll(String bizId){ public List<IdxBizJgPipelineOperationHist> listAll(String bizId){
EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class); EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class);
return handler.listBackup(getBizType(), bizId); return handler.listAllBackupOfOneBizId(getBizType(), bizId);
} }
public abstract List<String> getRecords(String bizId); public abstract List<String> getRecords(String bizId);
......
package com.yeejoin.amos.boot.module.jg.biz.edit.backup;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Component
@RequiredArgsConstructor
public class TechParamsBackupService {
private final IIdxBizJgTechParamsElevatorService iIdxBizJgTechParamsElevatorService;
private final IIdxBizJgTechParamsVehicleService iIdxBizJgTechParamsVehicleService;
private final IIdxBizJgTechParamsRopewayService iIdxBizJgTechParamsRopewayService;
private final IIdxBizJgTechParamsRidesService iIdxBizJgTechParamsRidesService;
private final IIdxBizJgTechParamsBoilerService iIdxBizJgTechParamsBoilerService;
private final IIdxBizJgTechParamsVesselService iIdxBizJgTechParamsVesselService;
private final IIdxBizJgTechParamsPipelineService iIdxBizJgTechParamsPipelineService;
private final IIdxBizJgTechParamsLiftingService iIdxBizJgTechParamsLiftingService;
public Object getTechParams(String equList, String record) {
EquipmentClassifityEnum equipmentClassifityEnum = EquipmentClassifityEnum.getOne(equList);
switch (Objects.requireNonNull(equipmentClassifityEnum)) {
case GL:
// 锅炉
return iIdxBizJgTechParamsBoilerService.getOneData(record);
case YLRQ:
// 压力容器
return iIdxBizJgTechParamsVesselService.getOneData(record);
case DT:
// 电梯
return iIdxBizJgTechParamsElevatorService.getOneData(record);
case QZJX:
// 起重机械
return iIdxBizJgTechParamsLiftingService.getOneData(record);
case CC:
// 场(厂)内专用机动车辆
return iIdxBizJgTechParamsVehicleService.getOneData(record);
case YLSS:
// 大型游乐设施
return iIdxBizJgTechParamsRidesService.getOneData(record);
case YLGD:
// 压力管道
return iIdxBizJgTechParamsPipelineService.getOneData(record);
case KYSD:
// 客运索道
return iIdxBizJgTechParamsRopewayService.getOneData(record);
default:
break;
}
return null;
}
public void save(String equList, String json) {
EquipmentClassifityEnum equipmentClassifityEnum = EquipmentClassifityEnum.getOne(equList);
switch (Objects.requireNonNull(equipmentClassifityEnum)) {
case GL:
// 锅炉
IdxBizJgTechParamsBoiler bizJgTechParamsBoiler = JSONObject.parseObject(json, IdxBizJgTechParamsBoiler.class);
iIdxBizJgTechParamsBoilerService.save(bizJgTechParamsBoiler);
case YLRQ:
// 压力容器
IdxBizJgTechParamsVessel techParamsVessel = JSONObject.parseObject(json, IdxBizJgTechParamsVessel.class);
iIdxBizJgTechParamsVesselService.save(techParamsVessel);
case DT:
// 电梯
IdxBizJgTechParamsElevator techParamsElevator = JSONObject.parseObject(json, IdxBizJgTechParamsElevator.class);
iIdxBizJgTechParamsElevatorService.save(techParamsElevator);
case QZJX:
// 起重机械
IdxBizJgTechParamsLifting jgTechParamsLifting = JSONObject.parseObject(json, IdxBizJgTechParamsLifting.class);
iIdxBizJgTechParamsLiftingService.save(jgTechParamsLifting);
case CC:
// 场(厂)内专用机动车辆
IdxBizJgTechParamsVehicle techParamsVehicle = JSONObject.parseObject(json, IdxBizJgTechParamsVehicle.class);
iIdxBizJgTechParamsVehicleService.save(techParamsVehicle);
case YLSS:
// 大型游乐设施
IdxBizJgTechParamsRides techParamsRides = JSONObject.parseObject(json, IdxBizJgTechParamsRides.class);
iIdxBizJgTechParamsRidesService.save(techParamsRides);
case YLGD:
// 压力管道
IdxBizJgTechParamsPipeline techParamsPipeline = JSONObject.parseObject(json, IdxBizJgTechParamsPipeline.class);
iIdxBizJgTechParamsPipelineService.save(techParamsPipeline);
case KYSD:
// 客运索道
IdxBizJgTechParamsRopeway techParamsRopeway = JSONObject.parseObject(json, IdxBizJgTechParamsRopeway.class);
iIdxBizJgTechParamsRopewayService.save(techParamsRopeway);
default:
break;
}
}
}
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.BizRelationDataDto; import com.yeejoin.amos.boot.module.jg.api.dto.BizRelationDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta; import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.dto.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipDataProcessStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipDataProcessStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.controller.BizDataChangeController; import com.yeejoin.amos.boot.module.jg.biz.controller.BizDataChangeController;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.IEventPublisher; import com.yeejoin.amos.boot.module.jg.biz.edit.core.IEventPublisher;
...@@ -45,7 +46,7 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEve ...@@ -45,7 +46,7 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEve
changeData.remove("changeReason"); changeData.remove("changeReason");
changeData.remove("changeAttachment"); changeData.remove("changeAttachment");
IEquipChangeDataProcessStrategy dataProcessor = EquipDataProcessStrategyContext.getStrategy(model); IEquipChangeDataProcessStrategy dataProcessor = EquipDataProcessStrategyContext.getStrategy(model);
List<FieldChangeMeta> allChangeColumns = dataProcessor.handle(changeData, bizId); List<FieldChangeMeta> allChangeColumns = dataProcessor.handle(changeData, bizId, this::callBack);
List<FieldChangeMeta> bizEditColumns = postSave(bizId, applyNo, model, changeData, allChangeColumns); List<FieldChangeMeta> bizEditColumns = postSave(bizId, applyNo, model, changeData, allChangeColumns);
allChangeColumns.addAll(bizEditColumns); allChangeColumns.addAll(bizEditColumns);
// 发送数据变更消息 // 发送数据变更消息
...@@ -53,6 +54,9 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEve ...@@ -53,6 +54,9 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEve
} }
} }
private void callBack(Map<String, List<PipelineChangeItemDto>> stringListMap) {
}
public abstract void preSave(String bizId, String applyNo, ModelType model, Map<String, Object> changeData); public abstract void preSave(String bizId, String applyNo, ModelType model, Map<String, Object> changeData);
private void publish2OtherBiz(List<FieldChangeMeta> allChangeColumns, String applyNo, JSONObject oData, ReginParams selectedOrgInfo) { private void publish2OtherBiz(List<FieldChangeMeta> allChangeColumns, String applyNo, JSONObject oData, ReginParams selectedOrgInfo) {
......
...@@ -7,6 +7,8 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; ...@@ -7,6 +7,8 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity; import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant; import com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta; import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.dto.PieLineDesignChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.DefaultBizDataChangeHandler; import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy;
...@@ -20,6 +22,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -20,6 +22,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer;
/** /**
* 单个维护设备-策略实现类 * 单个维护设备-策略实现类
...@@ -32,7 +35,7 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy ...@@ -32,7 +35,7 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
private final CommonEquipDataProcessService commonEquipDataProcessService; private final CommonEquipDataProcessService commonEquipDataProcessService;
@Override @Override
public List<FieldChangeMeta> handle(Map<String, Object> changeData, String record) { public List<FieldChangeMeta> handle(Map<String, Object> changeData, String record, Consumer<Map<String, List<PipelineChangeItemDto>>> callBack) {
JSONObject changeJson = new JSONObject(changeData); JSONObject changeJson = new JSONObject(changeData);
List<FieldChangeMeta> allChangeColumns = new ArrayList<>(); List<FieldChangeMeta> allChangeColumns = new ArrayList<>();
......
...@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component; ...@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
/** /**
* 单个装置维护-策略实现类 * 单个装置维护-策略实现类
...@@ -33,7 +34,7 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS ...@@ -33,7 +34,7 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
@Override @Override
public List<FieldChangeMeta> handle(Map<String, Object> changeData, String projectContraptionId) { public List<FieldChangeMeta> handle(Map<String, Object> changeData, String projectContraptionId, Consumer<Map<String, List<PipelineChangeItemDto>>> callBack) {
JSONObject data = (JSONObject) changeData; JSONObject data = (JSONObject) changeData;
// 新增编辑的管道------------------tableData // 新增编辑的管道------------------tableData
JSONArray insertOrEditPieLines = data.getJSONArray(RequestChangeData.multiDataKey); JSONArray insertOrEditPieLines = data.getJSONArray(RequestChangeData.multiDataKey);
......
package com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy; package com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta; import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.api.dto.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer;
/** /**
* 处理监策略类 * 处理监策略类
...@@ -21,5 +23,6 @@ public interface IEquipChangeDataProcessStrategy { ...@@ -21,5 +23,6 @@ public interface IEquipChangeDataProcessStrategy {
/** /**
* 处理 * 处理
*/ */
List<FieldChangeMeta> handle(Map<String, Object> changeData, String defaultChangeId); List<FieldChangeMeta> handle(Map<String, Object> changeData, String defaultChangeId, Consumer<Map<String, List<PipelineChangeItemDto>>> callBack);
} }
...@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; ...@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; 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.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser; import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.changeRegistrationReform.ChangeRegisterReformBackupManager;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; 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.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
...@@ -183,6 +184,11 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -183,6 +184,11 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
@Autowired @Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryServiceImpl; private JgRegistrationHistoryServiceImpl jgRegistrationHistoryServiceImpl;
@Autowired
private ChangeRegisterReformBackupManager backupManager;
@Autowired
private IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineServiceImpl;
/*** /***
* @deprecated 根据查询调教获取分页对象 * @deprecated 根据查询调教获取分页对象
* @param dto 查询的dto对象 * @param dto 查询的dto对象
...@@ -1480,8 +1486,30 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -1480,8 +1486,30 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
iCmWorkflowService.stopProcess(jgChangeRegistrationReform.getInstanceId(), jgChangeRegistrationReform.getCancelReason()); iCmWorkflowService.stopProcess(jgChangeRegistrationReform.getInstanceId(), jgChangeRegistrationReform.getCancelReason());
// 3.清空redis(缓存的流程中的设备) // 3.清空redis(缓存的流程中的设备)
this.clearDataForCheckEquipRepeatUsed2(jgChangeRegistrationReform); this.clearDataForCheckEquipRepeatUsed2(jgChangeRegistrationReform);
if(jgChangeRegistrationReform.getProjectContraptionId()!=null){
// 编辑过则按照编辑的数据进行恢复管道信息
Boolean isRollBack = backupManager.restore(jgChangeRegistrationReform.getSequenceNbr() + "");
if(isRollBack){ // 进行过编辑逻辑
// 1.原装置、新装置重新计算管道长度
this.updateTotalPieLineLength(jgChangeRegistrationReform.getProjectContraptionId());
}
} }
} }
}
private void updateTotalPieLineLength(String pid) {
List<String> records = idxBizJgUseInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().in(IdxBizJgUseInfo::getProjectContraptionId, pid)).stream().map(IdxBizJgUseInfo::getRecord).collect(toList());
List<IdxBizJgTechParamsPipeline> paramsPipelines = idxBizJgTechParamsPipelineServiceImpl.list(new LambdaQueryWrapper<IdxBizJgTechParamsPipeline>().in(IdxBizJgTechParamsPipeline::getRecord, records).select(IdxBizJgTechParamsPipeline::getRecord,IdxBizJgTechParamsPipeline::getPipeLength));
double totalLength = paramsPipelines.stream()
.map(IdxBizJgTechParamsPipeline::getPipeLength) // 先提取长度字符串
.filter(Objects::nonNull) // 过滤掉null值
.mapToDouble(Double::parseDouble) // 解析字符串为double并转为DoubleStream
.sum();
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, totalLength);
updateWrapper.eq(BaseEntity::getSequenceNbr, pid);
jgProjectContraptionService.update(updateWrapper);
}
private void finishedTask(JgChangeRegistrationReform jgChangeRegistrationReform) { private void finishedTask(JgChangeRegistrationReform jgChangeRegistrationReform) {
HashMap<String, Object> taskMap = new HashMap<>(); HashMap<String, Object> taskMap = new HashMap<>();
......
...@@ -41,6 +41,7 @@ import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; ...@@ -41,6 +41,7 @@ import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; 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.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser; import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister.UseRegisterBackupManager;
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.event.publisher.EventPublisher; 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.feign.TzsServiceFeignClient;
...@@ -249,6 +250,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -249,6 +250,11 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired @Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl inspectionDetectionInfoService; private IdxBizJgInspectionDetectionInfoServiceImpl inspectionDetectionInfoService;
@Autowired
private UseRegisterBackupManager useRegisterBackupManager;
@Autowired
private IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineServiceImpl;
/** /**
* @param auditPassDate 通过时间 * @param auditPassDate 通过时间
...@@ -3121,6 +3127,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -3121,6 +3127,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if ("unit".equals(jgUseRegistration.getManageType())){ if ("unit".equals(jgUseRegistration.getManageType())){
//单位办理-历史作废 //单位办理-历史作废
if ("1".equals(jgUseRegistration.getRegType())){ if ("1".equals(jgUseRegistration.getRegType())){
// 管道增减特殊作废逻辑,管道全量数据为装置下的所有管道(已完成时,编辑装置进行增减不会修改eq表,所以eq表不是全量管道)
if(!ValidationUtil.isEmpty(jgUseRegistration.getProjectContraptionId())){
records = idxBizJgUseInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, jgUseRegistration.getProjectContraptionId())).stream().map(IdxBizJgUseInfo::getRecord).collect(toList());
}
// 构建设备删除的 DTO 列表 // 构建设备删除的 DTO 列表
List<ESEquipmentCategoryDto> esDtoList = records.stream().map(v -> { List<ESEquipmentCategoryDto> esDtoList = records.stream().map(v -> {
ESEquipmentCategoryDto esDto = new ESEquipmentCategoryDto(); ESEquipmentCategoryDto esDto = new ESEquipmentCategoryDto();
...@@ -3161,6 +3171,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -3161,6 +3171,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (jgUseRegistration.getProjectContraptionId() != null) { if (jgUseRegistration.getProjectContraptionId() != null) {
//2.合并后作废 //2.合并后作废
if (!jgUseRegistration.getOriginProjectContraptionIds().contains(jgUseRegistration.getProjectContraptionId())){ if (!jgUseRegistration.getOriginProjectContraptionIds().contains(jgUseRegistration.getProjectContraptionId())){
Boolean isRollBack = useRegisterBackupManager.restore(jgUseRegistration.getSequenceNbr() + "");
if(isRollBack){ // 进行过编辑逻辑
// 1.根据工程装置ID查询工程装置父级,重置子工程装置父级为空
jgProjectContraptionService.update(
new LambdaUpdateWrapper<IdxBizJgProjectContraption>()
.in(BaseEntity::getSequenceNbr, Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(",")))
.set(IdxBizJgProjectContraption::getProjectContraptionParentId, null)
);
// 2.原装置、新装置重新计算管道长度
this.updateTotalPieLineLength(jgUseRegistration.getOriginProjectContraptionIds(), jgUseRegistration.getProjectContraptionId());
} else { // 为进行过编辑逻辑,走原来逻辑
eqList.stream() eqList.stream()
.filter(v -> jgUseRegistration.getOriginProjectContraptionIds().contains(v.getOriginProjectContraptionId())) .filter(v -> jgUseRegistration.getOriginProjectContraptionIds().contains(v.getOriginProjectContraptionId()))
.forEach(v -> esEquipmentCategory.findById(v.getEquId()).ifPresent(equInfoEs -> { .forEach(v -> esEquipmentCategory.findById(v.getEquId()).ifPresent(equInfoEs -> {
...@@ -3243,8 +3264,15 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -3243,8 +3264,15 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jgProjectContraptionService.updateById(projectContraption); jgProjectContraptionService.updateById(projectContraption);
} }
} }
}
//1.子工程装置作废,正常逻辑 //1.子工程装置作废,正常逻辑
else { else {
// 编辑过则按照编辑的数据进行恢复管道信息
Boolean isRollBack = useRegisterBackupManager.restore(jgUseRegistration.getSequenceNbr() + "");
if(isRollBack){ // 进行过编辑逻辑
// 1.原装置、新装置重新计算管道长度
this.updateTotalPieLineLength(null, jgUseRegistration.getProjectContraptionId());
}
// 统一处理设备的纳管状态【注册事务提交后的操作】 // 统一处理设备的纳管状态【注册事务提交后的操作】
processElseDataByStatus(oldStatus, jgUseRegistration); processElseDataByStatus(oldStatus, jgUseRegistration);
this.rollBackForPieLine(jgUseRegistration); this.rollBackForPieLine(jgUseRegistration);
...@@ -3271,6 +3299,25 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -3271,6 +3299,25 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return jgUseRegistration; return jgUseRegistration;
} }
private void updateTotalPieLineLength(String originProjectContraptionIds, String projectContraptionId) {
String[] oPids = originProjectContraptionIds != null ? originProjectContraptionIds.split(",") : null;
Set<String> pIds = new HashSet<>(Arrays.asList(oPids));
pIds.add(projectContraptionId);
pIds.parallelStream().forEach(pid->{
List<String> records = idxBizJgUseInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().in(IdxBizJgUseInfo::getProjectContraptionId, pid)).stream().map(IdxBizJgUseInfo::getRecord).collect(toList());
List<IdxBizJgTechParamsPipeline> paramsPipelines = idxBizJgTechParamsPipelineServiceImpl.list(new LambdaQueryWrapper<IdxBizJgTechParamsPipeline>().in(IdxBizJgTechParamsPipeline::getRecord, records).select(IdxBizJgTechParamsPipeline::getRecord,IdxBizJgTechParamsPipeline::getPipeLength));
double totalLength = paramsPipelines.stream()
.map(IdxBizJgTechParamsPipeline::getPipeLength) // 先提取长度字符串
.filter(Objects::nonNull) // 过滤掉null值
.mapToDouble(Double::parseDouble) // 解析字符串为double并转为DoubleStream
.sum();
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, totalLength);
updateWrapper.eq(BaseEntity::getSequenceNbr, pid);
jgProjectContraptionService.update(updateWrapper);
});
}
/** /**
* 注册事务提交后的同步操作 * 注册事务提交后的同步操作
*/ */
......
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