Prechádzať zdrojové kódy

知识库——设备子系统 V1
菜单展示字段信息接口

hyq 1 rok pred
rodič
commit
74eae6f8e7

+ 11 - 1
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/feign/RwAdminFeginImpl.java

@@ -10,6 +10,16 @@ public class RwAdminFeginImpl implements RwAdminFeign {
 
     @Override
     public R getSerialNumberCode(SysSerialVo sysSerialVo) {
-        return R.error("admin服务异常");
+        return R.error("admin服务异常!");
+    }
+
+    @Override
+    public R infoSysModule(String id) {
+        return R.error("admin服务异常!");
+    }
+
+    @Override
+    public R infoPagePart(String id) {
+        return R.error("admin服务异常!");
     }
 }

+ 29 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/feign/RwAdminFeign.java

@@ -4,6 +4,8 @@ import com.rongwei.bscommon.sys.config.FeignConfiguration;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
@@ -29,4 +31,31 @@ public interface RwAdminFeign {
 
     @PostMapping("/sys/generalCRUD/getSerialNumberCode")
     R getSerialNumberCode(@RequestBody SysSerialVo sysSerialVo);
+
+
+    /**
+     * 通过ID查询module
+     *
+     * @param id
+     * @return {@link R}
+     * @date 2024/1/5 13:55
+     * @author shangmi
+     *
+     */
+    @GetMapping("/sys/sysmodule/info/{id}")
+    R infoSysModule(@PathVariable("id") String id);
+
+
+    /**
+     * 通过pagePart id查询菜单
+     *
+     * @param id
+     * @return {@link R}
+     * @date 2024/1/8 11:53
+     * @author shangmi
+     *
+     */
+
+    @GetMapping("/sys/page/part/info/{id}")
+    R infoPagePart(@PathVariable("id") String id);
 }

+ 26 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/service/SubConfigService.java

@@ -0,0 +1,26 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.rongwei.bsentity.vo.KdSubsystemDetailVo;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author shangmi
+ * @title SubConfigService
+ * @date 2024/1/5 14:24
+ * @description 子系统配置
+ */
+@Service
+public interface SubConfigService {
+    /**
+     * 查询菜单字段详细
+     *
+     * @param id 菜单ID
+     * @return {@link List< KdSubsystemDetailVo>}
+     * @date 2024/1/8 11:48
+     * @author shangmi
+     *
+     */
+    List<KdSubsystemDetailVo> getModulesById(String id);
+}

+ 143 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/service/impl/SubConfigServiceImpl.java

