|
@@ -114,11 +114,13 @@ public class DataService implements IDataService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HashMap<String, List<DataGroupByCount>> orderTrend(Integer type,String startTime,String endTime) {
|
|
|
+ public HashMap<String, Object> orderTrend(Integer type,Integer dataType,String startTime,String endTime) {
|
|
|
startTime = Dateutils.formatStartTime(startTime,type);
|
|
|
endTime = Dateutils.formatEndTime(endTime,type);
|
|
|
-
|
|
|
- HashMap<String,List<DataGroupByCount>> map = new HashMap<>();
|
|
|
+ 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<>();
|
|
@@ -163,7 +165,56 @@ public class DataService implements IDataService {
|
|
|
}
|
|
|
map.put("incrementOrder",incrementOrderResultList);
|
|
|
map.put("downOrder",downOrderResultList);
|
|
|
- map.put("partOrder",partOrderList);
|
|
|
+ //map.put("partOrder",partOrderList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ break;
|
|
|
+ case 1 :
|
|
|
+ rule = Dateutils.WEEK;
|
|
|
+ incrementOrderList = dataMapper.userDataSumGroupByWeek("t_increment_order",startTime,endTime);
|
|
|
+ downOrderList = dataMapper.userDataSumGroupByWeek("t_download_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);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
|
|
|
+ HashMap<String,String> incrementMap = new HashMap<>();
|
|
|
+ HashMap<String,String> 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()));
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ map.put("incrementOrder",incrementOrderResultList);
|
|
|
+ map.put("downOrder",downOrderResultList);
|
|
|
+ //map.put("partOrder",partOrderList);
|
|
|
return map;
|
|
|
}
|
|
|
|