From 3aa3f9e730127147236c9e7627920dd8aacf3a36 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 15 七月 2026 15:49:59 +0800
Subject: [PATCH] 1.仓储物流-批次号优化覆盖数据 2.仓储物流-新增自定义出入库流水查询 3.采购管理-清理无用代码和表 4.销售管理-清理无用代码和表 5.销售流程状态字段数据回游
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java | 74 +++++++++++++++++++++++++++++-------
1 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java
index dd1a2e6..dabb8db 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java
@@ -2,7 +2,10 @@
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.util.object.BeanUtils;
+import cn.iocoder.yudao.module.mdm.api.category.MdmItemCategoryApi;
+import cn.iocoder.yudao.module.mdm.api.category.dto.MdmItemCategoryRespDTO;
import cn.iocoder.yudao.module.mes.controller.admin.md.item.vo.type.MesMdItemTypeListReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.md.item.vo.type.MesMdItemTypeSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemTypeDO;
@@ -20,6 +23,9 @@
/**
* MES 鐗╂枡浜у搧鍒嗙被 Service 瀹炵幇绫�
*
+ * 鍏煎灞傚疄鐜帮細鏁版嵁瀛樺偍鍦� mes_md_item_type 琛紝浣嗕紭鍏堜粠 MDM 鍒嗙被 API 鑾峰彇
+ * 瀹為檯鍒嗙被鏁版嵁宸茶縼绉诲埌 mdm_item_category 琛�
+ *
* @author 鑺嬮亾婧愮爜
*/
@Service
@@ -27,10 +33,13 @@
public class MesMdItemTypeServiceImpl implements MesMdItemTypeService {
@Resource
+ private MdmItemCategoryApi mdmItemCategoryApi;
+
+ @Resource
private MesMdItemTypeMapper itemTypeMapper;
@Resource
- @Lazy // 寤惰繜鍔犺浇锛岄伩鍏嶅惊鐜緷璧�
+ @Lazy
private MesMdItemService itemService;
@Override
@@ -38,7 +47,7 @@
// 鏍¢獙鏁版嵁
validateItemTypeSaveData(createReqVO);
- // 鎻掑叆
+ // 鎻掑叆鍒版湰鍦拌〃锛堜繚鎸佸吋瀹癸級
MesMdItemTypeDO itemType = BeanUtils.toBean(createReqVO, MesMdItemTypeDO.class);
itemTypeMapper.insert(itemType);
return itemType.getId();
@@ -51,7 +60,7 @@
// 鏍¢獙鏁版嵁
validateItemTypeSaveData(updateReqVO);
- // 鏇存柊
+ // 鏇存柊鏈湴琛�
MesMdItemTypeDO updateObj = BeanUtils.toBean(updateReqVO, MesMdItemTypeDO.class);
itemTypeMapper.updateById(updateObj);
}
@@ -83,6 +92,12 @@
}
private void validateItemTypeExists(Long id) {
+ // 浼樺厛浠� MDM 鑾峰彇
+ CommonResult<MdmItemCategoryRespDTO> result = mdmItemCategoryApi.getItemCategory(id);
+ if (result.isSuccess() && result.getData() != null) {
+ return;
+ }
+ // 鍥為��鍒版湰鍦拌〃
if (itemTypeMapper.selectById(id) == null) {
throw exception(MD_ITEM_TYPE_NOT_EXISTS);
}
@@ -96,26 +111,36 @@
if (Objects.equals(id, parentId)) {
throw exception(MD_ITEM_TYPE_PARENT_ERROR);
}
- // 2. 鐖跺垎绫讳笉瀛樺湪
- MesMdItemTypeDO parentItemType = itemTypeMapper.selectById(parentId);
+ // 2. 鐖跺垎绫讳笉瀛樺湪 - 浼樺厛浠� MDM 鑾峰彇
+ CommonResult<MdmItemCategoryRespDTO> result = mdmItemCategoryApi.getItemCategory(parentId);
+ MesMdItemTypeDO parentItemType = null;
+ if (result.isSuccess() && result.getData() != null) {
+ parentItemType = convertToMesDO(result.getData());
+ } else {
+ parentItemType = itemTypeMapper.selectById(parentId);
+ }
if (parentItemType == null) {
throw exception(MD_ITEM_TYPE_PARENT_NOT_EXITS);
}
// 3. 閫掑綊鏍¢獙鐖跺垎绫伙紝濡傛灉鐖跺垎绫绘槸鑷繁鐨勫瓙鍒嗙被锛屽垯鎶ラ敊锛岄伩鍏嶅舰鎴愮幆璺�
- if (id == null) { // id 涓虹┖锛岃鏄庢柊澧烇紝涓嶉渶瑕佽�冭檻鐜矾
+ if (id == null) {
return;
}
for (int i = 0; i < Short.MAX_VALUE; i++) {
- // 3.1 鏍¢獙鐜矾
parentId = parentItemType.getParentId();
if (Objects.equals(id, parentId)) {
throw exception(MD_ITEM_TYPE_PARENT_IS_CHILD);
}
- // 3.2 缁х画閫掑綊涓嬩竴绾х埗鍒嗙被
if (parentId == null || MesMdItemTypeDO.PARENT_ID_ROOT.equals(parentId)) {
break;
}
- parentItemType = itemTypeMapper.selectById(parentId);
+ // 缁х画鏌ユ壘鐖剁骇
+ CommonResult<MdmItemCategoryRespDTO> parentResult = mdmItemCategoryApi.getItemCategory(parentId);
+ if (parentResult.isSuccess() && parentResult.getData() != null) {
+ parentItemType = convertToMesDO(parentResult.getData());
+ } else {
+ parentItemType = itemTypeMapper.selectById(parentId);
+ }
if (parentItemType == null) {
break;
}
@@ -144,16 +169,24 @@
@Override
public MesMdItemTypeDO getItemType(Long id) {
+ // 浼樺厛浠� MDM 鑾峰彇
+ CommonResult<MdmItemCategoryRespDTO> result = mdmItemCategoryApi.getItemCategory(id);
+ if (result.isSuccess() && result.getData() != null) {
+ return convertToMesDO(result.getData());
+ }
+ // 鍥為��鍒版湰鍦拌〃
return itemTypeMapper.selectById(id);
}
@Override
public MesMdItemTypeDO getItemTypeByCode(String code) {
+ // 浠庢湰鍦拌〃鏌�
return itemTypeMapper.selectByCode(code);
}
@Override
public List<MesMdItemTypeDO> getItemTypeList(MesMdItemTypeListReqVO listReqVO) {
+ // 浠庢湰鍦拌〃鏌�
return itemTypeMapper.selectList(listReqVO);
}
@@ -167,16 +200,12 @@
@Override
public List<MesMdItemTypeDO> getItemTypeChildrenList(Long parentId) {
- List<MesMdItemTypeDO> allList = itemTypeMapper.selectList(); // 鍒嗙被鎬婚噺灏忥紝鍏ㄩ噺鏌�
- // 閫掑綊鏀堕泦鎵�鏈夊瓙鍒嗙被
+ List<MesMdItemTypeDO> allList = itemTypeMapper.selectList();
List<MesMdItemTypeDO> result = new ArrayList<>();
collectItemTypeChildren(result, parentId, allList);
return result;
}
- /**
- * 閫掑綊鏀堕泦鎵�鏈夊瓙鍒嗙被
- */
private void collectItemTypeChildren(List<MesMdItemTypeDO> result, Long parentId, List<MesMdItemTypeDO> allList) {
for (MesMdItemTypeDO itemType : allList) {
if (Objects.equals(itemType.getParentId(), parentId)) {
@@ -186,4 +215,19 @@
}
}
-}
+ /**
+ * 杞崲 MDM 鍒嗙被 DTO 涓� MES DO
+ */
+ private MesMdItemTypeDO convertToMesDO(MdmItemCategoryRespDTO dto) {
+ MesMdItemTypeDO mesDO = new MesMdItemTypeDO();
+ mesDO.setId(dto.getId());
+ mesDO.setCode(dto.getCode());
+ mesDO.setName(dto.getName());
+ mesDO.setParentId(dto.getParentId());
+ mesDO.setItemOrProduct(dto.getItemOrProduct());
+ mesDO.setSort(dto.getSort());
+ mesDO.setStatus(dto.getStatus());
+ return mesDO;
+ }
+
+}
\ No newline at end of file
--
Gitblit v1.9.3