瀏覽代碼

操作记录-查看操作记录补充空数据

yangzian 2 年之前
父節點
當前提交
2a9768abce

+ 33 - 2
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1916,6 +1916,29 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
+     * 获取 时 list
+     *
+     * @param
+     * @return
+     */
+    public static List<String> getHoursListDifference(List<String> betweenDaysList) {
+        List<String> dateList = new ArrayList<String>(){{
+            add("00");add("01");add("02");add("03");add("04");add("05");
+            add("06");add("07");add("08");add("09");add("10");add("11");
+            add("12");add("13");add("14");add("15");add("16");add("17");
+            add("18");add("19");add("20");add("21");add("22");add("23");
+        }};
+        List<String> resultList = new ArrayList<String>();
+        betweenDaysList.forEach(day ->{
+            dateList.forEach(hour ->{
+                resultList.add((day + hour).replace("-",""));
+            });
+        });
+        return resultList;
+    }
+
+
+    /**
      * 时间 去重 排序
      *
      * @param list
@@ -2022,8 +2045,16 @@ public class DateUtils extends PropertyEditorSupport {
         //BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(new BigDecimal(100));
         //System.out.println(unitRatio);
 
-        System.out.println(getFirstDayByMonth());
-        ;
+        //System.out.println(getFirstDayByMonth());
+
+        //System.out.println(getSubtractTime(new Date(),6));;
+
+        List<String> list = new ArrayList<String>();
+        list.add("2022-09-01");
+        list.add("2022-09-04");
+
+
+        System.out.println(getHoursListDifference(list));;
 
     }
 

+ 3 - 3
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/KuaishouOperationRecordMapper.java

@@ -54,11 +54,11 @@ public interface KuaishouOperationRecordMapper {
      * 查看快手 组数据信息
      * @param accountId
      * @param unitId
-     * @param startTime
-     * @param endTime
+     * @param statDate
+     * @param statHour
      * @return
      */
-    List<JSONObject> getKuaishouOperationUnitReport(@Param("accountId") long accountId,@Param("unitId") long unitId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+    JSONObject getKuaishouOperationUnitReport(@Param("accountId") long accountId,@Param("unitId") long unitId, @Param("statDate") String statDate, @Param("statHour") String statHour);
 
 
 }

+ 2 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/KuaishouOperationRecordMapper.xml

@@ -129,8 +129,8 @@
         FROM
         application.kuaishou_unit_report_hourly_dw
         WHERE
-        stat_date &gt;= date_format(#{startTime}, '%Y%m%d')
-        AND stat_date &lt;= date_format(#{endTime}, '%Y%m%d')
+        stat_date= #{statDate}
+        AND hour = #{statHour}
         AND account_id = #{accountId}
         AND unit_id = #{unitId}
         ORDER BY

+ 1 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/KuaishouOperationRecordService.java

@@ -21,7 +21,7 @@ public interface KuaishouOperationRecordService {
     Result getKuaishouUnitChargeTopTenByAccountId(String userId,long advertiserId,String startTime,String endTime) throws NoSuchFieldException;
 
 
-    Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime);
+    Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime)throws Exception;
 
 
 }

+ 29 - 8
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/KuaishouOperationRecordServiceImpl.java

@@ -129,17 +129,38 @@ public class KuaishouOperationRecordServiceImpl implements KuaishouOperationReco
      * @author: zianY
      */
     @Override
-    public Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime){
-        //查询时报数据
-        List<JSONObject> unitList =  kuaishouOperationRecordMapper.getKuaishouOperationUnitReport(advertiserId,unitId,startTime,endTime);
-        for (JSONObject unit : unitList) {
+    public Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime) throws Exception{
+        List<JSONObject> resultList = new ArrayList<>();
+        // 获取两个日期之间 所有的 时间 年-月-日
+        List<String> betweenDaysList = DateUtils.getAllDatesOfTwoTimes(startTime,endTime);
+        // 所有时间集
+        List<String> allHoursList = DateUtils.getHoursListDifference(betweenDaysList);
+        for (String time : allHoursList) {
+            JSONObject jsonObject = new JSONObject();
+            //2022090101 -年月日 时
+            String date = time.substring(0,time.length()-2);
+            String hour = time.substring(time.length()-2);
+            //查询时报数据
+            JSONObject unit =  kuaishouOperationRecordMapper.getKuaishouOperationUnitReport(advertiserId,unitId,date,hour);
+            if (Check.isNull(unit)){
+                jsonObject.put("charge",0);
+                jsonObject.put("statDate",date);
+                jsonObject.put("statHour",hour);
+                jsonObject.put("time",time);
+                resultList.add(jsonObject);
+                continue;
+            }
+
             long uId = Long.valueOf(unit.getString("unitId"));
-            String operationTime = unit.getString("statDate") + String.format("%0" + 2 + "d", unit.getInteger("statHour"));
             //查询操作记录
-            List<JSONObject> list =  kuaishouOperationRecordMapper.getKuaishouOperationRecordByAdvertiserId(advertiserId,uId,2,operationTime);
-            unit.put("operationList",list);
+            List<JSONObject> list =  kuaishouOperationRecordMapper.getKuaishouOperationRecordByAdvertiserId(advertiserId,uId,2,time);
+            if (!Check.isNull(list)){ list.forEach(json -> {json.put("content_log",json.getJSONArray("content_log"));});}
+            jsonObject = unit;
+            jsonObject.put("time",time);
+            jsonObject.put("operationList",list);
+            resultList.add(jsonObject);
         }
-        return Result.successMsg("查询成功",unitList);
+        return Result.successMsg("查询成功",resultList);
     }