package com.product.mobile.core.service;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.google.common.collect.Lists;
|
import com.google.common.collect.Maps;
|
import com.google.common.collect.Sets;
|
import com.product.common.lang.StringUtils;
|
import com.product.core.cache.DataPoolCacheImpl;
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.face.entity.FaceListEntity;
|
import com.product.face.service.FaceApplyService;
|
import com.product.face.util.FaceUtil;
|
import com.product.mobile.core.config.MobileCoreCode;
|
import com.product.mobile.core.entity.FaceFieldEntity;
|
import com.product.tool.flow.config.CmnConst;
|
import com.product.tool.flow.service.FlowDetailService;
|
import com.product.util.BaseUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* @Author cheng
|
* @Date 2024/8/15 10:21
|
* @Desc
|
*/
|
@Service
|
public class FaceMobileService extends AbstractBaseService {
|
|
@Resource
|
FlowDetailService flowDetailService;
|
|
@Autowired
|
public BaseDao baseDao;
|
@Autowired
|
private FaceApplyService faceApplyService;
|
|
///获取表单总入口
|
/**
|
*
|
* @param fse传入表名,或 表UUID
|
* @return
|
*/
|
public Object getFaceConfig(FieldSetEntity fse) {
|
|
String tableUuid = fse.getString("table_uuid");
|
if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("uuid"))
|
&& StringUtils.isEmpty(fse.getString("table_name"))) {
|
//通过业务表信息查表单信息
|
FieldSetEntity detailFse = getBaseDao().getFieldSetEntity(CmnConst.TABLE_FLOW_DETAIL, fse.getString(CmnConst.FIELD_UUID), false);
|
if (detailFse != null) {
|
//获取表名
|
fse.setValue("table_name", detailFse.getString("table_name"));
|
}
|
|
}
|
//通过审批任务的uuid来查表单信息
|
if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("table_name"))) {
|
FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("所有表信息", new String[]{fse.getString("table_name")});
|
if (!FieldSetEntity.isEmpty(tableInfo)) {
|
tableUuid = tableInfo.getString("uuid");
|
fse.setValue("table_uuid", tableUuid);
|
}
|
}
|
|
if (tableUuid != null && fse.getString("table_name") == null) {
|
|
FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("所有表信息(uuid)", new String[]{tableUuid});
|
if (!FieldSetEntity.isEmpty(tableInfo)) {
|
//获取表名
|
fse.setValue("table_name", tableInfo.getString("table_name"));
|
}
|
}
|
|
Object o = getFaceFieldByTable(fse);
|
if (o instanceof FaceListEntity) {
|
return o;
|
}
|
List<FaceFieldEntity> ls = (List<FaceFieldEntity>) o;
|
if (ls == null) ls = new ArrayList<FaceFieldEntity>();
|
addproperty(tableUuid, fse.getString("table_name"), ls);
|
//所有表单uuid自动添加,并为hidden
|
return ls;
|
|
}
|
//递归把主表和子表的字段属性添加进去,如果没有配表单,则取表数据结构进行展示
|
|
/**
|
*
|
* @param ls查出来的表单信息
|
* @param tables 记录的所有表,对应的表单信息
|
*/
|
private void addproperty(String table_uuid, String table_name, List<FaceFieldEntity> ls) {
|
if (ls.size() > 0) {
|
for (int i = 0; i < ls.size(); i++) {
|
String subTableName = ls.get(i).getSubTableName();///可能是子表
|
if (StringUtils.isEmpty(subTableName)) {///主表字段
|
DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("表字段信息"
|
, new String[]{table_uuid, ls.get(i).getField()});
|
|
if (!DataTableEntity.isEmpty(dt)) {
|
// if(StringUtils.isEmpty(ls.get(i).getType())) {
|
// ls.get(i).setType(dt.getFieldSetEntity(0).getString("field_type"));
|
// }
|
if (StringUtils.isEmpty(ls.get(i).getPrompt()) &&
|
!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_reference"))) {
|
ls.get(i).setPrompt(dt.getFieldSetEntity(0).getString("field_reference"));
|
}
|
if (StringUtils.isEmpty(ls.get(i).getRequired()) &&
|
!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("is_required"))) {
|
ls.get(i).setRequired(dt.getFieldSetEntity(0).getString("is_required"));
|
}
|
if (StringUtils.isEmpty(ls.get(i).getName()) &&
|
!StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_show_name"))) {
|
ls.get(i).setName(dt.getFieldSetEntity(0).getString("field_show_name"));
|
}
|
if ("file".indexOf(ls.get(i).getComponentType()) != -1) {
|
//附件
|
//获取字段类型
|
String fieldType = dt.getString(0, "field_type");
|
if ("file-image".equals(fieldType)) {
|
ls.get(i).putOtherParam("fieldType", "image");
|
} else {
|
// ls.get(i).putOtherParam("fieldType", "file");
|
}
|
}
|
}
|
ls.get(i).setTable(table_name);
|
} else {
|
//============把子表字段也处理一下
|
//子表
|
FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("所有表信息", new String[]{subTableName});
|
if (!FieldSetEntity.isEmpty(tableInfo)) {
|
addproperty(tableInfo.getString("uuid"), tableInfo.getString("table_name"), ls.get(i).getSubField());
|
}
|
}
|
|
}
|
DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("表字段信息", new String[]{table_uuid, "uuid"});
|
if (!DataTableEntity.isEmpty(dt)) {
|
FaceFieldEntity uuid = new FaceFieldEntity();
|
uuid.setComponentType("uuid");
|
uuid.setField("uuid");
|
uuid.setName("编 码");
|
uuid.setType("String");
|
uuid.setTable(table_name);
|
uuid.setHidden("1");
|
uuid.setDisabled("1");
|
ls.add(uuid);
|
}
|
|
} else {///以表单设计为准,如果没有配置表单,则以数据表为准,全部保留
|
toConvertFace(table_uuid, table_name, ls, null);
|
//返回子表
|
Object[][] sub = baseDao.getSubTableName(table_name);
|
if (sub != null && sub.length > 0 && sub[0].length > 0) {
|
for (int i = 0; i < sub[0].length; i++) {
|
toConvertFace(sub[0][i].toString(), sub[1][i].toString(), new ArrayList<FaceFieldEntity>(), ls);
|
}
|
}
|
|
}
|
}
|
|
/**
|
* 数据库表字段定义转换成表单定义
|
* @param table_uuid
|
* @param table_name
|
* @param ls
|
* @param pls 父界面
|
*/
|
private void toConvertFace(String table_uuid, String table_name, List<FaceFieldEntity> ls, List<FaceFieldEntity> pls) {
|
if (ls == null) {
|
ls = new ArrayList<FaceFieldEntity>();
|
}
|
DataTableEntity dte = DataPoolCacheImpl.getInstance().getCacheData("所有字段信息并按表分组", new String[]{table_uuid});
|
for (int j = 0; j < dte.getRows(); j++) {
|
FaceFieldEntity uuid = new FaceFieldEntity();
|
FieldSetEntity f = dte.getFieldSetEntity(j);
|
if ("pk".equals(f.getString("field_type"))
|
// || "created_by".equals(f.getString("field_name"))
|
// || "created_utc_datetime".equals(f.getString("field_name"))
|
|| "updated_by".equals(f.getString("field_name"))
|
|| "updated_utc_datetime".equals(f.getString("field_name"))
|
|| "flowsign".equals(f.getString("field_type"))
|
) {
|
continue;
|
}
|
if ("uuid".equals(f.getString("field_name"))) {
|
uuid.setHidden("1");
|
uuid.setDisabled("1");
|
}
|
if ("userids".equals(f.getString("field_type")) || "orgUuids".equals(f.getString("field_type"))) {
|
uuid.setMultiple("1");
|
} else {
|
uuid.setMultiple("0");
|
}
|
|
if ("userids".equals(f.getString("field_type")) || "userid".equals(f.getString("field_type"))) {
|
uuid.setOrganizationType("5");
|
} else if ("orgUuids".equals(f.getString("field_type")) || "orgUuid".equals(f.getString("field_type"))) {
|
uuid.setOrganizationType("2");
|
}
|
|
uuid.setComponentType("");
|
uuid.setPrompt(f.getString("field_reference"));
|
uuid.setName(f.getString("field_show_name"));
|
uuid.setField(f.getString("field_name"));
|
uuid.setType(f.getString("field_type"));
|
uuid.setRequired(f.getString("is_required"));
|
uuid.setTable(table_name);
|
ls.add(uuid);
|
}
|
if (pls != null) {
|
FaceFieldEntity uuid = new FaceFieldEntity();
|
uuid.setHidden("");
|
uuid.setComponentType("subTable");
|
uuid.setPrompt("");
|
uuid.setName("");
|
uuid.setField("");
|
uuid.setType("");
|
uuid.setSubField(ls);
|
uuid.setSubTableName(table_name);
|
pls.add(uuid);
|
}
|
}
|
|
public Object getFaceFieldByTable(FieldSetEntity fse) {
|
String tableUuid = fse.getString("table_uuid");
|
String tableName = fse.getString("table_name");
|
if (StringUtils.isEmpty(tableUuid) && !StringUtils.isEmpty(tableName)) {
|
FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("所有表信息", new String[]{tableName});
|
if (!FieldSetEntity.isEmpty(tableInfo)) {
|
tableUuid = tableInfo.getString("uuid");
|
}
|
}
|
if (StringUtils.isEmpty(tableUuid)) {
|
throw new BaseException(MobileCoreCode.SYSTEM_FORM_COUNT);
|
}
|
String faceType = BaseUtil.ifNull(fse.getString("face_type"), "2");
|
FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=? and face_type=?", new Object[]{tableUuid, faceType}, true);
|
faceFse.setTableName(tableName);
|
if ("1".equals(faceType) && FieldSetEntity.isEmpty(faceFse)) {
|
//列表
|
return faceApplyService.getFaceListConf(faceFse);
|
}
|
return getFaceField(faceFse);
|
}
|
|
|
public List<FaceFieldEntity> getFlowFaceField(FieldSetEntity fse) throws BaseException {
|
String flowBusinessForm = flowDetailService.getFlowBusinessForm(fse);
|
JSONObject jsonObject = JSON.parseObject(flowBusinessForm);
|
JSONObject data = jsonObject.getJSONObject("data");
|
FieldSetEntity faceFse = null;
|
if (data != null && !StringUtils.isEmpty(data.getString("face_number"))) {
|
if (!StringUtils.isEmpty(data.getString("face_number"))) {
|
faceFse = getBaseDao().getFieldSetEntityByFilter("product_sys_face", "face_number=?", new Object[]{data.getString("face_number")}, true);
|
}
|
} else {
|
do {
|
//根据流程获取表名
|
FieldSetEntity detailFse;
|
if (CmnConst.TABLE_FLOW_TASK.equals(fse.getTableName())) {
|
detailFse = getBaseDao().getFieldSetEntityByFilter(CmnConst.TABLE_FLOW_DETAIL, "task_uuid=? and source_uuid is null", new Object[]{fse.getUUID()}, false);
|
} else {
|
detailFse = getBaseDao().getFieldSetEntity(CmnConst.TABLE_FLOW_DETAIL, fse.getString(CmnConst.FIELD_UUID), false);
|
}
|
if (FieldSetEntity.isEmpty(detailFse)) {
|
break;
|
}
|
//获取表名
|
String tableName = detailFse.getString("table_name");
|
FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("所有表信息", new String[]{tableName});
|
if (FieldSetEntity.isEmpty(tableInfo)) {
|
break;
|
}
|
String tableUuid = tableInfo.getString("uuid");
|
faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=?", new Object[]{tableUuid}, true);
|
} while (false);
|
|
}
|
return getFaceField(faceFse);
|
}
|
|
private List<FaceFieldEntity> getFaceField(FieldSetEntity faceFse) {
|
if (FieldSetEntity.isEmpty(faceFse) || DataTableEntity.isEmpty(faceFse.getSubDataTable("product_sys_face_control_property"))) {
|
return null;
|
// throw new BaseException(MobileCoreCode.GET_FACE_CONFIG_FAIL);
|
}
|
|
DataTableEntity productSysFaceControlProperty = faceFse.getSubDataTable("product_sys_face_control_property");
|
List<FieldSetEntity> tagFieldSetEntityList = new ArrayList<>();
|
//根据group_uuid 分组
|
Map<String, List<FieldSetEntity>> groupMap = new HashMap<>();
|
Map<String, List<FieldSetEntity>> parentMap = new HashMap<>();
|
for (FieldSetEntity fieldSetEntity : productSysFaceControlProperty.getData()) {
|
String groupUuid = fieldSetEntity.getString("group_uuid");
|
String parentUuid = fieldSetEntity.getString("parent_uuid");
|
if (!StringUtils.isEmpty(parentUuid)) {
|
List<FieldSetEntity> fieldSetEntities = parentMap.get(parentUuid);
|
if (fieldSetEntities == null) {
|
fieldSetEntities = new ArrayList<>();
|
parentMap.put(parentUuid, fieldSetEntities);
|
}
|
fieldSetEntities.add(fieldSetEntity);
|
}
|
if ("tag".equals(fieldSetEntity.getString("property_name"))) {
|
tagFieldSetEntityList.add(fieldSetEntity);
|
}
|
if (StringUtils.isEmpty(groupUuid)) {
|
continue;
|
}
|
if (!groupMap.containsKey(groupUuid)) {
|
groupMap.put(groupUuid, new ArrayList<>());
|
}
|
groupMap.get(groupUuid).add(fieldSetEntity);
|
}
|
|
if (CollectionUtil.isEmpty(groupMap)) {
|
throw new BaseException(MobileCoreCode.GET_FACE_CONFIG_FAIL);
|
}
|
Map<String, Map<String, Object>> group = new HashMap<>();
|
List<FaceFieldEntity> result = new ArrayList<>();
|
Map<String, List<FieldSetEntity>> subTableFieldMap = new HashMap<>();
|
for (FieldSetEntity fs : tagFieldSetEntityList) {
|
String groupUuid = fs.getString("group_uuid");
|
String parentUuid = fs.getString("parent_uuid");
|
if (StringUtils.isEmpty(groupUuid) || StringUtils.isEmpty(parentUuid)) {
|
continue;
|
}
|
List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid);
|
int i = result.size();
|
to(groupMap, fieldSetEntity, subTableFieldMap, result, parentMap);
|
String parentUuid1 = fieldSetEntity.get(0).getString("parent_uuid");
|
if (!CollectionUtil.isEmpty(fieldSetEntity) && !StringUtils.isEmpty(parentUuid1)) {
|
if (i + 1 == result.size()) {
|
Map<String, Object> o = group.get(parentUuid1);
|
List<FieldSetEntity> configValueList = null;
|
if (o == null) {
|
List<FieldSetEntity> fieldSetEntity1 = productSysFaceControlProperty.getFieldSetEntity(parentUuid1);
|
List<FieldSetEntity> fieldSetEntity2 = productSysFaceControlProperty.getFieldSetEntity(fieldSetEntity1.get(0).getString("parent_uuid"));
|
List<FieldSetEntity> fieldSetEntities = groupMap.get(fieldSetEntity2.get(0).getString("group_uuid"));
|
//list转map
|
Map<String, Object> map = new HashMap<>();
|
String tabsChldren = null;
|
for (FieldSetEntity fieldSetEntity3 : fieldSetEntities) {
|
map.put(fieldSetEntity3.getString("property_name"), fieldSetEntity3.getString("property_value"));
|
if ("__config__".equals(fieldSetEntity3.getString("property_name"))) {
|
configValueList = parentMap.get(fieldSetEntity3.getString("uuid"));
|
map.put("__config__", configValueList);
|
}
|
if ("children".equals(fieldSetEntity3.getString("property_name"))) {
|
tabsChldren = fieldSetEntity3.getString("property_value");
|
}
|
}
|
if (map.get("tag") != null && "el-tabs".equals(map.get("tag"))) {
|
map.remove("label");
|
if (tabsChldren != null) {
|
|
}
|
}
|
group.put(parentUuid1, map);
|
o = map;
|
|
} else {
|
configValueList = (List<FieldSetEntity>) o.get("__config__");
|
}
|
result.get(i).putOtherParam("parentContainerName", BaseUtil.ifNull(o.get("title"), o.get("label")));
|
result.get(i).putOtherParam("parentContainer", parentUuid1);
|
Map<String, Object> configValueMap = null;
|
if (configValueList != null) {
|
|
//获取property_name=showComponentFilter
|
Optional<FieldSetEntity> showComponentFilter = configValueList.stream().filter(fieldSetEntity1 -> "showComponentFilter".equals(fieldSetEntity1.getString("property_name"))).findFirst();
|
if (showComponentFilter.isPresent()) {
|
String u = showComponentFilter.get().getString("uuid");
|
List<FieldSetEntity> fieldSetEntities = parentMap.get(u);
|
JSONArray arrFilter = null;
|
if (fieldSetEntities != null && !fieldSetEntities.isEmpty()) {
|
JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(showComponentFilter.get()), parentMap);
|
arrFilter = propertyJson.getJSONArray("showComponentFilter");
|
}
|
if (arrFilter != null) {
|
if (result.get(i).getShowComponentFilter() == null) {
|
result.get(i).setShowComponentFilter(arrFilter);
|
} else {
|
result.get(i).getShowComponentFilter().addAll(arrFilter);
|
}
|
}
|
}
|
}
|
if (o.get("configValue") != null) {
|
configValueMap = (Map<String, Object>) o.get("configValue");
|
}
|
if ((configValueList != null || configValueMap != null) && StringUtils.isEmpty(BaseUtil.ifNull(o.get("title"), o.get("label")))) {
|
if (configValueMap == null) {
|
configValueMap = new HashMap<>();
|
for (FieldSetEntity fieldSetEntity4 : configValueList) {
|
configValueMap.put(fieldSetEntity4.getString("property_name"), fieldSetEntity4.getString("property_value"));
|
}
|
}
|
//tag
|
String tag = (String) configValueMap.get("tag");
|
if ("el-card".equals(tag)) {
|
result.get(i).putOtherParam("parentContainerName", configValueMap.get("label"));
|
} else if ("el-tabs".equals(tag)) {
|
System.out.println(1);
|
} else {
|
System.out.println(2);
|
}
|
o.put("configValue", configValueMap);
|
}
|
}
|
}
|
}
|
//根据group_uuid 将子表字段分组5
|
if (!CollectionUtil.isEmpty(subTableFieldMap)) {
|
//根据子表表名装载
|
Map<String, FaceFieldEntity> tableByFaceField = new HashMap<>();
|
for (Map.Entry<String, List<FieldSetEntity>> entry : subTableFieldMap.entrySet()) {
|
List<FieldSetEntity> fieldSetEntities = entry.getValue();
|
String parentUuid = fieldSetEntities.get(0).getString("parent_uuid");
|
//先找到children
|
List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid);
|
if (CollectionUtil.isEmpty(fieldSetEntities)) {
|
continue;
|
}
|
//找到了children
|
FieldSetEntity fieldSetEntity1 = fieldSetEntity.get(0);
|
String p = fieldSetEntity1.getString("parent_uuid");
|
String cGroupUuid = fieldSetEntity1.getString("group_uuid");
|
if (StringUtils.isEmpty(p) || StringUtils.isEmpty(cGroupUuid)) {
|
continue;
|
}
|
List<FieldSetEntity> childrenGroup = groupMap.get(cGroupUuid);
|
List<FieldSetEntity> fieldSetEntity2 = productSysFaceControlProperty.getFieldSetEntity(p);
|
if (CollectionUtil.isEmpty(fieldSetEntity2) || CollectionUtil.isEmpty(childrenGroup)) {
|
continue;
|
}
|
//找到了 __config__
|
FieldSetEntity fieldSetEntity3 = fieldSetEntity2.get(0);
|
String groupUuid = fieldSetEntity3.getString("group_uuid");
|
if (StringUtils.isEmpty(groupUuid)) {
|
continue;
|
}
|
String uuid = fieldSetEntity3.getUUID();
|
|
FaceFieldEntity faceFieldEntity = tableByFaceField.get(uuid);
|
if (faceFieldEntity == null) {
|
faceFieldEntity = new FaceFieldEntity();
|
}
|
faceFieldEntity.setComponentType("subTable");
|
boolean isSub = CollectionUtil.isNotEmpty(faceFieldEntity.getSubField());
|
if (!isSub) {
|
for (FieldSetEntity setEntity : childrenGroup) {
|
String propertyName = setEntity.getString("property_name");
|
if ("tag".equals(propertyName) && "lx-form-sub-table".equals(setEntity.getString("property_value"))) {
|
isSub = true;
|
break;
|
}
|
}
|
}
|
if (!isSub) {
|
//不是子表组件
|
continue;
|
}
|
List<FaceFieldEntity> fields = new ArrayList<>();
|
for (FieldSetEntity setEntity : fieldSetEntities) {
|
to(groupMap, Lists.newArrayList(setEntity), null, fields, parentMap);
|
}
|
|
faceFieldEntity.setSubField(fields);
|
for (FieldSetEntity setEntity : groupMap.get(groupUuid)) {
|
String propertyName = setEntity.getString("property_name");
|
if ("subTableName".equals(propertyName)) {
|
faceFieldEntity.setSubTableName(setEntity.getString("property_value"));
|
tableByFaceField.put(faceFieldEntity.getSubTableName(), faceFieldEntity);
|
} else if ("add".equals(propertyName)) {
|
faceFieldEntity.setAllowAdd(setEntity.getBoolean("property_value"));
|
} else if ("delete".equals(propertyName)) {
|
faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value"));
|
} else if ("control_sequence".equals(propertyName)) {
|
faceFieldEntity.putOtherParam("controlSequence", setEntity.getInteger("property_value"));
|
} else if ("__config__".equals(propertyName)) {
|
|
String __config__ = setEntity.getUUID();
|
List<FieldSetEntity> fieldSetEntities2 = parentMap.get(__config__);
|
if (!CollectionUtil.isEmpty(fieldSetEntities2)) {
|
for (FieldSetEntity fieldSetEntity4 : fieldSetEntities2) {
|
if ("label".equals(fieldSetEntity4.getString("property_name"))) {
|
faceFieldEntity.setName(fieldSetEntity4.getString("property_value"));
|
} else if ("required".equals(fieldSetEntity4.getString("property_name"))) {
|
faceFieldEntity.setRequired(fieldSetEntity4.getBoolean("property_value") ? "1" : "0");
|
}
|
}
|
}
|
}
|
}
|
List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField();
|
if (CollectionUtil.isEmpty(subFieldList)) {
|
subFieldList = new ArrayList<>();
|
faceFieldEntity.setSubField(subFieldList);
|
}
|
if (!tableByFaceField.containsKey(uuid)) {
|
tableByFaceField.put(uuid, faceFieldEntity);
|
result.add(faceFieldEntity);
|
}
|
}
|
|
}
|
result.sort((item, item2) -> {
|
Object o = item.getOtherParams().get("controlSequence");
|
if (o == null) {
|
return -1;
|
}
|
Object o1 = item2.getOtherParams().get("controlSequence");
|
if (o1 == null) {
|
return 1;
|
}
|
return NumberUtil.parseInt(item.getOtherParams().get("controlSequence").toString()) - NumberUtil.parseInt(item2.getOtherParams().get("controlSequence").toString());
|
});
|
return result;
|
}
|
|
|
private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, Map<String, List<FieldSetEntity>> subTableField, List<FaceFieldEntity> result, Map<String, List<FieldSetEntity>> parentMap) {
|
FieldSetEntity parent = fieldSetEntity.get(0);
|
Map<String, List<FieldSetEntity>> oldParentMap = Maps.newHashMap(parentMap);
|
String groupUuid1 = parent.getString("group_uuid");
|
if (StringUtils.isEmpty(groupUuid1)) {
|
return;
|
}
|
List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1);
|
FaceFieldEntity faceFieldEntity = new FaceFieldEntity();
|
String __config__ = null;
|
List<FieldSetEntity> other = null;
|
do {
|
for (FieldSetEntity setEntity : parentGroup) {
|
//找到属性名称= __vModel__
|
String propertyName = setEntity.getString("property_name");
|
if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
|
continue;
|
}
|
if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) {
|
//子表字段
|
String parentUuid = setEntity.getString("parent_uuid");
|
List<FieldSetEntity> fieldSetEntities = subTableField.get(parentUuid);
|
if (fieldSetEntities == null) {
|
fieldSetEntities = new ArrayList<>();
|
subTableField.put(parentUuid, fieldSetEntities);
|
}
|
fieldSetEntities.add(setEntity);
|
result.remove(faceFieldEntity);
|
break;
|
}
|
if ("__vModel__".equals(setEntity.getString("property_name"))) {
|
result.add(faceFieldEntity);
|
propertyName = "field";
|
} else if ("label".equals(setEntity.getString("property_name"))) {
|
propertyName = "name";
|
} else if ("advanceName".equals(setEntity.getString("property_name"))) {
|
propertyName = "prompt";
|
} else if ("__config__".equals(propertyName)) {
|
__config__ = setEntity.getUUID();
|
List<FieldSetEntity> fieldSetEntities = oldParentMap.get(__config__);
|
if (!CollectionUtil.isEmpty(fieldSetEntities)) {
|
//查询showComponentFilter
|
Optional<FieldSetEntity> propertyName1 = fieldSetEntities.stream().filter(item -> "showComponentFilter".equals(item.getString("property_name"))).findFirst();
|
if (propertyName1.isPresent()) {
|
JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(propertyName1.get()), oldParentMap);
|
if (propertyJson != null && propertyJson.get("showComponentFilter") != null) {
|
faceFieldEntity.addShowComponentFilter(propertyJson.getJSONArray("showComponentFilter"));
|
}
|
}
|
}
|
}
|
if (!StringUtils.isAnyEmpty(__config__)) {
|
//读取子表属性
|
if (parentMap != null) {
|
other = parentMap.get(__config__);
|
}
|
}
|
propertyName = StrUtil.toCamelCase(propertyName);
|
if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) {
|
continue;
|
}
|
if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) {
|
ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
|
|
} else if (!StringUtils.isEmpty(setEntity.getObject("property_value"))) {
|
//判断是否
|
faceFieldEntity.putOtherParam(propertyName, setEntity.getObject("property_value"));
|
}
|
}
|
if (StringUtils.isEmpty(faceFieldEntity.getField())) {
|
return;
|
}
|
if (parentGroup == other) {
|
break;
|
}
|
if (other != null) {
|
parentGroup = other;
|
parentMap = null;
|
}
|
} while (other != null);
|
Set<FieldSetEntity> configGroup = Sets.newHashSet(groupMap.get(fieldSetEntity.get(0).getString("group_uuid")));
|
if (other != null) {
|
if (configGroup == null) {
|
configGroup = Sets.newHashSet(other);
|
} else {
|
configGroup.addAll(other);
|
}
|
}
|
parentGroup = groupMap.get(groupUuid1);
|
if (configGroup != null && parentGroup != null) {
|
configGroup.addAll(parentGroup);
|
}
|
|
for (FieldSetEntity setEntity : configGroup) {
|
//找到属性名称= __vModel__
|
String propertyName = setEntity.getString("property_name");
|
if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) {
|
continue;
|
}
|
if ("tag".equals(propertyName)) {
|
propertyName = "component_type";
|
} else if ("field".equals(propertyName)) {
|
propertyName = "fileField";
|
} else if ("tableName".equals(propertyName)) {
|
propertyName = "fileTableName";
|
} else if ("label".equals(setEntity.getString("property_name"))) {
|
propertyName = "name";
|
} else if ("advanceName".equals(setEntity.getString("property_name"))) {
|
propertyName = "prompt";
|
}
|
propertyName = StrUtil.toCamelCase(propertyName);
|
if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) {
|
continue;
|
}
|
Object propertyValue = setEntity.getObject("property_value");
|
if (oldParentMap != null && propertyValue == null && StringUtils.equalsAny(setEntity.getString("property_type"), "2", "3", "4")) {
|
JSONObject propertyJson = FaceUtil.getPropertyJson(Lists.newArrayList(setEntity), oldParentMap);
|
if (propertyJson != null && propertyJson.get(setEntity.getString("property_name")) != null) {
|
propertyValue = propertyJson.get(setEntity.getString("property_name"));
|
}
|
}
|
if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) {
|
ReflectUtil.setFieldValue(faceFieldEntity, propertyName, propertyValue);
|
}
|
}
|
}
|
|
}
|