|
|
@@ -1,481 +1,157 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.manage.common.FilePath;
|
|
|
+import com.fdkankan.manage.entity.DistrictCode;
|
|
|
import com.fdkankan.manage.entity.JyUser;
|
|
|
-import com.fdkankan.manage.entity.User;
|
|
|
import com.fdkankan.manage.mapper.IDataMapper;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
import com.fdkankan.manage.util.Dateutils;
|
|
|
+import com.fdkankan.manage.vo.request.SceneTotalParam;
|
|
|
import com.fdkankan.manage.vo.response.*;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.Count;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class DataService implements IDataService {
|
|
|
|
|
|
- static String dayFormat = "%Y-%m-%d";
|
|
|
- static String mouthFormat = "%Y-%m";
|
|
|
- static String yearFormat = "%Y";
|
|
|
-
|
|
|
@Autowired
|
|
|
IDataMapper dataMapper;
|
|
|
- @Autowired
|
|
|
- IUserService userService;
|
|
|
- @Autowired
|
|
|
- ISceneProService sceneProService;
|
|
|
- @Autowired
|
|
|
- IJyUserPlatformService jyUserPlatformService;
|
|
|
- @Autowired
|
|
|
- IJyUserService jyUserService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ IJyUserPlatformService userPlatformService;
|
|
|
+ @Autowired
|
|
|
+ IJyUserService jyUserService;
|
|
|
+ @Autowired
|
|
|
+ ISysRoleService sysRoleService;
|
|
|
+ @Autowired
|
|
|
+ IDistrictCodeService districtCodeService;
|
|
|
+ @Autowired
|
|
|
+ IScenePlusService scenePlusService;
|
|
|
+
|
|
|
+
|
|
|
+ private JyUser commonSetParam(SceneTotalParam param){
|
|
|
+ Long sysUserId = Long.valueOf(StpUtil.getLoginId().toString());
|
|
|
+ Integer loginPlatformId = userPlatformService.getLoginPlatformId();
|
|
|
+ JyUser jyUser = jyUserService.getBySysId(sysUserId);
|
|
|
+ if(!sysRoleService.isSuperAdmin()){
|
|
|
+ Boolean flag = sysRoleService.isAdmin();
|
|
|
+ if(!flag){
|
|
|
+ param.setUserId(jyUser.getUserId());
|
|
|
+ }else {
|
|
|
+ param.setPlatformId(loginPlatformId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return jyUser;
|
|
|
+ }
|
|
|
@Override
|
|
|
- public UserTotalVo getUserTotal() {
|
|
|
- UserTotalVo totalVo = new UserTotalVo();
|
|
|
- Long totalUserCount = dataMapper.totalUserCount("t_user",0);
|
|
|
- Long preMonthAddCount = dataMapper.preMonthAddCount("t_user",0);
|
|
|
- Long todayAddCount = dataMapper.todayAddCount("t_user",0);
|
|
|
- Long todayActiveCount = dataMapper.todayActiveCount();
|
|
|
+ public SceneTotalVo sceneTotal(SceneTotalParam param) {
|
|
|
+ JyUser jyUser = commonSetParam(param);
|
|
|
|
|
|
- totalVo.setTotalUserCount(totalUserCount);
|
|
|
- totalVo.setPreMonthAddCount(preMonthAddCount);
|
|
|
- totalVo.setTodayAddCount(todayAddCount);
|
|
|
- totalVo.setTodayActiveCount(todayActiveCount);
|
|
|
- return totalVo;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SceneTotalVo sceneTotal() {
|
|
|
- Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
- if(loginPlatformId != null) {
|
|
|
- userIds = jyUserService.getByUserIdPlatform(loginPlatformId);
|
|
|
- }else {
|
|
|
- JyUser jyUser = jyUserService.getBySysId(StpUtil.getLoginId());
|
|
|
- if(jyUser == null){
|
|
|
- return new SceneTotalVo();
|
|
|
- }
|
|
|
- userIds.add(jyUser.getUserId());
|
|
|
- }
|
|
|
SceneTotalVo totalVo = new SceneTotalVo();
|
|
|
- Long totalSceneCount = dataMapper.totalUserCount("t_scene_pro",1,userIds) + dataMapper.totalUserCount("t_scene_plus",0,userIds);
|
|
|
- Long preMonthAddCount = dataMapper.preMonthAddCount("t_scene_pro",1,userIds) + dataMapper.preMonthAddCount("t_scene_plus",0,userIds);
|
|
|
- Long todayAddCount = dataMapper.todayAddCount("t_scene_pro",1,userIds) + dataMapper.todayAddCount("t_scene_plus",0,userIds);
|
|
|
+ Long totalSceneCount = dataMapper.totalSceneCount(param);
|
|
|
|
|
|
- totalVo.setTotalSceneCount(totalSceneCount);
|
|
|
- totalVo.setPreMonthAddCount(preMonthAddCount);
|
|
|
- totalVo.setTodayAddCount(todayAddCount);
|
|
|
- return totalVo;
|
|
|
- }
|
|
|
+ param.setStartTime(Dateutils.getStartTime(Dateutils.getDaysAgoStr(30)));
|
|
|
+ param.setEndTime(Dateutils.getEndTime(Dateutils.getDaysAgoStr(30)));
|
|
|
+ Long preMonthAddCount = dataMapper.totalSceneCount(param);
|
|
|
|
|
|
- @Override
|
|
|
- public OrderTotalVo orderTotal() {
|
|
|
- Long preMonthPowCount = dataMapper.preMonthAddCount("t_increment_order",2);
|
|
|
- Long preMonthDownCount = dataMapper.preMonthAddCount("t_download_order",2);
|
|
|
- Long preMonthPartCount = dataMapper.preMonthAddCount("t_order",3);
|
|
|
- OrderTotalVo totalVo = new OrderTotalVo();
|
|
|
- totalVo.setPreMonThPowCount(preMonthPowCount);
|
|
|
- totalVo.setPreMonThDownCount(preMonthDownCount);
|
|
|
- totalVo.setPreMonThPartCount(preMonthPartCount);
|
|
|
-
|
|
|
- return totalVo;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<DataGroupByCount> userTrend(Integer type,Integer dataType,String startTime,String endTime) {
|
|
|
- startTime = Dateutils.formatStartTime(startTime);
|
|
|
- endTime = Dateutils.formatEndTime(endTime);
|
|
|
-
|
|
|
- List<DataGroupByCount> dataList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> result = new ArrayList<>();
|
|
|
- int rule = Dateutils.DAY;
|
|
|
- String tb = "t_user";
|
|
|
- if(dataType == 2){
|
|
|
- tb = "t_login_log";
|
|
|
- }
|
|
|
- switch (type){
|
|
|
- case 0 :
|
|
|
- dataList = dataMapper.userDataGroupBy(tb, dayFormat, startTime, endTime);
|
|
|
- break;
|
|
|
- case 1 :
|
|
|
- rule = Dateutils.WEEK;
|
|
|
- dataList = dataMapper.userDataGroupByWeek(tb,startTime,endTime);
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- rule = Dateutils.MONTH;
|
|
|
- dataList = dataMapper.userDataGroupBy(tb,mouthFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- }
|
|
|
- Long totalCount = 0L;
|
|
|
- if(dataType == 1){ //累加
|
|
|
- LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.lt(User::getCreateTime,startTime);
|
|
|
- totalCount = userService.count(wrapper);
|
|
|
- }
|
|
|
- //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
|
|
|
- HashMap<String,Long> map = new HashMap<>();
|
|
|
- dataList.forEach(entity -> map.put(entity.getGroupKey(),entity.getCount()));
|
|
|
- List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
|
|
|
+ param.setStartTime(Dateutils.getStartTime(Dateutils.getDaysAgoStr(0)));
|
|
|
+ param.setEndTime(Dateutils.getEndTime(Dateutils.getDaysAgoStr(0)));
|
|
|
+ Long todayAddCount = dataMapper.totalSceneCount(param);
|
|
|
+ Long totalUserCount = dataMapper.totalUserCount(param);
|
|
|
+ Integer totalSceneUserCount = dataMapper.totalSceneUserCount(param).size();
|
|
|
|
|
|
- setListData(result,map,dates,dataType,totalCount);
|
|
|
+ param.setUserId(jyUser.getUserId());
|
|
|
+ Long userSceneCount = dataMapper.totalSceneCount(param);
|
|
|
|
|
|
- return result;
|
|
|
+ totalVo.setTotalSceneCount(totalSceneCount);
|
|
|
+ totalVo.setTimeSceneCount(preMonthAddCount);
|
|
|
+ totalVo.setTodaySceneCount(todayAddCount);
|
|
|
+ totalVo.setTotalUserCount(totalUserCount);
|
|
|
+ totalVo.setTotalSceneUserCount(Long.valueOf(totalSceneUserCount));
|
|
|
+ totalVo.setUserSceneCount(userSceneCount);
|
|
|
+ return totalVo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HashMap<String, Object> orderTrend(Integer type,Integer dataType,String startTime,String endTime) {
|
|
|
- startTime = Dateutils.formatStartTime(startTime);
|
|
|
- endTime = Dateutils.formatEndTime(endTime);
|
|
|
-
|
|
|
- HashMap<String,Object> map = new HashMap<>();
|
|
|
- if(dataType == 1){
|
|
|
- return getAmountSumOrder(map,type,startTime,endTime);
|
|
|
- }
|
|
|
- List<DataGroupByCount> incrementOrderList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> downOrderList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> partOrderList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> incrementOrderResultList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> downOrderResultList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> partOrderResultList = new ArrayList<>();
|
|
|
- int rule = Dateutils.DAY;
|
|
|
- switch (type){
|
|
|
- case 0 :
|
|
|
- incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",dayFormat,startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataGroupBy("t_download_order",dayFormat,startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataGroupBy("t_order",dayFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- case 1 :
|
|
|
- rule = Dateutils.WEEK;
|
|
|
- incrementOrderList = dataMapper.userDataGroupByWeek("t_increment_order",startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataGroupByWeek("t_download_order",startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataGroupByWeek("t_order",startTime,endTime);
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- rule = Dateutils.MONTH;
|
|
|
- incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",mouthFormat,startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataGroupBy("t_download_order",mouthFormat,startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataGroupBy("t_order",mouthFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- }
|
|
|
- //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
|
|
|
- HashMap<String,Long> incrementMap = new HashMap<>();
|
|
|
- HashMap<String,Long> downOrderMap = new HashMap<>();
|
|
|
- HashMap<String,Long> partMap = new HashMap<>();
|
|
|
- incrementOrderList.forEach(entity -> incrementMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
- downOrderList.forEach(entity -> downOrderMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
- partOrderList.forEach(entity -> partMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
-
|
|
|
- List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
|
|
|
- for (String date : dates) {
|
|
|
- DataGroupByCount groupByCount = new DataGroupByCount();
|
|
|
- groupByCount.setGroupKey(date);
|
|
|
- groupByCount.setCount(incrementMap.get(date)== null ?0 :incrementMap.get(date));
|
|
|
- incrementOrderResultList.add(groupByCount);
|
|
|
-
|
|
|
- DataGroupByCount groupByCount2 = new DataGroupByCount();
|
|
|
- groupByCount2.setGroupKey(date);
|
|
|
- groupByCount2.setCount(downOrderMap.get(date)== null ?0 :downOrderMap.get(date));
|
|
|
- downOrderResultList.add(groupByCount2);
|
|
|
+ public List<SceneTrendVoList> sceneTrend(SceneTotalParam param) {
|
|
|
+ commonSetParam(param);
|
|
|
|
|
|
- DataGroupByCount groupByCount3 = new DataGroupByCount();
|
|
|
- groupByCount3.setGroupKey(date);
|
|
|
- groupByCount3.setCount(partMap.get(date)== null ?0 :partMap.get(date));
|
|
|
- partOrderResultList.add(groupByCount3);
|
|
|
- }
|
|
|
- map.put("incrementOrder",incrementOrderResultList);
|
|
|
- map.put("downOrder",downOrderResultList);
|
|
|
- map.put("partOrder",partOrderResultList);
|
|
|
- return map;
|
|
|
+ List<String> datesStr = new ArrayList<>();
|
|
|
+ if(param.getTimeList() == null || param.getTimeList().isEmpty()){
|
|
|
+ datesStr = Dateutils.findDatesStr(Dateutils.getAddTime(-30, Dateutils.DAY), new Date(), Dateutils.DAY);
|
|
|
+ }else {
|
|
|
+ datesStr = Dateutils.findDatesStr(Dateutils.getDate(param.getStartTime()),Dateutils.getDate(param.getEndTime()),Dateutils.DAY);
|
|
|
+ }
|
|
|
+ HashMap<String,Long> sceneMap = new HashMap<>();
|
|
|
+ HashMap<String,Long> userMap = new HashMap<>();
|
|
|
+ datesStr.forEach(e ->sceneMap.put(e,0L));
|
|
|
+ datesStr.forEach(e ->userMap.put(e,0L));
|
|
|
+
|
|
|
+ List<GroupByCountVo> groupByCounts = dataMapper.getSceneGroupByDay(param);
|
|
|
+ groupByCounts.forEach(e ->sceneMap.put(e.getGroupKey(),e.getTotalCount()));
|
|
|
+
|
|
|
+ List<GroupByCountVo> userCount = dataMapper.getUserGroupByDay(param);
|
|
|
+ userCount.forEach(e ->userMap.put(e.getGroupKey(),userMap.get(e.getGroupKey() +1)));
|
|
|
+
|
|
|
+ List<GroupByCountVo> sceneList = new ArrayList<>();
|
|
|
+ for (String key : sceneMap.keySet()) {
|
|
|
+ sceneList.add(new GroupByCountVo(key,sceneMap.get(key)));
|
|
|
+ }
|
|
|
+ List<GroupByCountVo> userList = new ArrayList<>();
|
|
|
+ for (String key : userMap.keySet()) {
|
|
|
+ userList.add(new GroupByCountVo(key,userMap.get(key)));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SceneTrendVoList> reList = new ArrayList<>();
|
|
|
+ SceneTrendVoList sceneTrendVoList = new SceneTrendVoList();
|
|
|
+ sceneTrendVoList.setType("scene");
|
|
|
+ sceneTrendVoList.setList(sceneList);
|
|
|
+ reList.add(sceneTrendVoList);
|
|
|
+ SceneTrendVoList sceneTrendVoList2 = new SceneTrendVoList();
|
|
|
+ sceneTrendVoList2.setType("user");
|
|
|
+ sceneTrendVoList2.setList(userList);
|
|
|
+ reList.add(sceneTrendVoList2);
|
|
|
+ return reList;
|
|
|
}
|
|
|
|
|
|
- private HashMap<String, Object> getAmountSumOrder(HashMap<String,Object> map,Integer type, String startTime, String endTime) {
|
|
|
- List<DataGroupBySum> incrementOrderList = new ArrayList<>();
|
|
|
- List<DataGroupBySum> downOrderList = new ArrayList<>();
|
|
|
- List<DataGroupBySum> partOrderList = new ArrayList<>();
|
|
|
- List<DataGroupBySum> incrementOrderResultList = new ArrayList<>();
|
|
|
- List<DataGroupBySum> downOrderResultList = new ArrayList<>();
|
|
|
- List<DataGroupBySum> partOrderResultList = new ArrayList<>();
|
|
|
- int rule = Dateutils.DAY;
|
|
|
- switch (type){
|
|
|
- case 0 :
|
|
|
- incrementOrderList = dataMapper.userDataSumGroupBy("t_increment_order",dayFormat,startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataSumGroupBy("t_download_order",dayFormat,startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataSumGroupBy("t_order",dayFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- case 1 :
|
|
|
- rule = Dateutils.WEEK;
|
|
|
- incrementOrderList = dataMapper.userDataSumGroupByWeek("t_increment_order",startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataSumGroupByWeek("t_download_order",startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataSumGroupByWeek("t_order",startTime,endTime);
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- rule = Dateutils.MONTH;
|
|
|
- incrementOrderList = dataMapper.userDataSumGroupBy("t_increment_order",mouthFormat,startTime,endTime);
|
|
|
- downOrderList = dataMapper.userDataSumGroupBy("t_download_order",mouthFormat,startTime,endTime);
|
|
|
- partOrderList = dataMapper.userDataSumGroupBy("t_order",mouthFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- }
|
|
|
- //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
|
|
|
- HashMap<String,String> incrementMap = new HashMap<>();
|
|
|
- HashMap<String,String> downOrderMap = new HashMap<>();
|
|
|
- HashMap<String,String> partMap = new HashMap<>();
|
|
|
- incrementOrderList.forEach(entity -> incrementMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
- downOrderList.forEach(entity -> downOrderMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
- partOrderList.forEach(entity -> partMap.put(entity.getGroupKey(),entity.getCount()));
|
|
|
-
|
|
|
- List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
|
|
|
- for (String date : dates) {
|
|
|
- DataGroupBySum groupByCount = new DataGroupBySum();
|
|
|
- groupByCount.setGroupKey(date);
|
|
|
- groupByCount.setCount(incrementMap.get(date)== null ?"0" :incrementMap.get(date));
|
|
|
- incrementOrderResultList.add(groupByCount);
|
|
|
-
|
|
|
- DataGroupBySum groupByCount2 = new DataGroupBySum();
|
|
|
- groupByCount2.setGroupKey(date);
|
|
|
- groupByCount2.setCount(downOrderMap.get(date)== null ?"0" :downOrderMap.get(date));
|
|
|
- downOrderResultList.add(groupByCount2);
|
|
|
-
|
|
|
- DataGroupBySum groupByCount3 = new DataGroupBySum();
|
|
|
- groupByCount3.setGroupKey(date);
|
|
|
- groupByCount3.setCount(partMap.get(date)== null ?"0" :partMap.get(date));
|
|
|
- partOrderResultList.add(groupByCount3);
|
|
|
- }
|
|
|
- map.put("incrementOrder",incrementOrderResultList);
|
|
|
- map.put("downOrder",downOrderResultList);
|
|
|
- map.put("partOrder",partOrderResultList);
|
|
|
- return map;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
- public HashMap<String, List<DataGroupByCount>> sceneTrend(Integer type,Integer dataType,String startTime,String endTime) {
|
|
|
- startTime = Dateutils.formatStartTime(startTime);
|
|
|
- endTime = Dateutils.formatEndTime(endTime);
|
|
|
-
|
|
|
- Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
- if(loginPlatformId != null) {
|
|
|
- userIds = jyUserService.getByUserIdPlatform(loginPlatformId);
|
|
|
- }else {
|
|
|
- JyUser jyUser = jyUserService.getBySysId(StpUtil.getLoginId());
|
|
|
- if(jyUser == null){
|
|
|
- return new HashMap<>();
|
|
|
- }
|
|
|
- userIds.add(jyUser.getUserId());
|
|
|
- }
|
|
|
-
|
|
|
- HashMap<String,List<DataGroupByCount>> map = new HashMap<>();
|
|
|
- List<DataGroupByCount> kkList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> kjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> ssList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> ssObjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> sgList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> sgObjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> yzlList = new ArrayList<>();
|
|
|
+ public Object districtScatter(SceneTotalParam param) {
|
|
|
+ commonSetParam(param);
|
|
|
|
|
|
- List<DataGroupByCount> proList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> plusList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> proObjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> plusObjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> yzlDataList = new ArrayList<>();
|
|
|
- int rule = Dateutils.DAY;
|
|
|
- switch (type){
|
|
|
- case 0 :
|
|
|
- proList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat,startTime,endTime,userIds,null);
|
|
|
- plusList = dataMapper.sceneGroupBy("t_scene_plus",dayFormat,startTime,endTime,userIds,null);
|
|
|
- proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",dayFormat,startTime,endTime,userIds,null);
|
|
|
- plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",dayFormat,startTime,endTime,userIds,null);
|
|
|
- yzlDataList = dataMapper.sceneGroupBy("t_scene_plus",dayFormat,startTime,endTime,userIds,"yzl");
|
|
|
- break;
|
|
|
- case 1 :
|
|
|
- rule = Dateutils.WEEK;
|
|
|
- proList = dataMapper.sceneGroupByWeek("t_scene_pro",startTime,endTime,userIds,null);
|
|
|
- plusList = dataMapper.sceneGroupByWeek("t_scene_plus",startTime,endTime,userIds,null);
|
|
|
- proObjList = dataMapper.sceneObjGroupByWeek("t_scene_pro",startTime,endTime,userIds,null);
|
|
|
- plusObjList = dataMapper.sceneObjGroupByWeek("t_scene_plus",startTime,endTime,userIds,null);
|
|
|
- yzlDataList = dataMapper.sceneGroupByWeek("t_scene_plus",startTime,endTime,userIds,"yzl");
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- rule = Dateutils.MONTH;
|
|
|
- proList = dataMapper.sceneGroupBy("t_scene_pro",mouthFormat,startTime,endTime,userIds,null);
|
|
|
- plusList = dataMapper.sceneGroupBy("t_scene_plus",mouthFormat,startTime,endTime,userIds,null);
|
|
|
- proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",mouthFormat,startTime,endTime,userIds,null);
|
|
|
- plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",mouthFormat,startTime,endTime,userIds,null);
|
|
|
- yzlDataList = dataMapper.sceneGroupBy("t_scene_plus",mouthFormat,startTime,endTime,userIds,"yzl");
|
|
|
- break;
|
|
|
- }
|
|
|
- HashMap<String, Long> kkMap = new HashMap<>();
|
|
|
- HashMap<String, Long> kjMap = new HashMap<>();
|
|
|
- HashMap<String, Long> ssMap = new HashMap<>();
|
|
|
- HashMap<String, Long> ssObjMap = new HashMap<>();
|
|
|
- HashMap<String, Long> sgMap = new HashMap<>();
|
|
|
- HashMap<String, Long> sgObjMap = new HashMap<>();
|
|
|
- HashMap<String, Long> yzlMap = new HashMap<>();
|
|
|
- for (DataGroupByCount dataGroupByCount : proList) {
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("3")){ //看见
|
|
|
- kjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("4")){ //深时
|
|
|
- ssMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("5")){ //深时
|
|
|
- sgMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(Arrays.asList("1","2","12","13","14").contains(dataGroupByCount.getGroupKey2())){ //看看
|
|
|
- kkMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- }
|
|
|
- for (DataGroupByCount dataGroupByCount : plusList) {
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("3")){ //看见
|
|
|
- kjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("4")){ //深时
|
|
|
- ssMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("5")){ //深时
|
|
|
- sgMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(Arrays.asList("1","2","12","13","14").contains(dataGroupByCount.getGroupKey2())){ //看看
|
|
|
- kkMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- }
|
|
|
- for (DataGroupByCount dataGroupByCount : proObjList) {
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("4")){ //深时
|
|
|
- ssObjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
+ List<GroupByCountVo> dataList = dataMapper.getSceneGroupByDistrict(param);
|
|
|
+ List<String> districtCodeList = dataList.stream().map(GroupByCountVo::getGroupKey).collect(Collectors.toList());
|
|
|
+ HashMap<String, DistrictCode> map = districtCodeService.getByCodeList(districtCodeList);
|
|
|
+ for (GroupByCountVo groupByCountVo : dataList) {
|
|
|
+ if(groupByCountVo.getGroupKey() == null){
|
|
|
+ groupByCountVo.setGroupKey("unknown");
|
|
|
+ groupByCountVo.setGroupName("unknown");
|
|
|
}
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("5")){ //深时
|
|
|
- sgObjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
+ DistrictCode districtCode = map.get(groupByCountVo.getGroupKey());
|
|
|
+ if(districtCode != null){
|
|
|
+ groupByCountVo.setGroupName(districtCode.getName());
|
|
|
}
|
|
|
}
|
|
|
- for (DataGroupByCount dataGroupByCount : plusObjList) {
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("4")){ //深时
|
|
|
- ssObjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("5")){ //深时
|
|
|
- sgObjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- }
|
|
|
- for (DataGroupByCount dataGroupByCount : yzlDataList) {
|
|
|
- yzlMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- Long kkCount = 0L;
|
|
|
- Long KjCount = 0L;
|
|
|
- Long ssCount = 0L;
|
|
|
- Long ssObjCount = 0L;
|
|
|
- Long sgCount = 0L;
|
|
|
- Long sgObjCount = 0L;
|
|
|
- Long yzlCount = 0L;
|
|
|
- if(dataType == 1){
|
|
|
- kkCount = sceneProService.getKkCount(Arrays.asList("1","2","12","13","14"),startTime,userIds,null);
|
|
|
- KjCount = sceneProService.getKkCount(Arrays.asList("3"),startTime,userIds,null);
|
|
|
- ssCount = sceneProService.getSsCount(Arrays.asList("4"),startTime,userIds);
|
|
|
- ssObjCount = sceneProService.getSsObjCount(Arrays.asList("4"),startTime,userIds);
|
|
|
- sgCount = sceneProService.getSsCount(Arrays.asList("5"),startTime,userIds);
|
|
|
- sgObjCount = sceneProService.getSsObjCount(Arrays.asList("5"),startTime,userIds);
|
|
|
- yzlCount = sceneProService.getKkCount(Arrays.asList("1"),startTime,userIds,"yzl");
|
|
|
- }
|
|
|
- List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
|
|
|
- setListData(kkList,kkMap,dates,dataType,kkCount);
|
|
|
- setListData(kjList,kjMap,dates,dataType,KjCount);
|
|
|
- setListData(ssList,ssMap,dates,dataType,ssCount);
|
|
|
- setListData(ssObjList,ssObjMap,dates,dataType,ssObjCount);
|
|
|
-
|
|
|
- setListData(sgList,sgMap,dates,dataType,sgCount);
|
|
|
- setListData(sgObjList,sgObjMap,dates,dataType,sgObjCount);
|
|
|
- setListData(yzlList,yzlMap,dates,dataType,yzlCount);
|
|
|
|
|
|
- map.put("kkList",kkList);
|
|
|
- map.put("kjList",kjList);
|
|
|
- map.put("ssList",ssList);
|
|
|
- map.put("ssobjList",ssObjList);
|
|
|
- map.put("sgList",sgList);
|
|
|
- map.put("sgobjList",sgObjList);
|
|
|
- map.put("yzlList",yzlList);
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void setListData(List<DataGroupByCount> kkList, HashMap<String, Long> kkMap, List<String> dates,Integer dataType,Long totalCount) {
|
|
|
- for (String key : dates) {
|
|
|
- DataGroupByCount newCount = new DataGroupByCount();
|
|
|
- newCount.setGroupKey(key);
|
|
|
- Long count = kkMap.get(key) == null ? 0L : kkMap.get(key);
|
|
|
- if(dataType == 1){
|
|
|
- count += totalCount;
|
|
|
- totalCount = count;
|
|
|
- }
|
|
|
- newCount.setCount(count);
|
|
|
- kkList.add(newCount);
|
|
|
- }
|
|
|
- }
|
|
|
- private void setListData(List<DataGroupByCount> kkList, HashMap<String, Long> kkMap, List<String> dates) {
|
|
|
- for (String key : dates) {
|
|
|
- DataGroupByCount newCount = new DataGroupByCount();
|
|
|
- newCount.setGroupKey(key);
|
|
|
- Long count = kkMap.get(key) == null ? 0L : kkMap.get(key);
|
|
|
- newCount.setCount(count);
|
|
|
- kkList.add(newCount);
|
|
|
- }
|
|
|
+ return dataList;
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IExcelService excelService;
|
|
|
@Override
|
|
|
- public HashMap<String, Object> cameraTrend(Integer type, String startTime, String endTime) {
|
|
|
- startTime = Dateutils.formatStartTime(startTime);
|
|
|
- endTime = Dateutils.formatEndTime(endTime);
|
|
|
-
|
|
|
- HashMap<String,Object> map = new HashMap<>();
|
|
|
- List<DataGroupByCount> allList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> kkList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> kjList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> ssList = new ArrayList<>();
|
|
|
- List<DataGroupByCount> sgList = new ArrayList<>();
|
|
|
- int rule = Dateutils.DAY;
|
|
|
- switch (type){
|
|
|
- case 0 :
|
|
|
- allList = dataMapper.sceneOutTimeGroupBy("t_camera_detail",dayFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- case 1 :
|
|
|
- rule = Dateutils.WEEK;
|
|
|
- allList = dataMapper.sceneOutTimeGroupByWeek("t_camera_detail",startTime,endTime);
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- rule = Dateutils.MONTH;
|
|
|
- allList = dataMapper.sceneOutTimeGroupBy("t_camera_detail",mouthFormat,startTime,endTime);
|
|
|
- break;
|
|
|
- }
|
|
|
- HashMap<String, Long> kkMap = new HashMap<>();
|
|
|
- HashMap<String, Long> kjMap = new HashMap<>();
|
|
|
- HashMap<String, Long> ssMap = new HashMap<>();
|
|
|
- HashMap<String, Long> sgMap = new HashMap<>();
|
|
|
- for (DataGroupByCount dataGroupByCount : allList) {
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("9")){ //看见
|
|
|
- kjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("10")){ //深时
|
|
|
- ssMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(dataGroupByCount.getGroupKey2().equals("11")){ //深时
|
|
|
- sgMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
- if(Arrays.asList("1").contains(dataGroupByCount.getGroupKey2())){ //看看
|
|
|
- kkMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
|
|
|
- }
|
|
|
+ public void exportSceneList(SceneTotalParam param, HttpServletRequest req, HttpServletResponse resp) {
|
|
|
+ commonSetParam(param);
|
|
|
+ List<ExportSceneList> exportSceneLists = dataMapper.getExPortSceneList(param);
|
|
|
+ try {
|
|
|
+ excelService.commonExport(req,resp,"场景数据",exportSceneLists, ExportSceneList.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
|
|
|
- setListData(kkList,kkMap,dates);
|
|
|
- setListData(kjList,kjMap,dates);
|
|
|
- setListData(ssList,ssMap,dates);
|
|
|
- setListData(sgList,sgMap,dates);
|
|
|
-
|
|
|
- map.put("kkList",kkList);
|
|
|
- map.put("kjList",kjList);
|
|
|
- map.put("ssList",ssList);
|
|
|
- map.put("sgList",sgList);
|
|
|
- return map;
|
|
|
}
|
|
|
}
|