Commit b4eb682d authored by suhuiguang's avatar suhuiguang

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

1.改造告知增加装置查询
parent f788f847
......@@ -6,5 +6,5 @@ import java.util.List;
public interface DataBackupManager {
void backup(String key);
void restore(String key);
Boolean restore(String key);
}
......@@ -21,9 +21,9 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager {
handler.backup2Db(getBizType(), bizId, getRecords(bizId));
}
public void restore(String bizId) {
public Boolean restore(String bizId) {
EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class);
handler.restoreFormBackup(getBizType(), bizId);
return handler.restoreFormBackup(getBizType(), bizId);
}
public void updateLastOne(String bizId, List<FieldChangeMeta> changeMetas) {
......@@ -39,7 +39,7 @@ public abstract class DefaultEquipBackupManager implements DataBackupManager {
public List<IdxBizJgPipelineOperationHist> listAll(String bizId){
EquipBackupHandler handler = applicationContext.getBean(EquipBackupHandler.class);
return handler.listBackup(getBizType(), bizId);
return handler.listAllBackupOfOneBizId(getBizType(), 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;
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.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.controller.BizDataChangeController;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.IEventPublisher;
......@@ -45,7 +46,7 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEve
changeData.remove("changeReason");
changeData.remove("changeAttachment");
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);
allChangeColumns.addAll(bizEditColumns);
// 发送数据变更消息
......@@ -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);
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;
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.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.biz.edit.process.biz.DefaultBizDataChangeHandler;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
/**
* 单个维护设备-策略实现类
......@@ -32,7 +35,7 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
private final CommonEquipDataProcessService commonEquipDataProcessService;
@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);
List<FieldChangeMeta> allChangeColumns = new ArrayList<>();
......
......@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*;
import java.util.function.Consumer;
/**
* 单个装置维护-策略实现类
......@@ -33,7 +34,7 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
@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;
// 新增编辑的管道------------------tableData
JSONArray insertOrEditPieLines = data.getJSONArray(RequestChangeData.multiDataKey);
......
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.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
/**
* 处理监策略类
......@@ -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;
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.edit.process.biz.changeRegistrationReform.ChangeRegisterReformBackupManager;
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.ymt.api.entity.*;
......@@ -183,6 +184,11 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
@Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryServiceImpl;
@Autowired
private ChangeRegisterReformBackupManager backupManager;
@Autowired
private IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineServiceImpl;
/***
* @deprecated 根据查询调教获取分页对象
* @param dto 查询的dto对象
......@@ -1480,9 +1486,31 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
iCmWorkflowService.stopProcess(jgChangeRegistrationReform.getInstanceId(), jgChangeRegistrationReform.getCancelReason());
// 3.清空redis(缓存的流程中的设备)
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) {
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
......
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