From 6a70f946aca610f81245a5e314e9ac2bdf466c91 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期四, 25 十二月 2025 16:27:12 +0800
Subject: [PATCH] 首页大屏数据交互1

---
 fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java |  220 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 216 insertions(+), 4 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 6ab869d..5247da8 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
@@ -1,16 +1,24 @@
 package com.fzzy.group.manager;
 
 import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.constant.FoodVariety;
+import com.fzzy.igds.constant.RespCodeEnum;
+import com.fzzy.igds.data.*;
+import com.fzzy.igds.domain.Depot;
 import com.fzzy.igds.domain.Dept;
 import com.fzzy.igds.domain.DicArea;
-import com.fzzy.igds.service.CoreDeptService;
-import com.fzzy.igds.service.DicAreaService;
+import com.fzzy.igds.domain.InoutRecord;
+import com.fzzy.igds.service.*;
+import com.fzzy.igds.utils.ContextUtil;
+import com.fzzy.igds.utils.DateUtil;
+import com.fzzy.igds.utils.NumberUtil;
+import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
+import java.text.DecimalFormat;
+import java.util.*;
 
 /**
  * @Description
@@ -25,6 +33,12 @@
     private DicAreaService dicAreaService;
     @Resource
     private CoreDeptService deptService;
+    @Resource
+    private DepotService depotService;
+    @Resource
+    private CoreCompanyService coreCompanyService;
+    @Resource
+    private InoutRecordService inoutRecordService;
 
     /**
      * 鑾峰彇鐪佸強涓嬪睘甯傚窞闆嗗悎
@@ -105,4 +119,202 @@
     public List<Dept> getAllDept(String companyId) {
         return deptService.listDept(null, companyId, null);
     }
+
+
+    /**
+     * 澶у睆棣栭〉缁熻淇℃伅锛氫紒涓氭暟銆佸簱鍖烘暟銆佷粨搴撴暟銆佽川鎶间粨鏁般�佹暎绮強鎴愬搧绮暟銆佸垎鍝佺搴撳瓨鏁�
+     *
+     * @param param
+     * @return
+     */
+    public PageResponse<GroupIndexData> getGroupIndexData(IgdsBaseParam param) {
+
+        GroupIndexData indexData = new GroupIndexData();
+
+        //浼佷笟鏁�
+        Integer companyNum = coreCompanyService.getCompanyNum(param.getCompanyId());
+        indexData.setCompanyNum(companyNum);
+
+        //搴撳尯鏁�
+        List<Dept> deptList = deptService.listDept(null, param.getCompanyId(), null);
+        if (null != deptList) {
+            indexData.setDeptNum(deptList.size());
+        }
+
+        ///浠撳簱鏁板強璐ㄦ娂浠撳簱鏁�
+        List<Depot> depotList = depotService.getCacheDepotList(param.getCompanyId());
+        if (null != depotList) {
+            Double foodSum = 0.0;
+            Double packFoodSum = 0.0;
+            indexData.setDepotNum(depotList.size());
+
+            //鐢ㄤ簬缁熻鍒嗗搧绉嶅簱瀛�
+            LinkedHashMap<String, Double> varietyMap = new LinkedHashMap<>();
+            for (Depot depot : depotList) {
+                if(StringUtils.isNotBlank(depot.getPledgeBank())){
+                    indexData.setDepotBankNum(indexData.getDepotBankNum() + 1);
+                }
+                if(null == depot.getStorageReal()){
+                    depot.setStorageReal(0.0);
+                }
+                if(StringUtils.isNotBlank(depot.getStoreType()) && "2".equals(depot.getStoreType())){
+                    packFoodSum += depot.getStorageReal()/1000;
+                }else {
+                    foodSum += depot.getStorageReal()/1000;
+                }
+
+                if(depot.getStorageReal() > 0){
+                    if(StringUtils.isBlank(depot.getFoodVariety())){
+                        //璁剧疆涓哄叾浠栧搧绫�
+                        depot.setFoodVariety("9999000");
+                    }
+
+                    varietyMap.putIfAbsent(depot.getFoodVariety(), 0.000);
+                    varietyMap.put(depot.getFoodVariety(), varietyMap.get(depot.getFoodVariety()) + NumberUtil.keepPrecision(depot.getStorageReal()/1000, 3));
+                }
+            }
+
+            for (String mapKey : varietyMap.keySet()) {
+                if (varietyMap.get(mapKey) <= 0) {
+                    continue;
+                }
+                indexData.getXaxis().add(FoodVariety.getMsg(mapKey));
+                indexData.getSeriesData().add(new DecimalFormat("0.000").format(varietyMap.get(mapKey)));
+            }
+            indexData.setFoodSum(new DecimalFormat("0.000").format(foodSum));
+            indexData.setPackFoodSum(new DecimalFormat("0.000").format(packFoodSum));
+        }
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000, indexData);
+    }
+
+    /**
+     * 澶у睆棣栭〉-搴撳尯淇℃伅缁熻
+     * @param param
+     * @return
+     */
+    public PageResponse<List<GroupDeptData>> indexDeptList(IgdsBaseParam param) {
+
+        List<GroupDeptData> list = new ArrayList<>();
+        GroupDeptData deptData;
+        List<Dept> deptList = deptService.getDeptData();
+        if (null != deptList && !deptList.isEmpty()) {
+            List<Depot> depotList;
+            for (Dept dept : deptList) {
+                deptData = new GroupDeptData();
+                deptData.setDeptName(dept.getKqmc());
+                deptData.setCode(dept.getXzqhdm());
+                deptData.setCounty(dept.getXzqhmc());
+                deptData.setJd(dept.getJd());
+                deptData.setWd(dept.getWd());
+
+                //缁熻浠撳簱鏁�
+                depotList = depotService.getCacheDepotList(dept.getCompanyId(), dept.getId());
+                if (null != depotList && !depotList.isEmpty()) {
+                    for (Depot depot : depotList) {
+                        deptData.setDepotNumber(deptData.getDepotNumber() + 1);
+
+                        if(StringUtils.isNotBlank(depot.getPledgeBank())){
+                            deptData.setDepotBankNumber(deptData.getDepotBankNumber() + 1);
+                        }
+
+                        if(null == depot.getStorageReal()){
+                            depot.setStorageReal(0.0);
+                        }
+                        deptData.setStorageNum(deptData.getStorageNum() + depot.getStorageReal()/1000);
+                    }
+                }
+
+                //缁熻鍑哄叆搴撴暟閲�
+                InoutParam inoutParam = new InoutParam();
+                inoutParam.setDeptId(dept.getId());
+                inoutParam.setCompanyId(param.getCompanyId());
+                inoutParam.setStart(DateUtil.getCurZero(new Date()));
+                inoutParam.setEnd(DateUtil.getNextZero(new Date()));
+                List<InoutRecord> inoutRecords = inoutRecordService.listInout(inoutParam);
+                if (null != inoutRecords && !inoutRecords.isEmpty()) {
+                    for (InoutRecord inoutRecord : inoutRecords) {
+                        if (Constant.TYPE_IN.equals(inoutRecord.getType())) {
+                            deptData.setInNum(deptData.getInNum() + 1);
+                        }
+                        if (Constant.TYPE_OUT.equals(inoutRecord.getType())){
+                            deptData.setOutNum(deptData.getOutNum() + 1);
+
+                        }
+                    }
+                }
+                list.add(deptData);
+            }
+        }
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
+    }
+
+    /**
+     * 缁熻gis鏁版嵁锛屽彧缁熻鐧诲綍浜轰笅灞炵殑鏁版嵁缁熻
+     *
+     * @return
+     */
+    public GroupGisData getGisData() {
+
+        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.getDeptData();
+        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.getData(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null), false);
+        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