4 Commits

Author SHA1 Message Date
fcbde4322d 今日报警总数 2025-09-09 16:39:43 +08:00
832234269d 获取设备使用数据 2025-09-09 16:06:34 +08:00
7e87971c0b 新增绑定设备 2025-09-09 15:02:46 +08:00
ebd8668178 在线设备 2025-09-09 11:03:38 +08:00
7 changed files with 83 additions and 36 deletions

View File

@ -61,13 +61,15 @@ public class HomePageController {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceId 设备ID * @param deviceTypeId 设备ID (可选)
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
@GetMapping("/getEquipmentUsageData/{deviceId}/{range}") @GetMapping("/getEquipmentUsageData/{range}")
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) { public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Integer range,
return R.ok(deviceService.getEquipmentUsageData(deviceId, range)); @RequestParam(required = false) Long deviceTypeId) {
return R.ok(deviceService.getEquipmentUsageData(deviceTypeId, range));
} }
} }

View File

@ -21,6 +21,18 @@ public class AlarmInformationVo {
*/ */
private Integer processingAlarm = 0; private Integer processingAlarm = 0;
/**
* 今日报警总数
*/
private Integer alarmsTotalToday = 0;
/**
* 今日总处理报警
*/
private Integer processingAlarmToday = 0;
/** /**
* 强制报警 * 强制报警
*/ */

View File

@ -26,4 +26,24 @@ public class EquipmentClassificationVo {
*/ */
private Integer devices4GAndBluetooth = 0; private Integer devices4GAndBluetooth = 0;
/**
* 设备总数
*/
private Integer total;
/**
* 计算设备总数
*
* @return 设备总数
*/
public Integer getTotal() {
if (total == null) {
total = (equipment4G == null ? 0 : equipment4G) +
(deviceBluetooth == null ? 0 : deviceBluetooth) +
(devices4GAndBluetooth == null ? 0 : devices4GAndBluetooth);
}
return total;
}
} }

View File

@ -99,11 +99,11 @@ public interface DeviceMapper extends BaseMapper<Device> {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceId 设备ID * @param deviceTypeId 设备ID
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range); List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range);
// 在DeviceMapper.java中添加方法 // 在DeviceMapper.java中添加方法
int getUsageDataForMonth(@Param("deviceId") Long deviceId, int getUsageDataForMonth(@Param("deviceId") Long deviceId,

View File

@ -139,9 +139,9 @@ public interface DeviceService extends IService<Device> {
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceId * @param deviceTypeId
* @param range * @param range
* @return * @return
*/ */
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range); List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range);
} }

View File

@ -630,6 +630,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override @Override
public EquipmentClassificationVo getEquipmentClassification() { public EquipmentClassificationVo getEquipmentClassification() {
EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification(); EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification();
equipmentClassification.getTotal();
return equipmentClassification; return equipmentClassification;
} }
@ -648,13 +649,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
/** /**
* 获取设备使用数据 * 获取设备使用数据
* *
* @param deviceId 设备ID * @param deviceTypeId 设备ID
* @param range 时间范围 1:半年 2:一年 * @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表 * @return 每月使用数据列表
*/ */
@Override @Override
public List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range) { public List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range) {
List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceId, range); List<Map<String, Object>> equipmentUsageData = deviceMapper.getEquipmentUsageData(deviceTypeId, range);
return equipmentUsageData; return equipmentUsageData;
} }

View File

@ -321,11 +321,11 @@
<!-- 获取数据总览 --> <!-- 获取数据总览 -->
<select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo"> <select id="getDataOverview" resultType="com.fuyuanshen.equipment.domain.vo.DataOverviewVo">
SELECT (SELECT COUNT(1) FROM device) AS devicesNumber, SELECT (SELECT COUNT(1) FROM device) AS devicesNumber,
(SELECT COUNT(1) FROM device WHERE device_status = 1) AS equipmentOnline, (SELECT COUNT(1) FROM device WHERE online_status = 1) AS equipmentOnline,
(SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE()) AS bindingNew, ( (SELECT COUNT(1) FROM device WHERE DATE (create_time) = CURDATE() AND binding_status = 1 ) AS bindingNew, (
SELECT COUNT (1) SELECT COUNT (1)
FROM device FROM device
WHERE device_status = 2) AS equipmentAbnormal WHERE online_status = 2) AS equipmentAbnormal
</select> </select>
<!-- 获取设备分类 --> <!-- 获取设备分类 -->
@ -347,30 +347,38 @@
<!-- 获取告警信息 --> <!-- 获取告警信息 -->
<select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo"> <select id="getAlarmInformation" resultType="com.fuyuanshen.equipment.domain.vo.AlarmInformationVo">
SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0 AND DATE (create_time) = CURDATE()) AS alarmsTotal, ( SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) AS alarmsTotal
, (SELECT COUNT(1)
FROM device_alarm
WHERE treatment_state = 0) AS processingAlarm
, (SELECT COUNT(1)
FROM device_alarm
WHERE treatment_state = 0 AND
DATE (create_time) = CURDATE()) AS alarmsTotalToday
, (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE treatment_state = 0 WHERE treatment_state = 0
AND DATE (create_time) = CURDATE()) AS processingAlarm AND DATE (create_time) = CURDATE()) AS processingAlarmToday
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 0 WHERE device_action = 0
AND DATE (create_time) = CURDATE()) AS alarmForced ) AS alarmForced
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 1 WHERE device_action = 1
AND DATE (create_time) = CURDATE()) AS intrusionImpact ) AS intrusionImpact
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 2 WHERE device_action = 2
AND DATE (create_time) = CURDATE()) AS alarmManual ) AS alarmManual
, ( , (
SELECT COUNT (1) SELECT COUNT (1)
FROM device_alarm FROM device_alarm
WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic WHERE device_action = 3) AS fenceElectronic
</select> </select>
@ -391,11 +399,15 @@
FROM device_log dl FROM device_log dl
LEFT JOIN device d ON dl.device_id = d.id LEFT JOIN device d ON dl.device_id = d.id
LEFT JOIN device_type dt ON d.device_type = dt.id LEFT JOIN device_type dt ON d.device_type = dt.id
WHERE dt.id = #{deviceId} <where>
<if test="deviceTypeId != null">
dt.id = #{deviceTypeId}
</if>
AND ( AND (
(#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR (#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR
(#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH)) (#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH))
) )
</where>
</select> </select>
<select id="getUsageDataForMonth" resultType="java.lang.Integer"> <select id="getUsageDataForMonth" resultType="java.lang.Integer">