Browse Source

:fix:优化GS游戏区服

zhangxianyu 1 year ago
parent
commit
e78984ba7c

+ 8 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GSServerRetentionVO.java

@@ -41,4 +41,12 @@ public class GSServerRetentionVO {
      * 超大R留存率
      */
     private String superR;
+    /**
+     * 创建总人数
+     */
+    private String totalRegNum;
+    /**
+     * 付费总人数
+     */
+    private String totalAmountNum;
 }

+ 35 - 37
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameServerServiceImpl.java

@@ -510,11 +510,9 @@ public class GameServerServiceImpl implements IGameServerService {
      */
     @Override
     public Page<GSGameServerDayVO> getGSGameServerDataDay(GSGameServerDayDTO dto) {
-        StopWatch stopWatch = new StopWatch();
-        stopWatch.start();
         Criteria cri = getGameServerDayCriteria(dto);
         Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
-        Sql sql = Sqls.create(getGSGameServerDateSql() + cri);
+        Sql sql = Sqls.create(getGSGameServerDateSql(cri));
         sql.setCallback(Sqls.callback.entities());
         sql.setEntity(dao.getEntity(GSGameServerDayVO.class));
         sql.setPager(pager);
@@ -561,18 +559,18 @@ public class GameServerServiceImpl implements IGameServerService {
                     GSServerRetentionVO retentionVO = GSServerRetentionVO.builder()
                             .activeRetention(split[0])
                             .PaidRetentionRate(split[1])
-                            .smallR(split[2])
-                            .mediumR(split[3])
-                            .largeR(split[4])
-                            .superR(split[5]).build();
+                            .totalRegNum(split[2])
+                            .totalAmountNum(split[3])
+                            .smallR(split[4])
+                            .mediumR(split[5])
+                            .largeR(split[6])
+                            .superR(split[7]).build();
                     fieldObjectList.get(i).set(vo, retentionVO);
                 } catch (IllegalAccessException e) {
                     throw new RuntimeException(e);
                 }
             }
 
-            stopWatch.stop();
-            log.info("GS区服查询消耗时间:{}", stopWatch.getTotalTimeMillis());
         }
         return new Page<>(vos, pager);
     }
@@ -586,8 +584,6 @@ public class GameServerServiceImpl implements IGameServerService {
      */
     @Override
     public GSGameServerDayVO getGSGameServerDataDayTotal(GSGameServerDayDTO dto) {
-        StopWatch stopWatch = new StopWatch();
-        stopWatch.start();
         Criteria cri = getGameServerDayCriteria(dto);
         Sql sql = Sqls.create(getGSGameServerDateTotalSql() + cri);
         sql.setCallback(Sqls.callback.entities());
@@ -651,18 +647,18 @@ public class GameServerServiceImpl implements IGameServerService {
                 GSServerRetentionVO retentionVO = GSServerRetentionVO.builder()
                         .activeRetention(split[0])
                         .PaidRetentionRate(split[1])
-                        .smallR(split[2])
-                        .mediumR(split[3])
-                        .largeR(split[4])
-                        .superR(split[5]).build();
+                        .totalRegNum(split[2])
+                        .totalAmountNum(split[3])
+                        .smallR(split[4])
+                        .mediumR(split[5])
+                        .largeR(split[6])
+                        .superR(split[7]).build();
                 fieldObjectList.get(i).set(vo, retentionVO);
 //                field.set(vo, value + "/" + rData);
             } catch (IllegalAccessException e) {
                 throw new RuntimeException(e);
             }
         }
-        stopWatch.stop();
-        log.info("耗时:" + stopWatch.getTotalTimeMillis() + "ms");
         return vo;
     }
 
@@ -784,25 +780,27 @@ public class GameServerServiceImpl implements IGameServerService {
         return cri;
     }
 