@@ -0,0 +1,143 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.rongwei.bscommon.sys.feign.RwAdminFeign;
+import com.rongwei.bscommon.sys.service.SubConfigService;
+import com.rongwei.bsentity.enums.InsttypeEnum;
+import com.rongwei.bsentity.vo.KdSubsystemDetailVo;
+import com.rongwei.rwcommon.base.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @author shangmi
+ * @title SubConfigServiceImpl
+ * @date 2024/1/5 14:31
+ * @description
+ */
+@Service
+public class SubConfigServiceImpl implements SubConfigService {
+
+    private final String[] JSON_NAME = {
+            "urladdr", "insttype", "roption", "global", "base", "editPage", "id",
+            "rowEdit", "layout", "form", "data", "tableColumnName", "columns",
+            "tableColumnType", "tableName", "label"
+    };
+
+    private final String[] TYPE_NAME = {
+            "controlType", "enumType",
+            "dict", "customapi","custom","sql","pagesource",
+            "customApiUrl", "customEnum", "customSql","cacheIdSql"
+    };
+    @Autowired
+    private RwAdminFeign rwAdminFeign;
+
+    /**
+     * 查询菜单字段详细
+     *
+     * @param id 菜单ID
+     * @return {@link List< KdSubsystemDetailVo>}
+     * @date 2024/1/8 11:48
+     * @author shangmi
+     *
+     */
+
+    @Override
+    public List<KdSubsystemDetailVo> getModulesById(String id) {
+        R sysModule = rwAdminFeign.infoSysModule(id);
+        // 获得pagePartID
+        JSONObject module = JSONUtil.parseObj(sysModule.getData());
+        String[] split = module.get(JSON_NAME[0]).toString().split("/");
+        String pagePartId = split[split.length - 1];
+        // 获取编辑页信息
+        String pagePart = getPagePart(pagePartId);
+        //查询页面展示的所有字段
+        return getTableNameByData(pagePart);
+    }
+
+
+    /**
+     * 根据pagePartID查到该ID
+     *
+     * @param pagePartId
+     * @return {@link String}
+     * @date 2024/1/5 16:54
+     * @author shangmi
+     */
+
+    public String getPagePart(String pagePartId) {
+        R sysPagePart = rwAdminFeign.infoPagePart(pagePartId);
+        JSONObject pagePart = JSONUtil.parseObj(sysPagePart.getData());
+        if (InsttypeEnum.TABLE.getMassage().equals(pagePart.get(JSON_NAME[1], String.class)) && !JSONUtil.parseObj(
+                JSONUtil.parseObj(JSONUtil.parseObj(pagePart
+                                .get(JSON_NAME[2])).get(JSON_NAME[3]))
+                        .get(JSON_NAME[4])).get(JSON_NAME[7], Boolean.class)) {
+            // 判断当前页面如果是table页且非行编辑时,将内部editPage页的ID获取并重新调用本方法
+            return getPagePart(JSONUtil.parseObj(JSONUtil.parseObj(JSONUtil.parseObj(JSONUtil.parseObj(pagePart.get(JSON_NAME[2]))
+                    .get(JSON_NAME[3])).get(JSON_NAME[4])).get(JSON_NAME[5])).get(JSON_NAME[6], String.class));
+        } else if (InsttypeEnum.FORM.getMassage().equals(pagePart.get(JSON_NAME[1], String.class))
+                || (InsttypeEnum.TABLE.getMassage().equals(pagePart.get(JSON_NAME[1], String.class))
+                && JSONUtil.parseObj(JSONUtil.parseObj(JSONUtil.parseObj(pagePart
+                .get(JSON_NAME[2])).get(JSON_NAME[3])).get(JSON_NAME[4])).get(JSON_NAME[7], Boolean.class))) {
+            // 当前页面为form时或者table是行编辑时返回他们的roption
+            return pagePart.get(JSON_NAME[2], String.class);
+        }
+        return null;
+    }
+
+
+    /**
+     * 查询页面展示的所有表名
+     *
+     * @param pagePart
+     * @return {@link List< String>}
+     * @date 2024/1/8 10:09
+     * @author shangmi
+     */
+
+    public List<KdSubsystemDetailVo> getTableNameByData(String pagePart) {
+        List form = JSONUtil.parseObj(JSONUtil.parseObj(pagePart).get(JSON_NAME[8])).get(JSON_NAME[9], List.class);
+        List tableColumNameList = (List) form.stream().map(info -> JSONUtil.parseObj(JSONUtil.parseObj(info).get(JSON_NAME[10]))
+                .get(JSON_NAME[11], String.class)).filter(Objects::nonNull).collect(Collectors.toList());
+        List base = JSONUtil.parseObj(JSONUtil.parseObj(pagePart).get(JSON_NAME[12])).get(JSON_NAME[4], List.class);
+        List<KdSubsystemDetailVo> kdSubsystemDetailList = (List<KdSubsystemDetailVo>) base.stream().map(info -> {
+            KdSubsystemDetailVo kdSubsystemDetail = new KdSubsystemDetailVo();
+            JSONObject json = JSONUtil.parseObj(JSONUtil.parseObj(info).get(JSON_NAME[4]));
+            String tablecolumnnane = json.get(JSON_NAME[11], String.class);
+            if (!tableColumNameList.contains(tablecolumnnane)){
+                return null;
+            }
+            kdSubsystemDetail.setTablecolumnnane(tablecolumnnane)
+                    .setTablecolumntype(json.get(JSON_NAME[13], String.class))
+                    .setTablename(json.get(JSON_NAME[14], String.class))
+                    .setLabel(json.get(JSON_NAME[15], String.class));
+            JSONObject controlType = JSONUtil.parseObj(JSONUtil.parseObj(json.get(TYPE_NAME[0])));
+            String enumtype = controlType.get(TYPE_NAME[1], String.class);
+            kdSubsystemDetail.setControltype(controlType.get(TYPE_NAME[0], String.class))
+                    .setEnumtype(enumtype);
+            if (enumtype==null) {
+                return kdSubsystemDetail;
+            }
+            if (TYPE_NAME[2].equals(enumtype)) {
+                kdSubsystemDetail.setDataorigin(controlType.get(TYPE_NAME[2], String.class));
+            } else if (TYPE_NAME[3].equals(enumtype)) {
+                kdSubsystemDetail.setDataorigin(controlType.get(TYPE_NAME[7], String.class));
+            } else if (TYPE_NAME[4].equals(enumtype)) {
+                kdSubsystemDetail.setDataorigin(controlType.get(TYPE_NAME[8], String.class));
+            } else if (TYPE_NAME[5].equals(enumtype)) {
+                kdSubsystemDetail.setDataorigin(controlType.get(TYPE_NAME[9], String.class));
+            } else if (TYPE_NAME[6].equals(enumtype)) {
+                kdSubsystemDetail.setDataorigin(controlType.get(TYPE_NAME[10], String.class));
+            }
+            return kdSubsystemDetail;
+        }).filter(Objects::nonNull).collect(Collectors.toList());
+        return kdSubsystemDetailList;
+    }
+
+
+}

