Commit 6637281c authored by jiawei's avatar jiawei

要求修改=》播放数据统计,展板点播趋势图 日期不能超出当前时间

parent e9250468
......@@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
/**
......@@ -40,7 +39,7 @@ public class TBoardStatisticController extends BaseController {
@Resource
private TBoardStatisticService tBoardStatisticService;
// @ApiImplicitParams(value = {
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
// @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer")
// })
......@@ -51,7 +50,7 @@ public class TBoardStatisticController extends BaseController {
TUser user = null;
try {
user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
survey.setOrganCode(user.getOrgCode());
}
} catch (Exception e) {
......@@ -73,13 +72,13 @@ public class TBoardStatisticController extends BaseController {
TUser user = null;
try {
user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
rank.setOrganCode(user.getOrgCode());
}
} catch (Exception e) {
rank.setOrganCode(null);
}
Page<TBoardPlayRank> page = this.tBoardStatisticService.getBoardRankPageList(getPage(),rank);
Page<TBoardPlayRank> page = this.tBoardStatisticService.getBoardRankPageList(getPage(), rank);
for (TBoardPlayRank tBoardStatistic : page.getRecords()) {
}
......@@ -97,44 +96,45 @@ public class TBoardStatisticController extends BaseController {
TUser user = null;
try {
user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
trend.setOrganCode(user.getOrgCode());
}
} catch (Exception e) {
trend.setOrganCode(null);
}
// 如果查询日志为空,则默认当月
if (StringUtils.isEmpty(trend.getPlayDate())){
if (StringUtils.isEmpty(trend.getPlayDate())) {
trend.setPlayDate(DateUtil.getCurrentDate("yyyyMM"));
}
// Page<TBoardPlayTrend> page = this.tBoardStatisticService.getBoardTrendPageList(getPage(),trend);
List<TBoardPlayTrend> records = this.tBoardStatisticService.getBoardTrendPageList(getPage(),trend);
List<TBoardPlayTrend> records = this.tBoardStatisticService.getBoardTrendPageList(getPage(), trend);
// 处理数据为展板趋势图
Map map = new HashMap();
List dateList = new ArrayList();
List cntList = new ArrayList();
//按照 播放数据统计大屏 中 展板点播趋势图要求返回本月每天的播放量需求 修改接口
getDateList(trend.getPlayDate(),dateList, cntList);
getDateList(trend.getPlayDate(), dateList, cntList);
// for (TBoardPlayTrend t : page.getRecords()) {
for (TBoardPlayTrend t : records) {
// dateList.add(t.getPlayDate());
// cntList.add(t.getPlayNumber());
int index = dateList.indexOf(t.getPlayDate());
if (index>=0){
cntList.set(index,t.getPlayNumber());
if (index >= 0) {
cntList.set(index, t.getPlayNumber());
}
}
// page.getRecords().sort(Comparator.comparing(TBoardPlayTrend::getPlayNumber).reversed());
map.put("dateList",dateList);
map.put("cntList",cntList);
map.put("dateList", dateList);
map.put("cntList", cntList);
// map.put("page",page);
return getResult(map);
}
/**
*按照 播放数据统计大屏 中 展板点播趋势图要求返回本月每天的播放量 新增方法
* 按照 播放数据统计大屏 中 展板点播趋势图要求返回本月每天的播放量 新增方法
*
* @param dateFormat
* @param dateList
* @param cntList
......@@ -144,18 +144,27 @@ public class TBoardStatisticController extends BaseController {
Date date;
Date beginTime;
Date endTime;
Date nowDate = new Date();
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);
// 设置最后时间不能大于当前时间
if (nowDate.after(beginTime) && nowDate.before(endTime)) {
endTime = nowDate;
}
} else {
date = new SimpleDateFormat("yyyy").parse(dateFormat);
beginTime = cn.hutool.core.date.DateUtil.beginOfYear(date);
endTime = cn.hutool.core.date.DateUtil.endOfYear(date);
// 设置最后时间不能大于当前时间
if (nowDate.after(beginTime) && nowDate.before(endTime)) {
endTime = nowDate;
}
}
//生成范围类的一系列日期
List<DateTime> dateTimes = cn.hutool.core.date.DateUtil.rangeToList(beginTime, endTime, DateField.DAY_OF_MONTH);
dateTimes.stream().forEach(dt->{
dateTimes.stream().forEach(dt -> {
String yyyyMMdd = dt.toString("yyyyMMdd");
dateList.add(yyyyMMdd);
//默认初始值0
......@@ -174,14 +183,14 @@ public class TBoardStatisticController extends BaseController {
TUser user = null;
try {
user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
district.setOrganCode(user.getOrgCode());
}
} catch (Exception e) {
district.setOrganCode(null);
}
Page<TDistrictBoardStatistic> page = this.tBoardStatisticService.getBoardDistrictPageList(getPage(),district);
Page<TDistrictBoardStatistic> page = this.tBoardStatisticService.getBoardDistrictPageList(getPage(), district);
for (TDistrictBoardStatistic tBoardStatistic : page.getRecords()) {
}
......@@ -200,13 +209,13 @@ public class TBoardStatisticController extends BaseController {
String orgCode = null;
try {
TUser user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
orgCode = user.getOrgCode();
}
} catch (Exception e) {
orgCode = null;
}
List list = this.tBoardStatisticService.getBoardProvincePlayTotalList(organId,orgCode);
List list = this.tBoardStatisticService.getBoardProvincePlayTotalList(organId, orgCode);
return getResult(list);
}
......@@ -222,35 +231,36 @@ public class TBoardStatisticController extends BaseController {
String orgCode = null;
try {
TUser user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
orgCode = user.getOrgCode();
}
} catch (Exception e) {
orgCode = null;
}
if (StringUtils.isEmpty(frequencyDate)){
if (StringUtils.isEmpty(frequencyDate)) {
frequencyDate = DateUtil.getCurrentDate("yyyyMM");
}
Page page = this.tBoardStatisticService.getInteractionFrequency(getPage(),frequencyDate,orgCode);
Page page = this.tBoardStatisticService.getInteractionFrequency(getPage(), frequencyDate, orgCode);
//
Map map = new HashMap();
List organList = new ArrayList<>();
List cntList = new ArrayList();
for (Object o : page.getRecords()){
for (Object o : page.getRecords()) {
Map m = (HashMap) o;
organList.add(m.get("organName"));
cntList.add(m.get("frequencyCnt"));
}
map.put("organList",organList);
map.put("cntList",cntList);
map.put("page",page);
map.put("organList", organList);
map.put("cntList", cntList);
map.put("page", page);
return getResult(map);
}
/**
* 以下两个接口是pc端专用
*
* @param trend
* @return
*/
......@@ -266,18 +276,18 @@ public class TBoardStatisticController extends BaseController {
TUser user = null;
try {
user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
trend.setOrganCode(user.getOrgCode());
}
} catch (Exception e) {
trend.setOrganCode(null);
}
// 如果查询日志为空,则默认当月
if (StringUtils.isEmpty(trend.getBeginDate())){
trend.setBeginDate(DateUtil.getCurrentDate("yyyy")+"01");
if (StringUtils.isEmpty(trend.getBeginDate())) {
trend.setBeginDate(DateUtil.getCurrentDate("yyyy") + "01");
trend.setEndDate(DateUtil.getCurrentDate("yyyyMM"));
}
Page<TBoardPlayTrend> page = this.tBoardStatisticService.getBoardPageList(getPage(),trend);
Page<TBoardPlayTrend> page = this.tBoardStatisticService.getBoardPageList(getPage(), trend);
// 处理数据为展板趋势图
Map map = new HashMap();
List dateList = new ArrayList();
......@@ -288,14 +298,14 @@ public class TBoardStatisticController extends BaseController {
cntList.add(t.getPlayNumber());
}
List<TBoardPlayTrend> list = page.getRecords();
list.sort(Comparator.comparing(TBoardPlayTrend::getPlayNumber,Comparator.reverseOrder()).thenComparing(TBoardPlayTrend::getPlayDate,Comparator.reverseOrder()));
if (list.size()>=10) {
list.sort(Comparator.comparing(TBoardPlayTrend::getPlayNumber, Comparator.reverseOrder()).thenComparing(TBoardPlayTrend::getPlayDate, Comparator.reverseOrder()));
if (list.size() >= 10) {
list = list.subList(0, 10);
}
page.setRecords(list);
map.put("dateList",dateList);
map.put("cntList",cntList);
map.put("page",page);
map.put("dateList", dateList);
map.put("cntList", cntList);
map.put("page", page);
return getResult(map);
}
......@@ -313,29 +323,29 @@ public class TBoardStatisticController extends BaseController {
String orgCode = null;
try {
TUser user = getcurUser();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
orgCode = user.getOrgCode();
}
} catch (Exception e) {
orgCode = null;
}
if (StringUtils.isEmpty(frequencyDate)){
if (StringUtils.isEmpty(frequencyDate)) {
frequencyDate = DateUtil.getCurrentDate("yyyyMM");
}
Page page = this.tBoardStatisticService.getInteractionFrequency(getPage(),frequencyDate,orgCode);
Page page = this.tBoardStatisticService.getInteractionFrequency(getPage(), frequencyDate, orgCode);
//
Map map = new HashMap();
List organList = new ArrayList<>();
List cntList = new ArrayList();
for (Object o : page.getRecords()){
for (Object o : page.getRecords()) {
Map m = (HashMap) o;
organList.add(m.get("organName"));
cntList.add(m.get("frequencyCnt"));
}
map.put("organList",organList);
map.put("cntList",cntList);
map.put("page",page);
map.put("organList", organList);
map.put("cntList", cntList);
map.put("page", page);
return getResult(map);
}
}
......
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