Ver Fonte

医健宝-首页统计,总公司剩余流量

chenguo há 4 dias atrás
pai
commit
b8945b470b

+ 21 - 5
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -1,6 +1,7 @@
 package com.fs.api.controller;
 
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.entity.SysDept;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.company.constant.CompanyTrafficConstants;
 import com.fs.company.domain.Company;
@@ -180,12 +181,27 @@ public class IndexStatisticsController {
         TrafficLogDTO result = new TrafficLogDTO();
         if(!"1".equals(medicalMallConfig.getStatics()) || (param.getCompanyId() == null && param.getDeptId() == null) || (param.getCompanyId() == null && param.getDeptId() == 1)) {
             result = redisCache.getCacheObject(DATA_OVERVIEW_TRAFFIC_LOG);
-            SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
-            if(result == null || sysConfig == null) {
-                return null;
+            if (!"1".equals(medicalMallConfig.getStatics())) {
+                SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
+                if(result == null || sysConfig == null) {
+                    return null;
+                }
+                String configValue = sysConfig.getConfigValue();
+                result.setTraffic(configValue);
+            } else {
+                //所有部门流量之和
+                SysDept dept = new SysDept();
+                dept.setParentId(1L);
+                Long[] deptIds = deptService.selectDeptList(dept).stream().map(SysDept::getDeptId).toArray(Long[]::new);
+                long trafficTemp = 0L;
+                for(Long deptId : deptIds){
+                    Object clildTraffic = redisCache.getCacheObject(CompanyTrafficConstants.CACHE_KEY+":"+deptId);
+                    if(clildTraffic != null){
+                        trafficTemp += Long.parseLong(clildTraffic.toString());
+                    }
+                }
+                result.setTraffic(String.format("%.2f",trafficTemp * 1024.0));
             }
-            String configValue = sysConfig.getConfigValue();
-            result.setTraffic(configValue);
         }else if(param.getCompanyId() != null){
             Company company = companyService.selectCompanyById(param.getCompanyId());
             getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+company.getDeptId()+":"+param.getCompanyId());