package com.dl.flowable.utils; import cn.hutool.core.convert.Convert; import com.dl.flowable.core.FormConf; import java.util.List; import java.util.Map; /** * 流程表单工具类 * * @author KonBAI * @createTime 2022/8/7 17:09 */ public class ProcessFormUtils { private static final String CONFIG = "__config__"; private static final String MODEL = "__vModel__"; /** * 填充表单项内容 * * @param formConf 表单配置信息 * @param data 表单内容 */ public static void fillFormData(FormConf formConf, Map data) { for (Map field : formConf.getFields()) { recursiveFillField(field, data); } } @SuppressWarnings("unchecked") private static void recursiveFillField(final Map field, final Map data) { if (!field.containsKey(CONFIG)) { return; } Map configMap = (Map) field.get(CONFIG); if (configMap.containsKey("children")) { List> childrens = (List>) configMap.get("children"); for (Map children : childrens) { recursiveFillField(children, data); } } String modelKey = Convert.toStr(field.get(MODEL)); Object value = data.get(modelKey); if (value != null) { configMap.put("defaultValue", value); } } }