Commit d459b297 authored by suhuiguang's avatar suhuiguang

fix(jg):bug处理

1.大编辑履历没将充装介质转义
parent 6b6fbf80
......@@ -10,6 +10,7 @@ import java.lang.annotation.*;
public @interface FieldDisplayDefine {
String value();
/**
* 字段别名 兼容前端使用
*
......@@ -21,15 +22,53 @@ public @interface FieldDisplayDefine {
String format() default "yyyy-MM-dd";
/**
* 是否是数据库字典
*
* @return 是否
*/
boolean isExist() default true;
/**
* 处理器bean 名称
*
* @return bean 名称唯一
*/
String typeHandler() default "defaultTypeHandler";
/**
* 字典 key
*
* @return 字典key
*/
String dictCode() default "";
/**
* 字典类型
*
* @return 平台字典、还是业务字典
*/
DictType dictType() default DictType.no;
/**
* 是否冗余字段,如行政区划名称,冗余时则该字段不再记录变更日志
*
* @return 是否冗余
*/
boolean isRepeatColumn() default false;
enum DictType {
/**
* 业务字典
*/
cb,
/**
* 平台字典
*/
platform,
/**
* 非字典
*/
no
}
}
......@@ -36,7 +36,7 @@ public class TechParamsVesselChangeFieldDto extends BaseTechParamsFieldDto {
@FieldDisplayDefine(value = "总容积")
private String totalVolume;
@FieldDisplayDefine(value = "充装介质", dictCode = "CZJZ")
@FieldDisplayDefine(value = "充装介质", dictCode = "FILLING_MEDIUM", dictType = FieldDisplayDefine.DictType.platform)
private String chargingMedium;
@FieldDisplayDefine(value = "规格")
......
......@@ -21,6 +21,8 @@ public class FormatService {
private final CbDataDictTypeHandler dataDictTypeHandler;
private final PlatformDictTypeHandler platformDictTypeHandler;
private final Map<String, TypeHandler<String>> handlerCache = new ConcurrentHashMap<>();
@Value("${type-handler.default:defaultTypeHandler}")
......@@ -28,9 +30,15 @@ public class FormatService {
public String format(FieldDisplayDefine displayDefine, String value) {
// 字典优先
if (StringUtils.isNotEmpty(displayDefine.dictCode())) {
// 1.1兼容之前的业务字典,有字典配置时默认是业务字典
if(StringUtils.isNotEmpty(displayDefine.dictCode()) && (displayDefine.dictType().equals(FieldDisplayDefine.DictType.no) || displayDefine.dictType().equals(FieldDisplayDefine.DictType.cb))){
return dataDictTypeHandler.handle(displayDefine.dictCode(), value);
}
// 1.2平台字典
if(StringUtils.isNotEmpty(displayDefine.dictCode()) && displayDefine.dictType().equals(FieldDisplayDefine.DictType.platform)){
return platformDictTypeHandler.handle(displayDefine.dictCode(), value);
}
// 其次是自定义的处理器
try {
TypeHandler<String> handler = handlerCache.computeIfAbsent(displayDefine.typeHandler(),
......
......@@ -28,7 +28,8 @@ public class PlatformDictTypeHandler implements DictTypeHandler {
if (StringUtils.isEmpty(dictCode)){
return null;
}
return cache.computeIfAbsent(dictCode, k -> {
String key = dictType + "_" + dictCode;
return cache.computeIfAbsent(key, k -> {
try {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues(dictType).getResult();
......
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