From b06233aa71b70f7a30ff382ae1ba19c29b134d7c Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 28 十一月 2025 15:41:51 +0800
Subject: [PATCH] #库存调整完成

---
 src/main/java/com/zy/asrs/entity/CheckOrderDetl.java              |   22 +----
 src/main/java/com/zy/asrs/service/impl/CheckOrderServiceImpl.java |   41 ++++++++++
 src/main/webapp/static/js/locDetl/locDetl.js                      |   25 +++---
 src/main/webapp/views/checkOrder/checkOrder.html                  |    1 
 src/main/java/com/zy/asrs/controller/CheckOrderController.java    |   29 +++++++
 src/main/java/com/zy/asrs/entity/LocDetl.java                     |    7 +
 src/main/java/com/zy/asrs/enums/CheckStatusEnum.java              |   33 ++++++++
 src/main/java/com/zy/asrs/service/CheckOrderService.java          |    2 
 src/main/webapp/static/js/checkOrder/checkOrder.js                |   35 ++++++++
 src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java       |    3 
 src/main/webapp/static/js/adjustOrder/adjustOrder.js              |   11 +-
 11 files changed, 173 insertions(+), 36 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/CheckOrderController.java b/src/main/java/com/zy/asrs/controller/CheckOrderController.java
index 4b88046..e3a6a16 100644
--- a/src/main/java/com/zy/asrs/controller/CheckOrderController.java
+++ b/src/main/java/com/zy/asrs/controller/CheckOrderController.java
@@ -11,8 +11,10 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.CheckTaskListParam;
+import com.zy.asrs.entity.param.OpenAdjustmentOrderParam;
 import com.zy.asrs.entity.param.OrderDomainParam;
 import com.zy.asrs.entity.result.CheckOrderExportDTO;
+import com.zy.asrs.enums.CheckStatusEnum;
 import com.zy.asrs.enums.OrderTypeEnum;
 import com.zy.asrs.service.*;
 import com.core.annotations.ManagerAuth;
@@ -41,6 +43,8 @@
     private SnowflakeIdWorker snowflakeIdWorker;
     @Autowired
     private DocTypeService docTypeService;
+    @Autowired
+    private OpenService openService;
 
     @PostMapping(value = "/checkOrder/pdaComplete/auth")
     @ManagerAuth(memo = "pda锛氬畬鎴愮洏鐐�")
@@ -342,4 +346,29 @@
         return R.ok();
     }
 
+
+    @PostMapping(value = "/adjustOrder/create/test")
+    @ManagerAuth(memo = "鍐呴儴娴嬭瘯锛氱敓鎴愯皟鏁村崟")
+    public R adjustOrderCreateTest(@RequestParam("orderId") Long orderId) {
+        CheckOrder checkOrder = checkOrderService.selectById(orderId);
+        List<CheckOrderDetl> checkOrderDetls = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId));
+        checkOrderDetls.forEach(checkOrderDetl -> { checkOrderDetl.setStatus(1);});
+        OpenAdjustmentOrderParam openAdjustmentOrderParam = new OpenAdjustmentOrderParam();
+        openAdjustmentOrderParam.setOrderTime(DateUtils.convert(new Date()));
+        openAdjustmentOrderParam.setOrderDetails(checkOrderDetls);
+
+        openService.adjustmentOrderCreate(openAdjustmentOrderParam);
+
+        return R.ok();
+
+    }
+
+    @PostMapping(value = "/adjustOrder/complete/auth")
+    @ManagerAuth(memo = "瀹屾垚璋冩暣鍗�")
+    public R adjustOrderComplete(@RequestParam("orderId") Long orderId) {
+        checkOrderService.adjustOrderComplete(orderId,getUserId());
+        return R.ok();
+    }
+
+
 }
