|
|
@@ -622,7 +622,10 @@ public class ProcessInstanceServiceImpl implements ProcessInstanceService {
|
|
|
}
|
|
|
}
|
|
|
if (!hasPermission) throw new BusinessException("只有当前节点处理人可补充材料");
|
|
|
- String changeDesc = this.diffFormData(instance.getFormData(), formData);
|
|
|
+ // 从流程定义的表单配置中获取 字段名->显示名 映射,记录变更时使用显示名
|
|
|
+ ProcessDefinition def = this.processDefinitionMapper.selectById(instance.getProcessDefinitionId());
|
|
|
+ Map<String, String> fieldLabelMap = this.buildFieldLabelMap(def);
|
|
|
+ String changeDesc = this.diffFormData(instance.getFormData(), formData, fieldLabelMap);
|
|
|
this.processInstanceMapper.update(null, Wrappers.<ProcessInstance>lambdaUpdate()
|
|
|
.eq(ProcessInstance::getId, instanceId)
|
|
|
.set(ProcessInstance::getFormData, formData));
|
|
|
@@ -644,8 +647,30 @@ public class ProcessInstanceServiceImpl implements ProcessInstanceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /** 对比新旧表单数据,返回变更说明;无变化返回 null */
|
|
|
- private String diffFormData(String oldJson, String newJson) {
|
|
|
+ /** 从流程定义的表单配置(form_schema)构建 字段名 -> 显示名 映射 */
|
|
|
+ private Map<String, String> buildFieldLabelMap(ProcessDefinition def) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ if (def == null || def.getFormSchema() == null || def.getFormSchema().isBlank()) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> fields = this.objectMapper.readValue(
|
|
|
+ def.getFormSchema(), new TypeReference<List<Map<String, Object>>>() {});
|
|
|
+ for (Map<String, Object> f : fields) {
|
|
|
+ Object name = f.get("name");
|
|
|
+ Object label = f.get("label");
|
|
|
+ if (name != null && label != null) {
|
|
|
+ map.put(String.valueOf(name), String.valueOf(label));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ // 表单配置解析失败时降级为使用字段名
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 对比新旧表单数据,返回变更说明(使用字段显示名);无变化返回 null */
|
|
|
+ private String diffFormData(String oldJson, String newJson, Map<String, String> labelMap) {
|
|
|
if (newJson == null || newJson.isBlank()) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -654,17 +679,19 @@ public class ProcessInstanceServiceImpl implements ProcessInstanceService {
|
|
|
if (oldMap == null || oldMap.isEmpty()) {
|
|
|
return "补充表单数据";
|
|
|
}
|
|
|
+ java.util.function.Function<String, String> labelOf =
|
|
|
+ key -> labelMap != null && labelMap.containsKey(key) ? labelMap.get(key) : key;
|
|
|
List<String> changed = new ArrayList<>();
|
|
|
for (Map.Entry<String, Object> e : newMap.entrySet()) {
|
|
|
Object oldVal = oldMap.get(e.getKey());
|
|
|
Object newVal = e.getValue();
|
|
|
if (!Objects.equals(oldVal, newVal)) {
|
|
|
- changed.add(e.getKey());
|
|
|
+ changed.add(labelOf.apply(e.getKey()));
|
|
|
}
|
|
|
}
|
|
|
for (String k : oldMap.keySet()) {
|
|
|
if (!newMap.containsKey(k)) {
|
|
|
- changed.add(k + "(删除)");
|
|
|
+ changed.add(labelOf.apply(k) + "(删除)");
|
|
|
}
|
|
|
}
|
|
|
if (changed.isEmpty()) {
|