|  | @@ -7,27 +7,30 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 |  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 |  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.erp.base.ErpServer;
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.erp.base.rpc.ISysUserRpc;
 | 
											
												
													
														|  |  import com.zanxiang.erp.security.util.SecurityUtil;
 |  |  import com.zanxiang.erp.security.util.SecurityUtil;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
 |  |  import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.game.module.manage.enums.GameServerAssignEnum;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.enums.GameServerExcelEnum;
 |  |  import com.zanxiang.game.module.manage.enums.GameServerExcelEnum;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
 |  |  import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.dto.GameServerExcelDTO;
 |  |  import com.zanxiang.game.module.manage.pojo.dto.GameServerExcelDTO;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.params.GameMergeServerParam;
 |  |  import com.zanxiang.game.module.manage.pojo.params.GameMergeServerParam;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.params.GameServerAddUpdateParam;
 |  |  import com.zanxiang.game.module.manage.pojo.params.GameServerAddUpdateParam;
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.game.module.manage.pojo.params.GameServerAssignParam;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.params.GameServerListParam;
 |  |  import com.zanxiang.game.module.manage.pojo.params.GameServerListParam;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.vo.GameServerListVO;
 |  |  import com.zanxiang.game.module.manage.pojo.vo.GameServerListVO;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.manage.pojo.vo.GameServerVO;
 |  |  import com.zanxiang.game.module.manage.pojo.vo.GameServerVO;
 | 
											
												
													
														|  | -import com.zanxiang.game.module.manage.service.IGameAuthService;
 |  | 
 | 
											
												
													
														|  | -import com.zanxiang.game.module.manage.service.IGameServerService;
 |  | 
 | 
											
												
													
														|  | -import com.zanxiang.game.module.manage.service.IGameService;
 |  | 
 | 
											
												
													
														|  | -import com.zanxiang.game.module.manage.service.IGameSupperService;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.game.module.manage.service.*;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.mybatis.entity.GameServer;
 |  |  import com.zanxiang.game.module.mybatis.entity.GameServer;
 | 
											
												
													
														|  | 
 |  | +import com.zanxiang.game.module.mybatis.entity.GameServerAssignLog;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.mybatis.entity.GameSupper;
 |  |  import com.zanxiang.game.module.mybatis.entity.GameSupper;
 | 
											
												
													
														|  |  import com.zanxiang.game.module.mybatis.mapper.GameServerMapper;
 |  |  import com.zanxiang.game.module.mybatis.mapper.GameServerMapper;
 | 
											
												
													
														|  |  import com.zanxiang.module.util.bean.BeanUtil;
 |  |  import com.zanxiang.module.util.bean.BeanUtil;
 | 
											
												
													
														|  |  import com.zanxiang.module.util.excel.ExcelUtil;
 |  |  import com.zanxiang.module.util.excel.ExcelUtil;
 | 
											
												
													
														|  |  import com.zanxiang.module.util.exception.BaseException;
 |  |  import com.zanxiang.module.util.exception.BaseException;
 | 
											
												
													
														|  |  import lombok.extern.slf4j.Slf4j;
 |  |  import lombok.extern.slf4j.Slf4j;
 | 
											
												
													
														|  | 
 |  | +import org.apache.dubbo.config.annotation.DubboReference;
 | 
											
												
													
														|  |  import org.apache.logging.log4j.util.Strings;
 |  |  import org.apache.logging.log4j.util.Strings;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
										
											
												
													
														|  | @@ -51,6 +54,9 @@ import java.util.stream.Collectors;
 | 
											
												
													
														|  |  @Service
 |  |  @Service
 | 
											
												
													
														|  |  public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameServer> implements IGameServerService {
 |  |  public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameServer> implements IGameServerService {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
 | 
											
												
													
														|  | 
 |  | +    private ISysUserRpc sysUserRpc;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private IGameService gameService;
 |  |      private IGameService gameService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -60,6 +66,54 @@ public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameSer
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private IGameSupperService gameSupperService;
 |  |      private IGameSupperService gameSupperService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private IGameServerAssignLogService gameServerAssignLogService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    @Transactional(rollbackFor = Exception.class)
 | 
											
												
													
														|  | 
 |  | +    public Boolean gameServerAssignBatch(GameServerAssignParam param) {
 | 
											
												
													
														|  | 
 |  | +        List<GameServer> gameServerList = super.listByIds(param.getIdList());
 | 
											
												
													
														|  | 
 |  | +        if (CollectionUtils.isEmpty(gameServerList)) {
 | 
											
												
													
														|  | 
 |  | +            throw new BaseException("参数错误, 区服信息不存在");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        gameServerList.forEach(gameServer -> this.gameServerAssign(param, gameServer));
 | 
											
												
													
														|  | 
 |  | +        return Boolean.TRUE;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void gameServerAssign(GameServerAssignParam param, GameServer gameServer) {
 | 
											
												
													
														|  | 
 |  | +        //老的指派人员id
 | 
											
												
													
														|  | 
 |  | +        String oldUserIds = null;
 | 
											
												
													
														|  | 
 |  | +        if (Objects.equals(param.getAssignType(), GameServerAssignEnum.GAME_SERVER_ASSIGN_GS)) {
 | 
											
												
													
														|  | 
 |  | +            oldUserIds = gameServer.getGsIds();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        if (Objects.equals(param.getAssignType(), GameServerAssignEnum.GAME_SERVER_ASSIGN_CUSTOMER)) {
 | 
											
												
													
														|  | 
 |  | +            oldUserIds = gameServer.getCustomerIds();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        //新的指派人员id
 | 
											
												
													
														|  | 
 |  | +        String userIds = null;
 | 
											
												
													
														|  | 
 |  | +        if (CollectionUtils.isNotEmpty(param.getAssignUserIdList())) {
 | 
											
												
													
														|  | 
 |  | +            List<String> collect = param.getAssignUserIdList().stream()
 | 
											
												
													
														|  | 
 |  | +                    .map(String::valueOf).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +            userIds = String.join(",", collect);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        //更新区服信息
 | 
											
												
													
														|  | 
 |  | +        super.update(new LambdaUpdateWrapper<GameServer>()
 | 
											
												
													
														|  | 
 |  | +                .eq(GameServer::getId, gameServer.getId())
 | 
											
												
													
														|  | 
 |  | +                .set(Objects.equals(param.getAssignType(), GameServerAssignEnum.GAME_SERVER_ASSIGN_GS),
 | 
											
												
													
														|  | 
 |  | +                        GameServer::getGsIds, userIds)
 | 
											
												
													
														|  | 
 |  | +                .set(Objects.equals(param.getAssignType(), GameServerAssignEnum.GAME_SERVER_ASSIGN_CUSTOMER),
 | 
											
												
													
														|  | 
 |  | +                        GameServer::getCustomerIds, userIds));
 | 
											
												
													
														|  | 
 |  | +        //新增保存指派记录
 | 
											
												
													
														|  | 
 |  | +        gameServerAssignLogService.save(GameServerAssignLog.builder()
 | 
											
												
													
														|  | 
 |  | +                .serverId(gameServer.getServerId())
 | 
											
												
													
														|  | 
 |  | +                .assignType(param.getAssignType().getValue())
 | 
											
												
													
														|  | 
 |  | +                .oldUserIds(oldUserIds)
 | 
											
												
													
														|  | 
 |  | +                .newUserIds(userIds)
 | 
											
												
													
														|  | 
 |  | +                .createBy(SecurityUtil.getUserId())
 | 
											
												
													
														|  | 
 |  | +                .createTime(LocalDateTime.now())
 | 
											
												
													
														|  | 
 |  | +                .build());
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public Boolean gameServerExcelImport(MultipartFile multipartFile, GameServerExcelEnum gameServerExcelEnum, Long gameId) {
 |  |      public Boolean gameServerExcelImport(MultipartFile multipartFile, GameServerExcelEnum gameServerExcelEnum, Long gameId) {
 | 
											
												
													
														|  |          StringBuilder stringBuilder = new StringBuilder();
 |  |          StringBuilder stringBuilder = new StringBuilder();
 | 
											
										
											
												
													
														|  | @@ -282,39 +336,68 @@ public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameSer
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          //合服子服列表
 |  |          //合服子服列表
 | 
											
												
													
														|  |          if (sonServerIdArray != null) {
 |  |          if (sonServerIdArray != null) {
 | 
											
												
													
														|  | -            List<GameServerListVO.ServerBean> sonServerList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -            for (String sonServerId : sonServerIdArray) {
 |  | 
 | 
											
												
													
														|  | -                GameServer sonServer = gameServerMap.get(sonServerId);
 |  | 
 | 
											
												
													
														|  | -                if (sonServer == null) {
 |  | 
 | 
											
												
													
														|  | -                    continue;
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                sonServerList.add(GameServerListVO.ServerBean.builder()
 |  | 
 | 
											
												
													
														|  | -                        .serverId(sonServerId)
 |  | 
 | 
											
												
													
														|  | -                        .serverName(sonServer.getServerName())
 |  | 
 | 
											
												
													
														|  | -                        .build());
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            gameServerListVO.setSonServerList(sonServerList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            gameServerListVO.setSonServerList(this.getSonServerList(sonServerIdArray, gameServerMap));
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          //合服原始服列表
 |  |          //合服原始服列表
 | 
											
												
													
														|  |          if (sourceServerIdArray != null) {
 |  |          if (sourceServerIdArray != null) {
 | 
											
												
													
														|  | -            List<Integer> sourceServerIdList = Arrays.stream(sourceServerIdArray)
 |  | 
 | 
											
												
													
														|  | -                    .map(Integer::parseInt)
 |  | 
 | 
											
												
													
														|  | -                    .sorted().collect(Collectors.toList());
 |  | 
 | 
											
												
													
														|  | -            List<GameServerListVO.ServerBean> sourceServerList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | -            for (Integer sourceServerId : sourceServerIdList) {
 |  | 
 | 
											
												
													
														|  | -                GameServer sourceServer = gameServerMap.get(sourceServerId.toString());
 |  | 
 | 
											
												
													
														|  | -                if (sourceServer != null) {
 |  | 
 | 
											
												
													
														|  | -                    sourceServerList.add(GameServerListVO.ServerBean.builder()
 |  | 
 | 
											
												
													
														|  | -                            .serverId(sourceServerId.toString())
 |  | 
 | 
											
												
													
														|  | -                            .serverName(sourceServer.getServerName())
 |  | 
 | 
											
												
													
														|  | -                            .build());
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            gameServerListVO.setSourceServerList(sourceServerList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            gameServerListVO.setSourceServerList(this.getSourceServerList(sourceServerIdArray, gameServerMap));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        //指派客服
 | 
											
												
													
														|  | 
 |  | +        if (Strings.isNotBlank(gameServer.getCustomerIds())) {
 | 
											
												
													
														|  | 
 |  | +            gameServerListVO.setCustomerList(this.getUserBeanList(gameServer.getCustomerIds()));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        //指派GS
 | 
											
												
													
														|  | 
 |  | +        if (Strings.isNotBlank(gameServer.getGsIds())) {
 | 
											
												
													
														|  | 
 |  | +            gameServerListVO.setGsList(this.getUserBeanList(gameServer.getGsIds()));
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return gameServerListVO;
 |  |          return gameServerListVO;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    private List<GameServerListVO.ServerBean> getSonServerList(String[] sonServerIdArray, Map<String, GameServer> gameServerMap) {
 | 
											
												
													
														|  | 
 |  | +        List<GameServerListVO.ServerBean> sonServerList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        for (String sonServerId : sonServerIdArray) {
 | 
											
												
													
														|  | 
 |  | +            GameServer sonServer = gameServerMap.get(sonServerId);
 | 
											
												
													
														|  | 
 |  | +            if (sonServer == null) {
 | 
											
												
													
														|  | 
 |  | +                continue;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            sonServerList.add(GameServerListVO.ServerBean.builder()
 | 
											
												
													
														|  | 
 |  | +                    .serverId(sonServerId)
 | 
											
												
													
														|  | 
 |  | +                    .serverName(sonServer.getServerName())
 | 
											
												
													
														|  | 
 |  | +                    .build());
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return sonServerList;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private List<GameServerListVO.ServerBean> getSourceServerList(String[] sourceServerIdArray, Map<String, GameServer> gameServerMap) {
 | 
											
												
													
														|  | 
 |  | +        List<Integer> sourceServerIdList = Arrays.stream(sourceServerIdArray)
 | 
											
												
													
														|  | 
 |  | +                .map(Integer::parseInt)
 | 
											
												
													
														|  | 
 |  | +                .sorted().collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +        List<GameServerListVO.ServerBean> sourceServerList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        sourceServerIdList.forEach(sourceServerId -> {
 | 
											
												
													
														|  | 
 |  | +            GameServer sourceServer = gameServerMap.get(sourceServerId.toString());
 | 
											
												
													
														|  | 
 |  | +            if (sourceServer == null) {
 | 
											
												
													
														|  | 
 |  | +                return;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            sourceServerList.add(GameServerListVO.ServerBean.builder()
 | 
											
												
													
														|  | 
 |  | +                    .serverId(sourceServerId.toString())
 | 
											
												
													
														|  | 
 |  | +                    .serverName(sourceServer.getServerName())
 | 
											
												
													
														|  | 
 |  | +                    .build());
 | 
											
												
													
														|  | 
 |  | +        });
 | 
											
												
													
														|  | 
 |  | +        return sourceServerList;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private List<GameServerListVO.UserBean> getUserBeanList(String userIds) {
 | 
											
												
													
														|  | 
 |  | +        List<GameServerListVO.UserBean> userList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        List<Long> userIdList = Arrays.stream(userIds.split(","))
 | 
											
												
													
														|  | 
 |  | +                .map(Long::valueOf).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +        Map<Long, String> userNameMap = sysUserRpc.getUserNameByIds(userIdList).getData();
 | 
											
												
													
														|  | 
 |  | +        userIdList.forEach(userId -> userList.add(GameServerListVO.UserBean.builder()
 | 
											
												
													
														|  | 
 |  | +                .userId(userId)
 | 
											
												
													
														|  | 
 |  | +                .userName(userNameMap.get(userId))
 | 
											
												
													
														|  | 
 |  | +                .build()));
 | 
											
												
													
														|  | 
 |  | +        return userList;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public Boolean mergeServerAddUpdate(GameMergeServerParam param) {
 |  |      public Boolean mergeServerAddUpdate(GameMergeServerParam param) {
 | 
											
												
													
														|  |          List<GameServer> gameServerList = super.list(new LambdaQueryWrapper<GameServer>()
 |  |          List<GameServer> gameServerList = super.list(new LambdaQueryWrapper<GameServer>()
 |