2
0

feat: add client and cdr interface

This commit is contained in:
caiyuchao
2024-12-17 14:49:04 +08:00
parent e61648bc98
commit bd2897437f
17 changed files with 254 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
cdr.user_id id,
min( ch.start_time ) start_time,
max( cdr.last_seen_time ) end_time,
max( cdr.activity ) activity,
sum(
ifnull( cdr.up_time, 0 ))+ sum(
ifnull( ch.duration, 0 )) duration,
@@ -72,4 +73,36 @@
AND c.client_mac = like concat('%', #{client.clientMac}, '%')
</if>
</select>
<select id="getHistoryByUser" resultType="org.wfc.user.domain.vo.UCdrHistoryUserVo">
SELECT
cdr.client_id id,
c.client_name,
c.client_mac,
c.client_device_type,
min( ch.start_time ) start_time,
max( ch.end_time ) end_time,
sum(
ifnull( ch.duration, 0 )) duration,
sum(
ifnull( ch.traffic_down, 0 )) traffic_down,
sum(
ifnull( ch.traffic_up, 0 )) traffic_up
FROM
u_cdr cdr
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
AND ch.del_flag = 0
LEFT JOIN u_client c ON cdr.client_id = c.id
AND c.del_flag = 0
WHERE
cdr.del_flag = 0
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>
GROUP BY
cdr.user_id,
cdr.client_id
ORDER BY
min( ch.start_time ) DESC
</select>
</mapper>

View File

@@ -2,4 +2,53 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.wfc.user.mapper.UClientMapper">
<select id="getCurrentClients" resultType="org.wfc.user.domain.vo.UClientCurrentVo">
SELECT
c.id,
c.client_mac,
c.client_name,
c.client_device_type,
cdr.traffic_up,
cdr.traffic_down,
cdr.up_time,
cdr.activity
FROM
u_cdr cdr
LEFT JOIN ( SELECT ch.cdr_id, max( ch.end_time ) end_time FROM u_cdr_history ch WHERE ch.del_flag = 0 GROUP BY ch.cdr_id ) ch ON cdr.id = ch.cdr_id
LEFT JOIN u_client c ON cdr.client_id = c.id
AND c.del_flag = 0
WHERE
cdr.del_flag = 0
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>
AND cdr.last_seen_time > ch.end_time
</select>
<select id="getHistoryByUser" resultType="org.wfc.user.domain.vo.UClientHistoryUserVo">
SELECT
cdr.client_id id,
c.client_name,
c.client_mac,
c.client_device_type,
ch.start_time,
ch.end_time,
ifnull( ch.duration, 0 ) duration,
ifnull( ch.traffic_down, 0 ) traffic_down,
ifnull( ch.traffic_up, 0 ) traffic_up
FROM
u_cdr cdr
LEFT JOIN u_cdr_history ch ON cdr.id = ch.cdr_id
AND ch.del_flag = 0
LEFT JOIN u_client c ON cdr.client_id = c.id
AND c.del_flag = 0
WHERE
cdr.del_flag = 0
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>
ORDER BY
ch.start_time DESC
</select>
</mapper>

View File

@@ -75,6 +75,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="email != null and email != ''">
AND u.email like concat('%', #{email}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>