1
This commit is contained in:
@@ -50,7 +50,6 @@ public class ClientMonitorController extends BaseController {
|
||||
startPage();
|
||||
return getDataTable(clientMonitorService.selectClientEventLogList(clientEventLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端数据采集报告列表
|
||||
*/
|
||||
@@ -108,7 +107,6 @@ public class ClientMonitorController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 客户端错误上报API
|
||||
*/
|
||||
@@ -151,10 +149,6 @@ public class ClientMonitorController extends BaseController {
|
||||
return AjaxResult.success(clientMonitorService.getVersionDistribution());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 清理过期数据
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
@@ -8,7 +7,6 @@ import com.ruoyi.system.mapper.ClientDeviceMapper;
|
||||
import com.ruoyi.web.sse.SseHubService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -42,7 +40,6 @@ public class ClientDeviceController {
|
||||
map.put("used", used);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户名查询设备列表(最近活动优先)
|
||||
* @param username 用户名,必需参数
|
||||
@@ -61,7 +58,7 @@ public class ClientDeviceController {
|
||||
* 设备注册(幂等)
|
||||
*
|
||||
* 根据 deviceId 判断:
|
||||
* - 不存在:插入新记录(后端生成设备名称、IP等信息)
|
||||
* - 不存在:插入新记录(检查设备数量限制)
|
||||
* - 已存在:更新设备信息
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
@@ -70,6 +67,15 @@ public class ClientDeviceController {
|
||||
String ip = IpUtils.getIpAddr(request);
|
||||
String deviceName = request.getHeader("X-Client-User") + "@" + ip + " (" + request.getHeader("X-Client-OS") + ")";
|
||||
if (exists == null) {
|
||||
// 检查设备数量限制
|
||||
List<ClientDevice> userDevices = clientDeviceMapper.selectByUsername(device.getUsername());
|
||||
int activeDeviceCount = 0;
|
||||
for (ClientDevice d : userDevices) {
|
||||
if (!"removed".equals(d.getStatus())) activeDeviceCount++;
|
||||
}
|
||||
if (activeDeviceCount >= DEFAULT_LIMIT) {
|
||||
return AjaxResult.error("设备数量已达上限(" + DEFAULT_LIMIT + "个),请先移除其他设备");
|
||||
}
|
||||
device.setIp(ip);
|
||||
device.setStatus("online");
|
||||
device.setLastActiveAt(new java.util.Date());
|
||||
@@ -153,6 +159,15 @@ public class ClientDeviceController {
|
||||
String ip = IpUtils.getIpAddr(request);
|
||||
String deviceName = request.getHeader("X-Client-User") + "@" + ip + " (" + request.getHeader("X-Client-OS") + ")";
|
||||
if (exists == null) {
|
||||
// 检查设备数量限制
|
||||
List<ClientDevice> userDevices = clientDeviceMapper.selectByUsername(device.getUsername());
|
||||
int activeDeviceCount = 0;
|
||||
for (ClientDevice d : userDevices) {
|
||||
if (!"removed".equals(d.getStatus())) activeDeviceCount++;
|
||||
}
|
||||
if (activeDeviceCount >= DEFAULT_LIMIT) {
|
||||
return AjaxResult.error("设备数量已达上限(" + DEFAULT_LIMIT + "个),请先移除其他设备");
|
||||
}
|
||||
device.setIp(ip);
|
||||
device.setStatus("online");
|
||||
device.setLastActiveAt(new java.util.Date());
|
||||
|
||||
@@ -23,7 +23,7 @@ public class BanmaOrderController extends BaseController {
|
||||
private IBanmaAccountService accountService;
|
||||
|
||||
/**
|
||||
* 查询账号列表(仅返回必要字段)
|
||||
* 查询账号列表(
|
||||
*/
|
||||
@GetMapping("/accounts")
|
||||
public R<?> listAccounts() {
|
||||
@@ -37,7 +37,9 @@ public class BanmaOrderController extends BaseController {
|
||||
@PostMapping("/accounts")
|
||||
public R<?> saveAccount(@RequestBody BanmaAccount body) {
|
||||
Long id = accountService.saveOrUpdate(body);
|
||||
return R.ok(Map.of("id", id));
|
||||
boolean ok = false;
|
||||
try { ok = accountService.refreshToken(id); } catch (Exception ignore) {}
|
||||
return ok ? R.ok(Map.of("id", id)) : R.fail("账号或密码错误,无法获取Token");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,4 +51,18 @@ public class BanmaOrderController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/** 手动刷新单个账号 Token */
|
||||
@PostMapping("/accounts/{id}/refresh-token")
|
||||
public R<?> refreshOne(@PathVariable Long id) {
|
||||
accountService.refreshToken(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/** 手动刷新全部启用账号 Token */
|
||||
@PostMapping("/refresh-all")
|
||||
public R<?> refreshAll() {
|
||||
accountService.refreshAllTokens();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -714,8 +714,8 @@ public class ClientMonitorServiceImpl implements IClientMonitorService {
|
||||
@Override
|
||||
public void cleanExpiredData() {
|
||||
try {
|
||||
// 清理过期的客户端(设置为离线状态)
|
||||
clientMonitorMapper.updateExpiredClientsOffline();
|
||||
// // 清理过期的客户端(设置为离线状态)
|
||||
// clientMonitorMapper.updateExpiredClientsOffline();
|
||||
|
||||
// 清理过期的设备(设置为离线状态)
|
||||
clientMonitorMapper.updateExpiredDevicesOffline();
|
||||
@@ -725,8 +725,6 @@ public class ClientMonitorServiceImpl implements IClientMonitorService {
|
||||
|
||||
// 删除过期的事件日志
|
||||
clientMonitorMapper.deleteExpiredEventLogs();
|
||||
|
||||
logger.info("过期数据清理完成");
|
||||
} catch (Exception e) {
|
||||
logger.error("清理过期数据失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("清理过期数据失败", e);
|
||||
|
||||
Reference in New Issue
Block a user