From 10d7b3239e4baec952b9ee8a3e948399916d336c Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期一, 20 十月 2025 08:23:58 +0800
Subject: [PATCH] 13

---
 src/main/java/com/zy/asrs/controller/LocMastController.java |  121 +++++++++++++++++++++++-----------------
 1 files changed, 69 insertions(+), 52 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/LocMastController.java b/src/main/java/com/zy/asrs/controller/LocMastController.java
index 56cda69..68e9b64 100644
--- a/src/main/java/com/zy/asrs/controller/LocMastController.java
+++ b/src/main/java/com/zy/asrs/controller/LocMastController.java
@@ -17,12 +17,10 @@
 import com.zy.asrs.service.BasWhsService;
 import com.zy.asrs.service.LocDetlService;
 import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.utils.Utils;
 import com.zy.common.entity.Parameter;
 import com.zy.common.model.Shelves;
 import com.zy.common.web.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.*;
@@ -59,37 +57,56 @@
 
     @RequestMapping(value = "/locMast/list/auth")
     @ManagerAuth
-    public R list(@RequestParam(defaultValue = "1")Integer curr,
-                  @RequestParam(defaultValue = "10")Integer limit,
-                  @RequestParam(required = false)String orderByField,
-                  @RequestParam(required = false)String orderByType,
-                  @RequestParam Map<String, Object> param){
+    public R list(@RequestParam(defaultValue = "1") Integer curr,
+                  @RequestParam(defaultValue = "10") Integer limit,
+                  @RequestParam(required = false) String orderByField,
+                  @RequestParam(required = false) String orderByType,
+                  @RequestParam Map<String, Object> param) {
         excludeTrash(param);
         EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
         convert(param, wrapper);
-        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+        if (!Cools.isEmpty(orderByField)) {
+            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
+        }
         return R.ok(locMastService.selectPage(new Page<>(curr, limit), wrapper));
     }
 
-    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+    @RequestMapping(value = "/locMast/crn/list/auth")
+    @ManagerAuth
+    public R crnList(@RequestParam(defaultValue = "1") Integer curr,
+                     @RequestParam(defaultValue = "10") Integer limit,
+                     @RequestParam(required = false) String orderByField,
+                     @RequestParam(required = false) String orderByType,
+                     @RequestParam Map<String, Object> param) {
+        excludeTrash(param);
+        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
+        convert(param, wrapper);
+        wrapper.in("crn_no", 1, 2);
+        if (!Cools.isEmpty(orderByField)) {
+            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
+        }
+        return R.ok(locMastService.selectPage(new Page<>(curr, limit), wrapper));
+    }
+
+    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
         boolean sign = false;
-        for (Map.Entry<String, Object> entry : map.entrySet()){
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
             String val = String.valueOf(entry.getValue());
-            if (val.contains(RANGE_TIME_LINK)){
+            if (val.contains(RANGE_TIME_LINK)) {
                 String[] dates = val.split(RANGE_TIME_LINK);
                 wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                 wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
-            } else if (entry.getKey().equals("loc_no")){
+            } else if (entry.getKey().equals("loc_no")) {
                 wrapper.like(entry.getKey(), val);
             } else {
-                if (entry.getKey().equals("loc_type1")){
-                    sign=true;
+                if (entry.getKey().equals("loc_type1")) {
+                    sign = true;
                 }
                 wrapper.eq(entry.getKey(), val);
             }
         }
-        if (sign){
-            wrapper.and().ne("loc_sts","Y");
+        if (sign) {
+            wrapper.and().ne("loc_sts", "Y");
         }
     }
 
@@ -104,10 +121,10 @@
         return R.ok();
     }
 
-	@RequestMapping(value = "/locMast/update/auth")
-	@ManagerAuth(memo = "搴撲綅淇敼")
-    public R update(LocMast locMast){
-        if (Cools.isEmpty(locMast) || null==locMast.getLocNo()){
+    @RequestMapping(value = "/locMast/update/auth")
+    @ManagerAuth(memo = "搴撲綅淇敼")
+    public R update(LocMast locMast) {
+        if (Cools.isEmpty(locMast) || null == locMast.getLocNo()) {
             return R.error();
         }
         LocMast oldLocMast = locMastService.selectById(locMast.getLocNo());
@@ -120,6 +137,9 @@
                 locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
             }
         }
+        if (locMast.getLocSts().equals("O")) {
+            locMast.setBarcode("");
+        }
         locMast.setModiUser(getUserId());
         locMast.setModiTime(new Date());
         locMastService.updateById(locMast);
@@ -128,12 +148,12 @@
 
     @RequestMapping(value = "/locMast/delete/auth")
     @ManagerAuth(memo = "搴撲綅鍒犻櫎")
-    public R delete(@RequestParam String param){
+    public R delete(@RequestParam String param) {
         List<LocMast> list = JSONArray.parseArray(param, LocMast.class);
-        if (Cools.isEmpty(list)){
+        if (Cools.isEmpty(list)) {
             return R.error();
         }
-        for (LocMast entity : list){
+        for (LocMast entity : list) {
             locMastService.delete(new EntityWrapper<>(entity));
         }
         return R.ok();
@@ -141,7 +161,7 @@
 
     @RequestMapping(value = "/locMast/export/auth")
     @ManagerAuth(memo = "搴撲綅瀵煎嚭")
-    public R export(@RequestBody JSONObject param){
+    public R export(@RequestBody JSONObject param) {
         List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
         EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
         Map<String, Object> map = excludeTrash(param.getJSONObject("locMast"));
@@ -157,7 +177,7 @@
         wrapper.like("loc_no", condition);
         Page<LocMast> page = locMastService.selectPage(new Page<>(0, 10), wrapper);
         List<Map<String, Object>> result = new ArrayList<>();
-        for (LocMast locMast : page.getRecords()){
+        for (LocMast locMast : page.getRecords()) {
             Map<String, Object> map = new HashMap<>();
             map.put("id", locMast.getLocNo());
             map.put("value", locMast.getLocNo());
@@ -170,7 +190,7 @@
     @ManagerAuth
     public R query(@RequestBody JSONObject param) {
         Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
-        if (null != locMastService.selectOne(wrapper)){
+        if (null != locMastService.selectOne(wrapper)) {
             return R.parse(BaseRes.REPEAT).add(getComment(LocMast.class, String.valueOf(param.get("key"))));
         }
         return R.ok();
@@ -180,48 +200,45 @@
     @ManagerAuth(memo = "鍒濆鍖栧簱浣�")
 //    @Transactional
     public R init(LocMastInitParam param) {
-        try{
+        try {
             List<LocMast> list = new ArrayList<>();
             BasWhs basWhs = basWhsService.selectByIdentifying(param.getIdentifying());
-            if (Cools.isEmpty(basWhs)){
+            if (Cools.isEmpty(basWhs)) {
                 return R.error("搴撳瀷涓嶅瓨鍦紒锛侊紒");
             }
-            for (int r=param.getStartRow(); r<=param.getEndRow(); r++){
-                for (int b=param.getStartBay(); b<=param.getEndBay(); b++) {
-                    for (int l=param.getStartLev(); l<=param.getEndLev(); l++) {
+            for (int r = param.getStartRow(); r <= param.getEndRow(); r++) {
+                for (int b = param.getStartBay(); b <= param.getEndBay(); b++) {
+                    for (int l = param.getStartLev(); l <= param.getEndLev(); l++) {
                         // 鑾峰彇搴撲綅鍙�
                         String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l);
                         // 鑾峰彇鍫嗗灈鏈哄彿
                         int crnNo = 0;
-                        if (basWhs.getIdentifying().equals("1") || basWhs.getIdentifying().equals("3")){
-                            try{
-                                Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount(),param.getStartRow());
-                                for (List<Integer> node : shelves.nodes){
+                        try {
+                            Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount(), param.getStartRow());
+                            for (List<Integer> node : shelves.nodes) {
 
-                                    if (node.contains(r)) {
-                                        if (!Cools.isEmpty(param.getStaCrn()) && param.getStaCrn() > 0){
-                                            crnNo = shelves.nodes.indexOf(node) + param.getStaCrn();
-                                        }else {
-                                            crnNo = shelves.nodes.indexOf(node) + 1;
-                                        }
-
-                                        break;
+                                if (node.contains(r)) {
+                                    if (!Cools.isEmpty(param.getStaCrn()) && param.getStaCrn() > 0) {
+                                        crnNo = shelves.nodes.indexOf(node) + param.getStaCrn();
+                                    } else {
+                                        crnNo = shelves.nodes.indexOf(node) + 1;
                                     }
+
+                                    break;
                                 }
-                            }catch (Exception e){
-                                throw new Exception("瑙f瀽鍫嗗灈鏈哄彿澶辫触锛岃濉啓姝g‘鐨勬暟鎹�!!!");
                             }
-                        }else {
-                            crnNo = param.getStaCrn();
+                        } catch (Exception e) {
+                            throw new Exception("瑙f瀽鍫嗗灈鏈哄彿澶辫触锛岃濉啓姝g‘鐨勬暟鎹�!!!");
                         }
-                        Date now =  new Date();
+
+                        Date now = new Date();
                         LocMast locMast = new LocMast();
                         locMast.setLocNo(locNo);
                         locMast.setLocSts("O");
                         locMast.setRow1(r); // 鎺�
                         locMast.setBay1(b); // 鍒�
                         locMast.setLev1(l); // 灞�
-                        locMast.setGro1(0); // 缁�
+                        locMast.setGro1(r); // 缁�
                         locMast.setCrnNo(crnNo); // 鍫嗗灈鏈�
                         locMast.setLocType1(!Cools.isEmpty(param.getLocType1()) ? param.getLocType1() : 1);
                         locMast.setLocType2(param.getLocType2());
@@ -235,13 +252,13 @@
                     }
                 }
             }
-            if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1){
+            if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1) {
                 locMastService.delete(new EntityWrapper<>());
             }
             locMastService.insertBatch(list);
             return R.ok("鍒濆鍖栨垚鍔�");
-        }catch (Exception e){
-            return R.error("鍒濆鍖栧け璐�===>"+e.getMessage());
+        } catch (Exception e) {
+            return R.error("鍒濆鍖栧け璐�===>" + e.getMessage());
         }
     }
 }

--
Gitblit v1.9.1