From 4114759a57d73661937f28a765fb8a67c017b14b Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 24 六月 2025 16:28:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/devlop' into devlop

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java |   45 +-------------
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java     |   42 +++++---------
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockService.java          |    2 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockItemService.java      |    2 
 rsf-server/src/main/resources/application.yml                                                 |    2 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java              |   64 +++++++++++++++++++++
 6 files changed, 87 insertions(+), 70 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockItemService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockItemService.java
index 56b43e2..20f7a50 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockItemService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockItemService.java
@@ -7,6 +7,7 @@
 import com.vincent.rsf.server.common.domain.BaseParam;
 import com.vincent.rsf.server.common.domain.PageParam;
 import com.vincent.rsf.server.manager.entity.AsnOrderItem;
+import com.vincent.rsf.server.manager.entity.LocItem;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashMap;
@@ -20,6 +21,5 @@
     R excelImport(MultipartFile file, HashMap<String, Object> hashMap, Long loginUserId) throws Exception;
 
     IPage<Map<String, Object>> listByAsnId(PageParam<AsnOrderItem, BaseParam> pageParam, QueryWrapper<AsnOrderItem> buildWrapper);
-
 
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockService.java
index 5cfcc4c..e078197 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/OutStockService.java
@@ -9,6 +9,7 @@
 import com.vincent.rsf.server.manager.entity.AsnOrder;
 import com.vincent.rsf.server.manager.entity.AsnOrderItem;
 import com.vincent.rsf.server.manager.entity.DeliveryItem;
+import com.vincent.rsf.server.manager.entity.LocItem;
 
 import java.util.List;
 
@@ -31,4 +32,5 @@
     R getSiteNos();
 
     R cancelOutOrderByItems(List<AsnOrderItem> orderItems);
+
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java
index 7068b65..62c4b3e 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java
@@ -15,6 +15,7 @@
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.mapper.AsnOrderMapper;
 import com.vincent.rsf.server.manager.service.*;
+import com.vincent.rsf.server.manager.utils.LocManageUtil;
 import com.vincent.rsf.server.manager.utils.OptimalAlgorithmUtil;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
@@ -567,44 +568,6 @@
     }
 
 
-    private List<LocItem> getEfficiencyFirstItemList(AsnOrderItem asnOrderItem) {
-        LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
-        locItemQueryWrapper.eq(LocItem::getMatnrCode, asnOrderItem.getMatnrCode());
-        locItemQueryWrapper.eq(LocItem::getBatch, asnOrderItem.getSplrBatch());
-        String applySql = String.format(
-                "EXISTS (SELECT 1 FROM man_loc ml " +
-                        "WHERE ml.use_status = '%s'" +
-                        "AND ml.id = man_loc_item.loc_id " +
-                        ")",
-                LocStsType.LOC_STS_TYPE_F.type
-        );
-        locItemQueryWrapper.apply(applySql);
-        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
-        locItems.sort(Comparator.comparing((LocItem item) -> !LocUtils.isShallowLoc(item.getLocCode())));
-        List<LocItem> locsSet = locItems.stream().filter(locItem -> locItem.getAnfme().compareTo(asnOrderItem.getAnfme()) == 0.0).collect(Collectors.toList());
-        if (!locsSet.isEmpty()) {
-            return locsSet;
-        }
-        return locItems;
-    }
-
-    private List<LocItem> getFirstInFirstOutItemList(AsnOrderItem asnOrderItem) {
-        LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
-        locItemQueryWrapper.eq(LocItem::getMatnrCode, asnOrderItem.getMatnrCode());
-        locItemQueryWrapper.eq(LocItem::getBatch, asnOrderItem.getSplrBatch());
-        locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
-        String applySql = String.format(
-                "EXISTS (SELECT 1 FROM man_loc ml " +
-                        "WHERE ml.use_status = '%s'" +
-                        "AND ml.id = man_loc_item.loc_id " +
-                        ")",
-                LocStsType.LOC_STS_TYPE_F.type
-        );
-        locItemQueryWrapper.apply(applySql);
-        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
-        return locItems;
-    }
-
     private List<OrderOutItemDto> getOutOrderList(Long orderId, WaveRule waveRule) {
         List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>()
                 .eq(AsnOrderItem::getAsnId, orderId));
