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 ...@@ -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.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationReformEqServiceImpl; 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.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.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import lombok.Getter; import lombok.Getter;
...@@ -82,8 +83,12 @@ public class ChangeRegistrationReformEditUpdateService { ...@@ -82,8 +83,12 @@ public class ChangeRegistrationReformEditUpdateService {
List<JgChangeRegistrationReformEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap); List<JgChangeRegistrationReformEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap);
this.insertRelationEq(jgChangeRegistrationReform.getSequenceNbr(), registrationEqs); this.insertRelationEq(jgChangeRegistrationReform.getSequenceNbr(), registrationEqs);
// 3.json history插入 // 3.json history插入
IdxBizJgProjectContraption projectContraption = commonEquipDataProcessService.getIdxBizJgProjectContraptionServiceImpl().getById(jgChangeRegistrationReform.getProjectContraptionId());
JSONObject jsonObject = mainService.getHisData(applyNo); JSONObject jsonObject = mainService.getHisData(applyNo);
jsonObject.remove("equipmentLists"); 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)); jsonObject.put("equipmentLists", pieLineDataChangeService.buildEquipmentLists(pipelineChangeItemMap));
commonServiceBiz.saveOrUpdateHistory("", jsonObject, bizId, applyNo); commonServiceBiz.saveOrUpdateHistory("", jsonObject, bizId, applyNo);
} else { // 完成时,把管道更新为已纳管状态 } else { // 完成时,把管道更新为已纳管状态
......
...@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -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.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice; 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.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.JgInstallationNoticeEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl; 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.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -22,9 +27,25 @@ public class InstallNoticeEditUpdateService { ...@@ -22,9 +27,25 @@ public class InstallNoticeEditUpdateService {
private final JgInstallationNoticeEqServiceImpl installationNoticeEqService; 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) { public Set<String> getEqsByApplyNo(String applyNo) {
JgInstallationNotice jgInstallationNotice = installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr)); JgInstallationNotice jgInstallationNotice = installationNoticeService.getOne(new LambdaQueryWrapper<JgInstallationNotice>().eq(JgInstallationNotice::getApplyNo, applyNo).select(BaseEntity::getSequenceNbr, JgInstallationNotice::getProjectContraptionId, JgInstallationNotice::getNoticeStatus));
List<JgInstallationNoticeEq> eqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId, BaseEntity::getSequenceNbr)); 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()); return eqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toSet());
} }
......
package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister; package com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.useRegister;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.BaseEntity;
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.dto.FieldChangeMeta; 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; ...@@ -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.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.CommonEquipDataProcessService;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.PieLineDataChangeServiceImpl; 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.JgUseRegistrationEqServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl; 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.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import lombok.Getter; import lombok.Getter;
...@@ -28,6 +26,8 @@ import org.apache.commons.lang3.StringUtils; ...@@ -28,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -73,10 +73,19 @@ public class UseRegisterUpdateService { ...@@ -73,10 +73,19 @@ public class UseRegisterUpdateService {
List<JgUseRegistrationEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap); List<JgUseRegistrationEq> registrationEqs = this.buildPipelineEqs(pipelineChangeItemMap);
this.insertRelationEq(useRegistration.getSequenceNbr(), registrationEqs); this.insertRelationEq(useRegistration.getSequenceNbr(), registrationEqs);
// 3.json history插入 // 3.json history插入
IdxBizJgProjectContraption projectContraption = commonEquipDataProcessService.getIdxBizJgProjectContraptionServiceImpl().getById(useRegistration.getProjectContraptionId());
JSONObject jsonObject = jgUseRegistrationService.getHisData(useRegistration); JSONObject jsonObject = jgUseRegistrationService.getHisData(useRegistration);
jsonObject.remove("equipmentLists"); jsonObject.remove("equipmentLists");
// 使用json的数据进行计算,因为编辑的数据此时还为入库
jsonObject.put("pipelineLength", pieLineDataChangeService.calPipelineLength(pipelineChangeItemMap));
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("equipmentLists", pieLineDataChangeService.buildEquipmentLists(pipelineChangeItemMap)); jsonObject.put("equipmentLists", pieLineDataChangeService.buildEquipmentLists(pipelineChangeItemMap));
jgUseRegistrationService.updateHistory(jsonObject, bizId, useRegistration.getSequenceNbr() + "", null); 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 { // 完成时,把管道更新为已纳管状态 } else { // 完成时,把管道更新为已纳管状态
// 按照装置id查询装置下管道,更新为已纳管状态 // 按照装置id查询装置下管道,更新为已纳管状态
List<IdxBizJgUseInfo> useInfos = jgUseRegistrationService.getIdxBizJgUseInfoService().list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, useRegistration.getProjectContraptionId()).eq(IdxBizJgUseInfo::getIsIntoManagement, false).select(TzsBaseEntity::getSequenceNbr, IdxBizJgUseInfo::getRecord)); 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 { ...@@ -90,6 +99,8 @@ public class UseRegisterUpdateService {
} }
} }
private List<JgUseRegistrationEq> buildPipelineEqs(Map<String, List<PipelineChangeItemDto>> pipelineChangeItemMap) { private List<JgUseRegistrationEq> buildPipelineEqs(Map<String, List<PipelineChangeItemDto>> pipelineChangeItemMap) {
List<PipelineChangeItemDto> newPipelines = pipelineChangeItemMap.get(EditConstant.NEW_PIPELINES); List<PipelineChangeItemDto> newPipelines = pipelineChangeItemMap.get(EditConstant.NEW_PIPELINES);
List<PipelineChangeItemDto> updPipelines = pipelineChangeItemMap.get(EditConstant.UPDATE_PIPELINES); List<PipelineChangeItemDto> updPipelines = pipelineChangeItemMap.get(EditConstant.UPDATE_PIPELINES);
......
...@@ -25,10 +25,10 @@ import com.yeejoin.amos.boot.module.jg.api.entity.IdxBizJgPipelineOperationHist; ...@@ -25,10 +25,10 @@ import com.yeejoin.amos.boot.module.jg.api.entity.IdxBizJgPipelineOperationHist;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum; import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.biz.edit.backup.DefaultEquipBackupManager; import com.yeejoin.amos.boot.module.jg.biz.edit.backup.DefaultEquipBackupManager;
import com.yeejoin.amos.boot.module.jg.biz.edit.factory.ColumnDiffFactory;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.FormatService; import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.FormatService;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler; import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.RegionCodeTypeHandler; import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.RegionCodeTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.utils.JsonDiffUtil;
import com.yeejoin.amos.boot.module.jg.biz.service.*; import com.yeejoin.amos.boot.module.jg.biz.service.*;
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.*;
...@@ -126,6 +126,8 @@ public class CommonEquipDataProcessService { ...@@ -126,6 +126,8 @@ public class CommonEquipDataProcessService {
private final FormatService formatService; private final FormatService formatService;
private final ColumnDiffFactory diffFactory;
private final RegionCodeTypeHandler regionCodeTypeHandler; private final RegionCodeTypeHandler regionCodeTypeHandler;
private final PieLineLevelTypeHandler pieLineLevelTypeHandler; private final PieLineLevelTypeHandler pieLineLevelTypeHandler;
...@@ -695,64 +697,11 @@ public class CommonEquipDataProcessService { ...@@ -695,64 +697,11 @@ public class CommonEquipDataProcessService {
TableField tableField = field.getAnnotation(TableField.class); TableField tableField = field.getAnnotation(TableField.class);
// 业务字段对比处理逻辑 // 业务字段对比处理逻辑
if (displayDefine != null && displayDefine.isExist()) { if (displayDefine != null && displayDefine.isExist()) {
// json 比较逻辑 FieldChangeMeta fieldChangeMeta = diffFactory.getDiffAdapter(displayDefine.type()).handleWithWrapper(displayDefine, oldVal, newVal, field, group, changeId, tableField, wrapper);
if (displayDefine.type().equals(JSON.class)) { if (fieldChangeMeta != null) {
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()));
changeData.add(fieldChangeMeta); changeData.add(fieldChangeMeta);
} }
continue;
} }
// 其他比较逻辑
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()));
changeData.add(fieldChangeMeta);
}
}
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
System.err.println("字段访问失败: " + field.getName()); System.err.println("字段访问失败: " + field.getName());
} }
...@@ -773,6 +722,7 @@ public class CommonEquipDataProcessService { ...@@ -773,6 +722,7 @@ public class CommonEquipDataProcessService {
/** /**
* 简化版字段对比更新工具 * 简化版字段对比更新工具
* 要求:对象字段名与数据库列名一致(驼峰转下划线自动处理) * 要求:对象字段名与数据库列名一致(驼峰转下划线自动处理)
*
* @param oldObj 旧对象(必须有id字段) * @param oldObj 旧对象(必须有id字段)
* @param newObj 新对象(必须与旧对象同一类型) * @param newObj 新对象(必须与旧对象同一类型)
*/ */
...@@ -796,60 +746,11 @@ public class CommonEquipDataProcessService { ...@@ -796,60 +746,11 @@ public class CommonEquipDataProcessService {
FieldDisplayDefine displayDefine = field.getAnnotation(FieldDisplayDefine.class); FieldDisplayDefine displayDefine = field.getAnnotation(FieldDisplayDefine.class);
// 业务字段对比处理逻辑 // 业务字段对比处理逻辑
if (displayDefine != null && displayDefine.isExist()) { if (displayDefine != null && displayDefine.isExist()) {
// json 比较逻辑 FieldChangeMeta fieldChangeMeta = diffFactory.getDiffAdapter(displayDefine.type()).handleNoWrapper(displayDefine, oldVal, newVal, field, group, changeId);
if (displayDefine.type().equals(JSON.class)) { if (fieldChangeMeta != null) {
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()));
changeData.add(fieldChangeMeta);
}
continue;
}
// 其他比较逻辑
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()));
changeData.add(fieldChangeMeta); changeData.add(fieldChangeMeta);
} }
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
System.err.println("字段访问失败: " + field.getName()); System.err.println("字段访问失败: " + field.getName());
} }
...@@ -1019,6 +920,7 @@ public class CommonEquipDataProcessService { ...@@ -1019,6 +920,7 @@ public class CommonEquipDataProcessService {
/** /**
* 重新装置详情 * 重新装置详情
*
* @param projectContraptionId 装置id * @param projectContraptionId 装置id
* @param records 装置下的管道 * @param records 装置下的管道
* @param aBoolean 是否需要json数据 * @param aBoolean 是否需要json数据
...@@ -1029,14 +931,14 @@ public class CommonEquipDataProcessService { ...@@ -1029,14 +931,14 @@ public class CommonEquipDataProcessService {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionServiceImpl.getById(projectContraptionId); IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionServiceImpl.getById(projectContraptionId);
Map<String, Object> re = BeanUtil.beanToMap(projectContraption); Map<String, Object> re = BeanUtil.beanToMap(projectContraption);
this.convertStringToJsonObject(re, IdxBizJgProjectContraptionServiceImpl.getJsonFieldsCamel()); this.convertStringToJsonObject(re, IdxBizJgProjectContraptionServiceImpl.getJsonFieldsCamel());
if(!aBoolean){ // 实时查询逻辑 if (!aBoolean) { // 实时查询逻辑
List<Map<String, Object>> equList = jgUseRegistrationService.getBaseMapper().queryForUnitPipelineEquipmentForEdit(new ArrayList<>(records)); List<Map<String, Object>> equList = jgUseRegistrationService.getBaseMapper().queryForUnitPipelineEquipmentForEdit(new ArrayList<>(records));
// 检验报告数据格式化 转json // 检验报告数据格式化 转json
equList.stream().filter(e -> e.get("inspectReport") != null).forEach(item -> item.put("inspectReport", JSON.parse(item.get("inspectReport").toString()))); equList.forEach(item -> item.put("inspectReport", item.get("inspectReport") != null ? JSON.parse(item.get("inspectReport").toString()) : null));
re.put("tableData", equList); re.put("tableData", equList);
} else { // 使用json的暂存数据逻辑 } else { // 使用json的暂存数据逻辑
// 直接使用json暂存的管道数据 + todo isEdit调整 // 直接使用json暂存的管道数据 + todo isEdit调整
re.put("tableData", oldJsonData.stream().map(r->{ re.put("tableData", oldJsonData.stream().map(r -> {
Map<String, Object> item = BeanUtil.beanToMap(r); Map<String, Object> item = BeanUtil.beanToMap(r);
// 检验报告数据格式化 转json // 检验报告数据格式化 转json
item.put("inspectReport", JSON.parse(r.getInspectReport())); item.put("inspectReport", JSON.parse(r.getInspectReport()));
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 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.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil; import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
...@@ -16,19 +17,26 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHand ...@@ -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.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgSupervisionInfoServiceImpl; 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.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.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; 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.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@Getter
public class PieLineDataChangeServiceImpl { public class PieLineDataChangeServiceImpl {
public static final String PIE_LINE_DELETE = "pie_line_delete"; public static final String PIE_LINE_DELETE = "pie_line_delete";
...@@ -57,6 +65,8 @@ public class PieLineDataChangeServiceImpl { ...@@ -57,6 +65,8 @@ public class PieLineDataChangeServiceImpl {
private final CbDataDictTypeHandler cbDataDictTypeHandler; private final CbDataDictTypeHandler cbDataDictTypeHandler;
private final IdxBizJgUseInfoServiceImpl useInfoService;
public void update(ProjectContraptionChangeDataDto projectContraptionChangeDataDtoNew, List<FieldChangeMeta> allChangeColumns) { public void update(ProjectContraptionChangeDataDto projectContraptionChangeDataDtoNew, List<FieldChangeMeta> allChangeColumns) {
// 原有对象行转列 // 原有对象行转列
...@@ -79,7 +89,6 @@ public class PieLineDataChangeServiceImpl { ...@@ -79,7 +89,6 @@ public class PieLineDataChangeServiceImpl {
updateWrapper.set(IdxBizJgProjectContraption::getEndLatitudeLongitude, projectContraptionChangeDataDtoNew.getEndLatitudeLongitude()); updateWrapper.set(IdxBizJgProjectContraption::getEndLatitudeLongitude, projectContraptionChangeDataDtoNew.getEndLatitudeLongitude());
updateWrapper.set(IdxBizJgProjectContraption::getProjectContraption, projectContraptionChangeDataDtoNew.getProjectContraption()); updateWrapper.set(IdxBizJgProjectContraption::getProjectContraption, projectContraptionChangeDataDtoNew.getProjectContraption());
updateWrapper.set(IdxBizJgProjectContraption::getProjectContraptionNo, projectContraptionChangeDataDtoNew.getProjectContraptionNo()); updateWrapper.set(IdxBizJgProjectContraption::getProjectContraptionNo, projectContraptionChangeDataDtoNew.getProjectContraptionNo());
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, projectContraptionChangeDataDtoNew.getPipelineLength());
updateWrapper.set(IdxBizJgProjectContraption::getProductPhoto, projectContraptionChangeDataDtoNew.getProductPhoto()); updateWrapper.set(IdxBizJgProjectContraption::getProductPhoto, projectContraptionChangeDataDtoNew.getProductPhoto());
updateWrapper.set(IdxBizJgProjectContraption::getOtherAccessories, projectContraptionChangeDataDtoNew.getOtherAccessories()); updateWrapper.set(IdxBizJgProjectContraption::getOtherAccessories, projectContraptionChangeDataDtoNew.getOtherAccessories());
updateWrapper.set(IdxBizJgProjectContraption::getProductQualificationCertificate, projectContraptionChangeDataDtoNew.getProductQualificationCertificate()); updateWrapper.set(IdxBizJgProjectContraption::getProductQualificationCertificate, projectContraptionChangeDataDtoNew.getProductQualificationCertificate());
...@@ -307,4 +316,26 @@ public class PieLineDataChangeServiceImpl { ...@@ -307,4 +316,26 @@ public class PieLineDataChangeServiceImpl {
}).collect(Collectors.toList()); }).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 ...@@ -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.HandleResult;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.IEquipChangeDataProcessStrategy; 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.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.IdxBizJgConstructionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
...@@ -24,7 +25,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -24,7 +25,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; 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.text.DateFormat;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -42,6 +42,8 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS ...@@ -42,6 +42,8 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
private final PieLineLevelTypeHandler pieLineLevelTypeHandler; private final PieLineLevelTypeHandler pieLineLevelTypeHandler;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoServiceImpl;
@Override @Override
public HandleResult handle(Map<String, Object> changeData, String projectContraptionId) { public HandleResult handle(Map<String, Object> changeData, String projectContraptionId) {
...@@ -68,14 +70,12 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS ...@@ -68,14 +70,12 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
// 2.装置基本信息校验、保存(前端返回的装置信息为大写 需注意) // 2.装置基本信息校验、保存(前端返回的装置信息为大写 需注意)
ProjectContraptionChangeDataDto projectContraptionChangeDataDto = CommonEquipDataProcessService.castMap2Bean(changeData, ProjectContraptionChangeDataDto.class); ProjectContraptionChangeDataDto projectContraptionChangeDataDto = CommonEquipDataProcessService.castMap2Bean(changeData, ProjectContraptionChangeDataDto.class);
this.setNameForDictKey(projectContraptionChangeDataDto); this.setNameForDictKey(projectContraptionChangeDataDto);
this.calTotalPieLineLength(projectContraptionChangeDataDto, items);
pieLineDataChangeService.update(projectContraptionChangeDataDto, allChangeColumns); pieLineDataChangeService.update(projectContraptionChangeDataDto, allChangeColumns);
Boolean isRequireTemporarySave = data.getBoolean(DefaultBizDataChangeHandler.IS_REQUIRES_TEMPORARY_SAVE); Boolean isRequireTemporarySave = data.getBoolean(DefaultBizDataChangeHandler.IS_REQUIRES_TEMPORARY_SAVE);
JSONArray oldPieLineJSONArray = data.getJSONArray(DefaultBizDataChangeHandler.TEMPORARY_PIPELINES_DATA); JSONArray oldPieLineJSONArray = data.getJSONArray(DefaultBizDataChangeHandler.TEMPORARY_PIPELINES_DATA);
List<PipelineChangeItemDto> oriPipelineList = oldPieLineJSONArray.toJavaList(PipelineChangeItemDto.class); List<PipelineChangeItemDto> oriPipelineList = oldPieLineJSONArray.toJavaList(PipelineChangeItemDto.class);
Map<String, PipelineChangeItemDto> oldRecordPipelineMap = oriPipelineList.stream().collect(Collectors.toMap(TechParamsPipelineChangeFieldDto::getRecord, Function.identity())); Map<String, PipelineChangeItemDto> oldRecordPipelineMap = oriPipelineList.stream().collect(Collectors.toMap(TechParamsPipelineChangeFieldDto::getRecord, Function.identity()));
// 3.管道信息入库保存 // 3.管道信息入库保存
items.forEach(pipelineNew -> { items.forEach(pipelineNew -> {
String record = pipelineNew.getRecord(); String record = pipelineNew.getRecord();
...@@ -113,6 +113,8 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS ...@@ -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(); 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.更新所有管道的的冗余的管道名称字段(重点注意包括本次没做使用登记的管道也要更新) // 4.更新所有管道的的冗余的管道名称字段(重点注意包括本次没做使用登记的管道也要更新)
pieLineDataChangeService.updateEs(projectContraptionChangeDataDto); pieLineDataChangeService.updateEs(projectContraptionChangeDataDto);
// 5.更新管道长度,按照装置下的已经入库的全量更新(todo 流程中编辑时数据不体现在这 还是原数据)
pieLineDataChangeService.updatePipelineLength(projectContraptionChangeDataDto.getProjectContraptionId());
return HandleResult.builder().fieldChangeMetas(allChangeColumns).pipelineChangeItemMap(pmap).build(); return HandleResult.builder().fieldChangeMetas(allChangeColumns).pipelineChangeItemMap(pmap).build();
} }
...@@ -194,7 +196,10 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS ...@@ -194,7 +196,10 @@ public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessS
IdxBizJgConstructionInfo constructionInfoOld = commonEquipDataProcessService.getJgUseRegistrationService().getIdxBizJgConstructionInfoService().getById(constructionInfoSeq); IdxBizJgConstructionInfo constructionInfoOld = commonEquipDataProcessService.getJgUseRegistrationService().getIdxBizJgConstructionInfoService().getById(constructionInfoSeq);
// todo 安装年月特殊处理 格式刷yyyy-MM // todo 安装年月特殊处理 格式刷yyyy-MM
IdxBizJgConstructionInfo constructionInfoNew = new IdxBizJgConstructionInfo(); 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); 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); BeanUtil.copyProperties(item, constructionInfoNew, true);
constructionInfoNew.setSequenceNbr(constructionInfoOld.getSequenceNbr()); constructionInfoNew.setSequenceNbr(constructionInfoOld.getSequenceNbr());
List<FieldChangeMeta> constructionInfoFieldChangeMetas = commonEquipDataProcessService.simpleTrackAndUpdate(commonEquipDataProcessService.getJgUseRegistrationService().getIdxBizJgConstructionInfoService().getBaseMapper(), constructionInfoOld, constructionInfoNew, projectContraptionChangeDataDto.getProjectContraptionId() + "/" + item.getRecord(), "SEQUENCE_NBR", 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 ...@@ -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) { 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