Browse Source

磁力金牛 初版1

zhaoxian 2 years ago
parent
commit
8eab1ea434

+ 30 - 3
ruixuan-live/src/main/java/com/ruixuan/report/service/impl/KuaishouLiveAccountReportServiceImpl.java

@@ -232,9 +232,13 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
         JSONObject result = new JSONObject();
         String type = map.get("type").toString();
         if (startDate.equals(endDate)) {
-            result.put("todayInfo", mapper.getOperateCostTrendChartListByHourly(map));
+            List<JSONObject> todayInfo = mapper.getOperateCostTrendChartListByHourly(map);
+            completeHour(todayInfo);
+            result.put("todayInfo", todayInfo);
             map.put("today", map.get("yesterday"));
-            result.put("yesterdayInfo", mapper.getOperateCostTrendChartListByHourly(map));
+            List<JSONObject> yesterdayInfo = mapper.getOperateCostTrendChartListByHourly(map);
+            completeHour(yesterdayInfo);
+            result.put("yesterdayInfo", yesterdayInfo);
         } else {
             List<JSONObject> dailyData = mapper.getOperateCostTrendChartListByDaily(map);
             List<String> allDates = DateUtils.getAllDatesOfTwoTimes(startDate, endDate);
@@ -268,7 +272,9 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
         Map<String, Object> map = getDateTime(startDate, endDate);
         map.put("accountIdList", request.getJSONArray("accountIdList"));
         if (startDate.equals(endDate)) {
-            return mapper.getvisitorStatisticsTrendChartListByHourly(map);
+            List<JSONObject> list = mapper.getvisitorStatisticsTrendChartListByHourly(map);
+            completeHour(list);
+            return list;
         } else {
             List<JSONObject> list = mapper.getvisitorStatisticsTrendChartListByDaily(map);
             List<String> allDates = DateUtils.getAllDatesOfTwoTimes(startDate, endDate);
@@ -351,6 +357,27 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
         });
     }
 
+
+    /*补全小时数据,排序 */
+    private void completeHour(List<JSONObject> list) {
+        List<Integer> newDayList = new ArrayList<>();
+        for (JSONObject data : list) {
+            newDayList.add(data.getInteger("time"));
+        }
+        List<Integer> dayList = new ArrayList<>();
+        for (int i = 0; i <= 23; i++) {
+            dayList.add(i);
+        }
+        for (Integer hour : dayList) {
+            if (!newDayList.contains(hour)) {
+                JSONObject obj = new JSONObject();
+                obj.put("time", hour);
+                obj.put("costTotal", 0);
+                list.add(obj);
+            }
+        }
+    }
+
     /*根据入参时间,整理上个时间周期,并判断查询日报OR时报*/
     private Map<String, Object> getDateTime(String startDate, String endDate) {
         Map<String, Object> map = new HashMap<>();