From e2e5cea7617ce0632750b3123dd600db95410919 Mon Sep 17 00:00:00 2001
From: DESKTOP-LMJ82IJ\Eno <creaycat@gmail.com>
Date: 星期日, 05 一月 2025 17:57:53 +0800
Subject: [PATCH] #平库入库功能

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/enums/LocAreaTypeSts.java    |   26 ++++++++
 zy-asrs-wms/src/main/resources/application.yml                                     |    2 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/MobileController.java    |    7 ++
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/MobileService.java          |    4 +
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java |   84 +++++++++++++++++++++++++---
 5 files changed, 112 insertions(+), 11 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/MobileController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/MobileController.java
index 30125de..41533b7 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/MobileController.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/MobileController.java
@@ -6,6 +6,7 @@
 import com.zy.asrs.framework.annotations.ManagerAuth;
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.framework.common.R;
+import com.zy.asrs.wms.asrs.entity.Loc;
 import com.zy.asrs.wms.asrs.entity.Order;
 import com.zy.asrs.wms.asrs.entity.WaitPakin;
 import com.zy.asrs.wms.asrs.entity.dto.OrderInfoDto;
@@ -89,8 +90,12 @@
             return R.error("搴撲綅涓嶈兘涓虹┖锛侊紒");
         }
         //TODO 缁戝畾搴撲綅锛屾坊鍔犲簱浣嶆槑缁�
+        if (mobileService.pakinToStock(shelvesParams)) {
+            return R.ok("鍏ュ簱鎴愬姛锛侊紒");
+        } else {
+            return R.error("鍏ュ簱澶辫触锛侊紒");
+        }
 
-        return R.ok();
     }
 
     /**
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/enums/LocAreaTypeSts.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/enums/LocAreaTypeSts.java
new file mode 100644
index 0000000..c91a9a7
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/enums/LocAreaTypeSts.java
@@ -0,0 +1,26 @@
+package com.zy.asrs.wms.asrs.entity.enums;
+
+
+/**
+ * 浠撳簱搴撳尯绫诲瀷
+ */
+public enum LocAreaTypeSts {
+
+    //鍥涙柟搴�
+    LOC_AREA_TYPE_ROUND(1L, "鍥涘悜搴�"),
+    //UTC搴�
+    LOC_AREA_TYPE_UTC(4L, "UTC搴�"),
+    //骞冲簱
+    LOC_AREA_TYPE_FLAT(7L, "骞冲簱")
+;
+
+
+    public Long id;
+    public String desc;
+
+    LocAreaTypeSts(Long id, String desc) {
+        this.id = id;
+        this.desc = desc;
+    }
+
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/MobileService.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/MobileService.java
index 197fb2f..4c2d52c 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/MobileService.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/MobileService.java
@@ -1,6 +1,8 @@
 package com.zy.asrs.wms.asrs.service;
 
+import com.zy.asrs.wms.asrs.entity.Loc;
 import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam;
+import com.zy.asrs.wms.asrs.entity.param.PakinOnShelvesParams;
 import com.zy.asrs.wms.system.entity.Host;
 
 import java.util.List;
@@ -11,4 +13,6 @@
     boolean batchMergeOrders(BatchMergeOrdersParam ordersParam);
 
     List<Host> getHosts();
+
+    boolean pakinToStock(PakinOnShelvesParams shelvesParams);
 }
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
index d01778e..31cee62 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
@@ -2,17 +2,13 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.exception.CoolException;
-import com.zy.asrs.wms.asrs.entity.Order;
-import com.zy.asrs.wms.asrs.entity.WaitPakin;
-import com.zy.asrs.wms.asrs.entity.enums.LocTypeHeightType;
+import com.zy.asrs.wms.asrs.entity.*;
+import com.zy.asrs.wms.asrs.entity.enums.*;
 import com.zy.asrs.wms.asrs.entity.enums.OrderType;
-import com.zy.asrs.wms.asrs.entity.enums.TaskStsType;
 import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam;
 import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
