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);
......
...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; ...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.entity.IdxBizJgPipelineOperationHist; import com.yeejoin.amos.boot.module.jg.api.entity.IdxBizJgPipelineOperationHist;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.*; import com.yeejoin.amos.boot.module.jg.biz.service.impl.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -25,7 +26,22 @@ public class EquipBackupHandler { ...@@ -25,7 +26,22 @@ public class EquipBackupHandler {
private final IdxBizJgRegisterInfoServiceImpl registerInfoService; private final IdxBizJgRegisterInfoServiceImpl registerInfoService;
private final IdxBizJgSupervisionInfoServiceImpl supervisionInfoService; private final IdxBizJgSupervisionInfoServiceImpl supervisionInfoService;
private final IdxBizJgFactoryInfoServiceImpl factoryInfoService; private final IdxBizJgFactoryInfoServiceImpl factoryInfoService;
private final IdxBizJgConstructionInfoServiceImpl constructionInfoService;
private final IdxBizJgInspectionDetectionInfoServiceImpl inspectionDetectionInfoService;
private final ESEquipmentCategory equipmentCategory; private final ESEquipmentCategory equipmentCategory;
private final TechParamsBackupService techParamsBackupService;
private final SuperviseInfoMapper superviseInfoMapper;
private final static String BACKUP_JSON_KEY_OTHER_INFO = "otherInfo";
private final static String BACKUP_JSON_KEY_USE_INFO = "useInfo";
private final static String BACKUP_JSON_KEY_REGISTER_INFO = "registerInfo";
private final static String BACKUP_JSON_KEY_SUPERVISION_INFO = "supervisionInfo";
private final static String BACKUP_JSON_KEY_FACTORY_INFO = "factoryInfo";
private final static String BACKUP_JSON_KEY_CONSTRUCTION_INFO = "constructionInfoList";
private final static String BACKUP_JSON_KEY_INSPECTION_DETECTION_INFO = "inspectionDetectionInfoList";
private final static String BACKUP_JSON_KEY_INSPECTION_ES_INFO = "esInfo";
private final static String BACKUP_JSON_KEY_TECH_PARAM_INFO = "techParamInfo";
public void backup2Db(String bizType, String bizId, List<String> records) { public void backup2Db(String bizType, String bizId, List<String> records) {
IdxBizJgPipelineOperationHist deleteHistory = pipelineDeleteHistoryService.getOne(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>().eq(IdxBizJgPipelineOperationHist::getBizType, bizType).eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByDesc(IdxBizJgPipelineOperationHist::getVersion).last("limit 1")); IdxBizJgPipelineOperationHist deleteHistory = pipelineDeleteHistoryService.getOne(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>().eq(IdxBizJgPipelineOperationHist::getBizType, bizType).eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByDesc(IdxBizJgPipelineOperationHist::getVersion).last("limit 1"));
...@@ -56,49 +72,91 @@ public class EquipBackupHandler { ...@@ -56,49 +72,91 @@ public class EquipBackupHandler {
private String buildDeleteData(List<String> records) { private String buildDeleteData(List<String> records) {
List<Map<String, Object>> data = records.stream().map(record -> { List<Map<String, Object>> data = records.stream().map(record -> {
IdxBizJgRegisterInfo registerInfo = registerInfoService.getOneData(record);
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
item.put("otherInfo", otherInfoService.getOneData(record)); item.put(BACKUP_JSON_KEY_OTHER_INFO, otherInfoService.getOneData(record));
item.put("registerInfo", registerInfoService.getOneData(record)); item.put(BACKUP_JSON_KEY_REGISTER_INFO, registerInfo);
item.put("supervisionInfo", supervisionInfoService.getOneData(record)); item.put(BACKUP_JSON_KEY_SUPERVISION_INFO, supervisionInfoService.getOneData(record));
item.put("factoryInfo", factoryInfoService.getOneData(record)); item.put(BACKUP_JSON_KEY_FACTORY_INFO, factoryInfoService.getOneData(record));
item.put("useInfo", useInfoService.getOneData(record)); item.put(BACKUP_JSON_KEY_USE_INFO, useInfoService.getOneData(record));
// 技术参数
item.put(BACKUP_JSON_KEY_TECH_PARAM_INFO, this.getTechParamByEquListAndRecord(registerInfo.getEquList(), record));
// 检验流水数组
item.put(BACKUP_JSON_KEY_INSPECTION_DETECTION_INFO, this.getInspectList(record));
// 施工流水
item.put(BACKUP_JSON_KEY_CONSTRUCTION_INFO, this.getConstructionList(record));
Optional<ESEquipmentCategoryDto> op = equipmentCategory.findById(record); Optional<ESEquipmentCategoryDto> op = equipmentCategory.findById(record);
op.ifPresent(e -> item.put("esInfo", e)); op.ifPresent(e -> item.put(BACKUP_JSON_KEY_INSPECTION_ES_INFO, e));
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return JSONObject.toJSONString(data); return JSONObject.toJSONString(data);
} }
private List<IdxBizJgConstructionInfo> getConstructionList(String record) {
return constructionInfoService.list(new LambdaQueryWrapper<IdxBizJgConstructionInfo>().eq(IdxBizJgConstructionInfo::getRecord, record));
}
private List<IdxBizJgInspectionDetectionInfo> getInspectList(String record) {
return inspectionDetectionInfoService.list(new LambdaQueryWrapper<IdxBizJgInspectionDetectionInfo>().eq(IdxBizJgInspectionDetectionInfo::getRecord, record));
}
private Object getTechParamByEquListAndRecord(String equList, String record) {
return techParamsBackupService.getTechParams(equList, record);
}
/** /**
* 在最小版本中恢复数据 * 在最小版本中恢复数据
* *
* @param bizType 业务类型 * @param bizType 业务类型
* @param bizId 业务唯一标识 * @param bizId 业务唯一标识
* @return 是否存在编辑记录-存在则恢复
*/ */
public void restoreFormBackup(String bizType, String bizId) { public Boolean restoreFormBackup(String bizType, String bizId) {
List<IdxBizJgPipelineOperationHist> opHisList = pipelineDeleteHistoryService.list(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>() List<IdxBizJgPipelineOperationHist> opHisList = pipelineDeleteHistoryService.list(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>()
.eq(IdxBizJgPipelineOperationHist::getBizType, bizType) .eq(IdxBizJgPipelineOperationHist::getBizType, bizType)
.eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByAsc(IdxBizJgPipelineOperationHist::getVersion)); .eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByAsc(IdxBizJgPipelineOperationHist::getVersion));
if (!opHisList.isEmpty()) { if (!opHisList.isEmpty()) {
IdxBizJgPipelineOperationHist deleteHistory = opHisList.get(0); // 按照最小的版本恢复数据
Optional.ofNullable(deleteHistory.getOData()).ifPresent(oData -> { IdxBizJgPipelineOperationHist operationHist = opHisList.get(0);
List<JSONObject> deleteEqs = JSONObject.parseArray(deleteHistory.getOData(), JSONObject.class); Optional.ofNullable(operationHist.getOData()).ifPresent(oData -> {
List<JSONObject> deleteEqs = JSONObject.parseArray(operationHist.getOData(), JSONObject.class);
deleteEqs.forEach(eq -> { deleteEqs.forEach(eq -> {
IdxBizJgOtherInfo otherInfo = JSONObject.parseObject(eq.getString("otherInfo"), IdxBizJgOtherInfo.class); IdxBizJgOtherInfo otherInfo = JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_OTHER_INFO), IdxBizJgOtherInfo.class);
IdxBizJgRegisterInfo registerInfo = JSONObject.parseObject(eq.getString("registerInfo"), IdxBizJgRegisterInfo.class); IdxBizJgRegisterInfo registerInfo = JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_REGISTER_INFO), IdxBizJgRegisterInfo.class);
IdxBizJgSupervisionInfo supervisionInfo = JSONObject.parseObject(eq.getString("supervisionInfo"), IdxBizJgSupervisionInfo.class); IdxBizJgSupervisionInfo supervisionInfo = JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_SUPERVISION_INFO), IdxBizJgSupervisionInfo.class);
IdxBizJgFactoryInfo factoryInfo = JSONObject.parseObject(eq.getString("factoryInfo"), IdxBizJgFactoryInfo.class); IdxBizJgFactoryInfo factoryInfo = JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_FACTORY_INFO), IdxBizJgFactoryInfo.class);
IdxBizJgUseInfo useInfo = JSONObject.parseObject(eq.getString("useInfo"), IdxBizJgUseInfo.class); IdxBizJgUseInfo useInfo = JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_USE_INFO), IdxBizJgUseInfo.class);
otherInfoService.save(otherInfo); otherInfoService.save(otherInfo);
registerInfoService.save(registerInfo); registerInfoService.save(registerInfo);
supervisionInfoService.save(supervisionInfo); supervisionInfoService.save(supervisionInfo);
factoryInfoService.save(factoryInfo); factoryInfoService.save(factoryInfo);
useInfoService.save(useInfo); useInfoService.save(useInfo);
equipmentCategory.save(JSONObject.parseObject(eq.getString("esInfo"), ESEquipmentCategoryDto.class)); // 检验流水
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_INSPECTION_DETECTION_INFO), IdxBizJgInspectionDetectionInfo.class);
if (!inspectionDetectionInfos.isEmpty()) {
inspectionDetectionInfoService.saveBatch(inspectionDetectionInfos);
}
// 施工流水
List<IdxBizJgConstructionInfo> constructionInfoList = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_CONSTRUCTION_INFO), IdxBizJgConstructionInfo.class);
if (!constructionInfoList.isEmpty()) {
constructionInfoService.saveBatch(constructionInfoList);
}
// 技术参数
techParamsBackupService.save(registerInfo.getEquList(), eq.getString(BACKUP_JSON_KEY_TECH_PARAM_INFO));
// 设备es数据
equipmentCategory.save(JSONObject.parseObject(eq.getString(BACKUP_JSON_KEY_INSPECTION_ES_INFO), ESEquipmentCategoryDto.class));
}); });
}); });
// insert的删除
List<String> insertIds = opHisList.stream().flatMap(o -> o.getInsertPipelines().stream()).collect(Collectors.toList());
insertIds.remove(null);
insertIds.remove("");
if (!insertIds.isEmpty()) {
superviseInfoMapper.deleteDataAll(insertIds);
}
} }
return !opHisList.isEmpty();
} }
public void updateOperateRecords(String bizId, String bizType, List<String> insertRecord, List<String> deleteRecords) { public void updateOperateRecords(String bizId, String bizType, List<String> insertRecord, List<String> deleteRecords) {
...@@ -110,7 +168,7 @@ public class EquipBackupHandler { ...@@ -110,7 +168,7 @@ public class EquipBackupHandler {
} }
} }
public List<IdxBizJgPipelineOperationHist> listBackup(String bizType, String bizId) { public List<IdxBizJgPipelineOperationHist> listAllBackupOfOneBizId(String bizType, String bizId) {
return pipelineDeleteHistoryService.list(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>() return pipelineDeleteHistoryService.list(new LambdaQueryWrapper<IdxBizJgPipelineOperationHist>()
.eq(IdxBizJgPipelineOperationHist::getBizType, bizType) .eq(IdxBizJgPipelineOperationHist::getBizType, bizType)
.eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByAsc(IdxBizJgPipelineOperationHist::getVersion)); .eq(IdxBizJgPipelineOperationHist::getBizId, bizId).orderByAsc(IdxBizJgPipelineOperationHist::getVersion));
......
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,9 +1486,31 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -1480,9 +1486,31 @@ 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<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
......
...@@ -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,90 +3171,108 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -3161,90 +3171,108 @@ 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())){
eqList.stream() Boolean isRollBack = useRegisterBackupManager.restore(jgUseRegistration.getSequenceNbr() + "");
.filter(v -> jgUseRegistration.getOriginProjectContraptionIds().contains(v.getOriginProjectContraptionId())) if(isRollBack){ // 进行过编辑逻辑
.forEach(v -> esEquipmentCategory.findById(v.getEquId()).ifPresent(equInfoEs -> { // 1.根据工程装置ID查询工程装置父级,重置子工程装置父级为空
equInfoEs.setProjectContraptionId(v.getOriginProjectContraptionId()); jgProjectContraptionService.update(
esEquipmentCategory.save(equInfoEs); new LambdaUpdateWrapper<IdxBizJgProjectContraption>()
.in(BaseEntity::getSequenceNbr, Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(",")))
LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda(); .set(IdxBizJgProjectContraption::getProjectContraptionParentId, null)
lambda.eq(IdxBizJgUseInfo::getRecord, String.valueOf(v.getEquId())); );
IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(lambda); // 2.原装置、新装置重新计算管道长度
useInfo.setProjectContraptionId(v.getOriginProjectContraptionId()); this.updateTotalPieLineLength(jgUseRegistration.getOriginProjectContraptionIds(), jgUseRegistration.getProjectContraptionId());
useInfoMapper.updateById(useInfo); } else { // 为进行过编辑逻辑,走原来逻辑
eqList.stream()
IdxBizJgProjectContraption originProjectContraption = jgProjectContraptionService.getById(v.getOriginProjectContraptionId()); .filter(v -> jgUseRegistration.getOriginProjectContraptionIds().contains(v.getOriginProjectContraptionId()))
//还原 原工程装置下equCode和监管码 .forEach(v -> esEquipmentCategory.findById(v.getEquId()).ifPresent(equInfoEs -> {
LambdaUpdateWrapper<IdxBizJgRegisterInfo> updateWrapper = new UpdateWrapper<IdxBizJgRegisterInfo>().lambda() equInfoEs.setProjectContraptionId(v.getOriginProjectContraptionId());
.eq(IdxBizJgRegisterInfo::getRecord, v.getEquId()); esEquipmentCategory.save(equInfoEs);
IdxBizJgRegisterInfo idxBizJgRegisterInfo = new IdxBizJgRegisterInfo();
idxBizJgRegisterInfo.setEquCode(originProjectContraption.getEquCode()); LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda();
idxBizJgRegisterInfoMapper.update(idxBizJgRegisterInfo, updateWrapper); lambda.eq(IdxBizJgUseInfo::getRecord, String.valueOf(v.getEquId()));
IdxBizJgUseInfo useInfo = useInfoMapper.selectOne(lambda);
LambdaUpdateWrapper<IdxBizJgOtherInfo> otherInfoLambdaUpdateWrapper = new UpdateWrapper<IdxBizJgOtherInfo>().lambda() useInfo.setProjectContraptionId(v.getOriginProjectContraptionId());
.eq(IdxBizJgOtherInfo::getRecord, v.getEquId()); useInfoMapper.updateById(useInfo);
IdxBizJgOtherInfo idxBizJgOtherInfo = new IdxBizJgOtherInfo();
idxBizJgOtherInfo.setSupervisoryCode(originProjectContraption.getSupervisoryCode()); IdxBizJgProjectContraption originProjectContraption = jgProjectContraptionService.getById(v.getOriginProjectContraptionId());
otherInfoMapper.update(idxBizJgOtherInfo, otherInfoLambdaUpdateWrapper); //还原 原工程装置下equCode和监管码
})); LambdaUpdateWrapper<IdxBizJgRegisterInfo> updateWrapper = new UpdateWrapper<IdxBizJgRegisterInfo>().lambda()
//2.根据工程装置ID查询工程装置父级,重置子工程装置父级为空 .eq(IdxBizJgRegisterInfo::getRecord, v.getEquId());
jgProjectContraptionService.update( IdxBizJgRegisterInfo idxBizJgRegisterInfo = new IdxBizJgRegisterInfo();
new LambdaUpdateWrapper<IdxBizJgProjectContraption>() idxBizJgRegisterInfo.setEquCode(originProjectContraption.getEquCode());
.in(BaseEntity::getSequenceNbr, Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(","))) idxBizJgRegisterInfoMapper.update(idxBizJgRegisterInfo, updateWrapper);
.set(IdxBizJgProjectContraption::getProjectContraptionParentId, null)
); LambdaUpdateWrapper<IdxBizJgOtherInfo> otherInfoLambdaUpdateWrapper = new UpdateWrapper<IdxBizJgOtherInfo>().lambda()
JgRegistrationHistory history = jgRegistrationHistoryService.queryLatestRegistrationHistory(Long.valueOf(jgUseRegistration.getProjectContraptionId())); .eq(IdxBizJgOtherInfo::getRecord, v.getEquId());
if (history != null && history.getChangeData() != null) { IdxBizJgOtherInfo idxBizJgOtherInfo = new IdxBizJgOtherInfo();
JSONObject hisJson = JSON.parseObject(history.getChangeData()); idxBizJgOtherInfo.setSupervisoryCode(originProjectContraption.getSupervisoryCode());
boolean isFirstMerge = Optional.ofNullable(hisJson.get("isFirstMerge")) otherInfoMapper.update(idxBizJgOtherInfo, otherInfoLambdaUpdateWrapper);
.map(Boolean.class::cast) }));
.orElse(false); //2.根据工程装置ID查询工程装置父级,重置子工程装置父级为空
//合并到无证总工程 jgProjectContraptionService.update(
IdxBizJgProjectContraption projectContraption = jgProjectContraptionService.getById(jgUseRegistration.getProjectContraptionId()); new LambdaUpdateWrapper<IdxBizJgProjectContraption>()
if (isFirstMerge) { .in(BaseEntity::getSequenceNbr, Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(",")))
projectContraption.setIsIntoManagement(false); .set(IdxBizJgProjectContraption::getProjectContraptionParentId, null)
projectContraption.setIsFirstMerge(true); );
projectContraption.setSupervisoryCode(null); JgRegistrationHistory history = jgRegistrationHistoryService.queryLatestRegistrationHistory(Long.valueOf(jgUseRegistration.getProjectContraptionId()));
projectContraption.setEquCode(null); if (history != null && history.getChangeData() != null) {
projectContraption.setUseRegistrationCode(null); JSONObject hisJson = JSON.parseObject(history.getChangeData());
projectContraption.setPipelineLength(0.0); boolean isFirstMerge = Optional.ofNullable(hisJson.get("isFirstMerge"))
// 处理非批量导入数据,更新关联业务状态 .map(Boolean.class::cast)
processElseDataByStatus(oldStatus, jgUseRegistration); .orElse(false);
// 统一处理设备的纳管状态【注册事务提交后的操作】 //合并到无证总工程
registerAfterCommitTask(records); IdxBizJgProjectContraption projectContraption = jgProjectContraptionService.getById(jgUseRegistration.getProjectContraptionId());
}else{ if (isFirstMerge) {
// 查询原工程装置及 useInfo 记录 projectContraption.setIsIntoManagement(false);
List<String> originProjectContraptionIds = Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(",")); projectContraption.setIsFirstMerge(true);
List<IdxBizJgProjectContraption> originProjectContraptionList = jgProjectContraptionService.lambdaQuery() projectContraption.setSupervisoryCode(null);
.in(BaseEntity::getSequenceNbr, originProjectContraptionIds) projectContraption.setEquCode(null);
.list(); projectContraption.setUseRegistrationCode(null);
projectContraption.setPipelineLength(0.0);
records = idxBizJgUseInfoService.lambdaQuery() // 处理非批量导入数据,更新关联业务状态
.select(IdxBizJgUseInfo::getRecord) processElseDataByStatus(oldStatus, jgUseRegistration);
.in(IdxBizJgUseInfo::getProjectContraptionId, originProjectContraptionIds) // 统一处理设备的纳管状态【注册事务提交后的操作】
.list() registerAfterCommitTask(records);
.stream() }else{
.map(IdxBizJgUseInfo::getRecord) // 查询原工程装置及 useInfo 记录
.collect(Collectors.toList()); List<String> originProjectContraptionIds = Arrays.asList(jgUseRegistration.getOriginProjectContraptionIds().split(","));
List<IdxBizJgProjectContraption> originProjectContraptionList = jgProjectContraptionService.lambdaQuery()
// 统一处理设备的纳管状态 .in(BaseEntity::getSequenceNbr, originProjectContraptionIds)
registerAfterCommitTask(records); .list();
processElseDataByStatus(oldStatus, jgUseRegistration);
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(oldStatus)) { records = idxBizJgUseInfoService.lambdaQuery()
// 计算管道长度并更新 .select(IdxBizJgUseInfo::getRecord)
double originPipelineLength = originProjectContraptionList.stream() .in(IdxBizJgUseInfo::getProjectContraptionId, originProjectContraptionIds)
.map(IdxBizJgProjectContraption::getPipelineLength) .list()
.filter(Objects::nonNull) .stream()
.mapToDouble(Double::doubleValue) .map(IdxBizJgUseInfo::getRecord)
.sum(); .collect(Collectors.toList());
projectContraption.setPipelineLength(projectContraption.getPipelineLength() - originPipelineLength);
// 统一处理设备的纳管状态
registerAfterCommitTask(records);
processElseDataByStatus(oldStatus, jgUseRegistration);
if (FlowStatusEnum.TO_BE_FINISHED.getName().equals(oldStatus)) {
// 计算管道长度并更新
double originPipelineLength = originProjectContraptionList.stream()
.map(IdxBizJgProjectContraption::getPipelineLength)
.filter(Objects::nonNull)
.mapToDouble(Double::doubleValue)
.sum();
projectContraption.setPipelineLength(projectContraption.getPipelineLength() - originPipelineLength);
}
} }
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