|
@@ -8,6 +8,7 @@ import com.fs.core.web.service.TokenService;
|
|
|
import com.fs.statis.StatisticsRedisConstant;
|
|
|
import com.fs.statis.dto.*;
|
|
|
import io.jsonwebtoken.lang.Assert;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.util.Asserts;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -20,6 +21,7 @@ import static com.fs.statis.StatisticsRedisConstant.*;
|
|
|
/**
|
|
|
* 首页-统计
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/index/statistics")
|
|
|
public class IndexStatisticsController {
|
|
@@ -161,20 +163,32 @@ public class IndexStatisticsController {
|
|
|
*/
|
|
|
@PostMapping("/rewardMoneyTopTen")
|
|
|
public R rewardMoneyTopTen(@RequestBody AnalysisPreviewQueryDTO param){
|
|
|
+ log.info("开始处理奖励金额top10请求");
|
|
|
+
|
|
|
Integer type = param.getType();
|
|
|
Integer dataType = param.getDataType();
|
|
|
Integer userType = param.getUserType();
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
Long companyUserId = loginUser.getUser().getUserId();
|
|
|
+ log.info("请求参数: type={}, dataType={}, userType={}, companyId={}, companyUserId={}",
|
|
|
+ type, dataType, userType, companyId, companyUserId);
|
|
|
|
|
|
param.setCompanyId(companyId);
|
|
|
List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS;
|
|
|
+ String cacheKey;
|
|
|
+
|
|
|
if(loginUser.getUser().isAdmin()) {
|
|
|
- rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId()));
|
|
|
+ cacheKey = String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId());
|
|
|
+ log.info("管理员用户,使用缓存key: {}", cacheKey);
|
|
|
+
|
|
|
} else {
|
|
|
- rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId(),companyUserId));
|
|
|
+ cacheKey = String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId(),companyUserId);
|
|
|
+ log.info("普通用户,使用缓存key: {}", cacheKey);
|
|
|
+
|
|
|
}
|
|
|
+ rewardMoneyTopTenDTOS = redisCache.getCacheObject(cacheKey);
|
|
|
+ log.info("从Redis缓存中获取到的数据大小: {}", rewardMoneyTopTenDTOS != null ? rewardMoneyTopTenDTOS.size() : 0);
|
|
|
|
|
|
return R.ok().put("data", rewardMoneyTopTenDTOS);
|
|
|
}
|
|
@@ -189,8 +203,13 @@ public class IndexStatisticsController {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
param.setCompanyId(companyId);
|
|
|
+ List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS;
|
|
|
+ if(loginUser.getUser().isAdmin()) {
|
|
|
+ rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId()));
|
|
|
+ } else {
|
|
|
+ rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId(),loginUser.getUser().getUserId()));
|
|
|
+ }
|
|
|
|
|
|
- List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId()));
|
|
|
return R.ok().put("data", rewardMoneyTrendDTOS);
|
|
|
}
|
|
|
|
|
@@ -206,8 +225,13 @@ public class IndexStatisticsController {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
param.setCompanyId(companyId);
|
|
|
+ List<CourseStatsDTO> courseStatsDTOS;
|
|
|
+ if(loginUser.getUser().isAdmin()) {
|
|
|
+ courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId()));
|
|
|
+ } else {
|
|
|
+ courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId(),loginUser.getUser().getUserId()));
|
|
|
+ }
|
|
|
|
|
|
- List<CourseStatsDTO> courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId()));
|
|
|
return R.ok().put("data", courseStatsDTOS);
|
|
|
}
|
|
|
|
|
@@ -219,7 +243,14 @@ public class IndexStatisticsController {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
|
|
|
- DealerAggregatedDTO dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId));
|
|
|
+ DealerAggregatedDTO dealerAggregatedDTO;
|
|
|
+
|
|
|
+ if(loginUser.getUser().isAdmin()) {
|
|
|
+ dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId));
|
|
|
+ } else {
|
|
|
+ dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId,loginUser.getUser().getUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return R.ok().put("data",dealerAggregatedDTO);
|
|
|
}
|