From 36deabe1df249a56a553fb606447dd326a2c81a7 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 06 三月 2025 15:22:54 +0800
Subject: [PATCH] UPDATE

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
index 5e141e1..0f7bbce 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -227,7 +227,7 @@
     }
 
     @Override
-    public List<MdcEquipmentTree> loadTreeListByDepart(String userId) {
+    public List<MdcEquipmentTree> loadTreeListByDepart(String userId, String key) {
         //鑾峰彇鎵�鏈夐儴闂ㄦ暟鎹�
         List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(SysDepart::getDepartOrder));
         //鏍规嵁鐢ㄦ埛ID鑾峰彇鎷ユ湁鐨勯儴闂╥d闆嗗悎
@@ -244,7 +244,7 @@
         //缁勮閮ㄩ棬璁惧鏍�
         List<MdcEquipmentTree> treeList = FindsEquipmentDepartUtil.wrapEquipmentDepartTreeList(list);
         //濉厖璁惧鏁版嵁
-        FillEquipmentByDepart(treeList);
+        FillEquipmentByDepart(treeList, key);
         return treeList;
     }
 
@@ -253,9 +253,9 @@
      *
      * @param treeList
      */
-    private void FillEquipmentByDepart(List<MdcEquipmentTree> treeList) {
+    private void FillEquipmentByDepart(List<MdcEquipmentTree> treeList, String key) {
         for (MdcEquipmentTree mdcEquipmentTree : treeList) {
-            List<MdcEquipment> equipmentList = this.baseMapper.queryByDepartId(mdcEquipmentTree.getKey());
+            List<MdcEquipment> equipmentList = this.baseMapper.queryByDepartId(mdcEquipmentTree.getKey(), key);
             if (equipmentList != null && !equipmentList.isEmpty()) {
                 for (MdcEquipment mdcEquipment : equipmentList) {
                     MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment);
@@ -265,7 +265,7 @@
                 mdcEquipmentTree.setLeaf(false);
             }
             if (!mdcEquipmentTree.getChildren().isEmpty()) {
-                FillEquipmentByDepart(mdcEquipmentTree.getChildren());
+                FillEquipmentByDepart(mdcEquipmentTree.getChildren(), key);
             }
         }
     }
@@ -292,7 +292,7 @@
 
 
     @Override
-    public List<MdcEquipmentTree> loadTreeListByProduction(String userId) {
+    public List<MdcEquipmentTree> loadTreeListByProduction(String userId, String key) {
         //鑾峰彇鎵�鏈変骇绾挎暟鎹�
         List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder));
         //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚�
@@ -309,7 +309,7 @@
         //缁勮浜х嚎璁惧鏍�
         List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list);
         //濉厖璁惧鏁版嵁
-        FillEquipmentByProduction(treeList);
+        FillEquipmentByProduction(treeList, key);
         return treeList;
     }
 
@@ -632,9 +632,9 @@
     /**
      * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹�
      */
-    private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList) {
+    private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList, String key) {
         for (MdcEquipmentTree mdcEquipmentTree : treeList) {
-            List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey());
+            List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey(), key);
             if (equipmentList != null && !equipmentList.isEmpty()) {
                 for (MdcEquipment mdcEquipment : equipmentList) {
                     MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment);
@@ -644,7 +644,7 @@
                 mdcEquipmentTree.setLeaf(false);
             }
             if (!mdcEquipmentTree.getChildren().isEmpty()) {
-                FillEquipmentByProduction(mdcEquipmentTree.getChildren());
+                FillEquipmentByProduction(mdcEquipmentTree.getChildren(), key);
             }
         }
     }
@@ -741,6 +741,9 @@
         if (StringUtils.isNotEmpty(vo.getDeviceCategory())) {
             queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(",")));
         }
+        if (vo.getDeviceImportanceLevel() != null) {
+            queryWrapper.eq(MdcEquipment::getDeviceImportanceLevel, vo.getDeviceImportanceLevel());
+        }
         List<MdcEquipment> list = super.list(queryWrapper);
 //        List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList));
         return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());
@@ -764,8 +767,9 @@
 //        List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getDriveType, "FANUC"));
         List<MdcEquipment> equipmentList = super.list();
         //List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, "2140198"));
-
+        Map<String, String> proNamesByEquipmentIds = this.getProNamesByEquipmentIds(equipmentList.stream().map(MdcEquipment::getId).collect(Collectors.toList()));
         for (MdcEquipment mdcEquipment : equipmentList) {
+            String productionName = proNamesByEquipmentIds.get(mdcEquipment.getId());
             List<MdcEquipmentThreshold> mdcEquipmentThresholdList = mdcEquipmentThresholdService.list(new LambdaQueryWrapper<MdcEquipmentThreshold>().eq(MdcEquipmentThreshold::getControlSystemType, mdcEquipment.getDriveType()));
             if (mdcEquipmentThresholdList != null && !mdcEquipmentThresholdList.isEmpty()) {
                 String saveTableName = mdcEquipment.getSaveTableName();
@@ -788,7 +792,7 @@
                         Integer max = mdcEquipmentThreshold.getMaxThreshold();
                         Integer min = mdcEquipmentThreshold.getMinThreshold();
                         MessageDTO messageDTO = new MessageDTO();
-                        messageDTO.setTitle("璁惧" + mdcEquipmentThreshold.getChineseName() + "鎶ヨ锛�");
+                        messageDTO.setTitle("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "鎶ヨ锛�");
                         messageDTO.setCategory(CommonConstant.MSG_CATEGORY_2);
                         messageDTO.setFromUser("admin");
                         messageDTO.setToUser("admin");
@@ -798,15 +802,15 @@
                         mdcOverrunAlarm.setRealValue(actualValue.toString());
                         if (actualValue > max) {
                             // 楂�
-                            messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒");
+                            messageDTO.setContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒");
                             sysBaseApi.sendSysAnnouncement(messageDTO);
-                            mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "楂樻姤璀�");
+                            mdcOverrunAlarm.setAlarmContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒");
                             mdcOverrunAlarmService.save(mdcOverrunAlarm);
                         } else if (actualValue < min) {
                             // 浣�
-                            messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒");
+                            messageDTO.setContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒");
                             sysBaseApi.sendSysAnnouncement(messageDTO);
-                            mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "浣庢姤璀�");
+                            mdcOverrunAlarm.setAlarmContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒");
                             mdcOverrunAlarmService.save(mdcOverrunAlarm);
                         }
                     }
@@ -855,12 +859,13 @@
         //缁勮浜х嚎璁惧鏍�
         List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list);
         //濉厖璁惧鏁版嵁
-        FillEquipmentByProduction(treeList);
+        FillEquipmentByProduction(treeList, null);
         return treeList;
     }
 
     /**
      * 鏌ヨ鍗曡〃鏁版嵁
+     *
      * @param tableName
      * @return
      */
@@ -891,6 +896,9 @@
         if (StringUtils.isNotEmpty(vo.getDeviceCategory())) {
             queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(",")));
         }
+        if (vo.getDeviceImportanceLevel() != null) {
+            queryWrapper.eq(MdcEquipment::getDeviceImportanceLevel, vo.getDeviceImportanceLevel());
+        }
         List<MdcEquipment> list = super.list(queryWrapper);
 //        List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList));
         return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());

--
Gitblit v1.9.3