|
@@ -20,12 +20,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.beans.PropertyDescriptor;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.BigInteger;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
* @author tianhua
|
|
@@ -64,24 +62,23 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
AdsOverallSummaryVO totalDataVO = totalDataSql.getObject(AdsOverallSummaryVO.class);
|
|
|
|
|
|
-
|
|
|
|
|
|
Condition todayDataCon = myCondition(param, false, 1);
|
|
|
|
|
|
String todayDataConString = todayDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
Sql todayDataSql = Sqls.create("SELECT \n" +
|
|
|
- "SUM(x.today_player_count) today_player_count ,\n" +
|
|
|
- "SUM(x.yesterday_player_count) yesterday_player_count ,\n" +
|
|
|
- "SUM(x.today_total_cost) today_total_cost ,\n" +
|
|
|
- "SUM(x.yesterday_total_cost) yesterday_total_cost ,\n" +
|
|
|
- "SUM(x.today_new_player_amount) today_new_player_amount ,\n" +
|
|
|
- "SUM(x.today_amount) today_amount ,\n" +
|
|
|
- "SUM(x.yesterday_new_player_amount) yesterday_new_player_amount ,\n" +
|
|
|
- "SUM(x.yesterday_amount) yesterday_amount ,\n" +
|
|
|
- "SUM(x.today_agent_count) today_agent_count ,\n" +
|
|
|
- "SUM(x.yesterday_agent_count) yesterday_agent_count ,\n" +
|
|
|
- "SUM(x.today_game_count) today_game_count ,\n" +
|
|
|
- "SUM(x.yesterday_game_count) yesterday_game_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_player_count),0) today_player_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_player_count),0) yesterday_player_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_total_cost),0) today_total_cost ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_total_cost),0) yesterday_total_cost ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_new_player_amount),0) today_new_player_amount ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_amount),0) today_amount ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_new_player_amount),0) yesterday_new_player_amount ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_amount),0) yesterday_amount ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_agent_count),0) today_agent_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_agent_count),0) yesterday_agent_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.today_game_count),0) today_game_count ,\n" +
|
|
|
+ "IFNULL(SUM(x.yesterday_game_count),0) yesterday_game_count ,\n" +
|
|
|
"IFNULL(SUM(x.first_new_user_amount)/SUM(x.today_total_cost),0) first_roi \n" +
|
|
|
"FROM ads_overall_summary x" + todayDataConString);
|
|
|
|
|
@@ -139,7 +136,8 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
dao.execute(sql);
|
|
|
|
|
|
- return sql.getList(AdsOverallSummaryLineDataVO.class);
|
|
|
+
|
|
|
+ return checkAllDateData(sql.getList(AdsOverallSummaryLineDataVO.class), param);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -172,10 +170,10 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 如果是组长 则需要排除掉 pitcher = -2 的所有数据
|
|
|
- * cri.where().andNotEquals("pithcerId", -2);
|
|
|
- * 如果是管理员账号 则不需要排除 pitcher = -2 的数据
|
|
|
- * */
|
|
|
+ * 如果是组长 则需要排除掉 pitcher = -2 的所有数据
|
|
|
+ * cri.where().andNotEquals("pithcerId", -2);
|
|
|
+ * 如果是管理员账号 则不需要排除 pitcher = -2 的数据
|
|
|
+ * */
|
|
|
|
|
|
|
|
|
switch (queryDays) {
|
|
@@ -197,14 +195,13 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
|
|
|
if (needLocalDate) {
|
|
|
- if (param.getBeginDate() != null && param.getEndDate() != null) {
|
|
|
-
|
|
|
- cri.where().andBetween("dt", param.getBeginDate(), param.getEndDate());
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- cri.where().andBetween("dt", LocalDate.now().minusDays(30), LocalDate.now());
|
|
|
+
|
|
|
+ if (param.getBeginDate() == null || param.getEndDate() == null) {
|
|
|
+ param.setBeginDate(LocalDate.now().minusDays(30));
|
|
|
+ param.setEndDate(LocalDate.now());
|
|
|
}
|
|
|
+
|
|
|
+ cri.where().andBetween("dt", param.getBeginDate(), param.getEndDate());
|
|
|
|
|
|
cri.getGroupBy().groupBy("dt");
|
|
|
|
|
@@ -220,7 +217,7 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
* @param source 原数据
|
|
|
* @param target 目标数据
|
|
|
*/
|
|
|
- public static void copyNullProperties(Object source, Object target) {
|
|
|
+ private void copyNullProperties(Object source, Object target) {
|
|
|
BeanUtils.copyProperties(source, target, getNullField(source));
|
|
|
}
|
|
|
|
|
@@ -247,5 +244,50 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
return notNullFieldSet.toArray(notNullField);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 检查前端查询日期内的数据是否在数据库中都存在
|
|
|
+ * 不存在要设置默认值 0
|
|
|
+ *
|
|
|
+ * @param list 返回给前端的折线图数据 list
|
|
|
+ * @param param 前端传递的查询参数实体
|
|
|
+ */
|
|
|
+ private List<AdsOverallSummaryLineDataVO> checkAllDateData(List<AdsOverallSummaryLineDataVO> list, AdsOverallSummaryParam param) {
|
|
|
+
|
|
|
+
|
|
|
+ Map<LocalDate, Integer> map = new HashMap<>();
|
|
|
+
|
|
|
+ LocalDate tempDate = param.getBeginDate();
|
|
|
+ while (!tempDate.isAfter(param.getEndDate())) {
|
|
|
+ map.put(tempDate, 1);
|
|
|
+ tempDate = tempDate.plusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (AdsOverallSummaryLineDataVO vo : list) {
|
|
|
+ Integer value = map.get(vo.getDt());
|
|
|
+ if (value != null) {
|
|
|
+ map.put(vo.getDt(), ++value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map.Entry<LocalDate, Integer> entry : map.entrySet()) {
|
|
|
+ if (entry.getValue() == 1) {
|
|
|
+
|
|
|
+ list.add(AdsOverallSummaryLineDataVO.builder()
|
|
|
+ .dt(entry.getKey())
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .buyAmount(BigDecimal.ZERO)
|
|
|
+ .natureAmount(BigDecimal.ZERO)
|
|
|
+ .cost(BigDecimal.ZERO)
|
|
|
+ .firstRoi(BigDecimal.ZERO)
|
|
|
+ .playerAccount(BigInteger.ZERO)
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ list.sort((vo1, vo2) -> vo1.getDt().isBefore(vo2.getDt()) ? -1 : 1);
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|