From 652bbc43722b3eed164609d10dc6967989b253d5 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期一, 18 四月 2022 17:38:32 +0800
Subject: [PATCH] 节目/文件归属问题

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java |   72 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 5 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 7f9e40e..56aa7f9 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
@@ -34,6 +34,7 @@
 import com.sandu.ximon.admin.redis.LightKey;
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.admin.vo.PoleBindVO;
+import com.sandu.ximon.dao.domain.LedPlayerEntity;
 import com.sandu.ximon.dao.domain.Pole;
 import com.sandu.ximon.dao.domain.PoleBinding;
 import com.sandu.ximon.dao.domain.PoleGroupRelation;
@@ -44,10 +45,7 @@
 import org.springframework.stereotype.Service;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -116,13 +114,56 @@
     }
 
 
+    /**
+     * 缁熻鍦ㄧ嚎鐏潌鏁伴噺
+     *
+     * @return
+     */
+    public Map<String, Integer> poleCount() {
+        Map<String, Integer> result = new HashMap<>();
+        List<Pole> list = new ArrayList<>();
+        LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>();
+        if (SecurityUtils.getClientId() == null) {
+            wrapper = Wrappers.lambdaQuery(Pole.class);
+        } else {
+            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(
+                    w -> {
+                        w.eq(Pole::getUserId, SecurityUtils.getUserId());
+                    });
+        }
+        //鐏潌
+        list = list(wrapper);
+        List<Pole> poles = isOnLine(list);
+        result.put("poleOnlineCount", poles.size());
+        result.put("poleTotalCount", list.size());
+        //璇虹摝
+        // SpringContextHolder.getBean(LightService.class).listLight(SecurityUtils.getUserId(), SecurityUtils.getClientId());
+        List<LedPlayerEntity> ledPlayerEntities = SpringContextHolder.getBean(LedPlayerEntityService.class).ledPlayerEntityList(null, null);
+        int munber = 0;
+        for (LedPlayerEntity bean : ledPlayerEntities) {
+            if (bean.getOnlineStatus() == 1) {
+                munber++;
+            }
+        }
+        result.put("novaOnlineCount", munber);
+        result.put("novaTotalCount", ledPlayerEntities.size());
+
+        SpringContextHolder.getBean(C3ChargingService.class).list();
+
+
+        return result;
+    }
+
     public List<Pole> queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) {
         List<Pole> list = new ArrayList<>();
         LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>();
         if (SecurityUtils.getClientId() == null) {
             wrapper = Wrappers.lambdaQuery(Pole.class);
         } else {
-            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId());
+            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(
+                    w -> {
+                        w.eq(Pole::getUserId, SecurityUtils.getUserId());
+                    });
         }
         if (!param.getKeyword().isEmpty()) {
             wrapper.like(Pole::getPoleCode, param.getKeyword()).or(
@@ -132,6 +173,7 @@
             );
         }
 
+        PageHelper.startPage(pageNo, pageSize);
         list = list(wrapper);
         if (param.getGroupid() != null) {
             //  List<Long> poleIds = new ArrayList<>();
@@ -219,6 +261,26 @@
         return list;
     }
 
+
+    /**
+     * 鍦ㄧ嚎鐏潌
+     *
+     * @param list
+     * @param
+     * @return
+     */
+    public List<Pole> isOnLine(List<Pole> list) {
+        setOnline(list);
+        List<Pole> online = new ArrayList<>();//鍦ㄧ嚎
+        list.forEach(onLinePole -> {
+            if (("ONLINE").equals(onLinePole.getOnLineState())) {
+                online.add(onLinePole);
+            }
+        });
+
+        return online;
+    }
+
     /**
      * 鏌ヨ缁戝畾鐘舵��
      *

--
Gitblit v1.9.3