|
|
@@ -1,6 +1,7 @@
|
|
|
package com.ytpm.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.ytpm.advertise.enums.AdPlatformTypeEnum;
|
|
|
import com.ytpm.advertise.param.ComprehensiveReportParam;
|
|
|
import com.ytpm.advertise.param.ConcurrentHourReportsParams;
|
|
|
@@ -20,9 +21,11 @@ import com.ytpm.feign.AppFeign;
|
|
|
import com.ytpm.feign.RiskFeign;
|
|
|
import com.ytpm.general.Result;
|
|
|
import com.ytpm.util.DateUtil;
|
|
|
+import com.ytpm.util.RedisService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -61,6 +64,9 @@ public class AgentIndexController {
|
|
|
@Resource
|
|
|
private RiskFeign riskFeign;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询广告平台收益
|
|
|
*/
|
|
|
@@ -256,42 +262,50 @@ public class AgentIndexController {
|
|
|
@ApiOperation("查询分小时报表")
|
|
|
@PostMapping("/hourReport")
|
|
|
public Result<?> hourReport() {
|
|
|
-
|
|
|
- // 1. 准备日期参数
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
-
|
|
|
- // 今日和昨日日期
|
|
|
- String todayStr = today.format(formatter);
|
|
|
- Integer todayInt = Integer.valueOf(todayStr);
|
|
|
- List<AgentChannelView> agentChannelViews = channelMapper.channelList();
|
|
|
- ArrayList<IndexHourReportView> indexHourReportViews = new ArrayList<>();
|
|
|
- ArrayList<HourReportParam> hourReportParams = new ArrayList<>();
|
|
|
- ConcurrentHourReportsParams concurrentHourReportsParams = new ConcurrentHourReportsParams();
|
|
|
- for (AgentChannelView agentChannelView : agentChannelViews) {
|
|
|
- HourReportParam param = new HourReportParam();
|
|
|
- Integer networkId = agentChannelView.getNetworkId();
|
|
|
- param.setNetwork_id_list(Collections.singletonList(networkId));
|
|
|
- param.setStart_date(todayInt);
|
|
|
- param.setEnd_date(todayInt);
|
|
|
- param.setCurrency("CNY");
|
|
|
- param.setLimit(1000);
|
|
|
- param.setStart(0);
|
|
|
- param.setTime_zone("UTC+8");
|
|
|
- param.setChannelName(agentChannelView.getChannelName());
|
|
|
- hourReportParams.add(param);
|
|
|
+ if (redisService.hasKey("hourReport")) {
|
|
|
+ List<IndexHourReportView> hourReportResList = JSON.parseArray(redisService.getStr("hourReport"), IndexHourReportView.class);
|
|
|
+ return Result.resultObjOk(hourReportResList);
|
|
|
}
|
|
|
- concurrentHourReportsParams.setParam(hourReportParams);
|
|
|
- //进行远程调用获取数据
|
|
|
- Result<List<HourReportRes>> listResult = advertiseFeign.concurrentHourReports(concurrentHourReportsParams);
|
|
|
- List<HourReportRes> hourReportResList = listResult.getData();
|
|
|
- for (HourReportRes hourReportRes : hourReportResList) {
|
|
|
- //处理数据
|
|
|
- IndexHourReportView indexHourReportView = buildIndexHourReportView(hourReportRes);
|
|
|
- //加入数组中
|
|
|
- indexHourReportViews.add(indexHourReportView);
|
|
|
+ else {
|
|
|
+ // 1. 准备日期参数
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+
|
|
|
+ // 今日和昨日日期
|
|
|
+ String todayStr = today.format(formatter);
|
|
|
+ Integer todayInt = Integer.valueOf(todayStr);
|
|
|
+ List<AgentChannelView> agentChannelViews = channelMapper.channelList();
|
|
|
+ ArrayList<IndexHourReportView> indexHourReportViews = new ArrayList<>();
|
|
|
+ ArrayList<HourReportParam> hourReportParams = new ArrayList<>();
|
|
|
+ ConcurrentHourReportsParams concurrentHourReportsParams = new ConcurrentHourReportsParams();
|
|
|
+ for (AgentChannelView agentChannelView : agentChannelViews) {
|
|
|
+ HourReportParam param = new HourReportParam();
|
|
|
+ Integer networkId = agentChannelView.getNetworkId();
|
|
|
+ param.setNetwork_id_list(Collections.singletonList(networkId));
|
|
|
+ param.setStart_date(todayInt);
|
|
|
+ param.setEnd_date(todayInt);
|
|
|
+ param.setCurrency("CNY");
|
|
|
+ param.setLimit(1000);
|
|
|
+ param.setStart(0);
|
|
|
+ param.setTime_zone("UTC+8");
|
|
|
+ param.setChannelName(agentChannelView.getChannelName());
|
|
|
+ hourReportParams.add(param);
|
|
|
+ }
|
|
|
+ concurrentHourReportsParams.setParam(hourReportParams);
|
|
|
+ //进行远程调用获取数据
|
|
|
+ Result<List<HourReportRes>> listResult = advertiseFeign.concurrentHourReports(concurrentHourReportsParams);
|
|
|
+ List<HourReportRes> hourReportResList = listResult.getData();
|
|
|
+ for (HourReportRes hourReportRes : hourReportResList) {
|
|
|
+ //处理数据
|
|
|
+ IndexHourReportView indexHourReportView = buildIndexHourReportView(hourReportRes);
|
|
|
+ //加入数组中
|
|
|
+ indexHourReportViews.add(indexHourReportView);
|
|
|
+ }
|
|
|
+ //50分钟过期
|
|
|
+ redisService.setTimeOutStr("hourReport",JSON.toJSONString(indexHourReportViews),50*60*1000);
|
|
|
+ return Result.resultObjOk(indexHourReportViews);
|
|
|
}
|
|
|
- return Result.resultObjOk(indexHourReportViews);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|