From a23f3acdf2a09dd056778d2217964a1878b66ea6 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期三, 25 三月 2026 15:42:26 +0800
Subject: [PATCH] 大屏首页,AI事件统计,添加当日库区网关掉线的针对文案表述

---
 fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java |  227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 226 insertions(+), 1 deletions(-)

diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java b/fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java
index 6bb065f..b30a1ee 100644
--- a/fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java
@@ -21,6 +21,7 @@
 import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description
@@ -49,6 +50,14 @@
     private SnapRecordService snapRecordService;
     @Resource
     private SecCameraService cameraService;
+    @Resource
+    private BankService bankService;
+    @Resource
+    private PledgeContractService pledgeContractService;
+    @Resource
+    private PledgeContractDepotService pledgeContractDepotService;
+    @Resource
+    private GatewaySerService gatewaySerService;
 
     /**
      * 鑾峰彇鐪佸強涓嬪睘甯傚窞闆嗗悎
@@ -115,6 +124,116 @@
                 area.setChildren(children);
             }
 
+        }
+        list.add(area);
+        return list;
+    }
+
+
+    public List<DicArea> getBankAndChildDept(String areaCode) {
+
+        DicArea area = dicAreaService.listDicAreaByCode(areaCode);
+        if (null == area) {
+            return null;
+        }
+        List<DicArea> areaChildren = new ArrayList<>();
+
+        List<DicArea> list = new ArrayList<>();
+        if (Constant.AREA_TYPE_1.equals(area.getType())) {
+            //鏌ヨ鎵�鏈夌殑璐ㄦ娂鍚堝悓
+            List<PledgeContract> pledgeContractList = pledgeContractService.listAll(null);
+            //鏌ヨ鎵�鏈夌殑搴撳尯
+            List<Dept> depotList = deptService.listDept(null, ContextUtil.getCompanyId(), null);
+            //鏌ヨ鎵�鏈夌殑閾惰
+            List<Bank> bankList = bankService.listAll(null);
+            DicArea defaultBank = new DicArea();
+            defaultBank.setCode("-1");
+            defaultBank.setName("鏃犺川鎶奸摱琛�");
+            defaultBank.setChildren(new ArrayList<>());
+
+            for (Dept dept : depotList) {
+                Boolean isPledge = false;
+                for (PledgeContract pledgeContract : pledgeContractList) {
+                    IgdsBaseParam param = new IgdsBaseParam();
+                    param.setParentId(pledgeContract.getId());
+                    List<PledgeContractDepot> pledgeContractDepots = pledgeContractDepotService.listAll(param);
+                    if (null == pledgeContractDepots || pledgeContractDepots.isEmpty()) {
+                        continue;
+                    }
+                    //鎵惧埌pledgeContractDepots涓殑deptId闆嗗悎锛屽苟鍘婚噸
+                    List<String> deptIdList = pledgeContractDepots.stream().map(PledgeContractDepot::getPledgeDept).distinct().collect(Collectors.toList());
+                    if (deptIdList.contains(dept.getId())) {
+                        //浠巐ist涓壘鍒板綋鍓嶈川鎶奸摱琛岀殑鏁版嵁
+                        DicArea pledgeBank = null;
+                        int indexBank = -1;
+                        for (DicArea item : areaChildren) {
+                            if (pledgeContract.getPledgeBank().equals(item.getCode())) {
+                                pledgeBank = item;
+                                indexBank = areaChildren.indexOf(pledgeBank);
+                                break;
+                            }
+                        }
+                        if (null == pledgeBank) {
+                            //鏈壘鍒拌川鎶奸摱琛屾暟鎹垯鏂板缓
+                            pledgeBank = new DicArea();
+                            pledgeBank.setCode(pledgeContract.getPledgeBank());
+                            pledgeBank.setName("璐ㄦ娂閾惰_" + pledgeContract.getPledgeBank());
+                            //浠庨摱琛屾暟鎹腑鎵惧埌璐ㄦ娂閾惰鐨勪俊鎭�
+                            for (Bank bank : bankList) {
+                                if (pledgeContract.getPledgeBank().equals(bank.getId())) {
+                                    pledgeBank.setName(bank.getName());
+                                }
+                            }
+                            //娣诲姞璐ㄦ娂閾惰涓嬬殑搴撳尯鏁版嵁
+                            DicArea deptDic = new DicArea();
+                            deptDic.setCode(dept.getId());
+                            deptDic.setName(dept.getKqmc());
+
+                            List<DicArea> children = pledgeBank.getChildren();
+                            if (null == children) {
+                                pledgeBank.setChildren(new ArrayList<>());
+                            }
+                            pledgeBank.getChildren().add(deptDic);
+                            //鏂板璐ㄦ娂閾惰鏁版嵁鍒發ist涓�
+                            areaChildren.add(pledgeBank);
+                            isPledge = true;
+                            break;
+                        } else {
+                            //娣诲姞璐ㄦ娂閾惰涓嬬殑搴撳尯鏁版嵁
+                            DicArea deptDic = new DicArea();
+                            deptDic.setCode(dept.getId());
+                            deptDic.setName(dept.getKqmc());
+
+                            List<DicArea> children = pledgeBank.getChildren();
+                            if (null == children) {
+                                pledgeBank.setChildren(new ArrayList<>());
+                            }
+                            pledgeBank.getChildren().add(deptDic);
+                            //鏇存柊list涓殑璐ㄦ娂閾惰鏁版嵁
+                            areaChildren.set(indexBank, pledgeBank);
+                            isPledge = true;
+                            break;
+                        }
+                    }
+
+                }
+                if (!isPledge) {
+                    DicArea deptDic = new DicArea();
+                    deptDic.setCode(dept.getId());
+                    deptDic.setName(dept.getKqmc());
+
+                    List<DicArea> children = defaultBank.getChildren();
+                    if (null == children) {
+                        defaultBank.setChildren(new ArrayList<>());
+                    }
+                    defaultBank.getChildren().add(deptDic);
+                }
+            }
+            List<DicArea> defaultBankChildren = defaultBank.getChildren();
+            if (defaultBankChildren.size() > 0) {
+                areaChildren.add(defaultBank);
+            }
+            area.setChildren(areaChildren);
         }
         list.add(area);
         return list;
@@ -191,6 +310,44 @@
             }
         }
 
+        return list;
+    }
+
+
+    /**
+     * 鑾峰彇搴撳尯灏佽淇℃伅
+     *
+     * @param companyId
+     * @return
+     */
+    public List<GroupDepotData> getDepotData(String companyId) {
+
+        List<GroupDepotData> list = new ArrayList<>();
+        GroupDepotData depotData;
+        List<Dept> deptList = deptService.getDeptByUserType(null);
+        if (null != deptList && !deptList.isEmpty()) {
+            List<Depot> depotList;
+            for (Dept dept : deptList) {
+                //缁熻浠撳簱鏁�
+                depotList = depotService.getCacheDepotList(dept.getCompanyId(), dept.getId());
+                if (null != depotList && !depotList.isEmpty()) {
+                    for (Depot depot : depotList) {
+                        depotData = new GroupDepotData();
+                        depotData.setDeptId(dept.getId());
+                        depotData.setDeptName(dept.getKqmc());
+                        depotData.setCode(dept.getXzqhdm());
+                        depotData.setCounty(dept.getXzqhmc());
+                        depotData.setDepotId(depot.getId());
+                        depotData.setDepotName(depot.getName());
+                        if (null == depot.getStorageReal()) {
+                            depot.setStorageReal(0.0);
+                        }
+                        depotData.setStorageNum(depot.getStorageReal() / 1000);
+                        list.add(depotData);
+                    }
+                }
+            }
+        }
         return list;
     }
 
