From 4eb9a3a99e21522ede60dcb8bee5b5856b515dc7 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 20 十月 2026 14:00:41 +0800
Subject: [PATCH] feat(mes): 添加MES数采功能支持MQTT设备数据采集
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
index bb3c226..52f1094 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
@@ -82,6 +82,8 @@
workshopService.getWorkshop(createReqVO.getWorkshopId());
// 鏍¢獙缂栫爜鍞竴
validateMachineryCodeUnique(null, createReqVO.getCode());
+ // 鏍¢獙鏁伴噰璁惧缂栧彿鍞竴
+ validateCollectDeviceCodeUnique(null, createReqVO.getCollectDeviceCode());
// 鎻掑叆
MesDvMachineryDO machinery = BeanUtils.toBean(createReqVO, MesDvMachineryDO.class);
@@ -103,6 +105,8 @@
workshopService.getWorkshop(updateReqVO.getWorkshopId());
// 鏍¢獙缂栫爜鍞竴
validateMachineryCodeUnique(updateReqVO.getId(), updateReqVO.getCode());
+ // 鏍¢獙鏁伴噰璁惧缂栧彿鍞竴
+ validateCollectDeviceCodeUnique(updateReqVO.getId(), updateReqVO.getCollectDeviceCode());
// 鏇存柊
MesDvMachineryDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMachineryDO.class);
@@ -148,6 +152,19 @@
}
if (ObjUtil.notEqual(machinery.getId(), id)) {
throw exception(DV_MACHINERY_CODE_DUPLICATE);
+ }
+ }
+
+ private void validateCollectDeviceCodeUnique(Long id, String collectDeviceCode) {
+ if (StrUtil.isBlank(collectDeviceCode)) {
+ return;
+ }
+ MesDvMachineryDO machinery = machineryMapper.selectByCollectDeviceCode(collectDeviceCode);
+ if (machinery == null) {
+ return;
+ }
+ if (ObjUtil.notEqual(machinery.getId(), id)) {
+ throw exception(DV_MACHINERY_COLLECT_CODE_DUPLICATE);
}
}
@@ -278,6 +295,15 @@
// 3.5 鍒ゆ柇锛氬垱寤� or 鏇存柊
MesDvMachineryDO existMachinery = machineryMapper.selectByCode(importItem.getCode());
+ if (StrUtil.isNotBlank(importItem.getCollectDeviceCode())) {
+ MesDvMachineryDO collectOwner = machineryMapper.selectByCollectDeviceCode(importItem.getCollectDeviceCode());
+ if (collectOwner != null && (existMachinery == null
+ || ObjUtil.notEqual(collectOwner.getId(), existMachinery.getId()))) {
+ respVO.getFailureCodes().put(key, "鏁伴噰璁惧缂栧彿[" + importItem.getCollectDeviceCode() + "]宸茶璁惧["
+ + collectOwner.getCode() + "]鍗犵敤");
+ return;
+ }
+ }
if (existMachinery == null) {
// 3.5.1 鍒涘缓
MesDvMachineryDO machinery = BeanUtils.toBean(importItem, MesDvMachineryDO.class);
--
Gitblit v1.9.3