From cc0e9036de6e922e8fe254fef01d8de9996024b7 Mon Sep 17 00:00:00 2001
From: hyingbo <1363390067@qq.com>
Date: 星期四, 17 七月 2025 18:16:03 +0800
Subject: [PATCH] 获取报警描述修改

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceInfoServiceImpl.java |  195 +++++++++++++++++++++++-------------------------
 1 files changed, 92 insertions(+), 103 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceInfoServiceImpl.java
index 60a0d52..83c0181 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceInfoServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceInfoServiceImpl.java
@@ -1,6 +1,6 @@
 package org.jeecg.modules.dnc.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
@@ -11,10 +11,17 @@
 
 import org.jeecg.modules.dnc.service.*;
 import org.jeecg.modules.dnc.service.support.DeviceTreeWrapper;
-import org.jeecg.modules.dnc.ucenter.UserDepartExt;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
 import org.jeecg.modules.dnc.entity.*;
+import org.jeecg.modules.mdc.entity.MdcEquipment;
+import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService;
+import org.jeecg.modules.system.entity.MdcProduction;
+import org.jeecg.modules.system.entity.MdcProductionEquipment;
+import org.jeecg.modules.system.entity.MdcUserProduction;
 import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.IMdcProductionService;
+import org.jeecg.modules.system.service.IMdcUserProductionService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.dnc.response.DeviceCode;
 import org.jeecg.modules.dnc.response.DeviceGroupCode;
@@ -54,8 +61,13 @@
     @Lazy
     private IProductInfoService productInfoService;
     @Autowired
-    private INcLogInfoService iNcLogInfoService;
-
+    private IMdcProductionService mdcProductionService;
+    @Autowired
+    private IMdcEquipmentService mdcEquipmentService;
+    @Autowired
+    private IMdcProductionEquipmentService mdcProductionEquipmentService;
+    @Autowired
+    private IMdcUserProductionService mdcUserProductionService;
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public boolean addDeviceInfo(DeviceInfo deviceInfo) {
@@ -84,15 +96,6 @@
         if(group == null) {
             ExceptionCast.cast(DeviceCode.DEVICE_GROUP_NONE);
         }
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("璁惧鍚嶇О锛�"+deviceInfo.getDeviceName()+"锛岃澶囩紪鍙凤細"+deviceInfo.getDeviceNo());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.save(deviceInfo);
         if(!b) {
             ExceptionCast.cast(DeviceCode.DEVICE_SAVE_ERROR);
@@ -135,17 +138,6 @@
             ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST);
         deviceInfo.setDeviceId(id);
         deviceInfo.setGroupId(null);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(3);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("璁惧鍚嶇О锛�"+deviceInfo.getDeviceName());
-        //淇敼淇濆瓨澶囨敞
-        ncLogInfo.setRemark(JSONObject.toJSONString(en));
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         return super.updateById(deviceInfo);
     }
 
@@ -169,15 +161,6 @@
         b = devicePermissionStreamService.deleteDepartByDeviceId(en.getGroupId(), en.getDeviceId());
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(4);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("璁惧鍚嶇О锛�"+en.getDeviceName());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         return super.removeById(en.getDeviceId());
     }
 
@@ -208,19 +191,19 @@
         if(!ValidateUtil.validateString(userId))
             ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
         if(nodeType == 1) {
-            DeviceGroup en = deviceGroupService.getById(paramId);
-            if(en == null) {
+            MdcProduction mdcProduction=mdcProductionService.getById(paramId);
+            if(mdcProduction == null) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
             }
-            DeviceGroupPermission permission = deviceGroupPermissionService.getByUserIdAndGroupId(userId, en.getGroupId());
-            if(permission == null)
+            MdcUserProduction mdcUserProduction=mdcUserProductionService.getByUserIdAndGroupId(userId,mdcProduction.getId());
+            if(mdcUserProduction == null)
                 return false;
             return true;
         }else if(nodeType == 2) {
-            DeviceInfo deviceInfo = super.getById(paramId);
-            if(deviceInfo == null)
+            MdcEquipment mdcEquipment = mdcEquipmentService.getById(paramId);
+            if(mdcEquipment == null)
                 ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST);
-            DevicePermission permission = devicePermissionService.getByUserIdAndDeviceId(userId, deviceInfo.getDeviceId());
+            DevicePermission permission = devicePermissionService.getByUserIdAndDeviceId(userId, mdcEquipment.getId());
             if(permission == null)
                 return false;
             return true;
@@ -230,13 +213,13 @@
     }
 
     @Override
