guarantee-lsq 11 месяцев назад
Родитель
Сommit
891b1e6863

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/dto/custom/CustomFormDTO.java

@@ -26,7 +26,7 @@ public class CustomFormDTO extends BaseDTO implements Serializable {
     /**
      * 报废单  调拨单。。。
      */
-    private Integer type;
+    private String type;
     /**
      * 表单json
      */
@@ -88,5 +88,5 @@ public class CustomFormDTO extends BaseDTO implements Serializable {
 
     private Integer status; // 表单状态 0 待发布 1 已发布 2 已废弃
 
-    private Integer category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
+    private String category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
 }

+ 1 - 0
platform-dao/src/main/java/com/platform/dao/dto/custom/CustomFormDataDTO.java

@@ -84,4 +84,5 @@ public class CustomFormDataDTO extends BaseDTO implements Serializable {
      */
     private String keyword;
 
+    private String targetId;  // 目标ID
 }

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/entity/custom/CustomForm.java

@@ -30,7 +30,7 @@ public class CustomForm implements Serializable{
     /**
      * 报废单  调拨单。。。
      */
-    private Integer type;
+    private String type;
     /**
      * 表单json
      */
@@ -78,5 +78,5 @@ public class CustomForm implements Serializable{
 
     private Integer status; // 表单状态 0 待发布 1 已发布 2 已废弃
 
-    private Integer category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
+    private String category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
 }

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/entity/custom/CustomFormData.java

@@ -74,4 +74,6 @@ public class CustomFormData implements Serializable{
     @Transient
     private DataScope dataScope;
 
+    private String targetId;  // 目标ID
+
 }

+ 43 - 0
platform-dao/src/main/java/com/platform/dao/util/TreeUtil.java

@@ -1,9 +1,12 @@
 package com.platform.dao.util;
 
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.platform.common.cache.DictCache;
 import com.platform.common.util.ListUtils;
 import com.platform.common.util.MapUtils;
 import com.platform.common.util.StringUtils;
+import com.platform.dao.entity.custom.CustomForm;
 import com.platform.dao.entity.repair.ErrorType;
 import com.platform.dao.entity.part.PartType;
 import com.platform.dao.entity.sb.SbInfo;
@@ -395,6 +398,46 @@ public class TreeUtil {
         return TreeUtil.buildByLoopWithoutRoot(trees);
     }
 
+    public List<CommonTree> buildCustomFormTree(List<CustomForm> forms) {
+        List<CommonTree> trees = new ArrayList<>();
+        if(CollectionUtil.isNotEmpty(forms)){
+            // 按照归属分类
+            Map<String,List<CustomForm>> maps = new HashMap<>();
+            forms.forEach(form -> {
+                String key = form.getCategory();
+                List<CustomForm> list = maps.get(key);
+                if(list == null){
+                    list = new ArrayList<>();
+                }
+                list.add(form);
+                maps.put(key, list);
+            });
+            for(Map.Entry<String,List<CustomForm>> entry : maps.entrySet()){
+                String key = entry.getKey();
+                List<CustomForm> list = entry.getValue();
+                CommonTree node = new CommonTree();
+                node.setId(key);
+                node.setKey(key);
+                node.setTitle(DictCache.getLabelByValue("CATEGORY_TYPE", key));
+                node.setValue(DictCache.getLabelByValue("CATEGORY_TYPE", key));
+                // 组装children
+                List<TreeNode> children = new ArrayList<>();
+                if(CollectionUtil.isNotEmpty(list)){
+                    list.forEach(item->{
+                        TreeNode child = new TreeNode();
+                        child.setId(item.getId());
+                        child.setParentId(key);
+                        child.setItem(DictCache.getLabelByValue("CUSTOM_FORM_TYPE",item.getType()));
+                        children.add(child);
+                    });
+                }
+                node.setChildren(children);
+                trees.add(node);
+            }
+        }
+        return trees;
+    }
+
     /**
      * 通过sysMenu创建树形节点
      *

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/custom/CustomFormDataVO.java

@@ -64,5 +64,7 @@ public class CustomFormDataVO extends BaseVO implements Serializable {
      */
     private LocalDateTime updateTime;
 
+    private String targetId; // 目标ID
+
 
 }

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/vo/query/custom/CustomFormVO.java

@@ -26,7 +26,7 @@ public class CustomFormVO extends BaseVO implements Serializable {
     /**
      * 报废单  调拨单。。。
      */
-    private Integer type;
+    private String type;
     /**
      * 表单json
      */
@@ -68,5 +68,5 @@ public class CustomFormVO extends BaseVO implements Serializable {
 
     private Integer status; // 表单状态 0 待发布 1 已发布 2 已废弃
 
-    private Integer category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
+    private String category; // 分类  category_type  设备 维修 采购 备件 仓库 巡检 点检  保养
 }

+ 10 - 0
platform-rest/src/main/java/com/platform/rest/controller/custom/CustomFormController.java

@@ -2,7 +2,10 @@ package com.platform.rest.controller.custom;
 
 import com.platform.common.util.R;
 import com.platform.dao.dto.custom.CustomFormDTO;
+import com.platform.dao.dto.upms.SysDictDTO;
 import com.platform.dao.entity.custom.CustomForm;
+import com.platform.dao.entity.upms.SysDict;
+import com.platform.dao.util.TreeUtil;
 import com.platform.service.custom.CustomFormService;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.vo.export.custom.ExportCustomFormVO;
@@ -138,4 +141,11 @@ public class CustomFormController {
         ExcelUtil.exportResponseDict(response, ExportCustomFormVO.class, BeanConverterUtil.copyListProperties(list, ExportCustomFormVO.class), "自定义表单表");
     }
 
+    @GetMapping("/tree")
+    @SysLog("获取树")
+    public R tree() {
+        List<CustomForm> forms = customFormService.getModelListByModel(new CustomForm());
+        return new R<>(TreeUtil.buildCustomFormTree(forms));
+    }
+
 }

+ 14 - 1
platform-service/src/main/java/com/platform/service/upms/impl/SysDictServiceImpl.java

@@ -6,6 +6,7 @@ import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.bean.DictVO;
 import com.platform.common.constant.UpmsRedisKeyConstants;
 import com.platform.common.enums.DictValueTypeEnum;
+import com.platform.common.util.ListUtils;
 import com.platform.common.util.RedisUtils;
 import com.platform.dao.bean.MyPage;
 import com.platform.dao.dto.upms.SysDictDTO;
@@ -88,7 +89,19 @@ public class SysDictServiceImpl extends BaseServiceImpl<SysDictMapper, SysDict,
 
     @Override
     public List<SysDict> selectTreeByDTO(SysDictDTO sysDictDTO) {
-        return mapper.selectTreeByDTO( sysDictDTO);
+        List<SysDict> list = mapper.select(new SysDict());
+        Map<String,SysDict> maps = new HashMap<>();
+        list.forEach(item->{
+            String key = item.getType();
+            if(maps.get(key) == null){
+                maps.put(key,item);
+            }
+        });
+        List<SysDict> treeList = ListUtils.newArrayList();
+        for(Map.Entry<String,SysDict> entry : maps.entrySet()){
+            treeList.add(entry.getValue());
+        }
+        return treeList;
     }
 
     @PostConstruct