Commit 19b108be authored by jiawei's avatar jiawei

王亭亭 要求修改=》播放数据统计,展板点播趋势图 返回本业每天的播放量,没有默认展示 0

parent 24a2e459
package cn.wisenergy.chnmuseum.party.web.controller; package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.log.MethodLog; import cn.hutool.core.date.DateField;
import cn.wisenergy.chnmuseum.party.common.log.OperModule; import cn.hutool.core.date.DateTime;
import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil; import cn.wisenergy.chnmuseum.party.common.util.DateUtil;
import cn.wisenergy.chnmuseum.party.model.*; import cn.wisenergy.chnmuseum.party.model.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import cn.wisenergy.chnmuseum.party.service.TBoardStatisticService; import cn.wisenergy.chnmuseum.party.service.TBoardStatisticService;
import cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.springframework.web.bind.annotation.PostMapping;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.springframework.web.bind.annotation.RequestMapping;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*; import java.util.*;
/** /**
...@@ -104,7 +93,7 @@ public class TBoardStatisticController extends BaseController { ...@@ -104,7 +93,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping("/getBoardTrendPageList") @PostMapping("/getBoardTrendPageList")
// @RequiresAuthentication //@RequiresPermissions("t:board:statistic:trendPage") // @RequiresAuthentication //@RequiresPermissions("t:board:statistic:trendPage")
@ApiOperation(value = "获取展板播放趋势", notes = "获取展板播放趋势") @ApiOperation(value = "获取展板播放趋势", notes = "获取展板播放趋势")
public Map<String, Object> getBoardTrendPageList(TBoardPlayTrend trend) { public Map<String, Object> getBoardTrendPageList(TBoardPlayTrend trend) throws ParseException {
TUser user = null; TUser user = null;
try { try {
user = getcurUser(); user = getcurUser();
...@@ -124,9 +113,15 @@ public class TBoardStatisticController extends BaseController { ...@@ -124,9 +113,15 @@ public class TBoardStatisticController extends BaseController {
Map map = new HashMap(); Map map = new HashMap();
List dateList = new ArrayList(); List dateList = new ArrayList();
List cntList = new ArrayList(); List cntList = new ArrayList();
//按照 播放数据统计大屏 中 展板点播趋势图要求返回本月每天的播放量需求 修改接口
getDateList(trend.getPlayDate(),dateList, cntList);
for (TBoardPlayTrend t : page.getRecords()) { for (TBoardPlayTrend t : page.getRecords()) {
dateList.add(t.getPlayDate()); // dateList.add(t.getPlayDate());
cntList.add(t.getPlayNumber()); // cntList.add(t.getPlayNumber());
int index = dateList.indexOf(t.getPlayDate());
if (index>=0){
cntList.set(index,t.getPlayNumber());
}
} }
page.getRecords().sort(Comparator.comparing(TBoardPlayTrend::getPlayNumber).reversed()); page.getRecords().sort(Comparator.comparing(TBoardPlayTrend::getPlayNumber).reversed());
map.put("dateList",dateList); map.put("dateList",dateList);
...@@ -135,6 +130,35 @@ public class TBoardStatisticController extends BaseController { ...@@ -135,6 +130,35 @@ public class TBoardStatisticController extends BaseController {
return getResult(map); return getResult(map);
} }
/**
*按照 播放数据统计大屏 中 展板点播趋势图要求返回本月每天的播放量 新增方法
* @param dateFormat
* @param dateList
* @param cntList
* @throws ParseException
*/
private void getDateList(String dateFormat, List dateList, List cntList) throws ParseException {
Date date;
Date beginTime;
Date endTime;
if (dateFormat.length() > 4) {
date = new SimpleDateFormat("yyyyMM").parse(dateFormat);
beginTime = cn.hutool.core.date.DateUtil.beginOfMonth(date);
endTime = cn.hutool.core.date.DateUtil.endOfMonth(date);
} else {
date = new SimpleDateFormat("yyyy").parse(dateFormat);
beginTime = cn.hutool.core.date.DateUtil.beginOfYear(date);
endTime = cn.hutool.core.date.DateUtil.endOfYear(date);
}
//生成范围类的一系列日期
List<DateTime> dateTimes = cn.hutool.core.date.DateUtil.rangeToList(beginTime, endTime, DateField.DAY_OF_MONTH);
dateTimes.stream().forEach(dt->{
String yyyyMMdd = dt.toString("yyyyMMdd");
dateList.add(yyyyMMdd);
//默认初始值0
cntList.add(0);
});
}
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment