0
0

大屏数据

This commit is contained in:
2025-09-27 15:30:12 +08:00
parent b7c81419a4
commit 2d59397de5
32 changed files with 1032 additions and 39 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceMapper">
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.Device">
<id column="id" property="id"/>
@ -319,6 +319,32 @@
a.create_time DESC
</select>
<!-- 获取设备总览信息 -->
<select id="getDeviceOverview" resultType="com.fuyuanshen.equipment.domain.vo.DeviceOverviewVo">
SELECT (SELECT COUNT(1) FROM device) AS totalDevices,
(SELECT COUNT(1) FROM device WHERE online_status = 1) AS onlineDevices,
(SELECT COUNT(DISTINCT device_type) FROM device) AS deviceTypes
</select>
<!-- 获取设备通讯方式统计数据 -->
<select id="getDeviceCommunicationModeStatistics" resultType="com.fuyuanshen.equipment.domain.vo.DeviceCommunicationModeStatisticsVo">
SELECT
dt.communication_mode AS communicationModeValue,
CASE
WHEN dt.communication_mode = 0 THEN '4G'
WHEN dt.communication_mode = 1 THEN '蓝牙'
WHEN dt.communication_mode = 2 THEN '4G&amp;蓝牙'
ELSE '未知'
END AS communicationModeName,
COUNT(d.id) AS totalDevices,
COUNT(CASE WHEN d.online_status = 2 THEN 1 END) AS abnormalDevices
FROM device_type dt
LEFT JOIN device d ON dt.id = d.device_type
WHERE dt.communication_mode IN (0, 1, 2)
GROUP BY dt.communication_mode
ORDER BY dt.communication_mode
</select>
<!-- 获取数据总览 -->
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
@ -423,6 +449,17 @@
AND MONTH (dl.create_time) = #{month}
</select>
<!-- 获取设备使用频次统计 -->
<select id="getDeviceUsageFrequency" resultType="com.fuyuanshen.equipment.domain.vo.DeviceUsageFrequencyVo">
SELECT
device_name AS deviceName,
COUNT(*) AS frequency
FROM device_log
WHERE create_time >= DATE_SUB(NOW(), INTERVAL #{days} DAY)
GROUP BY device_name
ORDER BY frequency DESC
</select>
<!-- 根据设备IMEI查询设备 -->
<select id="selectDeviceByImei" resultType="com.fuyuanshen.equipment.domain.Device">
SELECT *