|
@@ -27,6 +27,7 @@ import reactor.util.function.Tuples;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.Modifier;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -82,7 +83,7 @@ public class GameServerServiceImpl implements IGameServerService {
|
|
|
//游戏区服总计dayN映射
|
|
|
Map<String, Field> fieldTotalMap = new HashMap<>();
|
|
|
List<Field> dayNTotalFieldList = new ArrayList<>();
|
|
|
- Class<?> tempTotalClazz = GameServerDayVO.class;
|
|
|
+ Class<?> tempTotalClazz = GameServerDayTotalVO.class;
|
|
|
while (tempTotalClazz != null) {
|
|
|
//得到所有的field
|
|
|
Field[] fields = tempTotalClazz.getDeclaredFields();
|
|
@@ -108,7 +109,7 @@ public class GameServerServiceImpl implements IGameServerService {
|
|
|
Field sourceField = fieldTotalMap.get(dayNTotalField.getName().replace("Trend", ""));
|
|
|
sourceField.setAccessible(true);
|
|
|
if (sourceField != null) {
|
|
|
- dayNFieldMapList.add(Tuples.of(sourceField, dayNTotalField));
|
|
|
+ dayNTotalFieldMapList.add(Tuples.of(sourceField, dayNTotalField));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -272,19 +273,25 @@ public class GameServerServiceImpl implements IGameServerService {
|
|
|
if (CollectionUtils.isEmpty(dayNTotalFieldMapList)) {
|
|
|
return;
|
|
|
}
|
|
|
- dayNTotalFieldMapList.forEach(dayNFieldMap -> {
|
|
|
+ dayNTotalFieldMapList.forEach(dayNTotalFieldMap -> {
|
|
|
try {
|
|
|
- String[] temps = ((String) dayNFieldMap.getT1().get(vo)).split("/");
|
|
|
- dayNFieldMap.getT2().set(vo, GameServerTrendVO.builder()
|
|
|
+ String[] temps = ((String) dayNTotalFieldMap.getT1().get(vo)).split("/");
|
|
|
+ //付费金额
|
|
|
+ BigDecimal amount = new BigDecimal(temps[4]);
|
|
|
+ //滚服付费金额
|
|
|
+ BigDecimal rollServerAmount = new BigDecimal(temps[7]);
|
|
|
+ //设置trend对象
|
|
|
+ dayNTotalFieldMap.getT2().set(vo, GameServerTrendVO.builder()
|
|
|
.regNum(Long.parseLong(temps[0]))
|
|
|
.roleNum(Long.parseLong(temps[1]))
|
|
|
.activeNum(Long.parseLong(temps[2]))
|
|
|
.amountNum(Long.parseLong(temps[3]))
|
|
|
- .amount(new BigDecimal(temps[4]))
|
|
|
+ .amount(amount)
|
|
|
.rollServerNum(Long.parseLong(temps[5]))
|
|
|
.rollServerAmountNum(Long.parseLong(temps[6]))
|
|
|
- .rollServerAmount(new BigDecimal(temps[7]))
|
|
|
- .rollServerAmountRate(new BigDecimal(temps[8]))
|
|
|
+ .rollServerAmount(rollServerAmount)
|
|
|
+ .rollServerAmountRate(amount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ rollServerAmount.divide(amount, 4, RoundingMode.HALF_UP))
|
|
|
.build()
|
|
|
);
|
|
|
} catch (IllegalAccessException e) {
|
|
@@ -294,14 +301,72 @@ public class GameServerServiceImpl implements IGameServerService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算总计一栏的daN数据
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
private String trendDay() {
|
|
|
StringBuilder daySql = new StringBuilder(StringUtils.EMPTY);
|
|
|
-
|
|
|
+ //拼接da1-da30 sql
|
|
|
+ for (int i = 1; i < 31; i++) {
|
|
|
+ daySql.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 1) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 2) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 3) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 4) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 5) AS DECIMAL(10,2))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 6) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 7) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(da%s, '/', 8) AS DECIMAL(10,2)))
|
|
|
+ ) as da%s ,
|
|
|
+ """.formatted(i, i, i, i, i, i, i, i, i));
|
|
|
+ }
|
|
|
+ //拼接m2-m11 sql
|
|
|
+ for (int i = 2; i < 12; i++) {
|
|
|
+ daySql.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 1) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 2) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 3) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 4) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 5) AS DECIMAL(10,2))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 6) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 7) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(m%s, '/', 8) AS DECIMAL(10,2)))
|
|
|
+ ) as m%s ,
|
|
|
+ """.formatted(i, i, i, i, i, i, i, i, i));
|
|
|
+ }
|
|
|
+ //拼接y1
|
|
|
+ daySql.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 1) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 2) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 3) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 4) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 5) AS DECIMAL(10,2))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 6) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 7) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(y1, '/', 8) AS DECIMAL(10,2)))
|
|
|
+ ) as y1 ,
|
|
|
+ """);
|
|
|
+ //拼接total
|
|
|
+ daySql.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 1) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 2) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 3) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 4) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 5) AS DECIMAL(10,2))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 6) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 7) AS BIGINT(20))), '/',
|
|
|
+ SUM(CAST (SPLIT_PART(total, '/', 8) AS DECIMAL(10,2)))
|
|
|
+ ) as total
|
|
|
+ """);
|
|
|
|
|
|
return daySql.toString();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 游戏区服数据SQL
|
|
|
* @return String
|
|
@@ -381,53 +446,13 @@ public class GameServerServiceImpl implements IGameServerService {
|
|
|
IFNULL(SUM(out_total_num), 0) as out_total_num,
|
|
|
IFNULL(SUM(out_total_amount_num), 0) as out_total_amount_num,
|
|
|
IFNULL(SUM(out_total_amount), 0) as out_total_amount,
|
|
|
- IFNULL(SUM(out_total_rate), 0) as out_total_rate,
|
|
|
+ ROUND(IF(SUM(total_amount) > 0, SUM(out_total_amount) / SUM(total_amount), 0), 4) as out_total_rate,
|
|
|
IFNULL(SUM(total_role_num), 0) as total_role_num,
|
|
|
IFNULL(SUM(total_reg_num), 0) as total_reg_num,
|
|
|
IFNULL(SUM(total_amount_num), 0) as total_amount_num,
|
|
|
IFNULL(SUM(total_amount), 0) as total_amount,
|
|
|
- da1,
|
|
|
- da2,
|
|
|
- da3,
|
|
|
- da4,
|
|
|
- da5,
|
|
|
- da6,
|
|
|
- da7,
|
|
|
- da8,
|
|
|
- da9,
|
|
|
- da10,
|
|
|
- da11,
|
|
|
- da12,
|
|
|
- da13,
|
|
|
- da14,
|
|
|
- da15,
|
|
|
- da16,
|
|
|
- da17,
|
|
|
- da18,
|
|
|
- da19,
|
|
|
- da20,
|
|
|
- da21,
|
|
|
- da22,
|
|
|
- da23,
|
|
|
- da24,
|
|
|
- da25,
|
|
|
- da26,
|
|
|
- da27,
|
|
|
- da28,
|
|
|
- da29,
|
|
|
- da30,
|
|
|
- m2,
|
|
|
- m3,
|
|
|
- m4,
|
|
|
- m5,
|
|
|
- m6,
|
|
|
- m7,
|
|
|
- m8,
|
|
|
- m9,
|
|
|
- m10,
|
|
|
- m11,
|
|
|
- y1,
|
|
|
- total
|
|
|
+ """ + trendDay() +
|
|
|
+ """
|
|
|
FROM
|
|
|
game_ads.ads_game_server_day
|
|
|
""";
|