From 9834dbff448908d2008d8c52a2544aad00c099b1 Mon Sep 17 00:00:00 2001
From: haoyahui <2032914783@qq.com>
Date: 星期三, 22 十一月 2023 17:34:26 +0800
Subject: [PATCH] 库存盘点, 异常明细,报废管理

---
 consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java |   73 +++++++++++++++++++++++++++++-------
 1 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java b/consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java
index 6e03ebd..343c47b 100644
--- a/consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java
@@ -2,18 +2,26 @@
 
 import com.consum.base.BaseController;
 import com.consum.base.pojo.BaseCategoryParam;
+import com.consum.base.pojo.ProjectTreeResult;
 import com.consum.base.service.BaseCategoryServiceImpl;
 import com.consum.base.service.BaseGoodsTemplateServiceImpl;
 import com.consum.model.po.BaseCategory;
 import com.iplatform.model.po.S_user_core;
 import com.walker.db.page.GenericPager;
+import com.walker.infrastructure.tree.TreeNode;
 import com.walker.infrastructure.utils.StringUtils;
 import com.walker.web.ResponseValue;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * @Description 鐗╁搧鍒嗙被
@@ -29,6 +37,23 @@
 
     @Autowired
     private BaseGoodsTemplateServiceImpl baseGoodsTemplateService;
+
+    private boolean multiRoot = true;
+    private TreeNode dummyRoot = null;
+    private Map<Long, TreeNode> rootMap = new TreeMap();
+    private Map<Long, TreeNode> childMap = new TreeMap();
+    private long defaultParentId = 0L;
+
+    /**
+     * @Description 鑾峰彇鍒嗙被鏍�
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/10/30
+     */
+    @GetMapping("/select/tree")
+    public ResponseValue tree(String categoryName) {
+        List<ProjectTreeResult> tree = this.baseCategoryService.tree();
+        return ResponseValue.success(tree);
+    }
 
     /**
      * @Description 鏂板鍒嗙被
@@ -50,7 +75,9 @@
         }
 
         int result = this.baseCategoryService.add(param, this.getCurrentUser());
-        if (result > 0) return ResponseValue.success(1);
+        if (result > 0) {
+            return ResponseValue.success(1);
+        }
         return ResponseValue.error("鏂板澶辫触锛�");
     }
 
@@ -69,6 +96,7 @@
         return ResponseValue.success(pager);
     }
 
+
     /**
      * @Description 缂栬緫
      * @Author 鍗㈠簡闃�
@@ -86,11 +114,7 @@
         if (baseCategory.getOrderNumber() == null) {
             return ResponseValue.error("椤哄簭鍙蜂负绌�");
         }
-        //鍒ゆ柇鍚屼竴鐖剁被id涓嬪垎绫诲悕绉版槸鍚﹂噸澶�
-        BaseCategory category = this.baseCategoryService.getByCategoryNameAndFatherCategoryId(baseCategory.getCategoryName(), baseCategory.getFatherCategoryId());
-        if (category != null) {
-            return ResponseValue.error("鍒嗙被鍚嶇О宸插瓨鍦�");
-        }
+
         S_user_core currentUser = this.getCurrentUser();
         if (currentUser == null) {
             return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
@@ -103,7 +127,7 @@
      * 淇敼鐘舵��
      *
      * @author 鍗㈠簡闃�
-     * @date 2023/9/27
+     * @date 2023/10/23
      */
     //鍒嗙被涓嬫湁姝e父鐘舵�佺殑鐗╁搧鏃讹紝涓嶅厑璁哥鐢�
     @PostMapping("/updStatus")
@@ -122,7 +146,7 @@
     }
 
     /**
-     * @Description 鏍规嵁鑺傜偣id鍒犻櫎鑺傜偣(閫昏緫鍒犻櫎)
+     * @Description 鏍规嵁id鍒犻櫎鐗╁搧鍒嗙被
      * @Author 鍗㈠簡闃�
      * @Date 2023/10/23
      */
@@ -131,16 +155,16 @@
         if (baseCategory.getId() == null) {
             return ResponseValue.error("鍒嗙被id涓虹┖");
         }
-        int num = this.baseCategoryService.updateById(baseCategory,this.getCurrentUser());
+        int num = this.baseCategoryService.updateById(baseCategory, this.getCurrentUser());
 
         return num > 0 ? ResponseValue.success(1) : ResponseValue.error("鍒犻櫎澶辫触锛�");
     }
 
     /**
-     * 鏍规嵁鑺傜偣id鏌ヨ鑺傜偣璇︽儏
+     * 鏍规嵁鐗╁搧id鏌ヨ鑺傜偣璇︽儏
      *
      * @author 鍗㈠簡闃�
-     * @date 2023/9/26
+     * @Date 2023/10/23
      */
     @GetMapping("/detail")
     public ResponseValue getById(Long id) {
@@ -148,8 +172,27 @@
             return ResponseValue.error("鍒嗙被id涓虹┖");
         }
         BaseCategory baseCategory = this.baseCategoryService.getById(id);
-        if (baseCategory == null) return ResponseValue.error("鏌ヨ澶辫触锛�");
+        if (baseCategory == null) {
+            return ResponseValue.error("鏌ヨ澶辫触锛�");
+        }
         return ResponseValue.success("鏌ヨ鎴愬姛!", baseCategory);
     }
+
+    /**
+     * @Description 涓夌骇鍒嗙被鍒楄〃鏌ヨ
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/10/24
+     */
+    @GetMapping("/select/lv3_tree")
+    public ResponseValue tree() {
+        S_user_core currentUser = this.getCurrentUser();
+        if (currentUser == null) {
+            return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+        }
+
+        List<BaseCategory> baseCategories = this.baseCategoryService.queryForLv3Tree();
+        return ResponseValue.success(baseCategories);
+    }
+
 }
 

--
Gitblit v1.9.1