This commit is contained in:
2025-10-10 10:06:56 +08:00
parent 4fbe51d625
commit 6f22c9bffd
37 changed files with 2176 additions and 1183 deletions

View File

@@ -47,6 +47,10 @@ public class ClientAccount extends BaseEntity
/** 功能权限配置(JSON格式) */
private String permissions;
/** 设备数量限制 */
@Excel(name = "设备数量限制")
private Integer deviceLimit;
public void setId(Long id)
{
this.id = id;
@@ -133,4 +137,14 @@ public class ClientAccount extends BaseEntity
{
return permissions;
}
public void setDeviceLimit(Integer deviceLimit)
{
this.deviceLimit = deviceLimit;
}
public Integer getDeviceLimit()
{
return deviceLimit;
}
}

View File

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="allowedIpRange" column="allowed_ip_range" />
<result property="remark" column="remark" />
<result property="permissions" column="permissions" />
<result property="deviceLimit" column="device_limit" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectClientAccountVo">
select id, account_name, username, password, status, expire_time,
allowed_ip_range, remark, permissions, create_by, create_time, update_by, update_time
allowed_ip_range, remark, permissions, device_limit, create_by, create_time, update_by, update_time
from client_account
</sql>
@@ -57,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="allowedIpRange != null">allowed_ip_range,</if>
<if test="remark != null">remark,</if>
<if test="permissions != null">permissions,</if>
<if test="deviceLimit != null">device_limit,</if>
<if test="createBy != null">create_by,</if>
create_time
</trim>
@@ -69,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="allowedIpRange != null">#{allowedIpRange},</if>
<if test="remark != null">#{remark},</if>
<if test="permissions != null">#{permissions},</if>
<if test="deviceLimit != null">#{deviceLimit},</if>
<if test="createBy != null">#{createBy},</if>
sysdate()
</trim>
@@ -85,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="allowedIpRange != null">allowed_ip_range = #{allowedIpRange},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="permissions != null">permissions = #{permissions},</if>
<if test="deviceLimit != null">device_limit = #{deviceLimit},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate()
</trim>

View File

@@ -166,17 +166,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from client_info where client_id = #{clientId}
</select>
<!-- 查询客户端信息列表 -->
<select id="selectClientInfoList" parameterType="ClientInfo" resultMap="ClientInfoResult">
select * from client_info
select
d.device_id as client_id,
d.username,
d.os as os_name,
d.ip as ip_address,
d.last_active_at as last_active_time,
d.create_time as auth_time,
CASE WHEN d.status = 'online' THEN '1' ELSE '0' END as online,
a.account_name as hostname,
'' as app_version,
'' as os_version,
'' as java_version
from client_device d
left join client_account a on d.username COLLATE utf8mb4_unicode_ci = a.username
<where>
<if test="clientId != null and clientId != ''">AND client_id like concat('%', #{clientId}, '%')</if>
<if test="username != null and username != ''">AND username like concat('%', #{username}, '%')</if>
<if test="osName != null and osName != ''">AND os_name like concat('%', #{osName}, '%')</if>
<if test="status != null and status != ''">AND status = #{status}</if>
<if test="online != null and online != ''">AND online = #{online}</if>
<if test="clientId != null and clientId != ''">AND d.device_id like concat('%', #{clientId}, '%')</if>
<if test="username != null and username != ''">AND d.username like concat('%', #{username}, '%')</if>
<if test="osName != null and osName != ''">AND d.os like concat('%', #{osName}, '%')</if>
<if test="online != null and online != ''">
AND d.status =
<choose>
<when test="online == '1'">
'online'
</when>
<otherwise>
'offline'
</otherwise>
</choose>
</if>
</where>
order by last_active_time desc
order by d.last_active_at desc
</select>
<!-- 查询客户端错误报告列表 -->
@@ -223,14 +244,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by collect_time desc
</select>
<!-- 查询在线客户端数量 -->
<!-- 查询在线客户端数量 - 基于 client_device 表 -->
<select id="selectOnlineClientCount" resultType="int">
select count(*) from client_info where online = '1'
select count(*) from client_device where status = 'online'
</select>
<!-- 查询客户端总数 -->
<!-- 查询客户端总数 - 基于 client_device 表 -->
<select id="selectTotalClientCount" resultType="int">
SELECT COUNT(*) FROM client_info
SELECT COUNT(*) FROM client_device WHERE status != 'removed'
</select>
<!-- 查询今日错误数量 -->
@@ -342,11 +363,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from client_data_report
</sql>
<!-- 查询最近7天的客户端活跃趋势 -->
<!-- 查询最近7天的客户端活跃趋势 - 基于 client_device 表 -->
<select id="selectClientActiveTrend" resultType="map">
SELECT
days.date_str as date,
IFNULL(counts.client_count, 0) as count
IFNULL(counts.device_count, 0) as count
FROM
(
SELECT DATE_FORMAT(CURDATE() - INTERVAL 6 DAY, '%Y-%m-%d') as date_str
@@ -360,15 +381,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN
(
SELECT
DATE_FORMAT(auth_time, '%Y-%m-%d') as auth_date,
COUNT(DISTINCT client_id) as client_count
DATE_FORMAT(create_time, '%Y-%m-%d') as create_date,
COUNT(*) as device_count
FROM
client_info
client_device
WHERE
auth_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
AND status != 'removed'
GROUP BY
DATE_FORMAT(auth_time, '%Y-%m-%d')
) counts ON days.date_str = counts.auth_date
DATE_FORMAT(create_time, '%Y-%m-%d')
) counts ON days.date_str = counts.create_date
ORDER BY
days.date_str ASC
</select>