From e76f0739e647fe8a7e0e2618914e2faff554b1b7 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期一, 17 十一月 2025 17:33:23 +0800
Subject: [PATCH] 解决冲突
---
mes-processes/mes-plcSend/src/main/java/com/mes/device/mapper/DeviceGroupRelationMapper.java | 80 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
diff --git a/mes-processes/mes-plcSend/src/main/java/com/mes/device/mapper/DeviceGroupRelationMapper.java b/mes-processes/mes-plcSend/src/main/java/com/mes/device/mapper/DeviceGroupRelationMapper.java
new file mode 100644
index 0000000..6ae3625
--- /dev/null
+++ b/mes-processes/mes-plcSend/src/main/java/com/mes/device/mapper/DeviceGroupRelationMapper.java
@@ -0,0 +1,80 @@
+package com.mes.device.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.mes.device.entity.DeviceGroupRelation;
+import com.mes.device.vo.DeviceGroupVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 璁惧缁勫叧绯籑apper鎺ュ彛
+ *
+ * @author mes
+ * @since 2024-10-30
+ */
+@Mapper
+public interface DeviceGroupRelationMapper extends BaseMapper<DeviceGroupRelation> {
+
+ /**
+ * 鎵归噺娣诲姞璁惧鍒拌澶囩粍
+ *
+ * @param groupId 璁惧缁処D
+ * @param deviceIds 璁惧ID鍒楄〃
+ * @param deviceRole 璁惧瑙掕壊
+ */
+ void batchAddDevicesToGroup(@Param("groupId") Long groupId,
+ @Param("deviceIds") List<Long> deviceIds,
+ @Param("deviceRole") String deviceRole);
+
+ /**
+ * 鎵归噺浠庤澶囩粍绉婚櫎璁惧
+ *
+ * @param groupId 璁惧缁処D
+ * @param deviceIds 璁惧ID鍒楄〃
+ */
+ void batchRemoveDevicesFromGroup(@Param("groupId") Long groupId,
+ @Param("deviceIds") List<Long> deviceIds);
+
+ /**
+ * 鏇存柊璁惧鍦ㄨ澶囩粍涓殑瑙掕壊
+ *
+ * @param groupId 璁惧缁処D
+ * @param deviceId 璁惧ID
+ * @param deviceRole 璁惧瑙掕壊
+ */
+ void updateDeviceRole(@Param("groupId") Long groupId,
+ @Param("deviceId") Long deviceId,
+ @Param("deviceRole") String deviceRole);
+
+ /**
+ * 鑾峰彇璁惧缁勪笅鐨勮澶囧垪琛紙鑱旇〃鏌ヨ锛�
+ *
+ * @param groupId 璁惧缁処D
+ * @return 璁惧淇℃伅鍒楄〃
+ */
+ @Select("SELECT d.id, d.device_name as deviceName, d.device_code as deviceCode, " +
+ "d.device_type as deviceType, dgr.role, d.status, " +
+ "d.last_heartbeat as lastHeartbeat, d.is_online as isOnline " +
+ "FROM device_config d " +
+ "INNER JOIN device_group_relation dgr ON d.id = dgr.device_id " +
+ "WHERE dgr.group_id = #{groupId} AND dgr.is_deleted = 0 AND d.is_deleted = 0")
+ List<DeviceGroupVO.DeviceInfo> getGroupDevices(@Param("groupId") Long groupId);
+
+ /**
+ * 鑾峰彇璁惧鎵�灞炵殑璁惧缁勫垪琛紙鑱旇〃鏌ヨ锛�
+ *
+ * @param deviceId 璁惧ID
+ * @return 璁惧缁勪俊鎭垪琛�
+ */
+ @Select("SELECT dgc.id, dgc.group_code as groupCode, dgc.group_name as groupName, " +
+ "dgc.group_type as groupType, dgc.status, dgr.created_time as createTime, "+
+ "dgc.project_id as projectId, " +
+ "(SELECT COUNT(*) FROM device_group_relation WHERE group_id = dgc.id AND is_deleted = 0) as deviceCount " +
+ "FROM device_group_config dgc " +
+ "INNER JOIN device_group_relation dgr ON dgc.id = dgr.group_id " +
+ "WHERE dgr.device_id = #{deviceId} AND dgr.is_deleted = 0 AND dgc.is_deleted = 0")
+ List<DeviceGroupVO.GroupInfo> getDeviceGroups(@Param("deviceId") Long deviceId);
+}
\ No newline at end of file
--
Gitblit v1.8.0