From cfe049492f81d2c650a2b17348593edbc5054498 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 18 三月 2026 07:52:44 +0800
Subject: [PATCH] #3.5

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java |   57 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
index 49a184b..552d605 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
@@ -8,6 +8,7 @@
 import com.vincent.rsf.server.manager.controller.params.WaitPakinParam;
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.enums.PakinIOStatus;
+import com.vincent.rsf.server.manager.mapper.AsnOrderMapper;
 import com.vincent.rsf.server.manager.mapper.WaitPakinMapper;
 import com.vincent.rsf.server.manager.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +16,7 @@
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -26,11 +28,9 @@
 
 
     @Autowired
-    private AsnOrderService asnOrderService;
+    private AsnOrderMapper asnOrderMapper;
     @Autowired
     private AsnOrderItemService asnOrderItemService;
-    @Autowired
-    private WaitPakinService waitPakinService;
     @Autowired
     private WaitPakinItemService waitPakinItemService;
     @Autowired
@@ -38,10 +38,9 @@
     @Autowired
     private LocService locService;
     @Autowired
-    private TaskService taskService;
-    @Autowired
     private TaskItemService taskItemService;
     @Autowired
+    @Lazy
     private AgvService  agvService;
 
 
@@ -63,7 +62,7 @@
             throw new CoolException("鍙傛暟閿欒锛氭墭鐩樼爜涓虹┖锛侊紒");
         }
 //        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
-        WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
+        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
                 .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
         if (!Objects.isNull(pakin)) {
             throw new CoolException("鎵樼洏鐮侊細" + waitPakin.getBarcode() + "宸茶缁勬墭鍗曪細" + pakin.getCode() + "浣跨敤锛侊紒");
@@ -129,7 +128,7 @@
                     .setUpdateBy(userId)
                     .setCreateBy(userId)
                     .setMatnrCode(warehouseAreasItems.getMatnrCode());
-            WkOrder order = asnOrderService.getById(warehouseAreasItems.getAsnId());
+            WkOrder order = asnOrderMapper.selectById(warehouseAreasItems.getAsnId());
             if (!Objects.isNull(order)) {
                 pakinItem.setType(null == order.getType() ? null : order.getType())
                         .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()));
@@ -177,6 +176,38 @@
         return pakin;
     }
 
+    /**
+     * @author Munch D. Luffy
+     * @date 2026/01/23
+     * @description: PDA缁勬嫋鍓嶇疆妫�鏌�
+     * @version 1.0
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public synchronized boolean mergeItemsCheck(WaitPakinParam waitPakin, Long userId) {
+        if (StringUtils.isBlank(waitPakin.getBarcode())) {
+            throw new CoolException("鍙傛暟閿欒锛氭墭鐩樼爜涓虹┖锛侊紒");
+        }
+        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
+                .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
+        if (!Objects.isNull(pakin)) {
+            throw new CoolException("鎵樼洏鐮侊細" + waitPakin.getBarcode() + "宸茶缁勬墭鍗曪細" + pakin.getCode() + "浣跨敤锛侊紒");
+        }
+        List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
+        if (!locs.isEmpty()) {
+            List<String> locCodes = locs.stream().map(Loc::getCode).collect(Collectors.toList());
+            String join = StringUtils.join(locCodes, ",");
+            throw new CoolException("鎵樼洏鐮侊細" + waitPakin.getBarcode() + "宸茶搴撲綅锛�" + join + "浣跨敤锛侊紒");
+        }
+
+        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_WAIT_PAKIN_CODE, null);
+        if (StringUtils.isBlank(ruleCode)) {
+            throw new CoolException("缂栫爜瑙勫垯閿欒锛� 缂栫爜瑙勫垯銆孲YS_WAIT_PAKIN_CODE銆嶈鍒欐槸涓嶅瓨鍦�");
+        }
+
+        return agvService.AGVBindAndInTaskStart(waitPakin.getBarcode(),waitPakin.getStaNo());
+
+    }
 
 
     /**
@@ -195,7 +226,7 @@
             throw new CoolException("鍙傛暟閿欒锛氭墭鐩樼爜涓虹┖锛侊紒");
         }
 //        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
-        WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
+        WaitPakin pakin = this.getOne(new LambdaQueryWrapper<WaitPakin>()
                 .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
         if (!Objects.isNull(pakin)) {
             throw new CoolException("鎵樼洏鐮侊細" + waitPakin.getBarcode() + "宸茶缁勬墭鍗曪細" + pakin.getCode() + "浣跨敤锛侊紒");
@@ -250,7 +281,7 @@
                     .setUpdateBy(userId)
                     .setCreateBy(userId)
                     .setMatnrCode(warehouseAreasItems.getMatnrCode());
-            WkOrder order = asnOrderService.getById(warehouseAreasItems.getAsnId());
+            WkOrder order = asnOrderMapper.selectById(warehouseAreasItems.getAsnId());
             if (!Objects.isNull(order)) {
                 pakinItem.setType(null == order.getType() ? null : order.getType())
                         .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()));
@@ -316,7 +347,7 @@
     public synchronized WaitPakin unBind(WaitPakinParam param) {
         String barcode = param.getBarcode();
         if (StringUtils.isNotBlank(barcode)) {
-            WaitPakin waitPakins = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode));
+            WaitPakin waitPakins = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode));
             if (Objects.isNull(waitPakins)) {
                 throw new CoolException("缁勬墭涓嶅瓨鍦紒锛�");
             }
@@ -376,13 +407,13 @@
             double anfmes = paramItems.stream().mapToDouble(PakinItem::getReceiptQty).sum();
 //            double anfmes = warehouseAreasItems.stream().mapToDouble(WarehouseAreasItem::getAnfme).sum();
             if (waitPakins.getAnfme().compareTo(anfmes) <= 0) {
-                if (!waitPakinService.removeById(waitPakins.getId())) {
+                if (!this.removeById(waitPakins.getId())) {
                     throw new CoolException("缁勬墭鍒犻櫎澶辫触锛侊紒");
                 }
             } else {
                 Double anfme = Math.round((waitPakins.getAnfme() - anfmes) * 10000) / 10000.0;
                 waitPakins.setAnfme(anfme);
-                if (!waitPakinService.updateById(waitPakins)) {
+                if (!this.updateById(waitPakins)) {
                     throw new CoolException("缁勬墭鏁版嵁淇敼澶辫触锛侊紒");
                 }
             }
@@ -439,7 +470,7 @@
             }
         }
 
-        if (!waitPakinService.removeByIds(pakinIds)) {
+        if (!this.removeByIds(pakinIds)) {
             return R.error("Delete Fail");
         }
 

--
Gitblit v1.9.1