Commit 8d5d8d69 authored by suhuiguang's avatar suhuiguang

fix(大编辑):bug修复

1.管道长度编辑时机械能更新 2.流程中的改造变更登记、使用登记、安装告知更新冗余字段管道长度、管道名称
parent 60734bc3
package com.yeejoin.amos.boot.module.jg.biz.edit.factory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.List;
@Component
@RequiredArgsConstructor
public class ColumnDiffFactory {
private final List<IColumnDiff> IColumnDiffs;
public IColumnDiff getDiffAdapter(Class<?> clazz) {
for (IColumnDiff columnDiff : IColumnDiffs) {
if (columnDiff.supports(clazz)) {
return columnDiff;
}
}
throw new BadRequest("no found handler for class: " + clazz);
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.factory;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.biz.common.annotation.Group;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import java.lang.reflect.Field;
public interface IColumnDiff {
boolean supports(Class<?> type);
<T> FieldChangeMeta handleWithWrapper(FieldDisplayDefine fieldDisplayDefine, Object oldValue, Object newValue, Field field, Group group, String changeId, TableField tableField, UpdateWrapper<T> wrapper);
FieldChangeMeta handleNoWrapper(FieldDisplayDefine fieldDisplayDefine, Object oldValue, Object newValue, Field field, Group group, String changeId);
}
package com.yeejoin.amos.boot.module.jg.biz.edit.factory;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.biz.common.annotation.Group;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.FormatService;
import com.yeejoin.amos.boot.module.jg.biz.edit.utils.JsonDiffUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.Objects;
@Component
@RequiredArgsConstructor
public class JsonIColumnDiffHandler implements IColumnDiff {
private final FormatService formatService;
@Override
public boolean supports(Class<?> type) {
return type == JSON.class;
}
@Override
public <T> FieldChangeMeta handleWithWrapper(FieldDisplayDefine displayDefine, Object oldVal, Object newVal, Field field, Group group, String changeId, TableField tableField, UpdateWrapper<T> wrapper) {
if (!JsonDiffUtil.jsonEqualsIgnoreType((String) oldVal, (String) newVal)) {
String columnName = tableField.value();
wrapper.set(columnName, newVal);
String fieldName = displayDefine.value();
FieldChangeMeta fieldChangeMeta = new FieldChangeMeta();
fieldChangeMeta.setColumnKey(field.getName());
fieldChangeMeta.setColumnFamily(group.value());
fieldChangeMeta.setColumnLabel(fieldName);
fieldChangeMeta.setChangeId(changeId);
fieldChangeMeta.setIsRepeatColumn(displayDefine.isRepeatColumn());
// 字段类型前端渲染时使用
fieldChangeMeta.setColumnType(displayDefine.type().getSimpleName());
fieldChangeMeta.setColumnOldValue(Objects.toString(oldVal, null));
fieldChangeMeta.setColumnNewValue(Objects.toString(newVal, null));
fieldChangeMeta.setDisplayOldValue(formatService.format(displayDefine, fieldChangeMeta.getColumnOldValue()));
fieldChangeMeta.setDisplayNewValue(formatService.format(displayDefine, fieldChangeMeta.getColumnNewValue()));
return fieldChangeMeta;
}
return null;
}
@Override
public FieldChangeMeta handleNoWrapper(FieldDisplayDefine displayDefine, Object oldVal, Object newVal, Field field, Group group, String changeId) {
if (!JsonDiffUtil.jsonEqualsIgnoreType((String) oldVal, (String) newVal)) {
String fieldName = displayDefine.value();
FieldChangeMeta fieldChangeMeta = new FieldChangeMeta();
fieldChangeMeta.setColumnKey(field.getName());
fieldChangeMeta.setColumnFamily(group.value());
fieldChangeMeta.setColumnLabel(fieldName);
fieldChangeMeta.setChangeId(changeId);
fieldChangeMeta.setIsRepeatColumn(displayDefine.isRepeatColumn());
// 字段类型前端渲染时使用
fieldChangeMeta.setColumnType(displayDefine.type().getSimpleName());
fieldChangeMeta.setColumnOldValue(Objects.toString(oldVal, null));
fieldChangeMeta.setColumnNewValue(Objects.toString(newVal, null));
fieldChangeMeta.setDisplayOldValue(formatService.format(displayDefine, fieldChangeMeta.getColumnOldValue()));
fieldChangeMeta.setDisplayNewValue(formatService.format(displayDefine, fieldChangeMeta.getColumnNewValue()));
return fieldChangeMeta;
}
return null;
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.factory;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.biz.common.annotation.Group;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.FormatService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.Objects;
@Component
@RequiredArgsConstructor
public class StringIColumnDiffHandler implements IColumnDiff {
private final FormatService formatService;
@Override
public boolean supports(Class<?> type) {
return type == String.class;
}
@Override
public <T> FieldChangeMeta handleWithWrapper(FieldDisplayDefine displayDefine, Object oldVal, Object newVal, Field field, Group group, String changeId, TableField tableField, UpdateWrapper<T> wrapper) {
if (!Objects.equals(oldVal, newVal)) {
String columnName = tableField.value();
wrapper.set(columnName, newVal);
String fieldName = displayDefine.value();
FieldChangeMeta fieldChangeMeta = new FieldChangeMeta();
fieldChangeMeta.setColumnKey(field.getName());
fieldChangeMeta.setColumnFamily(group.value());
fieldChangeMeta.setColumnLabel(fieldName);
fieldChangeMeta.setChangeId(changeId);
fieldChangeMeta.setIsRepeatColumn(displayDefine.isRepeatColumn());
// 字段类型前端渲染时使用
fieldChangeMeta.setColumnType(displayDefine.type().getSimpleName());
if (newVal instanceof String) {
fieldChangeMeta.setColumnOldValue((String) oldVal);
fieldChangeMeta.setColumnNewValue((String) newVal);
} else if (newVal instanceof Number) {
fieldChangeMeta.setColumnOldValue(String.valueOf(oldVal));
fieldChangeMeta.setColumnNewValue(String.valueOf(newVal));
} else if (newVal instanceof Date) {
fieldChangeMeta.setColumnOldValue(DateUtil.formatDate((Date) oldVal));
fieldChangeMeta.setColumnNewValue(DateUtil.formatDate((Date) newVal));
} else if (newVal instanceof Boolean) {
fieldChangeMeta.setColumnOldValue(Boolean.toString((Boolean) oldVal));
fieldChangeMeta.setColumnNewValue(Boolean.toString((Boolean) newVal));
} else {
fieldChangeMeta.setColumnOldValue(Objects.toString(oldVal, null));
fieldChangeMeta.setColumnNewValue(Objects.toString(newVal, null));
}
fieldChangeMeta.setDisplayOldValue(formatService.format(displayDefine, fieldChangeMeta.getColumnOldValue()));
fieldChangeMeta.setDisplayNewValue(formatService.format(displayDefine, fieldChangeMeta.getColumnNewValue()));
return fieldChangeMeta;
}
return null;
}
@Override
public FieldChangeMeta handleNoWrapper(FieldDisplayDefine displayDefine, Object oldVal, Object newVal, Field field, Group group, String changeId) {
if (!Objects.equals(oldVal, newVal)) {
String fieldName = displayDefine.value();
FieldChangeMeta fieldChangeMeta = new FieldChangeMeta();
fieldChangeMeta.setColumnKey(field.getName());
fieldChangeMeta.setColumnFamily(group.value());
fieldChangeMeta.setColumnLabel(fieldName);
fieldChangeMeta.setChangeId(changeId);
fieldChangeMeta.setIsRepeatColumn(displayDefine.isRepeatColumn());
// 字段类型前端渲染时使用
fieldChangeMeta.setColumnType(displayDefine.type().getSimpleName());
if (newVal instanceof String) {
fieldChangeMeta.setColumnOldValue((String) oldVal);
fieldChangeMeta.setColumnNewValue((String) newVal);
} else if (newVal instanceof Number) {
fieldChangeMeta.setColumnOldValue(String.valueOf(oldVal));
fieldChangeMeta.setColumnNewValue(String.valueOf(newVal));
} else if (newVal instanceof Date) {
fieldChangeMeta.setColumnOldValue(DateUtil.formatDate((Date) oldVal));
fieldChangeMeta.setColumnNewValue(DateUtil.formatDate((Date) newVal));
} else if (newVal instanceof Boolean) {
fieldChangeMeta.setColumnOldValue(Boolean.toString((Boolean) oldVal));
fieldChangeMeta.setColumnNewValue(Boolean.toString((Boolean) newVal));
} else {
fieldChangeMeta.setColumnOldValue(Objects.toString(oldVal, null));
fieldChangeMeta.setColumnNewValue(Objects.toString(newVal, null));
}
fieldChangeMeta.setDisplayOldValue(formatService.format(displayDefine, fieldChangeMeta.getColumnOldValue()));
fieldChangeMeta.setDisplayNewValue(formatService.format(displayDefine, fieldChangeMeta.getColumnNewValue()));
return fieldChangeMeta;
}
return null;
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.PieLineDataChangeS
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationReformEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationReformServiceImpl;
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.FlowStatusEnum;
import lombok.Getter;
......@@ -82,8 +83,12 @@ public class ChangeRegistrationReformEditUpdateService {
List<JgChangeRegistrationReformEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap);
this.insertRelationEq(jgChangeRegistrationReform.getSequenceNbr(), registrationEqs);
// 3.json history插入
IdxBizJgProjectContraption projectContraption = commonEquipDataProcessService.getIdxBizJgProjectContraptionServiceImpl().getById(jgChangeRegistrationReform.getProjectContraptionId());
JSONObject jsonObject = mainService.getHisData(applyNo);
jsonObject.remove("equipmentLists");
jsonObject.put("pipelineLength", pieLineDataChangeService.calPipelineLength(pipelineChangeItemMap));
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("projectContraption", projectContraption.getProjectContraption());
jsonObject.put("equipmentLists", pieLineDataChangeService.buildEquipmentLists(pipelineChangeItemMap));
commonServiceBiz.saveOrUpdateHistory("", jsonObject, bizId, applyNo);
} else { // 完成时,把管道更新为已纳管状态
......
......@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -22,9 +27,25 @@ public class InstallNoticeEditUpdateService {
private final JgInstallationNoticeEqServiceImpl installationNoticeEqService;
private final IdxBizJgUseInfoServiceImpl useInfoService;
private static final List<String> NOT_FLOWING_STATE = Arrays.asList("6610", "6614", "6615");
public Set<String> getEqsByApplyNo(String applyNo) {
JgInstallationNotice jgInstallationNotice = installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr));
List<JgInstallationNoticeEq> eqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId, BaseEntity::getSequenceNbr));
JgInstallationNotice jgInstallationNotice = installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr, JgInstallationNotice::getProjectContraptionId, JgInstallationNotice::getNoticeStatus));
List<JgInstallationNoticeEq> eqs;
if (StringUtils.isNotEmpty(jgInstallationNotice.getProjectContraptionId())) { // 装置逻辑
if (NOT_FLOWING_STATE.contains(jgInstallationNotice.getNoticeStatus())) {
// 非流程中查询装置下的管道-原因未纳管装置可进行装置的增减
List<IdxBizJgUseInfo> useInfos = useInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, jgInstallationNotice.getProjectContraptionId()).select(IdxBizJgUseInfo::getRecord));
return useInfos.stream().map(IdxBizJgUseInfo::getRecord).collect(Collectors.toSet());
} else {
// 流程中按照eq表查询
eqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId, BaseEntity::getSequenceNbr));
}
} else {
eqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId, BaseEntity::getSequenceNbr));
}
return eqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toSet());
}
......
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
......@@ -15,10 +14,9 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.constant.EditConstant;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.CommonEquipDataProcessService;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.PieLineDataChangeServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.CbDataDictTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
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.FlowStatusEnum;
import lombok.Getter;
......@@ -28,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -73,10 +73,19 @@ public class UseRegisterUpdateService {
List<JgUseRegistrationEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap);
this.insertRelationEq(useRegistration.getSequenceNbr(), registrationEqs);
// 3.json history插入
IdxBizJgProjectContraption projectContraption = commonEquipDataProcessService.getIdxBizJgProjectContraptionServiceImpl().getById(useRegistration.getProjectContraptionId());
JSONObject jsonObject = jgUseRegistrationService.getHisData(useRegistration);
jsonObject.remove("equipmentLists");
// 使用json的数据进行计算,因为编辑的数据此时还为入库
jsonObject.put("pipelineLength", pieLineDataChangeService.calPipelineLength(pipelineChangeItemMap));
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("equipmentLists", pieLineDataChangeService.buildEquipmentLists(pipelineChangeItemMap));
jgUseRegistrationService.updateHistory(jsonObject, bizId, useRegistration.getSequenceNbr() + "", null);
// 4.更新单据的冗余的装置名称
LambdaUpdateWrapper<JgUseRegistration> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(JgUseRegistration::getSequenceNbr, useRegistration.getSequenceNbr());
wrapper.set(JgUseRegistration::getProjectContraption, projectContraption.getProjectContraption());
jgUseRegistrationService.update(wrapper);
} else { // 完成时,把管道更新为已纳管状态
// 按照装置id查询装置下管道,更新为已纳管状态
List<IdxBizJgUseInfo> useInfos = jgUseRegistrationService.getIdxBizJgUseInfoService().list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, useRegistration.getProjectContraptionId()).eq(IdxBizJgUseInfo::getIsIntoManagement, false).select(TzsBaseEntity::getSequenceNbr, IdxBizJgUseInfo::getRecord));
......@@ -90,6 +99,8 @@ public class UseRegisterUpdateService {
}
}
private List<JgUseRegistrationEq> buildPipelineEqs(Map<String, List<PipelineChangeItemDto>> pipelineChangeItemMap) {
List<PipelineChangeItemDto> newPipelines = pipelineChangeItemMap.get(EditConstant.NEW_PIPELINES);
List<PipelineChangeItemDto> updPipelines = pipelineChangeItemMap.get(EditConstant.UPDATE_PIPELINES);
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
......@@ -16,19 +17,26 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHand
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgSupervisionInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgTechParamsPipelineServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
@RequiredArgsConstructor
@Getter
public class PieLineDataChangeServiceImpl {
public static final String PIE_LINE_DELETE = "pie_line_delete";
......@@ -57,6 +65,8 @@ public class PieLineDataChangeServiceImpl {
private final CbDataDictTypeHandler cbDataDictTypeHandler;
private final IdxBizJgUseInfoServiceImpl useInfoService;
public void update(ProjectContraptionChangeDataDto projectContraptionChangeDataDtoNew, List<FieldChangeMeta> allChangeColumns) {
// 原有对象行转列
......@@ -79,7 +89,6 @@ public class PieLineDataChangeServiceImpl {
updateWrapper.set(IdxBizJgProjectContraption::getEndLatitudeLongitude, projectContraptionChangeDataDtoNew.getEndLatitudeLongitude());
updateWrapper.set(IdxBizJgProjectContraption::getProjectContraption, projectContraptionChangeDataDtoNew.getProjectContraption());
updateWrapper.set(IdxBizJgProjectContraption::getProjectContraptionNo, projectContraptionChangeDataDtoNew.getProjectContraptionNo());
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, projectContraptionChangeDataDtoNew.getPipelineLength());
updateWrapper.set(IdxBizJgProjectContraption::getProductPhoto, projectContraptionChangeDataDtoNew.getProductPhoto());
updateWrapper.set(IdxBizJgProjectContraption::getOtherAccessories, projectContraptionChangeDataDtoNew.getOtherAccessories());
updateWrapper.set(IdxBizJgProjectContraption::getProductQualificationCertificate, projectContraptionChangeDataDtoNew.getProductQualificationCertificate());
......@@ -307,4 +316,26 @@ public class PieLineDataChangeServiceImpl {
}).collect(Collectors.toList());
}
public void updatePipelineLength(String projectContraptionId) {
LambdaUpdateWrapper<IdxBizJgProjectContraption> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(BaseEntity::getSequenceNbr, projectContraptionId);
wrapper.set(IdxBizJgProjectContraption::getPipelineLength, this.calTotalPieLineLength(projectContraptionId));
idxBizJgProjectContraptionServiceImpl.update(wrapper);
}
private Double calTotalPieLineLength(String projectContraptionId) {
List<String> records = useInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, projectContraptionId).select(IdxBizJgUseInfo::getRecord)).stream().map(IdxBizJgUseInfo::getRecord).collect(Collectors.toList());
List<IdxBizJgTechParamsPipeline> techParamsPipelines = idxBizJgTechParamsPipelineService.list(new LambdaQueryWrapper<IdxBizJgTechParamsPipeline>().in(IdxBizJgTechParamsPipeline::getRecord, records).select(IdxBizJgTechParamsPipeline::getRecord, IdxBizJgTechParamsPipeline::getPipeLength));
return techParamsPipelines.stream().filter(i -> i.getPipeLength() != null).map(e -> new BigDecimal(e.getPipeLength()))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(3, RoundingMode.HALF_UP).doubleValue();
}
public String calPipelineLength(Map<String, List<PipelineChangeItemDto>> pipelineChangeItemMap) {
List<PipelineChangeItemDto> newPipelines = pipelineChangeItemMap.get(EditConstant.NEW_PIPELINES);
List<PipelineChangeItemDto> updPipelines = pipelineChangeItemMap.get(EditConstant.UPDATE_PIPELINES);
return Stream.concat(newPipelines.stream(), updPipelines.stream()).filter(i -> i.getPipeLength() != null).map(e -> new BigDecimal(String.valueOf(e.getPipeLength()))).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, RoundingMode.HALF_UP).toPlainString();
}
}
......@@ -15,6 +15,7 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataCha
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.HandleResult;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgConstructionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
......@@ -24,7 +25,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.DateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -42,6 +42,8 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
private final PieLineLevelTypeHandler pieLineLevelTypeHandler;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoServiceImpl;
@Override
public HandleResult handle(Map<String, Object> changeData, String projectContraptionId) {
......@@ -68,14 +70,12 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
// 2.装置基本信息校验、保存(前端返回的装置信息为大写 需注意)
ProjectContraptionChangeDataDto projectContraptionChangeDataDto = CommonEquipDataProcessService.castMap2Bean(changeData, ProjectContraptionChangeDataDto.class);
this.setNameForDictKey(projectContraptionChangeDataDto);
this.calTotalPieLineLength(projectContraptionChangeDataDto, items);
pieLineDataChangeService.update(projectContraptionChangeDataDto, allChangeColumns);
Boolean isRequireTemporarySave = data.getBoolean(DefaultBizDataChangeHandler.IS_REQUIRES_TEMPORARY_SAVE);
JSONArray oldPieLineJSONArray = data.getJSONArray(DefaultBizDataChangeHandler.TEMPORARY_PIPELINES_DATA);
List<PipelineChangeItemDto> oriPipelineList = oldPieLineJSONArray.toJavaList(PipelineChangeItemDto.class);
Map<String, PipelineChangeItemDto> oldRecordPipelineMap = oriPipelineList.stream().collect(Collectors.toMap(TechParamsPipelineChangeFieldDto::getRecord, Function.identity()));
// 3.管道信息入库保存
items.forEach(pipelineNew -> {
String record = pipelineNew.getRecord();
......@@ -113,6 +113,8 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
Map<String, List<PipelineChangeItemDto>> pmap = MapUtil.<String, List<PipelineChangeItemDto>>builder().put(EditConstant.NEW_PIPELINES, newPipelines).put(EditConstant.UPDATE_PIPELINES, updatePipelines).put(EditConstant.DELETE_PIPELINES, deletePipelines).build();
// 4.更新所有管道的的冗余的管道名称字段(重点注意包括本次没做使用登记的管道也要更新)
pieLineDataChangeService.updateEs(projectContraptionChangeDataDto);
// 5.更新管道长度,按照装置下的已经入库的全量更新(todo 流程中编辑时数据不体现在这 还是原数据)
pieLineDataChangeService.updatePipelineLength(projectContraptionChangeDataDto.getProjectContraptionId());
return HandleResult.builder().fieldChangeMetas(allChangeColumns).pipelineChangeItemMap(pmap).build();
}
......@@ -194,7 +196,10 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
IdxBizJgConstructionInfo constructionInfoOld = commonEquipDataProcessService.getJgUseRegistrationService().getIdxBizJgConstructionInfoService().getById(constructionInfoSeq);
// todo 安装年月特殊处理 格式刷yyyy-MM
IdxBizJgConstructionInfo constructionInfoNew = new IdxBizJgConstructionInfo();
// 统一格式按照年月进行比较
Optional.ofNullable(constructionInfoOld.getUscDate()).ifPresent(u -> constructionInfoOld.setUscDate(DateUtil.parse(DateUtil.format(u, DatePattern.NORM_MONTH_FORMAT), DatePattern.NORM_MONTH_FORMAT)));
BeanUtil.copyProperties(constructionInfoOld, constructionInfoNew, true);
Optional.ofNullable(item.getUscDate()).ifPresent(u -> item.setUscDate(DateUtil.parse(u, DatePattern.NORM_MONTH_FORMAT).toDateStr()));
BeanUtil.copyProperties(item, constructionInfoNew, true);
constructionInfoNew.setSequenceNbr(constructionInfoOld.getSequenceNbr());
List<FieldChangeMeta> constructionInfoFieldChangeMetas = commonEquipDataProcessService.simpleTrackAndUpdate(commonEquipDataProcessService.getJgUseRegistrationService().getIdxBizJgConstructionInfoService().getBaseMapper(), constructionInfoOld, constructionInfoNew, projectContraptionChangeDataDto.getProjectContraptionId() + "/" + item.getRecord(), "SEQUENCE_NBR", constructionInfoOld.getSequenceNbr());
......@@ -265,10 +270,6 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
}
}
private void calTotalPieLineLength(ProjectContraptionChangeDataDto projectContraptionChangeDataDto, List<PipelineChangeItemDto> items) {
projectContraptionChangeDataDto.setPipelineLength(items.stream().filter(i -> i.getPipeLength() != null).mapToDouble(TechParamsPipelineChangeFieldDto::getPipeLength).sum());
}
private Map<String, Object> cast2UnderCase(Map<String, Object> re) {
// 由于历史遗留问题,和前端保存统一,要转成大写下滑线驼峰
......
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