123
This commit is contained in:
1 parent
d4b1bc60b1
commit
36e5ab3308
8 files changed
+1024
-7
No files matched your search
@@ -0,0 +1,91 @@
|
||||
package com.ruoyi.system.service;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
/**
|
||||
* 玩家配置Service接口
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2026-05-10
|
||||
*/
|
||||
public interface IDmPlayerConfigService extends IService<DmPlayerConfigPlus>
|
||||
{
|
||||
|
||||
List<SelectItem> select(String keyword);
|
||||
/**
|
||||
* 查询玩家配置
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 玩家配置
|
||||
*/
|
||||
public DmPlayerConfig selectDmPlayerConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询玩家配置列表
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 玩家配置集合
|
||||
*/
|
||||
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig);
|
||||
|
||||
/**
|
||||
* 新增玩家配置
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
|
||||
|
||||
/**
|
||||
* 修改玩家配置
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
|
||||
|
||||
/**
|
||||
* 批量删除玩家配置
|
||||
*
|
||||
* @param ids 需要删除的玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDmPlayerConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除玩家配置信息
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDmPlayerConfigById(Long id);
|
||||
|
||||
List<DmPlayerConfigPlus> getByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns);
|
||||
|
||||
DmPlayerConfigPlus getById(Long id, SFunction<DmPlayerConfigPlus, ?>... columns);
|
||||
|
||||
Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns);
|
||||
|
||||
List<DmPlayerConfigPlus> getByIds(List<Long> ids);
|
||||
|
||||
Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids);
|
||||
|
||||
|
||||
Map<Long, DmPlayerConfigPlus> getMapByPlayerIds(List<Long> ids);
|
||||
/**
|
||||
* @param field sum 字段
|
||||
* @param where 条件
|
||||
* @param tClass 返回类型
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> T sum(String field, String where, Class<T> tClass);
|
||||
|
||||
Long count(String where);
|
||||
|
||||
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.luqj.util.HttpHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.DmPlayerConfigMapper;
|
||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
import com.ruoyi.system.service.IDmPlayerConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
/**
|
||||
* 玩家配置Service业务层处理
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2026-05-10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper, DmPlayerConfigPlus> implements IDmPlayerConfigService
|
||||
{
|
||||
@Autowired
|
||||
private DmPlayerConfigMapper dmPlayerConfigMapper;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
private HttpHelper httpHelper = new HttpHelper();
|
||||
@Value("${dm.server.ip:192.168.3.103}")
|
||||
private String serverIp;
|
||||
@Value("${dm.server.port:8080}")
|
||||
private Integer serverPort;
|
||||
@Override
|
||||
public List<DmPlayerConfigPlus> getByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.select(columns).in(DmPlayerConfigPlus::getId, ids);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
@Override
|
||||
public List<SelectItem> select(String keyword) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.select(DmPlayerConfigPlus::getId, DmPlayerConfigPlus::getPlayerId)
|
||||
.like(DmPlayerConfigPlus::getPlayerId, keyword);
|
||||
List<DmPlayerConfigPlus> list = this.list(lambdaQueryWrapper);
|
||||
List<SelectItem> result =new ArrayList<>();
|
||||
for (DmPlayerConfigPlus item : list){
|
||||
SelectItem selectItem = new SelectItem();
|
||||
selectItem.setName(item.getPlayerId()+"");
|
||||
selectItem.setId(item.getId());
|
||||
result.add(selectItem);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public DmPlayerConfigPlus getById(Long id, SFunction<DmPlayerConfigPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.select(columns).eq(DmPlayerConfigPlus::getId, id);
|
||||
return baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns) {
|
||||
List<DmPlayerConfigPlus> list = this.getByIds(ids, columns);
|
||||
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
|
||||
for (DmPlayerConfigPlus item : list) {
|
||||
map.put(item.getId(), item);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids) {
|
||||
List<DmPlayerConfigPlus> list = this.getByIds(ids);
|
||||
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
|
||||
for (DmPlayerConfigPlus item : list) {
|
||||
map.put(item.getId(), item);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, DmPlayerConfigPlus> getMapByPlayerIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.in(DmPlayerConfigPlus::getPlayerId, ids);
|
||||
List<DmPlayerConfigPlus> list = this.list(lambdaQueryWrapper);
|
||||
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
|
||||
for (DmPlayerConfigPlus item : list) {
|
||||
map.put(item.getId(), item);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public List<DmPlayerConfigPlus> getByIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>().in(DmPlayerConfigPlus::getId, ids);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
public <T> T sum(String field, String where, Class<T> tClass) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(" sum(" + field + ") as total ");
|
||||
stringBuffer.append(" from dm_player_config ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
T result = jdbcTemplate.queryForObject(stringBuffer.toString(), tClass);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Long count(String where) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(" count(1)");
|
||||
stringBuffer.append(" from ");
|
||||
stringBuffer.append(" dm_player_config ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
Long result = jdbcTemplate.queryForObject(stringBuffer.toString(), Long.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
public <T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(select);
|
||||
stringBuffer.append(" from ");
|
||||
stringBuffer.append(" dm_player_config ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
stringBuffer.append(" group by ");
|
||||
stringBuffer.append(groupby);
|
||||
List result = jdbcTemplate.queryForList(stringBuffer.toString());
|
||||
List<T> tList = JSONArray.parseArray(JSONArray.toJSONString(result), tClass);
|
||||
return tList;
|
||||
}
|
||||
/**
|
||||
* 查询玩家配置
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 玩家配置
|
||||
*/
|
||||
@Override
|
||||
public DmPlayerConfig selectDmPlayerConfigById(Long id)
|
||||
{
|
||||
return dmPlayerConfigMapper.selectDmPlayerConfigById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询玩家配置列表
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 玩家配置
|
||||
*/
|
||||
@Override
|
||||
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
return dmPlayerConfigMapper.selectDmPlayerConfigList(dmPlayerConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增玩家配置
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
dmPlayerConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return dmPlayerConfigMapper.insertDmPlayerConfig(dmPlayerConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改玩家配置
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
dmPlayerConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
int resutl= dmPlayerConfigMapper.updateDmPlayerConfig(dmPlayerConfig);
|
||||
if(resutl > 0){
|
||||
try {
|
||||
String result = httpHelper.getlHttpResult("http://" + this.serverIp + ":" + serverPort + "?cmd=8¶ms=" + URLEncoder.encode(JSONObject.toJSONString(dmPlayerConfig), "utf-8")
|
||||
, "get", new HashMap<>(), new HashMap<>());
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getString("code").equals("1")) {
|
||||
log.info("配置同步成功");
|
||||
}else{
|
||||
log.error("配置同步失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return resutl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除玩家配置
|
||||
*
|
||||
* @param ids 需要删除的玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDmPlayerConfigByIds(Long[] ids)
|
||||
{
|
||||
return dmPlayerConfigMapper.deleteDmPlayerConfigByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除玩家配置信息
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDmPlayerConfigById(Long id)
|
||||
{
|
||||
return dmPlayerConfigMapper.deleteDmPlayerConfigById(id);
|
||||
}
|
||||
}
|
||||
+40
-7
@@ -10,20 +10,20 @@ import com.ruoyi.common.select.SelectItem;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.DmOperateVo;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
import com.ruoyi.system.domain.DmPlayerent;
|
||||
import com.ruoyi.system.domain.DmPlayerentPlus;
|
||||
import com.ruoyi.system.mapper.DmPlayerentMapper;
|
||||
import com.ruoyi.system.service.IDmPlayerConfigService;
|
||||
import com.ruoyi.system.service.IDmPlayerentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 大漠代理Service业务层处理
|
||||
@@ -36,6 +36,9 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
private HttpHelper httpHelper = new HttpHelper();
|
||||
@Autowired
|
||||
private DmPlayerentMapper dmPlayerentMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IDmPlayerConfigService playerConfigService;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
@Value("${dm.server.ip:192.168.3.103}")
|
||||
@@ -162,7 +165,37 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
*/
|
||||
@Override
|
||||
public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) {
|
||||
return dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
|
||||
List<DmPlayerent> list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (DmPlayerent playerent : list) {
|
||||
ids.add(playerent.getId());
|
||||
}
|
||||
if (!ids.isEmpty()) {
|
||||
Map<Long, DmPlayerConfigPlus> map = playerConfigService.getMapByPlayerIds(ids);
|
||||
List<DmPlayerConfigPlus> saveList = new ArrayList<>();
|
||||
for (DmPlayerent playerent : list) {
|
||||
if (!map.containsKey(playerent.getId())) {
|
||||
DmPlayerConfigPlus playerConfigPlus = new DmPlayerConfigPlus();
|
||||
playerConfigPlus.setPlayerId(playerent.getId());
|
||||
playerConfigPlus.setAutoAddMana(0);
|
||||
playerConfigPlus.setAddManaThreshold(10);
|
||||
playerConfigPlus.setCreateTime(new Date());
|
||||
playerConfigPlus.setYoloHeight(160);
|
||||
playerConfigPlus.setYoloWidth(100);
|
||||
playerConfigPlus.setCustomParams("");
|
||||
playerConfigPlus.setUpdateTime(new Date());
|
||||
playerConfigPlus.setFixedDirection(0);
|
||||
playerConfigPlus.setShoutInterval(12000);
|
||||
playerConfigPlus.setShoutMana(55);
|
||||
playerConfigPlus.setShoutKey(69);
|
||||
saveList.add(playerConfigPlus);
|
||||
}
|
||||
}
|
||||
if (!saveList.isEmpty()) {
|
||||
this.playerConfigService.saveBatch(saveList);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,10 +213,10 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
@Override
|
||||
public boolean operate(DmOperateVo vo) {
|
||||
DmPlayerent dmPlayerent = this.dmPlayerentMapper.selectDmPlayerentById(Long.parseLong(vo.getPlayerId()));
|
||||
if(dmPlayerent == null){
|
||||
if (dmPlayerent == null) {
|
||||
throw new RuntimeException("找不到对象");
|
||||
}
|
||||
if(dmPlayerent.getOnlineStatus().equals("0")){
|
||||
if (dmPlayerent.getOnlineStatus().equals("0")) {
|
||||
throw new RuntimeException("设备离线");
|
||||
}
|
||||
JSONObject params = new JSONObject();
|
||||
|
||||
Reference in new issue
Block a user