Commit 6637281c authored by jiawei's avatar jiawei

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

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