|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|