许鹏程
2024-08-15 7a30e9d5c7e42202fab42af727c9821472d0da84
commit udpate
已添加3个文件
已修改2个文件
337 ■■■■■ 文件已修改
pom.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/config/MobileCoreCode.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/controller/FaceMobileController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/FaceMobileService.java 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -21,6 +21,14 @@
            <groupId>com.lx</groupId>
            <artifactId>product-server-admin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.lx</groupId>
            <artifactId>product-server-tool-flow</artifactId>
        </dependency>
        <dependency>
            <groupId>com.lx</groupId>
            <artifactId>product-server-tool-face</artifactId>
        </dependency>
        <!--releases  -->
        <dependency>
            <groupId>com.lx</groupId>
src/main/java/com/product/mobile/core/config/MobileCoreCode.java
@@ -10,39 +10,43 @@
 * @Desc é”™è¯¯æžšä¸¾
 */
public enum MobileCoreCode implements IEnum {
    SYSTEM_OPERATION_SUCCESS("成功", "200"),
    SYSTEM_FORM_NODATA("请求参数为空", "999"),
    SYSTEM_FORM_COUNT("请求参数有误", "998"),
    SYSTEM_TABLE_NODATA("请求表名有误", "997"),
    SYSTEM_ACQUIRE_PARAM_FAIL("获取参数失败", "996"),
    SYSTEM_CPAGES_NOT_NULL("分页参数不能为空", "995"),
    FIND_NAV_BAR_CONFIG_FAIL("查询导航栏配置详情失败", "001"),
    SAVE_NAV_BAR_CONFIG_FAIL("保存导航栏配置失败", "002"),
    GET_NAV_BAR_CONFIG_LIST_FAIL("查询导航栏配置列表失败", "003"),
    DEL_NAV_BAR_CONFIG_FAIL("删除导航栏配置失败", "004"),
    GET_NAV_BAR_TREE_LIST_FAIL("获取导航栏失败", "005"),
    SYSTEM_OPERATION_SUCCESS("成功", "200"),
    SYSTEM_FORM_NODATA("请求参数为空", "999"),
    SYSTEM_FORM_COUNT("请求参数有误", "998"),
    SYSTEM_TABLE_NODATA("请求表名有误", "997"),
    SYSTEM_ACQUIRE_PARAM_FAIL("获取参数失败", "996"),
    SYSTEM_CPAGES_NOT_NULL("分页参数不能为空", "995"),
    FIND_NAV_BAR_CONFIG_FAIL("查询导航栏配置详情失败", "001"),
    SAVE_NAV_BAR_CONFIG_FAIL("保存导航栏配置失败", "002"),
    GET_NAV_BAR_CONFIG_LIST_FAIL("查询导航栏配置列表失败", "003"),
    DEL_NAV_BAR_CONFIG_FAIL("删除导航栏配置失败", "004"),
    GET_NAV_BAR_TREE_LIST_FAIL("获取导航栏失败", "005"),
    GET_ROUTER_FAIL("获取路由失败", "006"),
    GET_ROUTER_FAIL("获取路由失败", "006"),
    LIST_READ_MESSAGE_FAIL("获取已读消息列表失败", "007"),
    ;
    LIST_READ_MESSAGE_FAIL("获取已读消息列表失败", "007"),
    MobileCoreCode(String text, String code) {
        this.code = code;
        this.text = text;
    }
    GET_FACE_FIELD_FAIL("获取表单字段失败", "008"),
    private String code;
    GET_FACE_CONFIG_FAIL("获取表单配置失败", "009"),
    ;
    private String text;
    MobileCoreCode(String text, String code) {
        this.code = code;
        this.text = text;
    }
    @Override
    public String getText() {
        return this.text;
    }
    private String code;
    @Override
    public String getValue() {
        return ModuleEnum.MOBILE.getValue() + this.code;
    }
    private String text;
    @Override
    public String getText() {
        return this.text;
    }
    @Override
    public String getValue() {
        return ModuleEnum.MOBILE.getValue() + this.code;
    }
}
src/main/java/com/product/mobile/core/controller/FaceMobileController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
package com.product.mobile.core.controller;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.mobile.core.config.MobileCoreCode;
import com.product.mobile.core.service.FaceMobileService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import com.product.util.support.AbstractBaseController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
 * @Author cheng
 * @Date 2024/8/15 10:19
 * @Desc
 */