-    private String getGSGameServerDateSql() {
+    private String getGSGameServerDateSql(Criteria cri) {
         return """
                 select
                     """ + getRemainDaySql() + """
-                    a.source_system,
-                    a.server_id,
-                    a.server_name,
-                    a.dt,
-                    a.parent_game_id,
-                    a.parent_game_classify,
-                    a.parent_game_name,
-                    a.gs_ids,
-                    a.total_role_num,
-                    a.total_reg_num,
-                    a.total_amount_num
-                    from game_ads_parent.ads_game_server_gs_day_parent a
-                    left join game_dw_parent.dw_game_server_active_role_day_parent e  on a.source_system = e.source_system  and a.server_id =e.server_id and a.parent_game_id=e.parent_game_id and a.dt = e.dt
-                    left join game_dw_parent.dw_game_server_day_parent c  on a.source_system =c.source_system  and a.server_id =c.server_id and a.parent_game_id=c.parent_game_id and a.dt = c.dt
-                    left join game_dw_parent.dw_game_server_active_order_day_parent d on a.source_system = d.source_system  and a.server_id =d.server_id and a.parent_game_id=d.parent_game_id and a.dt = d.dt
+                a.source_system,
+                a.server_id,
+                a.server_name,
+                a.dt,
+                a.parent_game_id,
+                a.parent_game_classify,
+                a.parent_game_name,
+                a.gs_ids,
+                a.total_role_num,
+                a.total_reg_num,
+                a.total_amount_num
+                from game_ads_parent.ads_game_server_gs_day_parent a
+                left join game_dw_parent.dw_game_server_active_role_day_parent e  on a.source_system = e.source_system  and a.server_id =e.server_id and a.parent_game_id=e.parent_game_id and a.dt = e.dt
+                left join game_dw_parent.dw_game_server_day_parent c  on a.source_system =c.source_system  and a.server_id =c.server_id and a.parent_game_id=c.parent_game_id and a.dt = c.dt
+                left join game_dw_parent.dw_game_server_active_order_day_parent d on a.source_system = d.source_system  and a.server_id =d.server_id and a.parent_game_id=d.parent_game_id and a.dt = d.dt
+                """ + cri + """
+                order by a.dt desc
                 """;
     }
 
@@ -827,8 +825,8 @@ public class GameServerServiceImpl implements IGameServerService {
         StringBuilder sql = new StringBuilder(StringUtils.EMPTY);
         for (int i = 1; i <= 90; i++) {
             sql.append("""
-                    concat(ifnull(round(c.da%d_active_num / e.new_da%d_total_num ,4),0),'/',ifnull(round(d.new_da%d_num + d.old_da%d_num / d.new_da%d_total_num,4),0)) as da_str%d,
-                     """.formatted(i, i, i, i, i, i));
+                    concat(ifnull(round(c.da%d_active_num / e.new_da%d_total_num ,4),0),'/',ifnull(round(d.new_da%d_num + d.old_da%d_num / d.new_da%d_total_num,4),0),'/',IFNULL(c.da%d_reg_num,0),'/',IFNULL(c.da%d_num,0)) as da_str%d,
+                     """.formatted(i, i, i, i, i, i, i, i));
 
         }
         return sql.toString();
@@ -841,8 +839,8 @@ public class GameServerServiceImpl implements IGameServerService {
         StringBuilder sql = new StringBuilder(StringUtils.EMPTY);
         for (int i = 1; i <= 90; i++) {
             sql.append("""
-                    concat(ifnull(round(SUM(c.da%d_active_num) / SUM(e.new_da%d_total_num) ,4),0),'/',ifnull(round(SUM(d.new_da%d_num) + SUM(d.old_da%d_num) / SUM(d.new_da%d_total_num),4),0)) as da_str%d,
-                     """.formatted(i, i, i, i, i, i));
+                    concat(ifnull(round(SUM(c.da%d_active_num) / SUM(e.new_da%d_total_num) ,4),0),'/',ifnull(round(SUM(d.new_da%d_num) + SUM(d.old_da%d_num) / SUM(d.new_da%d_total_num),4),0),'/',IFNULL(SUM(c.da%d_reg_num),0),'/',IFNULL(SUM(c.da%d_num),0)) as da_str%d,
+                     """.formatted(i, i, i, i, i, i, i, i));
         }
         return sql.toString();
     }