@@ -620,11 +583,11 @@
             }
             List<LocItem> locItems = new ArrayList<>();
             if (WaveRuleType.Efficiency_First.type.equals(waveRule.getType())) {
-                locItems = getEfficiencyFirstItemList(asnOrderItem);
+                locItems = LocManageUtil.getEfficiencyFirstItemList(asnOrderItem.getMatnrCode(), asnOrderItem.getSplrBatch(), asnOrderItem.getAnfme());
             } else if (WaveRuleType.First_In_First_Out.type.equals(waveRule.getType())) {
-                locItems = getFirstInFirstOutItemList(asnOrderItem);
+                locItems = LocManageUtil.getFirstInFirstOutItemList(asnOrderItem.getMatnrCode(), asnOrderItem.getSplrBatch(), asnOrderItem.getAnfme());
             } else {
-                locItems = getFirstInFirstOutItemList(asnOrderItem);
+                locItems = LocManageUtil.getFirstInFirstOutItemList(asnOrderItem.getMatnrCode(), asnOrderItem.getSplrBatch(), asnOrderItem.getAnfme());
             }
             for (LocItem locItem : locItems) {
                 Loc loc = locService.getById(locItem.getLocId());
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
index 53d92c7..0b07961 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
@@ -13,6 +13,7 @@
 import com.vincent.rsf.server.manager.mapper.WaveMapper;
 import com.vincent.rsf.server.manager.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.vincent.rsf.server.manager.utils.LocManageUtil;
 import com.vincent.rsf.server.manager.utils.OptimalAlgorithmUtil;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
@@ -118,12 +119,10 @@
             throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
         }
 
-        if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
-                .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)
-                .in(WaveItem::getId, waveItems))) {
-            throw new CoolException("涓嬪彂鎵ц寮傚父锛岃绋嶅�欓噸璇曪紒");
+        for (int i = 0; i < items.size(); i++) {
+            List<LocItem> locItems = LocManageUtil.getEfficiencyFirstItemList(items.get(i).getMatnrCode(), items.get(i).getSplrBatch(), items.get(i).getAnfme());
+            items.get(i).setStockLocs(JSONArray.toJSONString(locItems)).setStockQty(items.get(i).getAnfme());
         }
-
         /**鐢熸垚鍑哄簱浠诲姟*/
         try {
             generateOutTask(items, loginUserId, waves);
@@ -131,6 +130,13 @@
             log.error("UNK", e);
             throw new CoolException(e.getMessage());
         }
+
+        if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
+                .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)
+                .in(WaveItem::getId, waveItems))) {
+            throw new CoolException("涓嬪彂鎵ц寮傚父锛岃绋嶅�欓噸璇曪紒");
+        }
+
         return R.ok();
     }
 
