From 5072520172e8f45e3ccb8afc26cf0c8186ba4cdd Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 19 十月 2026 16:31:42 +0800
Subject: [PATCH] refactor(mes): 重构质量管理和批次绑定功能

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/bagcode/MesProBagCodeServiceImpl.java |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/bagcode/MesProBagCodeServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/bagcode/MesProBagCodeServiceImpl.java
index bfcd3af..1990cd8 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/bagcode/MesProBagCodeServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/bagcode/MesProBagCodeServiceImpl.java
@@ -83,9 +83,9 @@
      */
     private static final String UNIT_TYPE_TON = "鍚�";
     /**
-     * 璁¢噺鍗曚綅绫诲瀷銆孨鍗冨厠銆嶏細姣忔墭鐩樿 N 涓鐮�
+     * 璁¢噺鍗曚綅绫诲瀷銆孨琚嬨�嶏細姣忔墭鐩樿 N 涓鐮�
      */
-    private static final Pattern KG_TYPE_PATTERN = Pattern.compile("^(\\d{1,5})鍗冨厠$");
+    private static final Pattern BAG_TYPE_PATTERN = Pattern.compile("^(\\d{1,5})琚�$");
 
     @Resource
     private MesCodeRedisDAO codeRedisDao;
@@ -99,9 +99,9 @@
         MesMdmItemDO item = mdmItemService.validateItemExists(generateReqVO.getItemId());
         String type = getUnitType(item);
 
-        // 2. 鎸夌被鍨嬫崲绠楄鐮佹暟閲忥細N鍗冨厠 = 姣忔墭 N 琚� 脳 鎵樼洏鏁帮紱鍚� = 鐩存帴杈撳叆琚嬬爜鏁帮紙鏃犳墭鐩橈級
+        // 2. 鎸夌被鍨嬫崲绠楄鐮佹暟閲忥細N琚� = 姣忔墭 N 琚� 脳 鎵樼洏鏁帮紱鍚� = 鐩存帴杈撳叆琚嬬爜鏁帮紙鏃犳墭鐩橈級
         boolean ton = UNIT_TYPE_TON.equals(type);
-        int perPallet = ton ? 0 : parseKgPerPallet(type);
+        int perPallet = ton ? 0 : parseBagsPerPallet(type);
         int totalCount;
         int palletCount = 0;
         if (ton) {
@@ -190,7 +190,7 @@
     }
 
     /**
-     * 璇诲彇鍝佺涓昏閲忓崟浣嶇殑绫诲瀷锛�48鍗冨厠/100鍗冨厠/鍚級锛屾湭閰嶇疆鎴栨棤娉曡瘑鍒椂鎶ラ敊
+     * 璇诲彇鍝佺涓昏閲忓崟浣嶇殑绫诲瀷锛�48琚�/100琚�/鍚級锛屾湭閰嶇疆鎴栨棤娉曡瘑鍒椂鎶ラ敊
      */
     private String getUnitType(MesMdmItemDO item) {
         String type = null;
@@ -203,17 +203,31 @@
         if (type == null) {
             throw exception(PRO_BAG_CODE_ITEM_TYPE_NOT_CONFIGURED);
         }
-        if (!UNIT_TYPE_TON.equals(type) && !KG_TYPE_PATTERN.matcher(type).matches()) {
+        if (!UNIT_TYPE_TON.equals(type) && !BAG_TYPE_PATTERN.matcher(type).matches()) {
             throw exception(PRO_BAG_CODE_ITEM_TYPE_NOT_CONFIGURED);
         }
         return type;
     }
 
+    @Override
+    public List<MesProBagCodeDO> getUnboundTonBags() {
+        Map<Long, Boolean> tonItems = new LinkedHashMap<>();
+        return bagCodeMapper.selectUnboundPalletlessList().stream()
+                .filter(bag -> tonItems.computeIfAbsent(bag.getItemId(), id -> {
+                    MesMdmItemDO item = mdmItemService.getItem(id);
+                    if (item == null || item.getUnitMeasureId() == null) return false;
+                    CommonResult<MdmUnitMeasureRespDTO> result = unitMeasureApi.getUnitMeasure(item.getUnitMeasureId());
+                    return result != null && result.isSuccess() && result.getData() != null
+                            && UNIT_TYPE_TON.equals(StrUtil.trim(result.getData().getType()));
+                }))
+                .toList();
+    }
+
     /**
-     * 瑙f瀽銆孨鍗冨厠銆嶇被鍨嬪緱鍑烘瘡鎵樼洏琚嬫暟
+     * 瑙f瀽銆孨琚嬨�嶇被鍨嬪緱鍑烘瘡鎵樼洏琚嬫暟
      */
-    private int parseKgPerPallet(String type) {
-        Matcher matcher = KG_TYPE_PATTERN.matcher(type);
+    private int parseBagsPerPallet(String type) {
+        Matcher matcher = BAG_TYPE_PATTERN.matcher(type);
         if (!matcher.matches()) {
             throw exception(PRO_BAG_CODE_ITEM_TYPE_NOT_CONFIGURED);
         }

--
Gitblit v1.9.3