From f7273277023f3497ac071bf98f556a569cb4dd25 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 17 九月 2026 16:24:10 +0800
Subject: [PATCH] feat(mes): 重构袋码生成与物料分类功能

---
 yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java |   48 +++---------------------------------------------
 1 files changed, 3 insertions(+), 45 deletions(-)

diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
index 138b8e0..3176e2f 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java
@@ -2,28 +2,20 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemPageReqVO;
 import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSaveReqVO;
-import cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO;
 import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemBatchConfigDO;
 import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO;
 import cn.iocoder.yudao.module.mdm.dal.dataobject.unit.MdmUnitMeasureDO;
 import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemBatchConfigMapper;
 import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemMapper;
 import cn.iocoder.yudao.module.mdm.service.brand.MdmBrandService;
-import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService;
 import cn.iocoder.yudao.module.mdm.service.unit.MdmUnitMeasureService;
 import cn.iocoder.yudao.module.mes.api.item.MesMdItemApi;
-import cn.iocoder.yudao.module.mes.api.item.MesMdItemTypeApi;
 import cn.iocoder.yudao.module.mes.api.item.dto.MesMdItemSyncReqDTO;
-import cn.iocoder.yudao.module.mes.api.item.dto.MesMdItemTypeRespDTO;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import jakarta.annotation.Resource;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -33,7 +25,6 @@
 import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
 import static cn.iocoder.yudao.module.mdm.enums.ErrorCodeConstants.*;
 
 /**
@@ -49,8 +40,6 @@
     private MdmItemMapper itemMapper;
 
     @Resource
-    private MdmItemCategoryService itemCategoryService;
-    @Resource
     private MdmUnitMeasureService unitMeasureService;
     @Resource
     private MdmBrandService brandService;
@@ -60,9 +49,6 @@
     private MesMdItemApi mesMdItemApi;
     @Resource
     private MdmItemBatchConfigMapper itemBatchConfigMapper;
-
-    @Resource
-    private MesMdItemTypeApi mesMdItemTypeApi;
 
 
     @Override
@@ -115,10 +101,9 @@
     }
 
     /**
-     * 鍚屾鐗╂枡鍒� MES锛堝崟浣�/鍒嗙被鎸� code 鏄犲皠锛�
+     * 鍚屾鐗╂枡鍒� MES锛堝崟浣嶆寜 code 鏄犲皠锛�
      *
-     * MDM 鐨� unitMeasureId/categoryId 涓� MES 鐨� unitMeasureId/itemTypeId 鍒嗗睘涓ゅ涓绘暟鎹紝
-     * 杩欓噷鍏堝湪 MDM 渚цВ鏋愬嚭 code锛屽啀浜ょ敱 MesMdItemApi 鍦� MES 渚цВ鏋愪负瀵瑰簲 id銆�
+     * 鍝佺绠$悊宸插幓鎺夈�屽搧绉嶅垎绫汇�嶅瓧娈碉紝鍚屾涓嶅啀浼犻�� MES 鐗╂枡鍒嗙被锛坕tem_type_id 鐣欑┖锛屽彲鍦� MES 渚цˉ濉級銆�
      * 鍚屾澶辫触灏嗘姏鍑哄紓甯革紝瑙﹀彂澶栧眰 @Transactional 鏁翠綋鍥炴粴锛圡DM 鎿嶄綔涓�骞跺洖婊氾級銆�
      */
     private void syncItemToMes(MdmItemSaveReqVO reqVO) {
@@ -131,12 +116,6 @@
             }
             unitCode = unitMeasure.getCode();
         }
-        // 瑙f瀽鍒嗙被 id -> code锛堜娇鐢� MDM 鏈湴鍒嗙被鏈嶅姟锛�
-        String itemTypeCode = null;
-        if (reqVO.getCategoryId() != null) {
-            CommonResult<MesMdItemTypeRespDTO> itemType = mesMdItemTypeApi.getItemType(reqVO.getCategoryId());
-            itemTypeCode = itemType.getData().getCode();
-        }
         // 缁勮鍚屾 DTO
         MesMdItemSyncReqDTO syncReqDTO = new MesMdItemSyncReqDTO();
         syncReqDTO.setCode(reqVO.getCode());
@@ -144,7 +123,6 @@
         syncReqDTO.setName(reqVO.getName());
         syncReqDTO.setSpecification(reqVO.getSpecification());
         syncReqDTO.setUnitCode(unitCode);
-        syncReqDTO.setItemTypeCode(itemTypeCode);
         syncReqDTO.setSafeStockFlag(Boolean.TRUE); // 淇濈暀 MDM 鐨� minStock/maxStock锛岄伩鍏嶈 MES 娓呴浂
         syncReqDTO.setMinStock(reqVO.getMinStock());
         syncReqDTO.setMaxStock(reqVO.getMaxStock());
@@ -274,17 +252,6 @@
         }
     }
 
-    private void validateCategoryExists(Long categoryId) {
-        if (categoryId == null) {
-            return;
-        }
-        // 浣跨敤 MDM 鏈湴鍒嗙被鏈嶅姟鏍¢獙
-        MdmItemCategoryDO category = itemCategoryService.getItemCategory(categoryId);
-        if (category == null) {
-            throw exception(MDM_ITEM_CATEGORY_NOT_EXISTS);
-        }
-    }
-
     private void validateUnitMeasureExists(Long unitMeasureId) {
         if (unitMeasureService.getUnitMeasure(unitMeasureId) == null) {
             throw exception(MDM_UNIT_MEASURE_NOT_EXISTS);
@@ -328,17 +295,8 @@
 
     @Override
     public PageResult<MdmItemDO> getItemPage(MdmItemPageReqVO pageReqVO) {
-        // 鏌ユ壘鏃讹紝濡傛灉鏌ユ壘鏌愪釜鍒嗙被缂栧彿锛屽垯鍖呭惈瀹冪殑瀛愬垎绫�
-        Set<Long> categoryIds = null;
-        if (pageReqVO.getCategoryId() != null) {
-            categoryIds = new HashSet<>();
-            categoryIds.add(pageReqVO.getCategoryId());
-            List<cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO> children =
-                    itemCategoryService.getItemCategoryChildrenList(pageReqVO.getCategoryId());
-            categoryIds.addAll(convertSet(children, cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO::getId));
-        }
         // 鍒嗛〉鏌ヨ
-        return itemMapper.selectPage(pageReqVO, categoryIds);
+        return itemMapper.selectPage(pageReqVO, (Collection<Long>) null);
     }
 
     @Override

--
Gitblit v1.9.3