From ae39f3877901b92e04c1ef9ee1d7e99123a66672 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 04 三月 2022 18:14:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |  209 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 159 insertions(+), 50 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
index df13ffc..7518889 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -148,68 +148,100 @@
             list = pole;
         }
 
-        list.forEach(bindwarpper -> {
-//                Long clientId = bindwarpper.getClientId();
-            if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
-                unbindList.add(bindwarpper);
-                if (bindwarpper.getDeviceCode() == null) {//鍒ゆ柇鐏潌绫诲瀷
-                    isFalse.add(bindwarpper);
-                } else {
-                    isTrue.add(bindwarpper);
+//        List<Pole> bind = isBind(list, param);
+//        List<Pole> aTrue = isTrue(list, param);
+//        List<Pole> onLine = isOnLine(list, param);
+
+        if (param.getBingStates() != 2) {//鏄惁缁戝畾
+            list = isBind(list, param);//   缁戝畾/鏈粦瀹�
+            if (param.getIsTrue() != 2) {//宸茬粦瀹氱殑鏄惁鏄湡瀹炵伅鏉�
+                list = isTrue(list, param);
+                if (param.getOnLineStates() != 2) {//缁戝畾鐨勭湡瀹炵伅鏉嗘槸鍚﹀湪绾�
+                    list = isOnLine(list, param);
                 }
-            } else {
-                bindList.add(bindwarpper);
-                if (bindwarpper.getDeviceCode() == null) {
-                    isFalse.add(bindwarpper);
-                } else {
-                    isTrue.add(bindwarpper);
+            }else {//鍏ㄩ儴鐏潌  瀹炰綋/铏氭嫙
+                if (param.getOnLineStates() != 2) {  //鏌ヨ鍏ㄩ儴鐏潌鏄惁鍦ㄧ嚎
+                    list = isOnLine(list, param);
                 }
             }
-        });
-        if (param.getBingStates() == 1) { //鏈粦瀹�
-            list = unbindList;
-        } else if (param.getBingStates() == 0) {//宸茬粦瀹�
-            list = bindList;
-        }// else {//鍏ㄩ儴
-//            list = list(wrapper);
-//        }
-
-        setOnline(list);
-        if (param.getIsTrue() == 1) { //铏氭嫙鐏潌
-            list = isFalse;
-        } else if (param.getIsTrue() == 0) {//瀹炰綋鐏潌
-            list = isTrue;
-            list.forEach(onLinePole -> {
-//                System.out.println("online-----------------------"+onLinePole.getOnLineState());
-                if (("ONLINAE").equals(onLinePole.getOnLineState())) {
-                    online.add(onLinePole);
-                } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
-                    offline.add(onLinePole);
+        }else {//鍏ㄩ儴 缁戝畾/鏈粦瀹�
+            if (param.getIsTrue() != 2) {// 鍒ゆ柇鐏潌绫诲瀷
+                list = isTrue(list, param);// 瀹炰綋/铏氭嫙
+                if (param.getOnLineStates() != 2) {// 鐏潌鐨勫湪绾垮垽鏂�
+                    list = isOnLine(list, param);//鍦ㄧ嚎/绂荤嚎
                 }
-            });
-        } else {//鍏ㄩ儴
-           // setOnline(list);
-           list.forEach(onLinePole -> {
-//               System.out.println("online-----------------------"+onLinePole.getOnLineState());
-               if (("ONLINE").equals(onLinePole.getOnLineState())) {
-                    online.add(onLinePole);
-                } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
-                    offline.add(onLinePole);
+            }else {//鍏ㄧ被鍨嬬伅鏉�
+                if (param.getOnLineStates() != 2) {//鍒ゆ柇鍦ㄧ嚎鐘舵��
+                    list = isOnLine(list, param);//鍦ㄧ嚎/绂荤嚎
                 }
-            });
-       }
-
-        if (param.getOnLineStates() == 1) { //绂荤嚎
-            list = offline;
-        } else if (param.getOnLineStates() == 0) {//鍦ㄧ嚎
-            list = online;
+            }
         }
+
+
+//        list.forEach(bindwarpper -> {
+////                Long clientId = bindwarpper.getClientId();
+//            if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
+//                unbindList.add(bindwarpper);
+//                if (bindwarpper.getDeviceCode() == null) {//鍒ゆ柇鐏潌绫诲瀷
+//                    isFalse.add(bindwarpper);
+//                } else {
+//                    isTrue.add(bindwarpper);
+//                }
+//            } else {
+//                bindList.add(bindwarpper);
+//                if (bindwarpper.getDeviceCode() == null) {
+//                    isFalse.add(bindwarpper);
+//                } else {
+//                    isTrue.add(bindwarpper);
+//                }
+//            }
+//        });
+//        if (param.getBingStates() == 1) { //鏈粦瀹�
+//            list = unbindList;
+//        } else if (param.getBingStates() == 0) {//宸茬粦瀹�
+//            list = bindList;
+//        }// else {//鍏ㄩ儴
+////            list = list(wrapper);
+////        }
+//
+//        if (param.getIsTrue() == 1) { //铏氭嫙鐏潌
+//            list = isFalse;
+//        } else if (param.getIsTrue() == 0) {//瀹炰綋鐏潌
+//            setOnline(list);
+//            list = isTrue;
+//            list.forEach(onLinePole -> {
+//                System.out.println("online---------------------------------------------------"+("ONLINE").equals(onLinePole.getOnLineState()));
+//                System.out.println("online---------------------------------------------------"+(onLinePole.getOnLineState()));
+//                if (("ONLINE").equals(onLinePole.getOnLineState())) {
+//                    online.add(onLinePole);
+//                } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
+//                    offline.add(onLinePole);
+//                }
+//            });
+//        } else {//鍏ㄩ儴
+//            setOnline(list);
+//           list.forEach(onLinePole -> {
+//           //    System.out.println("online-----------------------"+onLinePole.getOnLineState());
+//               if (("ONLINE").equals(onLinePole.getOnLineState())) {
+//                    online.add(onLinePole);
+//                } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
+//                    offline.add(onLinePole);
+//                }
+//            });
+//       }
+//
+//        if (param.getOnLineStates() == 1) { //绂荤嚎
+//            list = offline;
+//        } else if (param.getOnLineStates() == 0) {//鍦ㄧ嚎
+//            list = online;
+//        }
         setCount(list);
         return list;
     }
 
     /**
      * 璁剧疆缁戝畾璁惧鏁伴噺
+     *
      * @param list
      * @return
      */
@@ -222,8 +254,85 @@
         return list;
     }
 
+
+    /**
+     * 鍦ㄧ嚎鐘舵�佸鐞�
+     *
+     * @param list
+     * @param param
+     * @return
+     */
+    public List<Pole> isOnLine(List<Pole> list, PoleStatesParam param) {
+        setOnline(list);
+        List<Pole> online = new ArrayList<>();//鍦ㄧ嚎
+        List<Pole> offline = new ArrayList<>();//绂荤嚎
+        list.forEach(onLinePole -> {
+            System.out.println("online---------------------------------------------------" + ("ONLINE").equals(onLinePole.getOnLineState()));
+            System.out.println("online---------------------------------------------------" + (onLinePole.getOnLineState()));
+            if (("ONLINE").equals(onLinePole.getOnLineState())) {
+                online.add(onLinePole);
+            } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
+                offline.add(onLinePole);
+            }
+        });
+
+        if (param.getOnLineStates() == 0) {
+            return online;
+        } else if (param.getOnLineStates() == 1) {
+            return offline;
+        }
+        return list;
+    }
+
+    /**
+     * 鏌ヨ缁戝畾鐘舵��
+     *
+     * @param list
+     * @param param
+     * @return
+     */
+    public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
+        List<Pole> bindList = new ArrayList<>();//宸茬粦瀹氬鎴�
+        List<Pole> unbindList = new ArrayList<>();//鏈粦瀹氬鎴�
+        list.forEach(bindwarpper -> {
+//                Long clientId = bindwarpper.getClientId();
+            if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
+                unbindList.add(bindwarpper);
+            } else {
+                bindList.add(bindwarpper);
+            }
+        });
+        if (param.getBingStates() == 0) {
+            return bindList;
+        } else if (param.getBingStates() == 1) {
+            return unbindList;
+        }
+        return list;
+    }
+
+    public List<Pole> isTrue(List<Pole> list, PoleStatesParam param) {
+        List<Pole> isTrue = new ArrayList<>();//瀹炰綋鐏潌
+        List<Pole> isFalse = new ArrayList<>();//铏氭嫙鐏潌
+        list.forEach(bindwarpper -> {
+//                Long clientId = bindwarpper.getClientId();
+            if (bindwarpper.getDeviceCode() == null) {
+                isFalse.add(bindwarpper);
+            } else {
+                isTrue.add(bindwarpper);
+            }
+        });
+        if (param.getIsTrue() == 0) {
+            return isTrue;
+        } else if (param.getIsTrue() == 1) {
+            return isFalse;
+        }
+        return list;
+    }
+
+
     /**
      * 璁剧疆鍦ㄧ嚎鐘舵��
+     *
      * @param list
      * @return
      */

--
Gitblit v1.9.3