chenguo 5 дней назад
Родитель
Сommit
8d7042751f

+ 18 - 12
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -15,6 +15,7 @@ import com.fs.statis.param.StatisticsDeptCompanyParam;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysDeptService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
@@ -33,6 +34,7 @@ import static com.fs.statis.StatisticsRedisConstant.*;
  */
 @RestController
 @RequestMapping("/index/statistics")
+@Slf4j
 public class IndexStatisticsController {
     @Autowired
     private RedisCache redisCache;
@@ -184,11 +186,10 @@ public class IndexStatisticsController {
             }
             String configValue = sysConfig.getConfigValue();
             result.setTraffic(configValue);
-        }
-        if(param.getCompanyId() != null){
+        }else if(param.getCompanyId() != null){
             Company company = companyService.selectCompanyById(param.getCompanyId());
             getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+company.getDeptId()+":"+param.getCompanyId());
-        }else if(param.getDeptId() != null) {
+        }else{
             getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+param.getDeptId());
         }
         return R.ok().put("data",result);
@@ -201,15 +202,19 @@ public class IndexStatisticsController {
         Object todayCount = redisCache.getCacheObject(key+":"+LocalDate.now());
         Object thisMonthCount = redisCache.getCacheObject(key+":"+YearMonth.now());
         Object traffic = redisCache.getCacheObject(key);
-        result.setYesterday((yesterdayCount == null)?0L:((Integer)yesterdayCount).longValue());
+        result.setYesterday(parseRedisNumberValueToLong(yesterdayCount));
         //今天
-        result.setToday(todayCount == null?0L:((Integer)todayCount).longValue());
+        result.setToday(parseRedisNumberValueToLong(todayCount));
         //本月
-        result.setThisMonth(thisMonthCount == null?0L:((Integer)thisMonthCount).longValue());
+        result.setThisMonth(parseRedisNumberValueToLong(thisMonthCount));
         //剩余
         result.setTraffic(traffic == null?"0":traffic.toString());
     }
 
+    private Long parseRedisNumberValueToLong(Object value){
+        return value == null ? 0 : Long.parseLong(value.toString());
+    }
+
     /**
      * 观看趋势
      */
@@ -670,6 +675,7 @@ public class IndexStatisticsController {
      */
     @GetMapping("/authorizationInfo")
     public R authorizationInfo(StatisticsDeptCompanyParam  param){
+        AuthorizationInfoDTO authorizationInfoDTO = new AuthorizationInfoDTO();
         if (!"1".equals(medicalMallConfig.getStatics()) || (param.getCompanyId() == null && param.getDeptId() == null) || (param.getCompanyId() == null && param.getDeptId() == 1)){
             return R.ok().put("data", redisCache.getCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO));
         }else if(param.getCompanyId() != null){
@@ -677,24 +683,24 @@ public class IndexStatisticsController {
         }else{
             Company company = new Company();
             company.setDeptId(param.getDeptId());
-            AuthorizationInfoDTO authorizationInfoDTO = new AuthorizationInfoDTO();
+            AuthorizationInfoDTO authorizationInfoDTO1 = new AuthorizationInfoDTO();
             Long[] companyIds = companyService.selectCompanyList(company).stream().map(Company::getCompanyId).toArray(Long[]::new);
             for(Long companyId : companyIds) {
                 AuthorizationInfoDTO companyDTO = redisCache.getCacheObject(String.format("%s:%d", DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO, companyId));
+                log.info("授权信息:{}", authorizationInfoDTO);
                 if (companyDTO != null) {
-                    authorizationInfoDTO.setTodayWatchUserCount(
-                            (authorizationInfoDTO.getTodayWatchUserCount() == null ? 0 : authorizationInfoDTO.getTodayWatchUserCount()) +
+                    authorizationInfoDTO1.setTodayWatchUserCount(
+                            (authorizationInfoDTO1.getTodayWatchUserCount() == null ? 0 : authorizationInfoDTO1.getTodayWatchUserCount()) +
                                     (companyDTO.getTodayWatchUserCount() == null ? 0 : companyDTO.getTodayWatchUserCount())
                     );
 
-                    authorizationInfoDTO.setVersionLimit(
-                            (authorizationInfoDTO.getVersionLimit() == null ? 0 : authorizationInfoDTO.getVersionLimit()) +
+                    authorizationInfoDTO1.setVersionLimit(
+                            (authorizationInfoDTO1.getVersionLimit() == null ? 0 : authorizationInfoDTO1.getVersionLimit()) +
                                     (companyDTO.getVersionLimit() == null ? 0 : companyDTO.getVersionLimit())
                     );
                 }
             }
         }
-        AuthorizationInfoDTO authorizationInfoDTO = redisCache.getCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO);
 
         return R.ok().put("data", authorizationInfoDTO);
     }