-    public List<UserDepartExt> getUserPermsList(Integer nodeType, String paramId) {
+    public List<SysUser> getUserPermsList(Integer nodeType, String paramId) {
         if(!ValidateUtil.validateInteger(nodeType) || !ValidateUtil.validateString(paramId))
             return null;
         if(nodeType == 1) {
-            return deviceGroupPermissionService.getUserPermsByGroupId(paramId);
+            return mdcUserProductionService.getUserPermsByGroupId(paramId);
         }else if(nodeType == 2) {
-            return devicePermissionService.getUserPermsByDeviceId(paramId);
+            return mdcUserProductionService.getUserPermsByDeviceId(paramId);
         }else {
             return null;
         }
@@ -247,9 +230,9 @@
         if(!ValidateUtil.validateInteger(nodeType) || !ValidateUtil.validateString(paramId))
             return null;
         if(nodeType == 1) {
-            return deviceGroupPermissionService.getUserNonPermsByGroupId(paramId);
+            return mdcUserProductionService.getUserNonPermsByGroupId(paramId);
         }else if(nodeType == 2) {
-            return devicePermissionService.getUserNonPermsByDeviceId(paramId);
+            return mdcUserProductionService.getUserNonPermsByDeviceId(paramId);
         }else {
             return null;
         }
@@ -270,43 +253,43 @@
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         if(relativeFlag == 1 && nodeType == 1) {
             //鍒嗛厤鍒嗙粍鏉冮檺鎵嶅彲鍚戜笅浼犻�掔敤鎴�
-            DeviceGroup deviceGroup = deviceGroupService.getById(paramId);
-            if(deviceGroup == null) {
+            MdcProduction mdcProduction= mdcProductionService.getById(paramId);
+            if(mdcProduction == null) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
             }
-            boolean b1 = checkDevicePerm(1, deviceGroup.getGroupId());
+            boolean b1 = checkDevicePerm(1, mdcProduction.getId());
             if(!b1) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
             }
-            b1 = deviceGroupService.assignAddUser(deviceGroup, userList);
+            b1 = deviceGroupPermissionService.assignAddUser(mdcProduction, userList);
             if(!b1) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
             }
             //鑾峰彇鍒嗙粍涓嬫墍鏈夌殑瀛愬垎缁�
-            List<DeviceGroup> childrenList = deviceGroupService.getChildrenByParentId(deviceGroup.getGroupId());
+            List<MdcProduction> childrenList = mdcProductionService.recursionChildrenByPid(mdcProduction.getId());
             List<String> childrenIds = new ArrayList<>();
             if(childrenList != null && !childrenList.isEmpty()) {
                 childrenList.forEach(item -> {
-                    childrenIds.add(item.getGroupId());
-                    boolean b = checkDevicePerm(1, item.getGroupId());
+                    childrenIds.add(item.getId());
+                    boolean b = checkDevicePerm(1, item.getId());
                     if(b) {
-                        b = deviceGroupService.assignAddUser(item, userList);
+                        b = deviceGroupPermissionService.assignAddUser(item, userList);
                         if(!b) {
                             ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                         }
                     }
                 });
             }
-            List<DeviceInfo> deviceInfoList = null;
+            List<MdcEquipment> mdcEquipmentList = null;
             if(childrenIds.isEmpty()) {
-                deviceInfoList = getByGroupId(deviceGroup.getGroupId());
+                mdcEquipmentList =mdcProductionEquipmentService.queryEquipmentsOfProduction(mdcProduction.getId());
             }else {
-                childrenIds.add(deviceGroup.getGroupId());
-                deviceInfoList = getByGroupIdList(childrenIds);
+                childrenIds.add(mdcProduction.getId());
+                mdcEquipmentList = mdcProductionEquipmentService.queryEquipmentsOfProductions(childrenIds);
             }
-            if(deviceInfoList != null && !deviceInfoList.isEmpty()) {
-                deviceInfoList.forEach(item -> {
-                    boolean b = checkDevicePerm(2, item.getDeviceId());
+            if(mdcEquipmentList != null && !mdcEquipmentList.isEmpty()) {
+                mdcEquipmentList.forEach(item -> {
+                    boolean b = checkDevicePerm(2, item.getId());
                     if(b) {
                         b = assignAddUser(item, userList);
                         if(!b)
@@ -318,29 +301,29 @@
         }else if(relativeFlag == 2) {
             if(nodeType == 1) {
                 //鍒嗘壒鍒嗙粍鏉冮檺
-                DeviceGroup deviceGroup = deviceGroupService.getById(paramId);
-                if(deviceGroup == null) {
+                MdcProduction mdcProduction = mdcProductionService.getById(paramId);
+                if(mdcProduction == null) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
                 }
-                boolean b = checkDevicePerm(1, deviceGroup.getGroupId());
+                boolean b = checkDevicePerm(1, mdcProduction.getId());
                 if(!b) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                 }
-                b = deviceGroupService.assignAddUser(deviceGroup, userList);
+                b = deviceGroupPermissionService.assignAddUser(mdcProduction, userList);
                 if(!b) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                 }
                 return true;
             }else if(nodeType == 2) {
                 //鍒嗛厤璁惧鏉冮檺
-                DeviceInfo deviceInfo = super.getById(paramId);
-                if(deviceInfo == null)
+                MdcEquipment mdcEquipment=mdcEquipmentService.getById(paramId);
+                if(mdcEquipment == null)
                     ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST);
-                boolean b = checkDevicePerm(2, deviceInfo.getDeviceId());
+                boolean b = checkDevicePerm(2, mdcEquipment.getId());
                 if(!b) {
                     ExceptionCast.cast(DeviceCode.DEVICE_USER_PERM_ERROR);
                 }
-                b = assignAddUser(deviceInfo, userList);
+                b = assignAddUser(mdcEquipment, userList);
                 if(!b) {
                     ExceptionCast.cast(DeviceCode.DEVICE_USER_PERM_ERROR);
                 }
@@ -352,25 +335,29 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignAddUser(DeviceInfo deviceInfo, Collection<SysUser> userList) {
-        if(deviceInfo == null || userList == null || userList.isEmpty())
+    public boolean assignAddUser(MdcEquipment mdcEquipment, Collection<SysUser> userList) {
+
+
+        if(mdcEquipment == null || userList == null || userList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        MdcProductionEquipment mdcProductionEquipment=mdcProductionEquipmentService
+                .list(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",mdcEquipment.getId())).get(0);
         List<DevicePermission> permissionList = new ArrayList<>();
         List<DevicePermissionStream> permissionStreamList = new ArrayList<>();
         userList.forEach(item -> {
-            DevicePermission en = devicePermissionService.getByUserIdAndDeviceId(item.getId(), deviceInfo.getDeviceId());
+            DevicePermission en = devicePermissionService.getByUserIdAndDeviceId(item.getId(), mdcEquipment.getId());
             if(en == null) {
                 en = new DevicePermission();
                 en.setUserId(item.getId());
-                en.setDeviceId(deviceInfo.getDeviceId());
+                en.setDeviceId(mdcEquipment.getId());
                 permissionList.add(en);
             }
-            DevicePermissionStream stream = devicePermissionStreamService.getByDeviceIdAndUserId(deviceInfo.getGroupId(), deviceInfo.getDeviceId(), item.getId());
+            DevicePermissionStream stream = devicePermissionStreamService.getByDeviceIdAndUserId(mdcProductionEquipment.getId(), mdcEquipment.getId(), item.getId());
             if(stream == null) {
                 stream = new DevicePermissionStream();
                 stream.setUserId(item.getId());
-                stream.setGroupId(deviceInfo.getGroupId());
-                stream.setDeviceId(deviceInfo.getDeviceId());
+                stream.setGroupId(mdcProductionEquipment.getProductionId());
+                stream.setDeviceId(mdcEquipment.getId());
                 permissionStreamList.add(stream);
             }
         });
@@ -391,23 +378,25 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignRemoveUser(DeviceInfo deviceInfo, Collection<SysUser> userList) {
-        if(deviceInfo == null || userList == null || userList.isEmpty())
+    public boolean assignRemoveUser(MdcEquipment mdcEquipment, Collection<SysUser> userList) {
+        if(mdcEquipment == null || userList == null || userList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        MdcProductionEquipment mdcProductionEquipment=mdcProductionEquipmentService
+                .list(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",mdcEquipment.getId())).get(0);
         List<DevicePermission> permissionList = new ArrayList<>();
         List<DevicePermissionStream> permissionStreamList = new ArrayList<>();
         userList.forEach(item -> {
-            DevicePermission en = devicePermissionService.getByUserIdAndDeviceId(item.getId(), deviceInfo.getDeviceId());
+            DevicePermission en = devicePermissionService.getByUserIdAndDeviceId(item.getId(), mdcEquipment.getId());
             if(en != null) {
                 permissionList.add(en);
             }
-            DevicePermissionStream stream = devicePermissionStreamService.getByDeviceIdAndUserId(deviceInfo.getGroupId(), deviceInfo.getDeviceId(), item.getId());
+            DevicePermissionStream stream = devicePermissionStreamService.getByDeviceIdAndUserId(mdcProductionEquipment.getId(), mdcEquipment.getId(), item.getId());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
         });
         //鏍¢獙娓呯┖鐢ㄦ埛鏉冮檺
-        List<DevicePermission> existList = devicePermissionService.getByDeviceId(deviceInfo.getDeviceId());
+        List<DevicePermission> existList = devicePermissionService.getByDeviceId(mdcEquipment.getId());
         if(existList.size() <= permissionList.size())
             ExceptionCast.cast(DeviceCode.DEVICE_USER_NONE);
         if(!permissionList.isEmpty()) {
@@ -456,43 +445,43 @@
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         if(relativeFlag == 1 && nodeType == 1) {
             //鍒嗛厤鍒嗙粍鏉冮檺鎵嶅彲鍚戜笅浼犻�掔敤鎴�
-            DeviceGroup deviceGroup = deviceGroupService.getById(paramId);
-            if(deviceGroup == null) {
+            MdcProduction mdcProduction=mdcProductionService.getById(paramId);
+            if(mdcProduction == null) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
             }
-            boolean b1 = checkDevicePerm(1, deviceGroup.getGroupId());
+            boolean b1 = checkDevicePerm(1, mdcProduction.getId());
             if(!b1) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
             }
-            b1 = deviceGroupService.assignRemoveUser(deviceGroup, userList);
+            b1 = deviceGroupPermissionService.assignRemoveUser(mdcProduction, userList);
             if(!b1) {
                 ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
             }
             //鑾峰彇鍒嗙粍涓嬫墍鏈夌殑瀛愬垎缁�
-            List<DeviceGroup> childrenList = deviceGroupService.getChildrenByParentId(deviceGroup.getGroupId());
+            List<MdcProduction> childrenList = mdcProductionService.recursionChildrenByPid(mdcProduction.getId());
             List<String> childrenIds = new ArrayList<>();
             if(childrenList != null && !childrenList.isEmpty()) {
                 childrenList.forEach(item -> {
-                    childrenIds.add(item.getGroupId());
-                    boolean b = checkDevicePerm(1, item.getGroupId());
+                    childrenIds.add(item.getId());
+                    boolean b = checkDevicePerm(1, item.getId());
                     if(b) {
-                        b = deviceGroupService.assignRemoveUser(item, userList);
+                        b = deviceGroupPermissionService.assignRemoveUser(item, userList);
                         if(!b) {
                             ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                         }
                     }
                 });
             }
-            List<DeviceInfo> deviceInfoList = null;
+            List<MdcEquipment> mdcEquipmentList = null;
             if(childrenIds.isEmpty()) {
-                deviceInfoList = getByGroupId(deviceGroup.getGroupId());
+                mdcEquipmentList =mdcProductionEquipmentService.queryEquipmentsOfProduction(mdcProduction.getId());
             }else {
-                childrenIds.add(deviceGroup.getGroupId());
-                deviceInfoList = getByGroupIdList(childrenIds);
+                childrenIds.add(mdcProduction.getId());
+                mdcEquipmentList = mdcProductionEquipmentService.queryEquipmentsOfProductions(childrenIds);
             }
-            if(deviceInfoList != null && !deviceInfoList.isEmpty()) {
-                deviceInfoList.forEach(item -> {
-                    boolean b = checkDevicePerm(2, item.getDeviceId());
+            if(mdcEquipmentList != null && !mdcEquipmentList.isEmpty()) {
+                mdcEquipmentList.forEach(item -> {
+                    boolean b = checkDevicePerm(2, item.getId());
                     if(b) {
                         b = assignRemoveUser(item, userList);
                         if(!b)
@@ -504,29 +493,29 @@
         }else if(relativeFlag == 2) {
             if(nodeType == 1) {
                 //鍒嗘壒鍒嗙粍鏉冮檺
-                DeviceGroup deviceGroup = deviceGroupService.getById(paramId);
-                if(deviceGroup == null) {
+                MdcProduction mdcProduction = mdcProductionService.getById(paramId);
+                if(mdcProduction == null) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
                 }
-                boolean b = checkDevicePerm(1, deviceGroup.getGroupId());
+                boolean b = checkDevicePerm(1, mdcProduction.getId());
                 if(!b) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                 }
-                b = deviceGroupService.assignRemoveUser(deviceGroup, userList);
+                b = deviceGroupPermissionService.assignRemoveUser(mdcProduction, userList);
                 if(!b) {
                     ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
                 }
                 return true;
             }else if(nodeType == 2) {
                 //鍒嗛厤璁惧鏉冮檺
-                DeviceInfo deviceInfo = super.getById(paramId);
-                if(deviceInfo == null)
+                MdcEquipment mdcEquipment=mdcEquipmentService.getById(paramId);
+                if(mdcEquipment == null)
                     ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST);
-                boolean b = checkDevicePerm(2, deviceInfo.getDeviceId());
+                boolean b = checkDevicePerm(2, mdcEquipment.getId());
                 if(!b) {
                     ExceptionCast.cast(DeviceCode.DEVICE_USER_PERM_ERROR);
                 }
-                b = assignRemoveUser(deviceInfo, userList);
+                b = assignRemoveUser(mdcEquipment, userList);
                 if(!b) {
                     ExceptionCast.cast(DeviceCode.DEVICE_USER_PERM_ERROR);
                 }

--
Gitblit v1.9.3