+ 126 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/domain/KbSubsystemConfigDo.java

@@ -0,0 +1,126 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * @author  cyn 
+ * @create 2024-01-03 14:07 
+ */
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("kb_subsystem_config")
+public class KbSubsystemConfigDo {
+
+	/**
+	 * table name:ID
+	 * table type:varchar(36)
+	 * table comment:主键
+	 */
+	private String id;
+
+	/**
+	 * table name:TENANTID
+	 * table type:varchar(36)
+	 * table comment:租户ID
+	 */
+	private String tenantid;
+
+	/**
+	 * table name:ROPTION
+	 * table type:longtext
+	 * table comment:扩展json格式配置
+	 */
+	private String roption;
+
+	/**
+	 * table name:DELETED
+	 * table type:char(1)
+	 * table comment:是否删除
+	 */
+	private String deleted;
+
+	/**
+	 * table name:REMARK
+	 * table type:text
+	 * table comment:备注
+	 */
+	private String remark;
+
+	/**
+	 * table name:CREATEDATE
+	 * table type:datetime
+	 * table comment:创建时间
+	 */
+	private Date createdate;
+
+	/**
+	 * table name:CREATEUSERID
+	 * table type:varchar(36)
+	 * table comment:创建用户ID
+	 */
+	private String createuserid;
+
+	/**
+	 * table name:MODIFYDATE
+	 * table type:datetime
+	 * table comment:修改日期
+	 */
+	private Date modifydate;
+
+	/**
+	 * table name:MODIFYUSERID
+	 * table type:varchar(36)
+	 * table comment:修改用户ID
+	 */
+	private String modifyuserid;
+
+	/**
+	 * table name:CREATEUSERNAME
+	 * table type:varchar(50)
+	 * table comment:创建人名称
+	 */
+	private String createusername;
+
+	/**
+	 * table name:MODIFYUSERNAME
+	 * table type:varchar(50)
+	 * table comment:修改人名称
+	 */
+	private String modifyusername;
+
+	/**
+	 * table name:NAME
+	 * table type:varchar(150)
+	 * table comment:名称
+	 */
+	private String name;
+
+	/**
+	 * table name:NUMBER
+	 * table type:varchar(15)
+	 * table comment:编号
+	 */
+	private String number;
+
+	/**
+	 * table name:MENU
+	 * table type:varchar(255)
+	 * table comment:菜单
+	 */
+	private String menu;
+
+	/**
+	 * table name:MENUID
+	 * table type:varchar(50)
+	 * table comment:菜单ID
+	 */
+	private String menuid;
+
+}

+ 168 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/domain/KbSubsystemDetailDo.java

@@ -0,0 +1,168 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * @author  cyn 
+ * @create 2024-01-03 14:08 
+ */
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("kb_subsystem_detail")
+public class KbSubsystemDetailDo {
+
+	/**
+	 * table name:ID
+	 * table type:varchar(36)
+	 * table comment:主键
+	 */
+	private String id;
+
+	/**
+	 * table name:TENANTID
+	 * table type:varchar(36)
+	 * table comment:租户ID
+	 */
+	private String tenantid;
+
+	/**
+	 * table name:ROPTION
+	 * table type:longtext
+	 * table comment:扩展json格式配置
+	 */
+	private String roption;
+
+	/**
+	 * table name:DELETED
+	 * table type:char(1)
+	 * table comment:是否删除
+	 */
+	private String deleted;
+
+	/**
+	 * table name:REMARK
+	 * table type:text
+	 * table comment:备注
+	 */
+	private String remark;
+
+	/**
+	 * table name:CREATEDATE
+	 * table type:datetime
+	 * table comment:创建时间
+	 */
+	private Date createdate;
+
+	/**
+	 * table name:CREATEUSERID
+	 * table type:varchar(36)
+	 * table comment:创建用户ID
+	 */
+	private String createuserid;
+
+	/**
+	 * table name:MODIFYDATE
+	 * table type:datetime
+	 * table comment:修改日期
+	 */
+	private Date modifydate;
+
+	/**
+	 * table name:MODIFYUSERID
+	 * table type:varchar(36)
+	 * table comment:修改用户ID
+	 */
+	private String modifyuserid;
+
+	/**
+	 * table name:CREATEUSERNAME
+	 * table type:varchar(50)
+	 * table comment:创建人名称
+	 */
+	private String createusername;
+
+	/**
+	 * table name:MODIFYUSERNAME
+	 * table type:varchar(50)
+	 * table comment:修改人名称
+	 */
+	private String modifyusername;
+
+	/**
+	 * table name:MASTERID
+	 * table type:varchar(36)
+	 * table comment:主表ID
+	 */
+	private String masterid;
+
+	/**
+	 * table name:TABLENAME
+	 * table type:varchar(64)
+	 * table comment:表名
+	 */
+	private String tablename;
+
+	/**
+	 * table name:TABLECOLUMNNANE
+	 * table type:varchar(64)
+	 * table comment:表中列名
+	 */
+	private String tablecolumnnane;
+
+	/**
+	 * table name:TABLECOLUMNTYPE
+	 * table type:varchar(20)
+	 * table comment:表中列类型
+	 */
+	private String tablecolumntype;
+
+	/**
+	 * table name:LABEL
+	 * table type:varchar(200)
+	 * table comment:表单名
+	 */
+	private String label;
+
+	/**
+	 * table name:CONTROLTYPE
+	 * table type:varchar(255)
+	 * table comment:表单类型
+	 */
+	private String controltype;
+
+	/**
+	 * table name:ENUMTYPE
+	 * table type:varchar(50)
+	 * table comment:表单数据来源
+	 */
+	private String enumtype;
+
+	/**
+	 * table name:DATAORIGIN
+	 * table type:text
+	 * table comment:数据源
+	 */
+	private String dataorigin;
+
+	/**
+	 * table name:MENU
+	 * table type:varchar(255)
+	 * table comment:菜单
+	 */
+	private String menu;
+
+	/**
+	 * table name:MENUID
+	 * table type:varchar(50)
+	 * table comment:菜单ID
+	 */
+	private String menuid;
+
+}