@RequestMapping("/mobile-face/")
@RestController
public class FaceMobileController extends AbstractBaseController {
    @Resource
    FaceMobileService faceMobileService;
    /**
     * èŽ·å–è¡¨å•æ‰€æœ‰ç»„ä»¶çš„å­—æ®µæ ¹æ®flow_task è¡¨ uuid æˆ–者 flow_detail è¡¨ uuid
     *
     * @param request
     * @return
     */
    @PostMapping("/get-face-field/{version}")
    @ApiVersion(1)
    public String getFaceField(HttpServletRequest request) {
        try {
            //不验证传入的表名 å¯èƒ½ä¼šæ˜¯ product_sys_flow_task/product_sys_flow_detail
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return BaseUtil.success(faceMobileService.getFaceField(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(MobileCoreCode.GET_FACE_FIELD_FAIL, e);
        }
    }
}
src/main/java/com/product/mobile/core/entity/FaceFieldEntity.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,72 @@
package com.product.mobile.core.entity;
/**
 * @Author cheng
 * @Date 2024/8/15 11:12
 * @Desc
 */
public class FaceFieldEntity {
    /**
     * æ˜¯å¦å¿…å¡«
     */
    private String required;
    /**
     * æ˜¾ç¤ºåç§°
     */
    private String label;
    /**
     * å‚照名称
     */
    private String advanceName;
    /**
     * ç»„件类型
     */
    private String componentType;
    /**
     * æ˜¯å¦å¤šé€‰
     */
    private String multiple;
    /**
     * ç¦ç”¨
     */
    private String disabled;
    /**
     * é»˜è®¤å€¼
     */
    private String defaultValue;
    /**
     * æç¤ºä¿¡æ¯
     */
    private String placeholder;
    /**
     * é™„件绑定表名
     */
    private String fileTableName;
    /**
     * é™„件绑定字段
     */
    private String fileField;
    /**
     * æŽ§ä»¶æŽ’序
     */
    private Integer controlSequence;
    /**
     * é«˜çº§å‚照关联设置
     */
    private String promptSetting;
    /**
     * æµæ°´å·é…ç½®
     */
    private String serialNumber;
}
src/main/java/com/product/mobile/core/service/FaceMobileService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,147 @@
package com.product.mobile.core.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.product.common.lang.StringUtils;
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.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.config.FlowCode;
import com.product.tool.flow.service.FlowDetailService;
import com.product.util.BaseUtil;
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;
    public List<FaceFieldEntity> getFaceField(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);
        }
        if (FieldSetEntity.isEmpty(faceFse) || DataTableEntity.isEmpty(faceFse.getSubDataTable("product_sys_face_control_property"))) {
            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<>();
        for (FieldSetEntity fieldSetEntity : productSysFaceControlProperty.getData()) {
            String groupUuid = fieldSetEntity.getString("group_uuid");
            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);
        }
        List<FaceFieldEntity> result = new ArrayList<>();
        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);
            if (CollectionUtil.isEmpty(fieldSetEntity)) {
                continue;
            }
            FieldSetEntity parent = fieldSetEntity.get(0);
            String groupUuid1 = parent.getString("group_uuid");
            if (StringUtils.isEmpty(groupUuid1)) {
                continue;
            }
            List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1);
            FaceFieldEntity faceFieldEntity = new FaceFieldEntity();
            for (FieldSetEntity setEntity : parentGroup) {
                //找到属性名称= __vModel__
                String propertyName = setEntity.getString("property_name");
                if ("__vModel__".equals(setEntity.getString("property_name"))) {
                    result.add(faceFieldEntity);
                    propertyName = "fieldName";
                }
                propertyName = StrUtil.toCamelCase(propertyName);
                if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
                    ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
                }
            }
            List<FieldSetEntity> configGroup = groupMap.get(groupUuid);
            for (FieldSetEntity setEntity : configGroup) {
                //找到属性名称= __vModel__
                String propertyName = setEntity.getString("property_name");
                if ("tag".equals(propertyName)) {
                    result.add(faceFieldEntity);
                    propertyName = "component_type";
                } else if ("field".equals(propertyName)) {
                    propertyName = "fileField";
                } else if ("tableName".equals(propertyName)) {
                    propertyName = "fileTableName";
                }
                propertyName = StrUtil.toCamelCase(propertyName);
                if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) {
                    ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value"));
                }
            }
        }
        return result;
    }
}