diff --git a/src/main/java/com/zy/asrs/entity/CheckOrderDetl.java b/src/main/java/com/zy/asrs/entity/CheckOrderDetl.java
index 0b3ade0..04afc24 100644
--- a/src/main/java/com/zy/asrs/entity/CheckOrderDetl.java
+++ b/src/main/java/com/zy/asrs/entity/CheckOrderDetl.java
@@ -3,6 +3,7 @@
 import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.enums.IdType;
 import com.core.common.SpringUtils;
+import com.zy.asrs.enums.CheckStatusEnum;
 import com.zy.asrs.service.OrderService;
 import com.zy.asrs.entity.Order;
 import com.baomidou.mybatisplus.annotations.TableField;
@@ -258,7 +259,7 @@
     /**
      * 鐘舵�� 1: 鏈敓鎴�  0: 绂佺敤  2锛氬緟鐩�  3锛氬凡鐩�
      */
-    @ApiModelProperty(value= "鐘舵�� 1: 鏈敓鎴�  0: 绂佺敤  2锛氬緟鐩�  3锛氬凡鐩�  4:寰呰皟鏁� 5:宸茶皟鏁�")
+    @ApiModelProperty(value= "鐘舵�� 1: 鏈敓鎴�  0: 绂佺敤  2锛氬緟鐩�  3锛氬凡鐩�  4:鍏佽  5:绂佹 6锛氬凡淇敼")
     private Integer status;
 
     /**
@@ -552,22 +553,9 @@
 
     public String getStatus$(){
         if (null == this.status){ return null; }
-        switch (this.status){
-            case 1:
-                return "鏈敓鎴�";
-            case 0:
-                return "绂佺敤";
-            case 2:
-                return "寰呯洏";
-            case 3:
-                return "宸茬洏";
-            case 4:
-                return "寰呰皟鏁�";
-            case 5:
-                return "宸茶皟鏁�";
-            default:
-                return String.valueOf(this.status);
-        }
+        String descByType = CheckStatusEnum.getDescByType(this.status);
+        if (Cools.isEmpty(descByType)){ return "鏈畾涔�"; }
+        return descByType;
     }
 
     public String getCreateBy$(){
diff --git a/src/main/java/com/zy/asrs/entity/LocDetl.java b/src/main/java/com/zy/asrs/entity/LocDetl.java
index 0a63eff..12178a7 100644
--- a/src/main/java/com/zy/asrs/entity/LocDetl.java
+++ b/src/main/java/com/zy/asrs/entity/LocDetl.java
@@ -246,9 +246,12 @@
 
 
     public BigDecimal getBookQty() {
-        if (diffQty.compareTo(BigDecimal.ZERO) == 0 || diffQty.compareTo(BigDecimal.ZERO) > 0) {
-            return new  BigDecimal(anfme.toString());
 
+        if (diffQty.compareTo(BigDecimal.ZERO) == 0 ) {
+            return BigDecimal.ZERO;
+        }
+        if ( diffQty.compareTo(BigDecimal.ZERO) > 0) {
+            return new  BigDecimal(anfme.toString());
         }
         return new BigDecimal(anfme.toString()).subtract(diffQty);
     }
diff --git a/src/main/java/com/zy/asrs/enums/CheckStatusEnum.java b/src/main/java/com/zy/asrs/enums/CheckStatusEnum.java
new file mode 100644
index 0000000..c4b3d83
--- /dev/null
+++ b/src/main/java/com/zy/asrs/enums/CheckStatusEnum.java
@@ -0,0 +1,33 @@
+package com.zy.asrs.enums;
+
+public enum CheckStatusEnum {
+    //鐘舵�� 1: 鏈敓鎴�  0: 绂佺敤  2锛氬緟鐩�  3锛氬凡鐩�
+    NO_CREATE(1, "鏈敓鎴�"),
+    DISABLED(0, "绂佺敤"),
+    WAIT_CHECK(2, "寰呯洏"),
+    CHECKED(3, "宸茬洏"),
+
+    //璋冩暣鍗�
+    ALLOW(4, "鍏佽"),
+    FORBID(5, "绂佹"),
+    MODIFIED(6, "宸蹭慨鏀�");
+
+
+
+    public final Integer type;
+
+    public final String desc;
+
+    CheckStatusEnum(Integer type, String desc) {
+        this.type = type;
+        this.desc = desc;
+    }
+    public static String getDescByType(Integer type) {
+        for (CheckStatusEnum value : CheckStatusEnum.values()) {
+            if (value.type.equals(type)) {
+                return value.desc;
+            }
+        }
+        return null;
+    }
+}
diff --git a/src/main/java/com/zy/asrs/service/CheckOrderService.java b/src/main/java/com/zy/asrs/service/CheckOrderService.java
index 3d531f6..1813d63 100644
--- a/src/main/java/com/zy/asrs/service/CheckOrderService.java
+++ b/src/main/java/com/zy/asrs/service/CheckOrderService.java
@@ -19,4 +19,6 @@
     List<CheckOrderDetl> getTaskList(String barcode);
 
     R pdaComplete(CheckTaskListParam checkTaskListParam);
+
+    void adjustOrderComplete(Long orderId, Long userId);
 }
diff --git a/src/main/java/com/zy/asrs/service/impl/CheckOrderServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/CheckOrderServiceImpl.java
index 28004d3..23754df 100644
--- a/src/main/java/com/zy/asrs/service/impl/CheckOrderServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/CheckOrderServiceImpl.java
@@ -7,6 +7,7 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.CheckTaskListParam;
+import com.zy.asrs.enums.CheckStatusEnum;
 import com.zy.asrs.mapper.CheckOrderMapper;
 import com.zy.asrs.service.*;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@@ -15,8 +16,10 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 @Service("checkOrderService")
@@ -148,4 +151,42 @@
 
         return R.ok();
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void adjustOrderComplete(Long orderId, Long userId) {
+        CheckOrder checkOrder = this.selectById(orderId);
+        if (Cools.isEmpty(checkOrder)) {
+            throw new CoolException("鏁版嵁閿欒");
+        }
+        List<CheckOrderDetl> selectList = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId));
+        for (CheckOrderDetl checkOrderDetl : selectList) {
+
+            LocDetl locDetl = locDetlService.selectById(checkOrderDetl.getLocDetlId());
+            if (Cools.isEmpty(locDetl)) {
+                throw new CoolException("鏈壘鍒板簱瀛樻暟鎹�,鏁版嵁閿欒");
+            }
+            if (checkOrderDetl.getStatus().equals(CheckStatusEnum.ALLOW.type)) {
+                BigDecimal decimal = locDetl.getBookQty().add(checkOrderDetl.getDiffQty());
+                locDetl.setAnfme(decimal.doubleValue());
+            }else if (checkOrderDetl.getStatus().equals(CheckStatusEnum.FORBID.type)) {
+                if (locDetl.getDiffQty().compareTo(BigDecimal.ZERO) < 0) {
+                    BigDecimal subtract = new BigDecimal(locDetl.getAnfme().toString()).subtract(locDetl.getDiffQty());
+                    locDetl.setAnfme(subtract.doubleValue());
+                }
+            }
+
+            locDetl.setDiffQty(BigDecimal.ZERO);
+            locDetl.setModiTime(new Date());
+            if (!locDetlService.updateById(locDetl)){
+                throw new CoolException("鏇存柊搴撳瓨鏁版嵁澶辫触");
+            }
+        }
+
+        checkOrder.setSettle(4L);
+        checkOrder.setUpdateTime(new Date());
+        if (!this.updateById(checkOrder)){
+            throw new CoolException("鏇存柊璋冩暣鍗曠姸鎬佸け璐�");
+        }
+    }
 }
diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
index 54d49d5..fc96836 100644
--- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -10,6 +10,7 @@
 import com.zy.asrs.entity.param.*;
 import com.zy.asrs.entity.result.OpenOrderCompeteResult;
 import com.zy.asrs.entity.result.StockVo;
+import com.zy.asrs.enums.CheckStatusEnum;
 import com.zy.asrs.mapper.TagMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.utils.MatUtils;
@@ -645,7 +646,7 @@
             checkOrderDetl.setAnfme(checkOrderDetl1.getAnfme());
             checkOrderDetl.setDiffQty(checkOrderDetl1.getDiffQty());
             checkOrderDetl.setWorkQty(checkOrderDetl1.getWorkQty());
-            checkOrderDetl.setStatus(4);
+            checkOrderDetl.setStatus(checkOrderDetl1.getStatus().equals(1)?CheckStatusEnum.ALLOW.type:CheckStatusEnum.FORBID.type);
             checkOrderDetl.setZpallet(locDetl.getZpallet());
             checkOrderDetl.setCreateTime(now);
             checkOrderDetl.setUpdateTime(now);
diff --git a/src/main/webapp/static/js/adjustOrder/adjustOrder.js b/src/main/webapp/static/js/adjustOrder/adjustOrder.js
index cff3f3e..70ba874 100644
--- a/src/main/webapp/static/js/adjustOrder/adjustOrder.js
+++ b/src/main/webapp/static/js/adjustOrder/adjustOrder.js
@@ -95,7 +95,7 @@
         if (layEvent === 'edit') {
             showEditModel(data);
         }else if (layEvent === 'adjust') {
-            pakoutPreview(data.id);
+            adjustComplete(data.id);
         }else if (layEvent === 'export') {
             export1(data.id);
         }else if (layEvent === 'del') {
@@ -451,10 +451,10 @@
     }
 
 
-    function pakoutPreview(id) {
+    function adjustComplete(id) {
         let loadIndex = layer.load(2);
         $.ajax({
-            url: baseUrl + "/checkOrder/preview/auth",
+            url: baseUrl + "/adjustOrder/complete/auth",
             headers: {'token': localStorage.getItem('token')},
             data: {
                 orderId: id
@@ -462,10 +462,13 @@
             method: 'POST',
             success: function (res) {
                 if (res.code === 200){
-
+                    layer.close(loadIndex);
+                    layer.msg(res.msg, {icon: 1});
+                    insTb.reload({where: null});
                 } else if (res.code === 403){
                     top.location.href = baseUrl+"/";
                 } else {
+                    layer.close(loadIndex);
                     layer.msg(res.msg, {icon: 2})
                 }
             }
diff --git a/src/main/webapp/static/js/checkOrder/checkOrder.js b/src/main/webapp/static/js/checkOrder/checkOrder.js
index 24cd161..cb64eb4 100644
--- a/src/main/webapp/static/js/checkOrder/checkOrder.js
+++ b/src/main/webapp/static/js/checkOrder/checkOrder.js
@@ -96,6 +96,8 @@
             showEditModel(data);
         }else if (layEvent === 'createTask') {
             pakoutPreview(data.id);
+        }else if (layEvent === 'createAdjust') {
+            createAdjust(data.id);
         }else if (layEvent === 'export') {
             export1(data.id);
         }else if (layEvent === 'del') {
@@ -452,6 +454,39 @@
         });
     }
 
+    function createAdjust(orderId) {
+        layer.confirm('纭畾瑕佺敓鎴愯皟鏁村崟鍚楋紵', {
+            shade: .1,
+            skin: 'layui-layer-admin'
+        }, function (i) {
+            layer.close(i);
+            layer.load(2);
+            $.ajax({
+                url: baseUrl+"/adjustOrder/create/test",
+                headers: {'token': localStorage.getItem('token')},
+                data: {
+                    orderId: orderId
+                },
+                method: 'POST',
+                success: function (res) {
+                    layer.closeAll('loading');
+                    if (res.code === 200){
+                        if (insTbCount === 0) {
+                            insTb.reload({page: {curr: 1}});
+                        } else {
+                            $(".layui-laypage-btn")[0].click();
+                        }
+                        layer.msg(res.msg, {icon: 1});
+                    } else if (res.code === 403){
+                        top.location.href = baseUrl+"/";
+                    }else {
+                        layer.msg(res.msg, {icon: 2});
+                    }
+                }
+            })
+        });
+    }
+
 
     function pakoutPreview(id) {
         let loadIndex = layer.load(2);
diff --git a/src/main/webapp/static/js/locDetl/locDetl.js b/src/main/webapp/static/js/locDetl/locDetl.js
index f55e8b1..531ae9b 100644
--- a/src/main/webapp/static/js/locDetl/locDetl.js
+++ b/src/main/webapp/static/js/locDetl/locDetl.js
@@ -9,7 +9,18 @@
         ,{field: 'orderNo', align: 'center',title: '鍗曟嵁缂栧彿', hide: true}
         ,{field: 'batch', align: 'center',title: '鎵瑰彿', width: 300, sort:true}
         ,{field: 'anfme', align: 'center',title: '鍙敤鏁伴噺'}
-        ,{field: 'bookQty', align: 'center',title: '璐﹂潰鏁伴噺'}
+        ,{field: 'diffQty', align: 'center',title: '宸紓鏁伴噺',
+            templet: function(d) {
+                // 鏍规嵁鏉′欢鍒ゆ柇瀛椾綋棰滆壊
+                if (d.diffQty < 0 ) {
+                    return '<span style="color: #de3434;">' +d.diffQty + '</span>';
+                }else if (d.diffQty > 0){
+                    return '<span style="color: #19fa02;">' +d.diffQty + '</span>';
+                } else {
+                    return '<span">' +d.diffQty + '</span>';
+                }
+            }}
+        ,{field: 'bookQty', align: 'center',title: '鍘熸暟閲�'}
         ,{field: 'zpallet', align: 'center',title: '鎵樼洏鏉$爜'}
         ,{field: 'specs', align: 'center',title: '瑙勬牸'}
         ,{field: 'model', align: 'center',title: '浠g爜', hide: true}
@@ -46,17 +57,7 @@
                     return '<span">' +d.frozen$ + '</span>';
                 }
             }}
-        ,{field: 'diffQty', align: 'center',title: '鐩樼偣鏁伴噺',
-            templet: function(d) {
-                // 鏍规嵁鏉′欢鍒ゆ柇瀛椾綋棰滆壊
-                if (d.diffQty < 0 ) {
-                    return '<span style="color: #de3434;">' +d.diffQty + '</span>';
-                }else if (d.diffQty > 0){
-                    return '<span style="color: #19fa02;">' +d.diffQty + '</span>';
-                } else {
-                    return '<span">' +d.diffQty + '</span>';
-                }
-            }}
+
     ];
 
     // cols.push.apply(cols, detlCols);
diff --git a/src/main/webapp/views/checkOrder/checkOrder.html b/src/main/webapp/views/checkOrder/checkOrder.html
index 6978c80..4c4bc30 100644
--- a/src/main/webapp/views/checkOrder/checkOrder.html
+++ b/src/main/webapp/views/checkOrder/checkOrder.html
@@ -113,6 +113,7 @@
     {{# } }}
     {{# if (d.settle == 4) { }}
     <a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs btn-complete" lay-event="export">瀵煎嚭宸紓鍗�</a>
+    <a class="layui-btn layui-btn-primary layui-btn-xs layui-border" lay-event="createAdjust">鐢熸垚璋冩暣鍗�</a>
     {{# } }}
 </script>
 <!-- 琛ㄦ牸鎿嶄綔鍒� -->

--
Gitblit v1.9.1