+ 20 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/enums/InsttypeEnum.java

@@ -0,0 +1,20 @@
+package com.rongwei.bsentity.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author shangmi
+ * @title InsttypeEnum
+ * @date 2024/1/5 16:20
+ * @description TODO
+ */
+@Getter
+@AllArgsConstructor
+public enum InsttypeEnum {
+    TABLE(1,"table"),
+    FORM(2,"form")
+    ;
+    private final Integer code;
+    private final String massage;
+}

+ 67 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/vo/KdSubsystemDetailVo.java

@@ -0,0 +1,67 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * @author shangmi
+ * @title KdSubsystemDetailVo
+ * @date 2024/1/4 10:02
+ * @description Vo
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
+public class KdSubsystemDetailVo {
+    /**
+     * table name:TABLENAME
+     * table type:varchar(64)
+     * table comment:表名
+     */
+    private String tablename;
+
+    /**
+     * table name:TABLECOLUMNNANE
+     * table type:varchar(64)
+     * table comment:表中列名
+     */
+    private String tablecolumnnane;
+
+    /**
+     * table name:TABLECOLUMNTYPE
+     * table type:varchar(20)
+     * table comment:表中列类型
+     */
+    private String tablecolumntype;
+
+    /**
+     * table name:LABEL
+     * table type:varchar(200)
+     * table comment:表单名
+     */
+    private String label;
+
+    /**
+     * table name:CONTROLTYPE
+     * table type:varchar(255)
+     * table comment:表单类型
+     */
+    private String controltype;
+
+    /**
+     * table name:ENUMTYPE
+     * table type:varchar(50)
+     * table comment:表单数据来源
+     */
+    private String enumtype;
+
+    /**
+     * table name:DATAORIGIN
+     * table type:text
+     * table comment:数据源
+     */
+    private String dataorigin;
+}

+ 50 - 0
cx-knowledge-base/cx-knowledge-base-server/src/main/java/com/rongwei/bsserver/sys/controller/SubConfigController.java

@@ -0,0 +1,50 @@
+package com.rongwei.bsserver.sys.controller;
+
+import com.rongwei.bscommon.sys.service.SubConfigService;
+import com.rongwei.bscommon.sys.utils.ExceptionUtils;
+import com.rongwei.rwcommon.base.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author shangmi
+ * @title SubConfigController
+ * @date 2024/1/5 13:59
+ * @description 子系统配置
+ */
+@Slf4j
+@RestController
+@RequestMapping("/subsystem-config")
+public class SubConfigController {
+
+    @Autowired
+    public SubConfigService subConfigService;
+
+    /**
+     * 查询菜单字段详细
+     *
+     * @param id 菜单ID
+     * @return {@link List < KdSubsystemDetailVo>}
+     * @date 2024/1/8 11:48
+     * @author shangmi
+     *
+     */
+
+    @GetMapping("/getModulesById")
+    public R getModulesById(@RequestParam("id")String id){
+        try {
+            log.info("进入接口:/subsystem-config/getModulesById,入参为:{}",id);
+            return R.ok(subConfigService.getModulesById(id));
+        }catch (Exception e){
+            ExceptionUtils.printExceptionDetail(e,"异常为:");
+            log.error(e.getMessage());
+            return R.error(e.getMessage());
+        }
+    }
+}