Bläddra i källkod

首页分时数据,补全时辰2

zhaoxian 11 månader sedan
förälder
incheckning
a0c2ed77c5

+ 5 - 5
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemCollectSamplesController.java

@@ -785,7 +785,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
     public JSONObject getGmvHour(@ApiParam("创建人ID") @RequestParam(value = "userId", required = true) Long userId,
                                  @ApiParam("类型,1-渠道;2-招商") @RequestParam(value = "type", required = true) String type,
                                  @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId,
-                                 @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
+                                 @ApiParam("开始日期") @RequestParam(value = "statDate", required = false) String statDate,
                                  @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate
     ) {
         JSONObject returnJson = new JSONObject();
@@ -795,13 +795,13 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             }
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");   // 当天
             String lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);  //  日期 -1
-            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
-                List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(startDate, endDate);
+            if (!Check.isNull(statDate) && !Check.isNull(endDate)) {
+                List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(statDate, endDate);
                 if (allDatesOfTwoTimes.size() == 2) {
                     nowDate = endDate;
-                    lastDate = startDate;
+                    lastDate = statDate;
                 } else if (allDatesOfTwoTimes.size() == 1) {
-                    nowDate = startDate;
+                    nowDate = statDate;
                     lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);  //  日期 -1
                 }
             }

+ 14 - 5
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -800,8 +800,8 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             today = supplyChainService.getKsCourtshipGmvHourByDate(userList, nowDate);
             yesterday = supplyChainService.getKsCourtshipGmvHourByDate(userList, lastDate);
         }
-        completionTime(today);
-        completionTime(yesterday);
+        completionTime(today, nowDate);
+        completionTime(yesterday, lastDate);
         JSONObject result = new JSONObject();
         result.put("today", today);
         result.put("yesterday", yesterday);
@@ -815,14 +815,23 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
     /**
      * 补全时辰
      */
-    private void completionTime(List<JSONObject> dataList) {
+    private void completionTime(List<JSONObject> dataList, String nowDate) {
+        String today = DateUtils.getNowDate("yyyy-MM-dd");   // 当天
+        Integer tohour = DateUtils.getNowHour(); // 当前小时
+
         List<Integer> newDayList = new ArrayList<>();
         for (JSONObject data : dataList) {
             newDayList.add(data.getInteger("time"));
         }
         List<Integer> dayList = new ArrayList<>();
-        for (int i = 0; i < 23; i++) {
-            dayList.add(i);
+        if (today.equals(nowDate)) {
+            for (int i = 0; i <= tohour; i++) {
+                dayList.add(i);
+            }
+        } else {
+            for (int i = 0; i <= 23; i++) {
+                dayList.add(i);
+            }
         }
         for (Integer hour : dayList) {
             if (!newDayList.contains(hour)) {