|
@@ -989,6 +989,12 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
criA.getOrderBy().orderBy("a.create_time", dto.getSortType());
|
|
|
} else {
|
|
|
+ if(dto.getSortFiled().equals("ip_role_count_filter")){
|
|
|
+ dto.setSortFiled("role_count_group_filters_count");
|
|
|
+ }
|
|
|
+ if(dto.getSortFiled().equals("role_user_ip_count_filter")){
|
|
|
+ dto.setSortFiled("role_user_group_filters_count");
|
|
|
+ }
|
|
|
criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
}
|
|
|
//列表sql
|
|
@@ -1386,57 +1392,13 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
|
|
|
private String getIpInfoListSql(Criteria criA) {
|
|
|
return """
|
|
|
- WITH
|
|
|
- login_data AS (
|
|
|
- SELECT
|
|
|
- role_id, game_id, user_id, ip
|
|
|
- FROM dm_game_order.t_user_login_log
|
|
|
- WHERE
|
|
|
- game_id IN (35,36,10035)
|
|
|
- AND role_id != 'null'
|
|
|
- AND ip IS NOT NULL AND ip != 'null' AND ip != ''
|
|
|
- ),
|
|
|
- user_role_counts AS (
|
|
|
- SELECT user_id, COUNT(DISTINCT role_id) AS user_role_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY user_id
|
|
|
- ),
|
|
|
- ip_relationships AS (
|
|
|
- SELECT
|
|
|
- a.role_id,
|
|
|
- COUNT(DISTINCT b.user_id) AS user_count,
|
|
|
- COUNT(DISTINCT b.role_id) AS role_count
|
|
|
- FROM login_data a
|
|
|
- LEFT JOIN login_data b ON a.ip = b.ip
|
|
|
- GROUP BY a.role_id
|
|
|
- ),
|
|
|
- role_ip_roles AS (
|
|
|
- SELECT
|
|
|
- r.role_id,
|
|
|
- COUNT(DISTINCT all_roles.role_id) AS role_count
|
|
|
- FROM login_data r
|
|
|
- JOIN login_data all_roles ON r.ip = all_roles.ip
|
|
|
- GROUP BY r.role_id
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SELECT
|
|
|
- a.*,
|
|
|
- GREATEST(e.role_count - urc.user_role_count, 0) AS ip_role_count_filter,
|
|
|
- GREATEST(f.role_count - urc.user_role_count, 0) AS role_user_ip_count_filter,
|
|
|
- game.game_name
|
|
|
- FROM game_ads.role_ip_monitor a
|
|
|
- LEFT JOIN (
|
|
|
- SELECT role_id, game_id, user_id, COUNT(DISTINCT ip) AS ip_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY role_id, game_id, user_id
|
|
|
- ) c ON a.role_id = c.role_id AND a.game_id = c.game_id AND a.user_id = c.user_id
|
|
|
- LEFT JOIN ip_relationships d ON a.role_id = d.role_id
|
|
|
- LEFT JOIN ip_relationships e ON a.role_id = e.role_id
|
|
|
- LEFT JOIN role_ip_roles f ON a.role_id = f.role_id
|
|
|
- LEFT JOIN user_role_counts urc ON a.user_id = urc.user_id
|
|
|
- LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
+ SELECT
|
|
|
+ a.*,
|
|
|
+ a.role_count_group_filters_count as ip_role_count_filter,
|
|
|
+ a.role_user_group_filters_count as role_user_ip_count_filter,
|
|
|
+ game.game_name
|
|
|
+ FROM game_ads.role_ip_monitor a
|
|
|
+ LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
""" + criA;
|
|
|
}
|
|
|
|
|
@@ -1497,62 +1459,15 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
|
|
|
private String getIpInfoListCountSql(Criteria criA) {
|
|
|
return """
|
|
|
- SELECT COUNT(1) FROM (
|
|
|
- WITH
|
|
|
- login_data AS (
|
|
|
- SELECT
|
|
|
- role_id, game_id, user_id, ip
|
|
|
- FROM dm_game_order.t_user_login_log
|
|
|
- WHERE
|
|
|
- game_id IN (35,36,10035)
|
|
|
- AND role_id != 'null'
|
|
|
- AND ip IS NOT NULL AND ip != 'null' AND ip != ''
|
|
|
- ),
|
|
|
- user_role_counts AS (
|
|
|
- SELECT user_id, COUNT(DISTINCT role_id) AS user_role_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY user_id
|
|
|
- ),
|
|
|
- ip_relationships AS (
|
|
|
- SELECT
|
|
|
- a.role_id,
|
|
|
- COUNT(DISTINCT b.user_id) AS user_count,
|
|
|
- COUNT(DISTINCT b.role_id) AS role_count
|
|
|
- FROM login_data a
|
|
|
- LEFT JOIN login_data b ON a.ip = b.ip
|
|
|
- GROUP BY a.role_id
|
|
|
- ),
|
|
|
- role_ip_roles AS (
|
|
|
- SELECT
|
|
|
- r.role_id,
|
|
|
- COUNT(DISTINCT all_roles.role_id) AS role_count
|
|
|
- FROM login_data r
|
|
|
- JOIN login_data all_roles ON r.ip = all_roles.ip
|
|
|
- GROUP BY r.role_id
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SELECT
|
|
|
- a.*,
|
|
|
- GREATEST(e.role_count - urc.user_role_count, 0) AS ip_role_count_filter,
|
|
|
- GREATEST(f.role_count - urc.user_role_count, 0) AS role_user_ip_count_filter,
|
|
|
- game.game_name
|
|
|
- FROM game_ads.role_ip_monitor a
|
|
|
- LEFT JOIN (
|
|
|
- SELECT role_id, game_id, user_id, COUNT(DISTINCT ip) AS ip_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY role_id, game_id, user_id
|
|
|
- ) c ON a.role_id = c.role_id AND a.game_id = c.game_id AND a.user_id = c.user_id
|
|
|
- LEFT JOIN ip_relationships d ON a.role_id = d.role_id
|
|
|
- LEFT JOIN ip_relationships e ON a.role_id = e.role_id
|
|
|
- LEFT JOIN role_ip_roles f ON a.role_id = f.role_id
|
|
|
- LEFT JOIN user_role_counts urc ON a.user_id = urc.user_id
|
|
|
- LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
- """ +
|
|
|
- criA
|
|
|
- + """
|
|
|
- ) a
|
|
|
+ select count(1) from ( SELECT
|
|
|
+ a.*,
|
|
|
+ a.role_count_group_filters_count as ip_role_count_filter,
|
|
|
+ a.role_user_group_filters_count as role_user_ip_count_filter,
|
|
|
+ game.game_name
|
|
|
+ FROM game_ads.role_ip_monitor a
|
|
|
+ LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
+ """+criA+"""
|
|
|
+ ) a
|
|
|
""";
|
|
|
}
|
|
|
|