许鹏程
2025-01-22 e616e2f0a90fb155ad67495d27bd5057a23cbf43
fix:移动端获取表单设计器新增属性【显示组件过滤】
已修改2个文件
106 ■■■■■ 文件已修改
src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/FaceMobileService.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java
@@ -1,5 +1,7 @@
package com.product.mobile.core.entity;
import com.alibaba.fastjson.JSONArray;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
@@ -98,6 +100,8 @@
     */
    private String hidden;
    
    private JSONArray showComponentFilter;
    public String getHidden() {
        return hidden;
@@ -107,6 +111,7 @@
    public void setHidden(String hidden) {
        this.hidden = hidden;
    }
    private Map<String, Object> otherParams = new HashMap<>();
    
    public String getType() {
@@ -271,6 +276,7 @@
    public void setSubField(List<FaceFieldEntity> subField) {
        this.subField = subField;
    }
        public String getTable() {
        return table;
    }
@@ -278,13 +284,32 @@
    public void setTable(String tableUuid) {
        this.table = tableUuid;
    }
    public Map<String, Object> getOtherParams() {
      return otherParams;
   }
   public void setOtherParams(Map<String, Object> otherParams) {
      this.otherParams = otherParams;
   }
   public Object putOtherParam(String key, Object value) {
      return otherParams.put(key, value);
   }
    public JSONArray getShowComponentFilter() {
        return showComponentFilter;
    }
    public void setShowComponentFilter(JSONArray showComponentFilter) {
        this.showComponentFilter = showComponentFilter;
    }
    public void addShowComponentFilter(JSONArray showComponentFilter){
        if(this.showComponentFilter == null){
            this.showComponentFilter = showComponentFilter;
        }else{
            this.showComponentFilter.addAll(showComponentFilter);
        }
    }
}
src/main/java/com/product/mobile/core/service/FaceMobileService.java
@@ -1,14 +1,12 @@
package com.product.mobile.core.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
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.drew.metadata.Face;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -19,21 +17,17 @@
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.face.util.FaceUtil;
import com.product.mobile.core.config.MobileCoreCode;
import com.product.mobile.core.config.MobileCoreConst;
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.io.File;
import java.nio.charset.Charset;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Author cheng
@@ -343,6 +337,7 @@
                            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");
@@ -357,10 +352,33 @@
                        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");
                    }
@@ -481,35 +499,10 @@
        return result;
    }
    public static void main(String[] args) {
        String textFilePath = "d:\\Desktop\\新建 文本文档 (2).txt";
        List<String> lines = FileUtil.readLines(new File(textFilePath), CharsetUtil.defaultCharset());
        for (int i = 0; i < lines.size(); i++) {
            //UPDATE `product_db_lift`.`product_sys_datamodel_table` SET `uuid` = '4503ea5c-1e10-40b6-a2b4-79760eea6474', `table_name` = 'product_deivce_failure_level_config', `table_description` = '设备故障等级配置', `table_primary_key` = NULL, `container_name` = NULL, `table_base_view` = NULL, `view_sql` = NULL, `org_level_uuid` = NULL, `is_international` = NULL, `table_type` = '1', `created_by` = '1', `created_utc_datetime` = '2024-08-09 00:00:00', `updated_by` = '1', `updated_utc_datetime` = '2024-08-09 00:00:00', `produce_msg` = NULL, `sequence` = 2, `view_status` = NULL WHERE `table_id` = 5300;
            String line = lines.get(i);
            line = line.replaceAll("`", "");
            String start = line.substring(line.indexOf("SET") + 3, line.indexOf("WHERE"));
            String[] split = start.split(",");
            Map<String, String> map = new HashMap<>();
            for (String s : split) {
                String[] split1 = s.split("=");
                String value = split1.length == 1 ? null : split1[1].trim();
                if ("null".equalsIgnoreCase(value)) {
                    value = null;
                }
                map.put(split1[0].trim(), value);
            }
            lines.set(i, lines.get(i).substring(0, lines.get(i).indexOf("WHERE")) + " WHERE `uuid`=" + map.get("uuid") + ";");
        }
        FileUtil.writeLines(lines, textFilePath, CharsetUtil.defaultCharset());
    }
    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;
@@ -546,6 +539,17 @@
                    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__)) {
                    //读取子表属性
@@ -610,8 +614,15 @@
            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, setEntity.getObject("property_value"));
                ReflectUtil.setFieldValue(faceFieldEntity, propertyName, propertyValue);
            }
        }
    }