From 4bec63c802692a402039f0d99eae068d26d63c55 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期六, 07 十一月 2026 16:11:44 +0800
Subject: [PATCH] 完善物料颜色同步并保护数据
---
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/service/item/MdmItemServiceImpl.java | 13 +++++-
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemImportExcelVO.java | 3 +
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/api/item/MesMdItemApiImpl.java | 15 +++++++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemPageReqVO.java | 3 +
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/dataobject/item/MdmItemDO.java | 7 +++
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java | 4 ++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemExcelVO.java | 3 +
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemSaveReqVO.java | 3 +
yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/api/item/dto/MesMdItemSyncReqDTO.java | 6 +++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApiImpl.java | 12 +++++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java | 2 +
sql/mysql/mdm_item_color_20261107.sql | 25 ++++++++++++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApi.java | 5 ++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemRespDTO.java | 5 ++
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemSyncReqDTO.java | 3 +
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemRespVO.java | 3 +
16 files changed, 106 insertions(+), 6 deletions(-)
diff --git a/sql/mysql/mdm_item_color_20261107.sql b/sql/mysql/mdm_item_color_20261107.sql
new file mode 100644
index 0000000..897b423
--- /dev/null
+++ b/sql/mysql/mdm_item_color_20261107.sql
@@ -0,0 +1,25 @@
+-- MDM 鐗╂枡琛ャ�岄鑹层�嶅瓧娈碉紙闇�姹傦細鐗╂枡棰滆壊鍦ㄧ墿鏂欑鐞�(mdm)椤甸潰鍚屾牱鍙淮鎶わ級
+-- 涓� mes_md_item.color 淇濇寔涓�鑷达紝骞舵寜鐗╂枡缂栫爜鎶� MES 宸叉湁鐨勯鑹插洖濉繃鏉ャ��
+
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='mdm_item' AND COLUMN_NAME='color');
+SET @s := IF(@c=0,
+ 'ALTER TABLE mdm_item ADD COLUMN color VARCHAR(64) DEFAULT NULL COMMENT ''棰滆壊'' AFTER specification',
+ 'SELECT 1');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+-- 鍥炲~锛氭寜鐗╂枡缂栫爜鎶� MES 渚у凡缁存姢鐨勯鑹插悓姝ュ埌 MDM锛堜粎濉厖 MDM 涓虹┖鐨勮褰曪級
+UPDATE mdm_item m
+JOIN mes_md_item s ON s.code = m.code AND CAST(s.deleted AS UNSIGNED)=0
+SET m.color = s.color
+WHERE CAST(m.deleted AS UNSIGNED)=0
+ AND s.color IS NOT NULL AND s.color <> ''
+ AND (m.color IS NULL OR m.color = '');
+
+-- 鍙嶅悜鍥炲~锛歁DM 鏈夐鑹茶�� MES 娌℃湁鏃讹紝鍚屾鍒� MES锛堜繚鎸佷袱杈逛竴鑷达級
+UPDATE mes_md_item s
+JOIN mdm_item m ON m.code = s.code AND CAST(m.deleted AS UNSIGNED)=0
+SET s.color = m.color
+WHERE CAST(s.deleted AS UNSIGNED)=0
+ AND m.color IS NOT NULL AND m.color <> ''
+ AND (s.color IS NULL OR s.color = '');
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApi.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApi.java
index b37ab57..a2e5afe 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApi.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApi.java
@@ -22,4 +22,7 @@
*/
CommonResult<Long> syncItemToMdm(MdmItemSyncReqDTO syncReqDTO);
-}
\ No newline at end of file
+ /** 浠呭悓姝ュ凡鏈夊悓缂栫爜鐗╂枡鐨勯鑹诧紝涓嶅垱寤虹墿鏂欐垨瑕嗙洊鍏朵粬涓绘暟鎹�� */
+ CommonResult<Boolean> syncExistingItemColor(String code, String color);
+
+}
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApiImpl.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApiImpl.java
index eadd522..77629a7 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApiImpl.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/MdmItemSyncApiImpl.java
@@ -30,6 +30,16 @@
private MdmItemBatchConfigMapper itemBatchConfigMapper;
@Override
+ public CommonResult<Boolean> syncExistingItemColor(String code, String color) {
+ MdmItemDO existingItem = itemMapper.selectByCode(code);
+ if (existingItem == null || color == null) {
+ return success(false);
+ }
+ itemMapper.updateById(new MdmItemDO().setId(existingItem.getId()).setColor(color));
+ return success(true);
+ }
+
+ @Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<Long> syncItemToMdm(MdmItemSyncReqDTO syncReqDTO) {
// 1. 鎸� code 鏌ヨ鏄惁宸插瓨鍦�
@@ -99,4 +109,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemRespDTO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemRespDTO.java
index b3c1993..bf21dbe 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemRespDTO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemRespDTO.java
@@ -24,6 +24,9 @@
@Schema(description = "瑙勬牸鍨嬪彿", example = "M8*20")
private String specification;
+ @Schema(description = "棰滆壊", example = "绾�")
+ private String color;
+
@Schema(description = "鐗╂枡鍒嗙被缂栧彿", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long categoryId;
@@ -72,4 +75,4 @@
@Schema(description = "澶囨敞", example = "澶囨敞淇℃伅")
private String remark;
-}
\ No newline at end of file
+}
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemSyncReqDTO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemSyncReqDTO.java
index a6d88cb..e839901 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemSyncReqDTO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/api/item/dto/MdmItemSyncReqDTO.java
@@ -23,6 +23,9 @@
@Schema(description = "瑙勬牸鍨嬪彿", example = "M6*20")
private String specification;
+ @Schema(description = "棰滆壊", example = "绾�")
+ private String color;
+
@Schema(description = "鐗╂枡绫诲瀷锛�1鍘熸枡, 2鍗婃垚鍝�, 3鎴愬搧, 4杈呮枡", example = "1")
private Long itemType;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemExcelVO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemExcelVO.java
index 6273789..a5c5dbc 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemExcelVO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemExcelVO.java
@@ -26,6 +26,9 @@
@ExcelProperty("瑙勬牸鍨嬪彿")
private String specification;
+ @ExcelProperty("棰滆壊")
+ private String color;
+
@ExcelProperty("鐗╂枡绫诲瀷")
private String itemTypeName;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemImportExcelVO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemImportExcelVO.java
index a490136..6cc3f33 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemImportExcelVO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemImportExcelVO.java
@@ -29,6 +29,9 @@
@ExcelProperty("瑙勬牸鍨嬪彿")
private String specification;
+ @ExcelProperty("棰滆壊")
+ private String color;
+
@ExcelProperty("鐗╂枡鍒嗙被缂栫爜")
private String categoryCode;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemPageReqVO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemPageReqVO.java
index 93e87b5..91dd0f9 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemPageReqVO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemPageReqVO.java
@@ -23,6 +23,9 @@
@Schema(description = "鐗╂枡鏉$爜", example = "12345678")
private String barCode;
+ @Schema(description = "棰滆壊锛堟ā绯婂尮閰嶏級", example = "绾�")
+ private String color;
+
@Schema(description = "鐗╂枡鍒嗙被缂栧彿", example = "1")
private Long categoryId;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemRespVO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemRespVO.java
index ae79448..cc6d617 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemRespVO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemRespVO.java
@@ -25,6 +25,9 @@
@Schema(description = "瑙勬牸鍨嬪彿", example = "M8*20")
private String specification;
+ @Schema(description = "棰滆壊", example = "绾�")
+ private String color;
+
@Schema(description = "鐗╂枡鍒嗙被缂栧彿", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long categoryId;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemSaveReqVO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemSaveReqVO.java
index 13710d4..58b1a27 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemSaveReqVO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/vo/MdmItemSaveReqVO.java
@@ -24,6 +24,9 @@
@Schema(description = "瑙勬牸鍨嬪彿", example = "M8*20")
private String specification;
+ @Schema(description = "棰滆壊", example = "绾�")
+ private String color;
+
@Schema(description = "鐗╂枡鍒嗙被缂栧彿锛堝叧鑱� MES 鐗╂枡鍒嗙被 mes_md_item_type锛�", example = "1")
private Long categoryId;
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/dataobject/item/MdmItemDO.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/dataobject/item/MdmItemDO.java
index c8cd307..3c49c99 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/dataobject/item/MdmItemDO.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/dataobject/item/MdmItemDO.java
@@ -56,6 +56,13 @@
private String specification;
/**
+ * 棰滆壊
+ *
+ * 鐢ㄤ簬鍖哄垎鍚屽瀷鍙蜂笉鍚岄鑹茬殑鐗╂枡
+ */
+ private String color;
+
+ /**
* 鐗╂枡鍒嗙被缂栧彿
*
* 鍏宠仈 {@link MdmItemCategoryDO#getId()}
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
index eec20ce..7fe4c99 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
@@ -25,6 +25,7 @@
.likeIfPresent(MdmItemDO::getCode, reqVO.getCode())
.likeIfPresent(MdmItemDO::getName, reqVO.getName())
.likeIfPresent(MdmItemDO::getBarCode, reqVO.getBarCode())
+ .likeIfPresent(MdmItemDO::getColor, reqVO.getColor())
.inIfPresent(MdmItemDO::getCategoryId, categoryIds)
.eqIfPresent(MdmItemDO::getItemType, reqVO.getItemType())
.eqIfPresent(MdmItemDO::getBrandId, reqVO.getBrandId())
@@ -38,6 +39,7 @@
return selectList(new LambdaQueryWrapperX<MdmItemDO>()
.likeIfPresent(MdmItemDO::getCode, reqVO.getCode())
.likeIfPresent(MdmItemDO::getName, reqVO.getName())
+ .likeIfPresent(MdmItemDO::getColor, reqVO.getColor())
.inIfPresent(MdmItemDO::getCategoryId, categoryIds)
.eqIfPresent(MdmItemDO::getItemType, reqVO.getItemType())
.eqIfPresent(MdmItemDO::getStatus, reqVO.getStatus())
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 cfbc790..fa4ba2f 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
@@ -107,7 +107,7 @@
@Transactional(rollbackFor = Exception.class)
public void updateItem(MdmItemSaveReqVO updateReqVO) {
// 鏍¢獙瀛樺湪
- validateItemExists(updateReqVO.getId());
+ MdmItemDO previousItem = validateItemExists(updateReqVO.getId());
// 鏍¢獙鏁版嵁
validateItemSaveData(updateReqVO);
@@ -120,7 +120,7 @@
// 鏍规嵁鍚屾寮�鍏冲喅瀹氾細鎵撳紑鍒欏悓姝ュ埌 MES锛屽叧闂垯鍙栨秷鍚屾锛堜粠 MES 鍒犻櫎锛�
if (Boolean.TRUE.equals(updateReqVO.getSyncMes())) {
- syncItemToMes(updateReqVO);
+ syncItemToMes(updateReqVO, previousItem.getCode());
} else {
mesMdItemApi.deleteItem(updateReqVO.getId());
}
@@ -139,6 +139,10 @@
* 鍚屾澶辫触灏嗘姏鍑哄紓甯革紝鍥炴粴鏈浜嬪姟锛堟湰琛岀殑 MDM 鎿嶄綔涓�骞跺洖婊氾紝涓嶅奖鍝嶅叾瀹冭锛夈��
*/
private void syncItemToMes(MdmItemSaveReqVO reqVO) {
+ syncItemToMes(reqVO, null);
+ }
+
+ private void syncItemToMes(MdmItemSaveReqVO reqVO, String previousCode) {
// 瑙f瀽璁¢噺鍗曚綅 id -> code
String unitCode = null;
if (reqVO.getUnitMeasureId() != null) {
@@ -157,9 +161,11 @@
// 缁勮鍚屾 DTO
MesMdItemSyncReqDTO syncReqDTO = new MesMdItemSyncReqDTO();
syncReqDTO.setCode(reqVO.getCode());
+ syncReqDTO.setPreviousCode(previousCode);
syncReqDTO.setMdmItemId(reqVO.getId());
syncReqDTO.setName(reqVO.getName());
syncReqDTO.setSpecification(reqVO.getSpecification());
+ syncReqDTO.setColor(reqVO.getColor());
syncReqDTO.setUnitCode(unitCode);
syncReqDTO.setItemTypeCode(itemTypeCode);
syncReqDTO.setSafeStockFlag(Boolean.TRUE); // 淇濈暀 MDM 鐨� minStock/maxStock锛岄伩鍏嶈 MES 娓呴浂
@@ -515,6 +521,7 @@
saveReqVO.setName(importVO.getName());
saveReqVO.setBarCode(importVO.getBarCode());
saveReqVO.setSpecification(importVO.getSpecification());
+ saveReqVO.setColor(importVO.getColor());
saveReqVO.setCategoryId(categoryId);
saveReqVO.setUnitMeasureId(unitMeasureId);
saveReqVO.setUnitMeasureId2(unitMeasureId2);
@@ -587,4 +594,4 @@
StrUtil.blankToDefault(importVO.getName(), "锛堝悕绉板拰缂栫爜涓虹┖鐨勮锛�"));
}
-}
\ No newline at end of file
+}
diff --git a/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/api/item/dto/MesMdItemSyncReqDTO.java b/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/api/item/dto/MesMdItemSyncReqDTO.java
index 1910fb0..0a7a33c 100644
--- a/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/api/item/dto/MesMdItemSyncReqDTO.java
+++ b/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/api/item/dto/MesMdItemSyncReqDTO.java
@@ -12,12 +12,18 @@
@Schema(description = "鐗╂枡缂栫爜", requiredMode = Schema.RequiredMode.REQUIRED, example = "ITEM001")
private String code;
+ @Schema(description = "淇敼鍓嶇殑鐗╂枡缂栫爜锛岀敤浜庡畨鍏ㄨ瘑鍒凡鍏宠仈鐨勭敓浜х墿鏂�")
+ private String previousCode;
+
@Schema(description = "鐗╂枡鍚嶇О", requiredMode = Schema.RequiredMode.REQUIRED, example = "铻轰笣")
private String name;
@Schema(description = "瑙勬牸鍨嬪彿", example = "M6*20")
private String specification;
+ @Schema(description = "棰滆壊", example = "绾�")
+ private String color;
+
@Schema(description = "璁¢噺鍗曚綅缂栫爜", requiredMode = Schema.RequiredMode.REQUIRED, example = "PCS")
private String unitCode;
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/api/item/MesMdItemApiImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/api/item/MesMdItemApiImpl.java
index 3376239..1218c78 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/api/item/MesMdItemApiImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/api/item/MesMdItemApiImpl.java
@@ -18,9 +18,11 @@
import org.springframework.validation.annotation.Validated;
import java.util.Collection;
+import java.util.Objects;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
/**
@@ -50,6 +52,7 @@
@Override
public Long createItem(MesMdItemSyncReqDTO syncReqDTO) {
log.info("[createItem] 鍚屾鍒涘缓 MES 鐗╂枡浜у搧锛宑ode={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId());
+ validateSharedId(syncReqDTO);
MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO);
// 浣跨敤 MDM 鐗╂枡 ID 浣滀负 MES 鐗╂枡 ID
if (syncReqDTO.getMdmItemId() != null) {
@@ -64,6 +67,7 @@
@Override
public void updateItem(MesMdItemSyncReqDTO syncReqDTO) {
log.info("[updateItem] 鍚屾鏇存柊 MES 鐗╂枡浜у搧锛宑ode={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId());
+ validateSharedId(syncReqDTO);
MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO);
// 浣跨敤 MDM 鐗╂枡 ID 浣滀负 MES 鐗╂枡 ID
if (syncReqDTO.getMdmItemId() != null) {
@@ -91,6 +95,17 @@
// saveBatchConfig(itemId, syncReqDTO);
}
+ private void validateSharedId(MesMdItemSyncReqDTO syncReqDTO) {
+ if (syncReqDTO.getMdmItemId() == null) {
+ return;
+ }
+ MesMdItemDO existing = itemMapper.selectAnyById(syncReqDTO.getMdmItemId());
+ if (existing != null && !Objects.equals(existing.getCode(), syncReqDTO.getCode())
+ && !Objects.equals(existing.getCode(), syncReqDTO.getPreviousCode())) {
+ throw invalidParamException("鍚屾澶辫触锛氱敓浜х墿鏂欑紪鍙峰凡琚叾浠栫紪鐮佸崰鐢紝璇锋牳瀵逛袱濂楃墿鏂欐暟鎹悗鍐嶆搷浣�");
+ }
+ }
+
/**
* 灏嗗悓姝� DTO 杞崲涓� MES 鐗╂枡浜у搧 SaveReqVO锛屽苟鎸� code 瑙f瀽鍗曚綅/鍒嗙被 id
*/
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java
index 0ad9119..7c00291 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemServiceImpl.java
@@ -133,6 +133,9 @@
if (Boolean.TRUE.equals(updateReqVO.getSyncMdm())) {
MesMdItemDO item = itemMapper.selectById(updateReqVO.getId());
syncItemToMdm(item, updateReqVO);
+ } else if (updateReqVO.getMdmItemId() == null && updateReqVO.getColor() != null) {
+ // MES 椤甸潰缂栬緫鏃跺彧鍚屾宸叉湁鍚岀紪鐮佺墿鏂欑殑棰滆壊锛岄伩鍏嶈鐩� MDM 鍏朵粬瀛楁鎴栧惊鐜悓姝ャ��
+ mdmItemSyncApi.syncExistingItemColor(updateReqVO.getCode(), updateReqVO.getColor()).checkError();
}
}
@@ -342,6 +345,7 @@
syncReqDTO.setCode(item.getCode());
syncReqDTO.setName(item.getName());
syncReqDTO.setSpecification(item.getSpecification());
+ syncReqDTO.setColor(item.getColor());
syncReqDTO.setItemType(itemType);
syncReqDTO.setUnitMeasureId(unitMeasureId);
syncReqDTO.setCategoryId(item.getItemTypeId());
--
Gitblit v1.9.3