Commit 6c697e1b authored by suhuiguang's avatar suhuiguang

fix(大编辑):bug修复

1.比较
parent 9de09a9d
......@@ -31,6 +31,7 @@ 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.PieLineLevelTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.RegionCodeTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.utils.DiffUtils;
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.ymt.api.entity.*;
......@@ -306,7 +307,7 @@ public class CommonEquipDataProcessService {
o.setColumnOldValue(oldKv.get(o.getColumnKey()).getColumnOldValue());
}
});
List<FieldChangeMeta> up = changeDataNew.stream().filter(n -> !StringUtils.equals(n.getColumnNewValue(), n.getColumnOldValue())).collect(Collectors.toList());
List<FieldChangeMeta> up = changeDataNew.stream().filter(n -> !DiffUtils.compare(n.getColumnType(), n.getColumnNewValue(), n.getColumnOldValue())).collect(Collectors.toList());
up.forEach(fieldChangeMeta -> {
fieldChangeMeta.setDisplayOldValue(formatService.format(fieldChangeMeta.getFieldDisplayDefine(), fieldChangeMeta.getColumnOldValue()));
fieldChangeMeta.setDisplayNewValue(formatService.format(fieldChangeMeta.getFieldDisplayDefine(), fieldChangeMeta.getColumnNewValue()));
......@@ -563,6 +564,12 @@ public class CommonEquipDataProcessService {
String value = DateUtil.format((Date) oV, displayDefine.format());
fieldChangeMeta.setColumnNewValue(value);
fieldChangeMeta.setColumnOldValue(value);
} else if (oV instanceof Boolean) {
fieldChangeMeta.setColumnOldValue(Boolean.toString((Boolean) oV));
fieldChangeMeta.setColumnNewValue(Boolean.toString((Boolean) oV));
} else {
fieldChangeMeta.setColumnOldValue(Objects.toString(oV, null));
fieldChangeMeta.setColumnNewValue(Objects.toString(oV, null));
}
changeData.add(fieldChangeMeta);
}
......@@ -949,7 +956,7 @@ public class CommonEquipDataProcessService {
// 兼容逻辑,管道级别 原业务存的name,编辑存的code,进行转换name/code->code
item.put("deviceLevel", pieLineLevelTypeHandler.getCodeByName(r.getDeviceLevel()));
// 原始业务不包含此字段 需要加上 否则流程中第一次编辑时该字段丢失导致安装信息无法更新
if(r.getConstructionInfoSeq() == null){
if (r.getConstructionInfoSeq() == null) {
IdxBizJgConstructionInfo constructionInfo = jgConstructionInfoService.queryNewestDetailIdByRecord(r.getRecord());
item.put("constructionInfoSeq", constructionInfo.getSequenceNbr());
}
......@@ -1121,7 +1128,7 @@ public class CommonEquipDataProcessService {
jgUseRegistrationService.getIdxBizJgRegisterInfoService().update(updateWrapper);
}
public void updatePipeline2InUse( String projectContraptionId, String useRegistrationCode) {
public void updatePipeline2InUse(String projectContraptionId, String useRegistrationCode) {
List<IdxBizJgUseInfo> useInfos = idxBizJgUseInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getProjectContraptionId, projectContraptionId).eq(IdxBizJgUseInfo::getIsIntoManagement, false).select(TzsBaseEntity::getSequenceNbr, IdxBizJgUseInfo::getRecord));
useInfos.parallelStream().forEach(e -> {
this.setNewPipelineUseState(e, useRegistrationCode);
......
package com.yeejoin.amos.boot.module.jg.biz.edit.utils;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiPredicate;
public class DiffUtils {
private static final Map<String, BiPredicate<String, String>> diffCache = new ConcurrentHashMap<>();
static {
registerDefaultComparators();
}
private static void registerDefaultComparators() {
diffCache.put(String.class.getSimpleName(), StringUtils::equals);
diffCache.put(JSON.class.getSimpleName(), JsonDiffUtil::jsonEqualsIgnoreType);
}
public static void register(String type, BiPredicate<String, String> comparator) {
diffCache.put(type, comparator);
}
public static boolean compare(String type, String newValue, String oldValue) {
if (type == null || newValue == null || oldValue == null) {
return Objects.equals(newValue, oldValue);
}
return diffCache.getOrDefault(type, Objects::equals).test(newValue, oldValue);
}
}
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