|
@@ -1,13 +1,12 @@
|
|
|
package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
-
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.zanxiang.erp.base.ErpServer;
|
|
|
import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.*;
|
|
|
import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.RoleGameCountryVO;
|
|
|
import com.zanxiang.game.data.serve.service.IRoleManageService;
|
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
|
import com.zanxiang.game.module.base.ServerInfo;
|
|
@@ -18,7 +17,6 @@ import com.zanxiang.game.module.base.pojo.vo.SendMsgResultVO;
|
|
|
import com.zanxiang.game.module.base.pojo.vo.SendMsgVO;
|
|
|
import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
|
|
|
import com.zanxiang.game.module.base.util.PageUtil;
|
|
|
-import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -938,7 +936,7 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
dao.execute(sql);
|
|
|
//查询结果
|
|
|
List<Map> list = sql.getList(Map.class);
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
List<String> keys = Arrays.asList("pitcherId", "operUserId", "gsId", "customerServiceId");
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
for (Map map : list) {
|
|
@@ -967,21 +965,491 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
return new Page<>(list, pager);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<Map> ipInfoListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
+ //创建查询条件
|
|
|
+ Criteria criA = getSqlByQuery(dto);
|
|
|
+ //分页对象
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //查询总记录数
|
|
|
+ Sql countSql = Sqls.create(getIpInfoListCountSql(criA));
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ //主表添加排序条件
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ criA.getOrderBy().orderBy("a.create_time", dto.getSortType());
|
|
|
+ } else {
|
|
|
+ criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
+ }
|
|
|
+ //列表sql
|
|
|
+ String ipInfoListSql = getIpInfoListSql(criA);
|
|
|
+ Sql sql = Sqls.create(ipInfoListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ sql.setPager(pager);
|
|
|
+ dao.execute(sql);
|
|
|
+ //查询结果
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return new Page<>(list, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, List<RoleGameCountryVO>> gameCountryDataList(GameCountryParamDTO dto) {
|
|
|
+ //创建查询条件
|
|
|
+ Criteria criA = getSqlByQuery(dto);
|
|
|
+ String gameCountryListSql = getGameCountryListSql(criA);
|
|
|
+ Sql sql1 = Sqls.create(gameCountryListSql);
|
|
|
+ dao.execute(sql1);
|
|
|
+ sql1.setCallback(Sqls.callback.entities());
|
|
|
+ sql1.setEntity(dao.getEntity(RoleGameCountryVO.class));
|
|
|
+ dao.execute(sql1);
|
|
|
+ //查询结果
|
|
|
+ List<RoleGameCountryVO> list = sql1.getList(RoleGameCountryVO.class);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ //以country为key,value是list分组
|
|
|
+ Map<String, List<RoleGameCountryVO>> map = list.stream().collect(Collectors.groupingBy(RoleGameCountryVO::getCs));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map> gameCountryRoleList(RoleGameCountryParamDTO dto) {
|
|
|
+ Criteria criA = getSqlByQuery(dto);
|
|
|
+ //分页对象
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //查询总记录数
|
|
|
+ Sql countSql = Sqls.create(getGameCountryRoleCountSql(criA));
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ //主表添加排序条件
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ criA.getOrderBy().orderBy("role_total_amount", dto.getSortType());
|
|
|
+ } else {
|
|
|
+ criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
+ }
|
|
|
+ //列表sql
|
|
|
+ String gameCountryRoleListSql = getGameCountryRoleListSql(criA);
|
|
|
+ Sql sql = Sqls.create(gameCountryRoleListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ sql.setPager(pager);
|
|
|
+ dao.execute(sql);
|
|
|
+ //查询结果
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return new Page<>(list, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map> gameCountryList(GameCountryParamDTO dto) {
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getServerId())) {
|
|
|
+ cri.where().andInStrList("server_id", dto.getServerId());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getGameId())) {
|
|
|
+ cri.where().andInList("parent_game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ String countryListSql = getCountryListSql(cri);
|
|
|
+ Sql sql = Sqls.create(countryListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ dao.execute(sql);
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
+ if (dto.getRoleId() == null) {
|
|
|
+ throw new BaseException("角色id不能为空");
|
|
|
+ }
|
|
|
+ Criteria criteria = Cnd.cri();
|
|
|
+ criteria.where().andEquals("role_id", dto.getRoleId());
|
|
|
+
|
|
|
+ //分页对象
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //查询总记录数
|
|
|
+ Sql countSql = Sqls.create(getRoleIpDetailListCountSql(criteria));
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ String roleIpDetailListSql = getRoleIpDetailListSql(criteria);
|
|
|
+ Sql sql = Sqls.create(roleIpDetailListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ sql.setPager(pager);
|
|
|
+ dao.execute(sql);
|
|
|
+ //查询结果
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return new Page<>(list, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map> roleDetailListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
+ Criteria criteria = getRoleDetailSqlByQuery(dto);
|
|
|
+ //分页对象
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //查询总记录数
|
|
|
+ Sql countSql = Sqls.create(getRoleDetailCountSql(criteria));
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ String roleIpDetailListSql = getRoleDetailList(criteria);
|
|
|
+ Sql sql = Sqls.create(roleIpDetailListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ sql.setPager(pager);
|
|
|
+ dao.execute(sql);
|
|
|
+ //查询结果
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return new Page<>(list, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRoleDetailCountSql(Criteria criteria) {
|
|
|
+ return """
|
|
|
+ select count(1) from ( select role_id roleId ,any_value(role_name) roleNmae,game_id gameId,any_value(game_name) gameName,ip,server_id serverId,any_value(server_name) serverName,user_id userId,any_value(user_name) userName from game_ads.role_ip_monitor
|
|
|
+ """ + criteria + """
|
|
|
+ group by role_id,game_id,ip,server_id,user_id)a
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRoleDetailList(Criteria criteria) {
|
|
|
+ return """
|
|
|
+ select role_id roleId ,any_value(role_name) roleNmae,game_id gameId,any_value(game_name) gameName,ip,server_id serverId,any_value(server_name) serverName,user_id userId,any_value(user_name) userName from game_ads.role_ip_monitor
|
|
|
+ """ + criteria + """
|
|
|
+ group by role_id,game_id,ip,server_id,user_id
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getRoleDetailSqlByQuery(RoleIpInfoParamDTO dto) {
|
|
|
+ Criteria criteria = Cnd.cri();
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRegIp())) {
|
|
|
+ criteria.where().andEquals("ip", dto.getRegIp());
|
|
|
+ }
|
|
|
+ return criteria;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRoleIpDetailListCountSql(Criteria criteria) {
|
|
|
+ return """
|
|
|
+ select count(1) from (select distinct a.ip,(select count(distinct role_id) from dm_game_order.t_user_login_log where ip = a.ip) from dm_game_order.t_user_login_log a
|
|
|
+ """
|
|
|
+ + criteria +
|
|
|
+ """
|
|
|
+ ) a
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ipRoleCount 同ip的角色数量
|
|
|
+ */
|
|
|
+ private String getRoleIpDetailListSql(Criteria criteria) {
|
|
|
+ return """
|
|
|
+ select distinct a.ip,(select count(distinct role_id) from dm_game_order.t_user_login_log where ip = a.ip) as ipRoleCount from dm_game_order.t_user_login_log a
|
|
|
+ """ + criteria;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCountryListSql(Criteria criteria) {
|
|
|
+ return """
|
|
|
+ select country,server_id as serverId,parent_name as gameName,server_name as serverName,parent_game_id as gameId from dm_game_order.t_server_country
|
|
|
+ """ + criteria;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getGameCountryRoleListSql(Criteria criA) {
|
|
|
+ return """
|
|
|
+ select a.country as country,a.role_id as roleId,user_id as userId ,role_name as roleName ,role_level as roleLevel ,combat_num as combatNum,
|
|
|
+ server_id as serverId ,server_name as serverName ,create_time as createTime,IFNULL(b.role_total_amount,0) as roleTotalAmount
|
|
|
+ from dm_game_order.t_game_user_role a
|
|
|
+ left join game_ads.ads_role_amount b on a.role_id = b.role_id
|
|
|
+ """ + criA;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getGameCountryRoleCountSql(Criteria criA) {
|
|
|
+ return """
|
|
|
+ select count(1) from ( select a.country as country,a.role_id as roleId,user_id as userId ,role_name as roleName ,role_level as roleLevel ,combat_num as combatNum,
|
|
|
+ server_id as serverId ,server_name as serverName ,create_time as createTime,IFNULL(b.role_total_amount,0) as roleTotalAmount
|
|
|
+ from dm_game_order.t_game_user_role a
|
|
|
+ left join game_ads.ads_role_amount b on a.role_id = b.role_id) a
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getSqlByQuery(RoleGameCountryParamDTO dto) {
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if (StringUtils.isNotEmpty(dto.getCountry())) {
|
|
|
+ cri.where().andEquals("country", dto.getCountry());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getServerId())) {
|
|
|
+ cri.where().andEquals("server_id", dto.getServerId());
|
|
|
+ }
|
|
|
+ cri.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
|
|
|
+ return cri;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getSqlByQuery(GameCountryParamDTO dto) {
|
|
|
+ Criteria criA = Cnd.cri();
|
|
|
+ //如果帮派为空就取4个帮派
|
|
|
+ if (CollectionUtils.isEmpty(dto.getGameCountryList())) {
|
|
|
+ String countryListSql = getCountryDataListSql(dto);
|
|
|
+ Sql sql = Sqls.create(countryListSql);
|
|
|
+ sql.setCallback(Sqls.callback.strList());
|
|
|
+ dao.execute(sql);
|
|
|
+ List<String> list = sql.getList(String.class);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ criA.where().andInStrList("cs", list);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ criA.where().andInStrList("cs", dto.getGameCountryList());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getGameId())) {
|
|
|
+ criA.where().andInList("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getServerId())) {
|
|
|
+ criA.where().andInStrList("server_id", dto.getServerId());
|
|
|
+ }
|
|
|
+ return criA;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getGameCountryListSql(Criteria criA) {
|
|
|
+ return """
|
|
|
+ select country,
|
|
|
+ country_level,
|
|
|
+ sum(role_total_amount) as role_total_amount,
|
|
|
+ count(1) as role_count,
|
|
|
+ sum(active) as active_count,
|
|
|
+ server_id,
|
|
|
+ ANY_VALUE(cs) cs,
|
|
|
+ ANY_VALUE(game_id) gameId,
|
|
|
+ ANY_VALUE(server_name) serverName
|
|
|
+ from (select a.country,
|
|
|
+ a.game_id,
|
|
|
+ a.server_name,
|
|
|
+ IFNULL(c.role_total_amount, 0) as role_total_amount,
|
|
|
+ if(b.role_level <= 13, 1, 0) as country_level,
|
|
|
+ if(d.role_id is not null, 1, 0) as active,
|
|
|
+ a.server_id,
|
|
|
+ concat(a.country,',',a.server_id) as cs
|
|
|
+ from dm_game_order.t_server_country a
|
|
|
+ left join dm_game_order.t_game_user_role b on a.country = b.country and a.server_id = b.server_id
|
|
|
+ left join game_ads.ads_role_amount c on c.role_id = b.role_id
|
|
|
+ left join (
|
|
|
+ select role_id,ROW_NUMBER()over(partition by role_id) as num from game_dw.dw_active_log
|
|
|
+ where game_id in (35,36,10035)
|
|
|
+ and dt = Date(NOW()) ) d on b.role_id = d.role_id and d.num = 1
|
|
|
+ ) a
|
|
|
+ """ + criA + """
|
|
|
+ group by country_level,country,server_id order by role_count desc
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCountryDataListSql(GameCountryParamDTO dto) {
|
|
|
+ Criteria criA = Cnd.cri();
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getGameId())) {
|
|
|
+ criA.where().andInList("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getServerId())) {
|
|
|
+ criA.where().andInStrList("server_id", dto.getServerId());
|
|
|
+ }
|
|
|
+ criA.where().andNotIsNull("country");
|
|
|
+ criA.where().andNotEquals("country", "");
|
|
|
+ criA.where().andNotEquals("country", "null");
|
|
|
+ criA.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
|
|
|
+ return """
|
|
|
+ select concat(country,',',server_id)
|
|
|
+ from dm_game_order.t_game_user_role
|
|
|
+ """ + criA + """
|
|
|
+ group by country,server_id order by count(role_id) desc limit 4
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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'
|
|
|
+ """ + criA;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getSqlByQuery(RoleIpInfoParamDTO dto) {
|
|
|
+ Criteria criA = Cnd.cri();
|
|
|
+ if (dto.getUserId() != null) {
|
|
|
+ //玩家id
|
|
|
+ criA.where().andEquals("a.user_id", dto.getUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getUserName())) {
|
|
|
+ //玩家名称
|
|
|
+ criA.where().andLike("a.user_name", dto.getUserName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getServerName())) {
|
|
|
+ //区服名称
|
|
|
+ criA.where().andLike("a.server_name", dto.getServerName());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getServerId())) {
|
|
|
+ //区服id
|
|
|
+ criA.where().andInStrList("a.server_id", dto.getServerId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getGameName())) {
|
|
|
+ //游戏名称
|
|
|
+ criA.where().andLike("a.game_name", dto.getGameName());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getGameId())) {
|
|
|
+ //游戏id
|
|
|
+ criA.where().andInList("a.game_id", dto.getGameId());
|
|
|
+ } else {
|
|
|
+ //游戏id
|
|
|
+ criA.where().andInList("a.game_id", Arrays.asList(35L, 36L, 10035L));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRoleId())) {
|
|
|
+ //角色id
|
|
|
+ criA.where().andEquals("a.role_id", dto.getRoleId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRoleName())) {
|
|
|
+ //角色名称
|
|
|
+ criA.where().andLike("a.role_name", dto.getRoleName());
|
|
|
+ }
|
|
|
+ //角色等级区间筛选
|
|
|
+ if (dto.getRoleLevelMin() != null) {
|
|
|
+ criA.where().andGTE("a.role_level", dto.getRoleLevelMin());
|
|
|
+ }
|
|
|
+ if (dto.getRoleLevelMax() != null) {
|
|
|
+ criA.where().andLTE("a.role_level", dto.getRoleLevelMax());
|
|
|
+ }
|
|
|
+ //角色创建时间
|
|
|
+ if (dto.getCreateTimeMin() != null && dto.getCreateTimeMax() != null) {
|
|
|
+ criA.where().andBetween("a.create_time", dto.getCreateTimeMin().atTime(LocalTime.MIN), dto.getCreateTimeMax().atTime(LocalTime.MAX));
|
|
|
+ }
|
|
|
+ //注册ip
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRegIp())) {
|
|
|
+ criA.where().andEquals("a.ip", dto.getRegIp());
|
|
|
+ }
|
|
|
+ return criA;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
private Criteria getSqlByQuery(RoleLevelParamDTO dto) {
|
|
|
Criteria criA = Cnd.cri();
|
|
|
- if(dto.getGsId()!=null){
|
|
|
+ if (dto.getGsId() != null) {
|
|
|
//gsId
|
|
|
criA.where().andEquals("b.gs_id", dto.getGsId());
|
|
|
}
|
|
|
- if(dto.getPitcherId()!=null){
|
|
|
+ if (dto.getPitcherId() != null) {
|
|
|
//投手id
|
|
|
criA.where().andEquals("c.pitcher_id", dto.getPitcherId());
|
|
|
}
|
|
|
- if(dto.getCustomerServiceId()!=null){
|
|
|
+ if (dto.getCustomerServiceId() != null) {
|
|
|
//客服id
|
|
|
criA.where().andEquals("b.customer_service_id", dto.getCustomerServiceId());
|
|
|
}
|
|
|
- if(dto.getOperUserId()!=null){
|
|
|
+ if (dto.getOperUserId() != null) {
|
|
|
//运营id
|
|
|
criA.where().andEquals("b.oper_user_id", dto.getOperUserId());
|
|
|
}
|