@@ -364,7 +521,11 @@
                         }
                     }
                 }
-
+                //鍒ゆ柇缃戝叧鏄惁鍦ㄧ嚎
+                GatewaySer cacheSerByDeptId = gatewaySerService.getCacheSerByDeptId(dept.getId());
+                if (null == cacheSerByDeptId || (null != cacheSerByDeptId && StringUtils.isNotBlank(cacheSerByDeptId.getStatus()) && cacheSerByDeptId.getStatus().equals(Constant.YN_N))) {
+                    deptData.setDailyTotal(-1);
+                }
                 list.add(deptData);
             }
         }
@@ -440,6 +601,70 @@
         return groupGisData;
     }
 
+
+    public GroupGisData getGisDataByCompanyId() {
+
+        GroupGisData groupGisData = new GroupGisData();
+
+        //鏌ヨ浼婄妬涓嬪睘鍖哄幙
+        //鍖哄幙
+        List<DicArea> dicAreaList = dicAreaService.listData("654000", null, null);
+
+        //缁熻鍖哄幙涓嬪簱鍖烘暟
+        LinkedHashMap<String, Integer> valuePieChart = new LinkedHashMap<>();
+        LinkedHashMap<String, String> namePieChart = new LinkedHashMap<>();
+        if (null != dicAreaList && !dicAreaList.isEmpty()) {
+            for (DicArea dicArea : dicAreaList) {
+                valuePieChart.put(dicArea.getCode(), 0);
+                namePieChart.put(dicArea.getCode(), dicArea.getName());
+            }
+        }
+        List<Dept> deptList = deptService.getDeptByUserType(null);
+        if (null != deptList && !deptList.isEmpty()) {
+            //搴撳尯鎬绘暟
+            groupGisData.setDeptNum(deptList.size());
+            for (Dept dept : deptList) {
+                if (StringUtils.isBlank(dept.getXzqhdm()) || null == valuePieChart.get(dept.getXzqhdm())) {
+                    if (null == valuePieChart.get("999999")) {
+                        valuePieChart.put("999999", 0);
+                        namePieChart.put("999999", "鍏朵粬鍖哄幙");
+                    }
+                    dept.setXzqhdm("999999");
+                }
+                valuePieChart.put(dept.getXzqhdm(), valuePieChart.get(dept.getXzqhdm()) + 1);
+            }
+        }
+
+        if (groupGisData.getDeptNum() > 0) {
+            for (String mapKey : valuePieChart.keySet()) {
+                groupGisData.getDeptList().add(new ChartPie(valuePieChart.get(mapKey) + "", namePieChart.get(mapKey), new DecimalFormat("0.0").format((double) valuePieChart.get(mapKey) / groupGisData.getDeptNum() * 100)));
+            }
+        }
+
+        //缁熻閲嶉噺
+        List<Depot> depotList = depotService.getCacheDepotList(ContextUtil.getCompanyId());
+        if (null != depotList && !depotList.isEmpty()) {
+            for (Depot depot : depotList) {
+                if (null == depot.getStorageReal()) {
+                    depot.setStorageReal(0.0);
+                }
+                groupGisData.setSum(groupGisData.getSum() + depot.getStorageReal());
+                if (StringUtils.isNotBlank(depot.getPledgeBank())) {
+                    groupGisData.setBankSum(groupGisData.getBankSum() + depot.getStorageReal());
+                } else {
+                    groupGisData.setNormalSum(groupGisData.getNormalSum() + depot.getStorageReal());
+                }
+            }
+        }
+        if (groupGisData.getSum() > 0) {
+            groupGisData.setSumPer(new DecimalFormat("0.00").format(groupGisData.getSum() / groupGisData.getSum() * 100L));
+            groupGisData.setBankSumPer(new DecimalFormat("0.00").format(groupGisData.getBankSum() / groupGisData.getSum() * 100L));
+            groupGisData.setNormalSumPer(new DecimalFormat("0.00").format(groupGisData.getNormalSum() / groupGisData.getSum() * 100L));
+        }
+
+        return groupGisData;
+    }
+
     /**
      * 澶у睆棣栭〉-鎶撴媿璺熻釜淇℃伅
      *

--
Gitblit v1.9.3