|
@@ -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);
|
|
|
}
|
|
|
|
|
|
|