|
@@ -9,9 +9,14 @@ import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAudienceAccountDa
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.Comparator;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,13 +57,24 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
|
|
String audienceType = "gender";
|
|
String audienceType = "gender";
|
|
String type = "gender";
|
|
String type = "gender";
|
|
List<JSONObject> list = null;
|
|
List<JSONObject> list = null;
|
|
|
|
+ List<String> typeList = accountDailyMapper.getTypeList(type, audienceType);
|
|
if ("pie".equals(dataType)) {
|
|
if ("pie".equals(dataType)) {
|
|
list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
|
|
list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
|
|
|
|
+ if (Check.isNull(list)) {
|
|
|
|
+ return Result.ok("未查询到数据");
|
|
|
|
+ }
|
|
|
|
+ completeData(list, typeList);
|
|
} else if ("line".equals(dataType)) {
|
|
} else if ("line".equals(dataType)) {
|
|
- list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(list)) {
|
|
|
|
- return Result.ok("未查询到数据");
|
|
|
|
|
|
+ String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
|
|
|
|
+ String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
|
|
|
|
+ List<String> dayList = DateUtils.getDays(startTime, endTime);
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
+ for (String day : dayList) {
|
|
|
|
+ list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType, day);
|
|
|
|
+ completeData(list, typeList);
|
|
|
|
+ data.put(day, list);
|
|
|
|
+ }
|
|
|
|
+ return Result.ok(data);
|
|
}
|
|
}
|
|
return Result.ok(list);
|
|
return Result.ok(list);
|
|
}
|
|
}
|
|
@@ -79,13 +95,24 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
|
|
String audienceType = "ageSegment";
|
|
String audienceType = "ageSegment";
|
|
String type = "age_segment";
|
|
String type = "age_segment";
|
|
List<JSONObject> list = null;
|
|
List<JSONObject> list = null;
|
|
|
|
+ List<String> typeList = accountDailyMapper.getTypeList(type, audienceType);
|
|
if ("pie".equals(dataType)) {
|
|
if ("pie".equals(dataType)) {
|
|
list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
|
|
list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
|
|
|
|
+ if (Check.isNull(list)) {
|
|
|
|
+ return Result.ok("未查询到数据");
|
|
|
|
+ }
|
|
|
|
+ completeData(list, typeList);
|
|
} else if ("line".equals(dataType)) {
|
|
} else if ("line".equals(dataType)) {
|
|
- list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(list)) {
|
|
|
|
- return Result.ok("未查询到数据");
|
|
|
|
|
|
+ String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
|
|
|
|
+ String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
|
|
|
|
+ List<String> dayList = DateUtils.getDays(startTime, endTime);
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
+ for (String day : dayList) {
|
|
|
|
+ list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType, day);
|
|
|
|
+ completeData(list, typeList);
|
|
|
|
+ data.put(day, list);
|
|
|
|
+ }
|
|
|
|
+ return Result.ok(data);
|
|
}
|
|
}
|
|
return Result.ok(list);
|
|
return Result.ok(list);
|
|
}
|
|
}
|
|
@@ -104,15 +131,63 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
|
|
parType = "alone";
|
|
parType = "alone";
|
|
}
|
|
}
|
|
List<JSONObject> list = null;
|
|
List<JSONObject> list = null;
|
|
|
|
+ List<String> typeList = accountDailyMapper.getSceneTypeList();
|
|
|
|
+ typeList.remove("全部");
|
|
if ("pie".equals(dataType)) {
|
|
if ("pie".equals(dataType)) {
|
|
list = accountDailyMapper.getSceneInfo(value, accountId, parType);
|
|
list = accountDailyMapper.getSceneInfo(value, accountId, parType);
|
|
|
|
+ if (Check.isNull(list)) {
|
|
|
|
+ return Result.ok("未查询到数据");
|
|
|
|
+ }
|
|
|
|
+ completeData(list, typeList);
|
|
} else if ("line".equals(dataType)) {
|
|
} else if ("line".equals(dataType)) {
|
|
- list = accountDailyMapper.getSceneEveryDayInfo(value, accountId, parType);
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(list)) {
|
|
|
|
- return Result.ok("未查询到数据");
|
|
|
|
|
|
+ String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
|
|
|
|
+ String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
|
|
|
|
+ List<String> dayList = DateUtils.getDays(startTime, endTime);
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
+ for (String day : dayList) {
|
|
|
|
+ list = accountDailyMapper.getSceneEveryDayInfo(value, accountId, parType, day);
|
|
|
|
+ completeData(list, typeList);
|
|
|
|
+ data.put(day, list);
|
|
|
|
+ }
|
|
|
|
+ return Result.ok(data);
|
|
}
|
|
}
|
|
return Result.ok(list);
|
|
return Result.ok(list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 补全数据
|
|
|
|
+ */
|
|
|
|
+ private void completeData(List<JSONObject> list, List<String> typeList) {
|
|
|
|
+ List<String> newDayList = new ArrayList<>();
|
|
|
|
+ for (JSONObject data : list) {
|
|
|
|
+ if (!newDayList.contains(data.getString("type"))) {
|
|
|
|
+ newDayList.add(data.getString("type"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (String type : typeList) {
|
|
|
|
+ if (!newDayList.contains(type)) {
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
+ obj.put("type", type);
|
|
|
|
+ obj.put("value", 0);
|
|
|
|
+ list.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ userRechargeListSort(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void userRechargeListSort(List<JSONObject> list) {
|
|
|
|
+ Collections.sort(list, new Comparator<JSONObject>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(JSONObject o1, JSONObject o2) {
|
|
|
|
+ try {
|
|
|
|
+ String st1 = o1.getString("type");
|
|
|
|
+ String st2 = o2.getString("type");
|
|
|
|
+ return st1.compareTo(st2);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|