-import com.zy.asrs.wms.asrs.service.MobileService;
-import com.zy.asrs.wms.asrs.service.OrderService;
-import com.zy.asrs.wms.asrs.service.WaitPakinService;
-import com.zy.asrs.wms.asrs.service.WorkService;
+import com.zy.asrs.wms.asrs.entity.param.PakinOnShelvesParams;
+import com.zy.asrs.wms.asrs.service.*;
 import com.zy.asrs.wms.system.entity.Host;
 import com.zy.asrs.wms.system.service.HostService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +16,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -32,9 +29,16 @@
     private WorkService workService;
     @Autowired
     private HostService hostService;
-
     @Autowired
     private OrderService orderService;
+    @Autowired
+    private LocService locService;
+    @Autowired
+    private LocDetlService locDetlService;
+    @Autowired
+    private LocAreaService locAreaService;
+    @Autowired
+    private LocAreaTypeService locAreaTypeService;
 
 
     @Override
@@ -85,4 +89,66 @@
     public List<Host> getHosts() {
         return hostService.list();
     }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean pakinToStock(PakinOnShelvesParams shelvesParams) {
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, shelvesParams.getLoc()));
+        if (Objects.isNull(loc)) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+        }
+        if (loc.getLocStsId() != LocStsType.O.val()) {
+            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉鏄┖搴撶姸鎬�." + LocStsType.O.val());
+        }
+
+        //鍒ゆ柇褰撳墠浠撳簱鏄惁涓哄钩搴撲綅
+        List<LocArea> locAreas = locAreaService.list(new LambdaQueryWrapper<LocArea>().eq(LocArea::getLocId, loc.getId()));
+        locAreas.forEach(locArea -> {
+            LocAreaType typeServiceOne = locAreaTypeService.getOne(new LambdaQueryWrapper<LocAreaType>().eq(LocAreaType::getId, locArea.getTypeId()), false);
+            if (typeServiceOne.getParentId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id && typeServiceOne.getId() != LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id) {
+                throw new CoolException("璇烽�夋嫨骞冲簱鍖哄簱浣嶏紝鍐嶆搷浣滐紒锛�");
+            }
+        });
+
+        loc.setBarcode(shelvesParams.getBarcode());
+        loc.setUpdateTime(new Date());
+        //搴撳瓨鐘舵�佷慨鏀逛负鍦ㄥ簱鐘舵��
+        loc.setLocStsId(LocStsType.F.val());
+        if (!locService.save(loc)) {
+            throw new CoolException("搴撲綅鏇存柊澶辫触锛侊紒");
+        }
+
+        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode()));
+        waitPakins.forEach(pakin -> {
+            LocDetl locDetl = new LocDetl();
+            locDetl.setAnfme(pakin.getAnfme());
+            locDetl.setBatch(pakin.getBatch());
+            locDetl.setMatnr(pakin.getMatnr());
+            locDetl.setCreateTime(new Date());
+            locDetl.setOrderNo(pakin.getOrderNo());
+            locDetl.setLocNo(loc.getLocNo());
+            locDetl.setLocId(loc.getLocStsId());
+            locDetl.setMatnr(pakin.getMatnr());
+            locDetl.setMemo(pakin.getMemo());
+            locDetl.setUpdateTime(new Date());
+            if (!locDetlService.save(locDetl)) {
+                throw new CoolException("搴撳瓨鏄庣粏鏇存柊澶辫触锛侊紒");
+            }
+        });
+
+        return true;
+    }
+
+//    /**
+//     * 鑾峰彇褰撳墠搴撲綅鏄惁瀛樺湪
+//     * @param shelvesParams
+//     * @return
+//     */
+//    @Override
+//    public Loc selectPakinLocs(PakinOnShelvesParams shelvesParams) {
+//        return locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, shelvesParams.getLoc()));
+//    }
+
+
 }
diff --git a/zy-asrs-wms/src/main/resources/application.yml b/zy-asrs-wms/src/main/resources/application.yml
index d58957b..9d1a596 100644
--- a/zy-asrs-wms/src/main/resources/application.yml
+++ b/zy-asrs-wms/src/main/resources/application.yml
@@ -14,7 +14,7 @@
       connection-test-query: select 1
     driver-class-name: com.mysql.cj.jdbc.Driver
 #    url: jdbc:mysql://127.0.0.1:3306/wms_dev_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
-    url: jdbc:mysql://127.0.0.1:3306/wms_dev_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+    url: jdbc:mysql://127.0.0.1:3306/wms_dev?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
     username: root
     password: 34821015
 #    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

--
Gitblit v1.9.1