@@ -150,31 +156,14 @@
         for (WaveItem param : itemParams) {
             String locs = param.getStockLocs();
             List<LocItem> locItems = JSONArray.parseArray(locs, LocItem.class);
-            List<Long> list = new ArrayList<>();
-            if (Objects.isNull(locItems) || locItems.isEmpty()) {
-                //TODO
-            } else {
-                list = locItems.stream().map(LocItem::getLocId).collect(Collectors.toList());
-            }
-
-            /**鏍规嵁渚涘簲鍟嗘壒娆★紝鐗╂枡鐮侊紝 鍔ㄦ�佸瓧娈垫煡璇㈡寚瀹氱殑鐗╂枡搴撳瓨淇℃伅*/
-            //TODO 杩欓噷闇�瑕佽鏍规嵁娉㈡瑙勫垯鏌ユ壘搴撳瓨淇℃伅
-            List<LocItem> items = locItemService.list(new LambdaQueryWrapper<LocItem>()
-                    .eq(LocItem::getBatch, param.getSplrBatch())
-                    .in(!list.isEmpty(),  LocItem::getLocId, list)
-//                    .eq(StringUtils.isNotBlank(param.getFieldsIndex()), LocItem::getFieldsIndex, param.getFieldsIndex())
-                    .eq(LocItem::getMatnrCode, param.getMatnrCode()));
-            if (items.isEmpty()) {
-                throw new CoolException("搴撳瓨淇℃伅鏈夊彉锛岃鍙栨秷褰撳墠娉㈡锛岀敓鏂扮敓鎴愭柊鐨勬尝娆★紒锛�");
-            }
             /***灏嗘湁璐ф湁鐨勬槑缁嗕俊鎭瓨鏀惧埌搴撲綅淇℃伅涓�*/
-            for (int i = 0; i < items.size(); i++) {
-                items.get(i)
+            for (int i = 0; i < locItems.size(); i++) {
+                locItems.get(i)
                         .setSourceId(param.getWaveId())
                         .setSourceCode(param.getWaveCode())
                         .setSource(param.getId());
             }
-            locItemList.addAll(items);
+            locItemList.addAll(locItems);
         }
         if (locItemList.isEmpty()) {
             throw new CoolException("娌℃湁鍚堥�傚簱浣嶏紒锛�");
@@ -205,7 +194,6 @@
 //            if (!items.isEmpty()) {
 //                throw new CoolException("娉㈡浠诲姟宸茬敓鎴愶紝涓嶈兘閲嶅鐢熸垚锛侊紒");
 //            }
-
             task.setTaskCode(ruleCode)
                     .setTaskType(TaskType.TASK_TYPE_OUT.type)
                     .setTaskStatus(TaskStsType.GENERATE_OUT.id)
@@ -241,7 +229,7 @@
             taskItems.forEach(item -> {
                 boolean update = waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
                         .eq(WaveItem::getId, item.getSource())
-                                .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_SEED.val)
+                        .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_SEED.val)
                         .set(WaveItem::getWorkQty, item.getAnfme()));
                 if (!update) {
                     throw new CoolException("娉㈡鎵ц鏁伴噺淇敼澶辫触锛侊紒");
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
index c4dcabd..a016244 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -2,13 +2,19 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.vincent.rsf.framework.common.SpringUtils;
+import com.vincent.rsf.server.api.utils.LocUtils;
 import com.vincent.rsf.server.manager.entity.DeviceSite;
 import com.vincent.rsf.server.manager.entity.Loc;
+import com.vincent.rsf.server.manager.entity.LocItem;
 import com.vincent.rsf.server.manager.service.DeviceSiteService;
+import com.vincent.rsf.server.manager.service.LocItemService;
 import com.vincent.rsf.server.manager.service.LocService;
 import com.vincent.rsf.server.manager.enums.LocStsType;
 
+import java.util.Comparator;
+import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 public class LocManageUtil {
 
@@ -48,4 +54,62 @@
         DeviceSite loc = deviceSite.getOne(new LambdaQueryWrapper<DeviceSite>().eq(DeviceSite::getStatus, 1), false);
         return !Objects.isNull(loc) ? loc.getSite() : null;
     }
+
+    /**
+     * 鍑哄簱绛栫暐锛�--銆堟晥鐜囦紭鍖栥��
+     * @param matnrCode
+     * @param splrBatch
+     * @param anfme
+     * @return
+     */
+    public static List<LocItem> getEfficiencyFirstItemList(String matnrCode, String splrBatch, Double anfme) {
+        LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
+        locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode);
+        locItemQueryWrapper.eq(LocItem::getBatch, splrBatch);
+        String applySql = String.format(
+                "EXISTS (SELECT 1 FROM man_loc ml " +
+                        "WHERE ml.use_status = '%s'" +
+                        "AND ml.id = man_loc_item.loc_id " +
+                        ")",
+                LocStsType.LOC_STS_TYPE_F.type
+        );
+        locItemQueryWrapper.apply(applySql);
+        LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
+        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
+        locItems.sort(Comparator.comparing((LocItem item) -> !LocUtils.isShallowLoc(item.getLocCode())));
+        List<LocItem> locsSet = locItems.stream().filter(locItem -> locItem.getAnfme().compareTo(anfme) == 0.0).collect(Collectors.toList());
+        if (!locsSet.isEmpty()) {
+            return locsSet;
+        }
+        return locItems;
+    }
+
+
+    /**
+     * 鍑哄簱绛栫暐锛�--<鍏堣繘鍏堝嚭>
+     * @param matnrCode
+     * @param splrBatch
+     * @param anfme
+     * @return
+     */
+    public static List<LocItem> getFirstInFirstOutItemList(String matnrCode, String splrBatch, Double anfme) {
+        LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
+        locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode);
+        locItemQueryWrapper.eq(LocItem::getBatch, splrBatch);
+        locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
+        String applySql = String.format(
+                "EXISTS (SELECT 1 FROM man_loc ml " +
+                        "WHERE ml.use_status = '%s'" +
+                        "AND ml.id = man_loc_item.loc_id " +
+                        ")",
+                LocStsType.LOC_STS_TYPE_F.type
+        );
+        locItemQueryWrapper.apply(applySql);
+        LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
+        List<LocItem> locItems = locItemService.list(locItemQueryWrapper);
+        return locItems;
+    }
+
+
+
 }
diff --git a/rsf-server/src/main/resources/application.yml b/rsf-server/src/main/resources/application.yml
index ac31a5b..db51329 100644
--- a/rsf-server/src/main/resources/application.yml
+++ b/rsf-server/src/main/resources/application.yml
@@ -25,7 +25,7 @@
   #  global-config:
   #    field-strategy: 0
   configuration:
-#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     map-underscore-to-camel-case: true
     cache-enabled: true
     call-setters-on-nulls: true

--
Gitblit v1.9.1