钉钉审批功能完善、混炼示方新增是否附加料
This commit is contained in:
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecg.modules.print.vo.PrintBizFieldItemVO;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
@@ -46,6 +47,7 @@ public final class PrintBizEntityFieldIntrospector {
|
||||
PrintBizFieldItemVO vo =
|
||||
new PrintBizFieldItemVO(name, resolveLabel(f), "");
|
||||
fillJavaJdbcSimple(vo, f.getType());
|
||||
fillDictMeta(vo, f);
|
||||
ordered.putIfAbsent(name, vo);
|
||||
}
|
||||
c = c.getSuperclass();
|
||||
@@ -223,6 +225,69 @@ public final class PrintBizEntityFieldIntrospector {
|
||||
return f.getName();
|
||||
}
|
||||
|
||||
//update-begin---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】扫描@Dict并补全字典元数据-----------
|
||||
/** 扫描 @Dict 注解,供绑定页选择「原值/显示文本」 */
|
||||
public static void fillDictMeta(PrintBizFieldItemVO vo, Field f) {
|
||||
if (vo == null || f == null) {
|
||||
return;
|
||||
}
|
||||
Dict dict = f.getAnnotation(Dict.class);
|
||||
if (dict == null) {
|
||||
vo.setTranslateKind("NONE");
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isNotBlank(dict.dictTable())) {
|
||||
vo.setTranslateKind("TABLE");
|
||||
vo.setDictTable(dict.dictTable().trim());
|
||||
vo.setDictText(StringUtils.isNotBlank(dict.dicText()) ? dict.dicText().trim() : "");
|
||||
vo.setDictCodeField(StringUtils.isNotBlank(dict.dicCode()) ? dict.dicCode().trim() : "id");
|
||||
} else if (StringUtils.isNotBlank(dict.dicCode())) {
|
||||
vo.setTranslateKind("DICT");
|
||||
vo.setDictCode(dict.dicCode().trim());
|
||||
} else {
|
||||
vo.setTranslateKind("NONE");
|
||||
}
|
||||
}
|
||||
|
||||
/** 按字段名在实体类上补全字典元数据(catalog 缓存字段可能缺 translateKind) */
|
||||
public static void enrichDictMeta(List<PrintBizFieldItemVO> fields, Class<?> clazz, String fieldKeyPrefix) {
|
||||
if (fields == null || fields.isEmpty() || clazz == null) {
|
||||
return;
|
||||
}
|
||||
String prefix = StringUtils.isBlank(fieldKeyPrefix) ? "" : fieldKeyPrefix.trim();
|
||||
if (StringUtils.isNotBlank(prefix) && !prefix.endsWith(".")) {
|
||||
prefix = prefix + ".";
|
||||
}
|
||||
Map<String, Field> fieldMap = new LinkedHashMap<>();
|
||||
Class<?> c = clazz;
|
||||
while (c != null && c != Object.class) {
|
||||
for (Field f : c.getDeclaredFields()) {
|
||||
fieldMap.putIfAbsent(f.getName(), f);
|
||||
}
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
for (PrintBizFieldItemVO vo : fields) {
|
||||
if (vo == null || StringUtils.isBlank(vo.getFieldKey())) {
|
||||
continue;
|
||||
}
|
||||
String key = vo.getFieldKey();
|
||||
if (StringUtils.isNotBlank(prefix) && key.startsWith(prefix)) {
|
||||
key = key.substring(prefix.length());
|
||||
}
|
||||
int dot = key.indexOf('.');
|
||||
if (dot >= 0) {
|
||||
key = key.substring(dot + 1);
|
||||
}
|
||||
Field f = fieldMap.get(key);
|
||||
if (f != null) {
|
||||
fillDictMeta(vo, f);
|
||||
} else if (StringUtils.isBlank(vo.getTranslateKind())) {
|
||||
vo.setTranslateKind("NONE");
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】扫描@Dict并补全字典元数据-----------
|
||||
|
||||
/** 按全限定类名加载 Class,失败返回 null */
|
||||
public static Class<?> tryLoadClass(String entityClassFqn) {
|
||||
if (StringUtils.isBlank(entityClassFqn)) {
|
||||
|
||||
@@ -35,6 +35,24 @@ public class PrintBizFieldItemVO implements Serializable {
|
||||
@Schema(description = "简化种类,便于前端格式化")
|
||||
private String simpleKind;
|
||||
|
||||
//update-begin---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】字段元数据支持字典/表字典-----------
|
||||
/** 取值翻译类型:NONE=普通字段,DICT=字典,TABLE=表字典(部门/用户等) */
|
||||
@Schema(description = "取值翻译类型:NONE/DICT/TABLE")
|
||||
private String translateKind;
|
||||
|
||||
@Schema(description = "字典编码(dicCode),translateKind=DICT 时有效")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典表名,translateKind=TABLE 时有效")
|
||||
private String dictTable;
|
||||
|
||||
@Schema(description = "字典表文本列,translateKind=TABLE 时有效")
|
||||
private String dictText;
|
||||
|
||||
@Schema(description = "字典表编码列,translateKind=TABLE 时有效")
|
||||
private String dictCodeField;
|
||||
//update-end---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】字段元数据支持字典/表字典-----------
|
||||
|
||||
/** 兼容旧三参构造(类型字段为空) */
|
||||
public PrintBizFieldItemVO(String fieldKey, String label, String description) {
|
||||
this.fieldKey = fieldKey;
|
||||
@@ -53,6 +71,13 @@ public class PrintBizFieldItemVO implements Serializable {
|
||||
o.setJavaType(src.getJavaType());
|
||||
o.setJdbcType(src.getJdbcType());
|
||||
o.setSimpleKind(src.getSimpleKind());
|
||||
//update-begin---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】复制字段时保留字典元数据-----------
|
||||
o.setTranslateKind(src.getTranslateKind());
|
||||
o.setDictCode(src.getDictCode());
|
||||
o.setDictTable(src.getDictTable());
|
||||
o.setDictText(src.getDictText());
|
||||
o.setDictCodeField(src.getDictCodeField());
|
||||
//update-end---author:GHT ---date:2026-06-10 for:【钉钉审批模板绑定】复制字段时保留字典元数据-----------
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user