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 |   76 +++++++++++++++++++++++++++++++++++---
 1 files changed, 70 insertions(+), 6 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 8e72e1e..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;
 
 /**
@@ -91,6 +89,8 @@
         if (pole == null) {
             throw new BusinessException("鏈壘鍒拌鐏潌");
         }
+        // 鍒犻櫎鐏潌缁戝畾鍏崇郴
+        poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId));
         return removeById(poleId);
     }
 
@@ -114,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(
@@ -130,6 +173,7 @@
             );
         }
 
+        PageHelper.startPage(pageNo, pageSize);
         list = list(wrapper);
         if (param.getGroupid() != null) {
             //  List<Long> poleIds = new ArrayList<>();
@@ -215,6 +259,26 @@
             return offline;
         }
         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;
     }
 
     /**
@@ -646,7 +710,7 @@
             } else if (poleBinding.getDeviceType() == 3) {//澶ф皵
                 bindVO.setAirMonitoring(SpringContextHolder.getBean(AirEquipmentService.class).getAirEquipment(poleBinding.getDeviceCode()));
             } else if (poleBinding.getDeviceType() == 4) {//姘磋川
-                 bindVO.setWaterMonitoring(SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(poleBinding.getDeviceCode()));
+                bindVO.setWaterMonitoring(SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(poleBinding.getDeviceCode()));
             } else if (poleBinding.getDeviceType() == 5) {//闊虫煴
                 bindVO.setIpVolume(SpringContextHolder.getBean(IpVolumeService.class).getIpTerminalDetail(Integer.valueOf(poleBinding.getDeviceCode())));
             } else if (poleBinding.getDeviceType() == 6) {//LCD

--
Gitblit v1.9.3