forked from dyf/fys-Multi-tenant
大屏数据
This commit is contained in:
@ -90,6 +90,8 @@ public class BjqAlarmRule implements MqttMessageRule {
|
|||||||
deviceAlarmBo.setDurationTime(durationBetween);
|
deviceAlarmBo.setDurationTime(durationBetween);
|
||||||
// 0已处理,1未处理
|
// 0已处理,1未处理
|
||||||
deviceAlarmBo.setTreatmentState(0);
|
deviceAlarmBo.setTreatmentState(0);
|
||||||
|
// 告警状态,0 解除告警, 1 告警中
|
||||||
|
deviceAlarmBo.setAlarmState(0);
|
||||||
deviceAlarmService.updateByBo(deviceAlarmBo);
|
deviceAlarmService.updateByBo(deviceAlarmBo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,6 +109,8 @@ public class BjqAlarmRule implements MqttMessageRule {
|
|||||||
deviceAlarmBo.setStartTime(new Date());
|
deviceAlarmBo.setStartTime(new Date());
|
||||||
// 0已处理,1未处理
|
// 0已处理,1未处理
|
||||||
deviceAlarmBo.setTreatmentState(1);
|
deviceAlarmBo.setTreatmentState(1);
|
||||||
|
// 告警状态,0 解除告警, 1 告警中
|
||||||
|
deviceAlarmBo.setAlarmState(1);
|
||||||
|
|
||||||
// LoginUser loginUser = LoginHelper.getLoginUser();
|
// LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
// deviceAlarmBo.setCreateBy(loginUser.getUserId());
|
// deviceAlarmBo.setCreateBy(loginUser.getUserId());
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import com.fuyuanshen.common.core.constant.GlobalConstants;
|
|||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil;
|
import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil;
|
||||||
import com.fuyuanshen.equipment.utils.map.LngLonUtil;
|
import com.fuyuanshen.equipment.utils.map.LngLonUtil;
|
||||||
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
||||||
@ -36,8 +38,9 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVIC
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BjqLocationDataRule implements MqttMessageRule {
|
public class BjqLocationDataRule implements MqttMessageRule {
|
||||||
|
|
||||||
private final MqttGateway mqttGateway;
|
private final MqttGateway mqttGateway;
|
||||||
|
private final DeviceService deviceService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,6 +59,8 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
|
|
||||||
// 异步发送经纬度到Redis
|
// 异步发送经纬度到Redis
|
||||||
asyncSendLocationToRedisWithFuture(context.getDeviceImei(), latitude, longitude);
|
asyncSendLocationToRedisWithFuture(context.getDeviceImei(), latitude, longitude);
|
||||||
|
// 异步保存数据
|
||||||
|
asyncSaveLocationToMySQLWithFuture(context.getDeviceImei(), latitude, longitude);
|
||||||
|
|
||||||
Map<String, Object> map = buildLocationDataMap(latitude, longitude);
|
Map<String, Object> map = buildLocationDataMap(latitude, longitude);
|
||||||
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map));
|
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map));
|
||||||
@ -114,13 +119,13 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
public void asyncSendLocationToRedisWithFuture(String deviceImei, String latitude, String longitude) {
|
public void asyncSendLocationToRedisWithFuture(String deviceImei, String latitude, String longitude) {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
if(StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)){
|
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// String[] latArr = latitude.split("\\.");
|
// String[] latArr = latitude.split("\\.");
|
||||||
// String[] lonArr = longitude.split("\\.");
|
// String[] lonArr = longitude.split("\\.");
|
||||||
// // 将位置信息存储到Redis中
|
// // 将位置信息存储到Redis中
|
||||||
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX;
|
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + deviceImei + DEVICE_LOCATION_KEY_PREFIX;
|
||||||
// String redisObj = RedisUtils.getCacheObject(redisKey);
|
// String redisObj = RedisUtils.getCacheObject(redisKey);
|
||||||
// JSONObject jsonOBj = JSONObject.parseObject(redisObj);
|
// JSONObject jsonOBj = JSONObject.parseObject(redisObj);
|
||||||
// if(jsonOBj != null){
|
// if(jsonOBj != null){
|
||||||
@ -153,7 +158,6 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
locationInfo.put("timestamp", System.currentTimeMillis());
|
locationInfo.put("timestamp", System.currentTimeMillis());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String locationJson = JsonUtils.toJsonString(locationInfo);
|
String locationJson = JsonUtils.toJsonString(locationInfo);
|
||||||
|
|
||||||
// 存储到Redis
|
// 存储到Redis
|
||||||
@ -171,12 +175,38 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步保存位置信息到MySQL数据库
|
||||||
|
*
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @param longitude 经度
|
||||||
|
*/
|
||||||
|
public void asyncSaveLocationToMySQLWithFuture(String deviceImei, String latitude, String longitude) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
if (StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用服务层方法更新设备位置信息
|
||||||
|
deviceService.updateDeviceLocationByImei(deviceImei, longitude, latitude);
|
||||||
|
|
||||||
|
log.info("位置信息已异步保存到MySQL: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("异步保存位置信息到MySQL时出错: device={}, error={}", deviceImei, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储设备30天历史轨迹到Redis (使用Sorted Set)
|
* 存储设备30天历史轨迹到Redis (使用Sorted Set)
|
||||||
*/
|
*/
|
||||||
public void storeDeviceTrajectoryWithSortedSet(String deviceImei, String locationJson) {
|
public void storeDeviceTrajectoryWithSortedSet(String deviceImei, String locationJson) {
|
||||||
try {
|
try {
|
||||||
String trajectoryKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + deviceImei + DeviceRedisKeyConstants.DEVICE_LOCATION_HISTORY_KEY_PREFIX;
|
String trajectoryKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + deviceImei + DeviceRedisKeyConstants.DEVICE_LOCATION_HISTORY_KEY_PREFIX;
|
||||||
// String trajectoryKey = "device:trajectory:zset:" + deviceImei;
|
// String trajectoryKey = "device:trajectory:zset:" + deviceImei;
|
||||||
// String locationJson = JsonUtils.toJsonString(locationInfo);
|
// String locationJson = JsonUtils.toJsonString(locationInfo);
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
@ -194,20 +224,20 @@ public class BjqLocationDataRule implements MqttMessageRule {
|
|||||||
log.error("存储设备轨迹到Redis(ZSet)失败: device={}, error={}", deviceImei, e.getMessage(), e);
|
log.error("存储设备轨迹到Redis(ZSet)失败: device={}, error={}", deviceImei, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> buildLocationDataMap(String latitude, String longitude) {
|
private Map<String, Object> buildLocationDataMap(String latitude, String longitude) {
|
||||||
String[] latArr = latitude.split("\\.");
|
String[] latArr = latitude.split("\\.");
|
||||||
String[] lonArr = longitude.split("\\.");
|
String[] lonArr = longitude.split("\\.");
|
||||||
|
|
||||||
ArrayList<Integer> intData = new ArrayList<>();
|
ArrayList<Integer> intData = new ArrayList<>();
|
||||||
intData.add(11);
|
intData.add(11);
|
||||||
intData.add(Integer.parseInt(latArr[0]));
|
intData.add(Integer.parseInt(latArr[0]));
|
||||||
String str1 = latArr[1];
|
String str1 = latArr[1];
|
||||||
intData.add(Integer.parseInt(str1.substring(0,4)));
|
intData.add(Integer.parseInt(str1.substring(0, 4)));
|
||||||
String str2 = lonArr[1];
|
String str2 = lonArr[1];
|
||||||
intData.add(Integer.parseInt(lonArr[0]));
|
intData.add(Integer.parseInt(lonArr[0]));
|
||||||
intData.add(Integer.parseInt(str2.substring(0,4)));
|
intData.add(Integer.parseInt(str2.substring(0, 4)));
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("instruct", intData);
|
map.put("instruct", intData);
|
||||||
return map;
|
return map;
|
||||||
|
|||||||
@ -0,0 +1,142 @@
|
|||||||
|
package com.fuyuanshen.web.controller;
|
||||||
|
|
||||||
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.*;
|
||||||
|
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
|
||||||
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
|
import com.fuyuanshen.equipment.service.IWeatherService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大屏数据
|
||||||
|
*
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-27 08:42
|
||||||
|
*/
|
||||||
|
@Tag(name = "大屏数据", description = "大屏数据")
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/largeScreen")
|
||||||
|
public class LargeScreenController {
|
||||||
|
|
||||||
|
private final IDeviceAlarmService deviceAlarmService;
|
||||||
|
private final DeviceService deviceService;
|
||||||
|
private final IWeatherService weatherService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备总览信息
|
||||||
|
* 包含设备总数、在线设备数量、设备型号数量
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceOverview")
|
||||||
|
public R<DeviceOverviewVo> getDeviceOverview() {
|
||||||
|
return R.ok(deviceService.getDeviceOverview());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 实时报警信息
|
||||||
|
* RealtimeAlarm
|
||||||
|
*/
|
||||||
|
@GetMapping("/getRealtimeAlarm")
|
||||||
|
public R<List<DeviceAlarmVo>> getRealtimeAlarm() {
|
||||||
|
return R.ok(deviceAlarmService.getRealtimeAlarm());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报警统计数据
|
||||||
|
* 包括正在报警数量、报警总数、已处理报警数量
|
||||||
|
*/
|
||||||
|
@GetMapping("/getAlarmStatistics")
|
||||||
|
public R<AlarmStatisticsVo> getAlarmStatistics() {
|
||||||
|
return R.ok(deviceAlarmService.getAlarmStatistics());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近一年每月告警统计数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/getMonthlyAlarmStatistics")
|
||||||
|
public R<MonthlyAlarmStatisticsVo> getMonthlyAlarmStatistics() {
|
||||||
|
return R.ok(deviceAlarmService.getMonthlyAlarmStatistics());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备通讯方式统计数据
|
||||||
|
* 包含通讯方式名称、设备总数、异常设备数
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceCommunicationModeStatistics")
|
||||||
|
public R<List<DeviceCommunicationModeStatisticsVo>> getDeviceCommunicationModeStatistics() {
|
||||||
|
return R.ok(deviceService.getDeviceCommunicationModeStatistics());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备使用频次统计数据
|
||||||
|
*
|
||||||
|
* @param days 天数(近一个月传30,近半年传180)
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceUsageFrequency")
|
||||||
|
public R<List<DeviceUsageFrequencyVo>> getDeviceUsageFrequency(@RequestParam int days) {
|
||||||
|
return R.ok(deviceService.getDeviceUsageFrequency(days));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询设备位置信息
|
||||||
|
*
|
||||||
|
* @param groupId 设备分组ID
|
||||||
|
* @param deviceType 设备类型
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @return 设备位置信息列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceLocationInfo")
|
||||||
|
public R<List<DeviceLocationVo>> getDeviceLocationInfo(
|
||||||
|
@RequestParam(required = false) Long groupId,
|
||||||
|
@RequestParam(required = false) Long deviceType,
|
||||||
|
@RequestParam(required = false) String deviceImei) {
|
||||||
|
return R.ok(deviceService.getDeviceLocationInfo(groupId, deviceType, deviceImei));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据经纬度获取天气信息
|
||||||
|
*
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @param longitude 经度
|
||||||
|
* @return 天气信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/weather")
|
||||||
|
public R<WeatherInfoVo> getWeatherInfo(
|
||||||
|
@RequestParam Double latitude,
|
||||||
|
@RequestParam Double longitude) {
|
||||||
|
if (latitude == null || longitude == null) {
|
||||||
|
return R.fail("经纬度参数不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 简单的经纬度范围校验
|
||||||
|
if (latitude < -90 || latitude > 90 || longitude < -180 || longitude > 180) {
|
||||||
|
return R.fail("经纬度参数范围不正确");
|
||||||
|
}
|
||||||
|
|
||||||
|
WeatherInfoVo weatherInfo = weatherService.getWeatherByCoordinates(latitude, longitude);
|
||||||
|
if (weatherInfo != null) {
|
||||||
|
return R.ok(weatherInfo);
|
||||||
|
} else {
|
||||||
|
return R.fail("获取天气信息失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -49,7 +49,7 @@ public class APPDeviceType extends TenantEntity {
|
|||||||
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
|
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||||
private String networkWay;
|
private String networkWay;
|
||||||
|
|
||||||
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
@Schema(name = "通讯方式", example = "通讯方式 0:4G;1:蓝牙,2 4G&蓝牙")
|
||||||
private String communicationMode;
|
private String communicationMode;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,9 @@ public class AppDeviceBindRecord extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private Date bindingTime;
|
private Date bindingTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
|
||||||
|
*/
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class APPDeviceQueryCriteria {
|
|||||||
@Schema(name = "租户ID")
|
@Schema(name = "租户ID")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
@Schema(name = "通讯方式", example = "通讯方式 0:4G;1:蓝牙,2 4G&蓝牙")
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,9 @@ public class APPDeviceTypeVo {
|
|||||||
|
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
|
||||||
|
*/
|
||||||
private String communicationMode;
|
private String communicationMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class AppDeviceDetailVo {
|
|||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通讯方式 0:4G;1:蓝牙
|
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
|
||||||
*/
|
*/
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class AppDeviceShareDetailVo implements Serializable {
|
|||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通讯方式 0:4G;1:蓝牙
|
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
|
||||||
*/
|
*/
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
|
|||||||
@ -114,5 +114,9 @@ public class DeviceAlarmBo extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer treatmentState;
|
private Integer treatmentState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警状态,0 解除告警, 1 告警中
|
||||||
|
*/
|
||||||
|
private Integer alarmState;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,57 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警统计信息
|
||||||
|
*
|
||||||
|
* @author: fuyuanshen
|
||||||
|
* @date: 2025-09-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlarmStatisticsVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正在报警数量(未处理的报警)
|
||||||
|
*/
|
||||||
|
private Integer activeAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警总数
|
||||||
|
*/
|
||||||
|
private Integer totalAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已处理报警数量
|
||||||
|
*/
|
||||||
|
private Integer processedAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制报警数量
|
||||||
|
* device_action = 0
|
||||||
|
*/
|
||||||
|
private Integer forcedAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撞击闯入报警数量
|
||||||
|
* device_action = 1
|
||||||
|
*/
|
||||||
|
private Integer intrusionImpactAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动报警数量
|
||||||
|
* device_action = 2
|
||||||
|
*/
|
||||||
|
private Integer manualAlarms = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏告警数量
|
||||||
|
* device_action = 3
|
||||||
|
*/
|
||||||
|
private Integer geoFenceAlarms = 0;
|
||||||
|
|
||||||
|
}
|
||||||
@ -123,6 +123,7 @@ public class DeviceAlarmVo implements Serializable {
|
|||||||
private String durationTime;
|
private String durationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 处理状态
|
||||||
* 0已处理,1未处理
|
* 0已处理,1未处理
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "0已处理,1未处理")
|
@ExcelProperty(value = "0已处理,1未处理")
|
||||||
@ -135,5 +136,4 @@ public class DeviceAlarmVo implements Serializable {
|
|||||||
@Schema(name = "设备图片")
|
@Schema(name = "设备图片")
|
||||||
private String devicePic;
|
private String devicePic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备通讯方式统计Vo
|
||||||
|
*
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceCommunicationModeStatisticsVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式名称
|
||||||
|
* 0:4G;1:蓝牙;2:4G&蓝牙
|
||||||
|
*/
|
||||||
|
private String communicationModeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式值
|
||||||
|
* 0:4G;1:蓝牙;2:4G&蓝牙
|
||||||
|
*/
|
||||||
|
private Integer communicationModeValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备总数
|
||||||
|
*/
|
||||||
|
private Integer totalDevices = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常设备数
|
||||||
|
*/
|
||||||
|
private Integer abnormalDevices = 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceGeoFence;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.FenceCheckResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备位置信息VO
|
||||||
|
*
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-2714:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "设备位置信息VO")
|
||||||
|
public class DeviceLocationVo {
|
||||||
|
|
||||||
|
@Schema(description = "设备ID")
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
@Schema(description = "设备名称")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@Schema(description = "设备是否在电子围栏内")
|
||||||
|
private Boolean inFence;
|
||||||
|
|
||||||
|
@Schema(description = "进入的电子围栏信息")
|
||||||
|
private DeviceGeoFence fenceInfo;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备总览信息
|
||||||
|
*
|
||||||
|
* @author: fuyuanshen
|
||||||
|
* @date: 2025-09-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceOverviewVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备总数
|
||||||
|
*/
|
||||||
|
private Integer totalDevices = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线设备数量
|
||||||
|
*/
|
||||||
|
private Integer onlineDevices = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备型号数量
|
||||||
|
*/
|
||||||
|
private Integer deviceTypes = 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备使用频次统计Vo
|
||||||
|
*
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceUsageFrequencyVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用频次
|
||||||
|
*/
|
||||||
|
private Integer frequency = 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每月告警统计信息
|
||||||
|
*
|
||||||
|
* @author: fuyuanshen
|
||||||
|
* @date: 2025-09-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MonthlyAlarmStatisticsVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每月告警统计数据
|
||||||
|
* key: 月份 (m1-m12)
|
||||||
|
* value: 告警数量
|
||||||
|
*/
|
||||||
|
private Map<String, Integer> monthlyStatistics = new HashMap<>();
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**天气信息视图对象
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-2715:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "天气信息视图对象")
|
||||||
|
public class WeatherInfoVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纬度
|
||||||
|
*/
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private Double latitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天气状况
|
||||||
|
*/
|
||||||
|
@Schema(description = "天气状况")
|
||||||
|
private String weatherCondition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天气描述
|
||||||
|
*/
|
||||||
|
@Schema(description = "天气描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 温度
|
||||||
|
*/
|
||||||
|
@Schema(description = "温度(摄氏度)")
|
||||||
|
private Double temperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 体感温度
|
||||||
|
*/
|
||||||
|
@Schema(description = "体感温度(摄氏度)")
|
||||||
|
private Double feelsLike;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 湿度
|
||||||
|
*/
|
||||||
|
@Schema(description = "湿度(%)")
|
||||||
|
private Integer humidity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 气压
|
||||||
|
*/
|
||||||
|
@Schema(description = "气压(hPa)")
|
||||||
|
private Double pressure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 能见度
|
||||||
|
*/
|
||||||
|
@Schema(description = "能见度(米)")
|
||||||
|
private Integer visibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风速
|
||||||
|
*/
|
||||||
|
@Schema(description = "风速(m/s)")
|
||||||
|
private Double windSpeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风向
|
||||||
|
*/
|
||||||
|
@Schema(description = "风向(度)")
|
||||||
|
private Integer windDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云量
|
||||||
|
*/
|
||||||
|
@Schema(description = "云量(%)")
|
||||||
|
private Integer cloudiness;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@Schema(description = "数据更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@ -4,10 +4,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.AlarmStatisticsVo;
|
||||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.MonthlyAlarmStatisticsVo;
|
||||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备告警Mapper接口
|
* 设备告警Mapper接口
|
||||||
*
|
*
|
||||||
@ -23,7 +29,7 @@ public interface DeviceAlarmMapper extends BaseMapperPlus<DeviceAlarm, DeviceAla
|
|||||||
* @param bo 设备告警
|
* @param bo 设备告警
|
||||||
* @return 设备告警
|
* @return 设备告警
|
||||||
*/
|
*/
|
||||||
Page<DeviceAlarmVo> selectVoPage( Page pageQuery,@Param("bo") DeviceAlarmBo bo);
|
Page<DeviceAlarmVo> selectVoPage(Page pageQuery, @Param("bo") DeviceAlarmBo bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备IMEI查询最新的一条告警数据
|
* 根据设备IMEI查询最新的一条告警数据
|
||||||
@ -34,4 +40,25 @@ public interface DeviceAlarmMapper extends BaseMapperPlus<DeviceAlarm, DeviceAla
|
|||||||
DeviceAlarmVo selectLatestByDeviceImei(@Param("deviceImei") String deviceImei);
|
DeviceAlarmVo selectLatestByDeviceImei(@Param("deviceImei") String deviceImei);
|
||||||
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 获取实时告警列表
|
||||||
|
*
|
||||||
|
* @return 设备告警列表
|
||||||
|
*/
|
||||||
|
List<DeviceAlarmVo> getRealtimeAlarm();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报警统计数据
|
||||||
|
*
|
||||||
|
* @return 报警统计数据
|
||||||
|
*/
|
||||||
|
AlarmStatisticsVo getAlarmStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近一年每月告警统计数据
|
||||||
|
*
|
||||||
|
* @return 每月告警统计数据
|
||||||
|
*/
|
||||||
|
@MapKey("key")
|
||||||
|
List<Map<String, Object>> getMonthlyAlarmStatistics();
|
||||||
|
}
|
||||||
@ -40,4 +40,13 @@ public interface DeviceFenceAccessRecordMapper extends BaseMapperPlus<DeviceFenc
|
|||||||
Page<DeviceFenceAccessRecordVo> selectVoPageByXml(Page<DeviceFenceAccessRecord> page, @Param("bo") DeviceFenceAccessRecordBo bo);
|
Page<DeviceFenceAccessRecordVo> selectVoPageByXml(Page<DeviceFenceAccessRecord> page, @Param("bo") DeviceFenceAccessRecordBo bo);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备最新的围栏记录
|
||||||
|
*
|
||||||
|
* @param deviceId 设备ID
|
||||||
|
* @return 围栏记录
|
||||||
|
*/
|
||||||
|
DeviceFenceAccessRecordVo selectLatestRecordByDeviceId(String deviceId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,6 +105,9 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range);
|
List<Map<String, Object>> getEquipmentUsageData(@Param("deviceTypeId") Long deviceTypeId, @Param("range") Integer range);
|
||||||
|
|
||||||
|
// 在DeviceMapper.java中添加方法
|
||||||
|
DeviceOverviewVo getDeviceOverview();
|
||||||
|
|
||||||
// 在DeviceMapper.java中添加方法
|
// 在DeviceMapper.java中添加方法
|
||||||
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
|
||||||
@Param("year") int year,
|
@Param("year") int year,
|
||||||
@ -117,4 +120,19 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
* @return 设备信息
|
* @return 设备信息
|
||||||
*/
|
*/
|
||||||
Device selectDeviceByImei(@Param("deviceImei") String deviceImei);
|
Device selectDeviceByImei(@Param("deviceImei") String deviceImei);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备通讯方式统计数据
|
||||||
|
*
|
||||||
|
* @return 通讯方式统计列表
|
||||||
|
*/
|
||||||
|
List<DeviceCommunicationModeStatisticsVo> getDeviceCommunicationModeStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备使用频次统计
|
||||||
|
*
|
||||||
|
* @param days 天数
|
||||||
|
* @return 设备使用频次统计列表
|
||||||
|
*/
|
||||||
|
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(@Param("days") int days);
|
||||||
}
|
}
|
||||||
@ -1,11 +1,13 @@
|
|||||||
package com.fuyuanshen.equipment.service;
|
package com.fuyuanshen.equipment.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Dict;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
@ -152,4 +154,49 @@ public interface DeviceService extends IService<Device> {
|
|||||||
* @return 设备信息
|
* @return 设备信息
|
||||||
*/
|
*/
|
||||||
Device selectDeviceByImei(String deviceImei);
|
Device selectDeviceByImei(String deviceImei);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备总览数据
|
||||||
|
*
|
||||||
|
* @return 设备总览数据
|
||||||
|
*/
|
||||||
|
DeviceOverviewVo getDeviceOverview();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备通讯方式统计数据
|
||||||
|
*
|
||||||
|
* @return 通讯方式统计数据列表
|
||||||
|
*/
|
||||||
|
List<DeviceCommunicationModeStatisticsVo> getDeviceCommunicationModeStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备使用频次统计
|
||||||
|
*
|
||||||
|
* @param days 天数(近一个月: 30, 近半年: 180)
|
||||||
|
* @return 设备使用频次统计列表
|
||||||
|
*/
|
||||||
|
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(int days);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备IMEI更新设备的经纬度信息
|
||||||
|
*
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @param longitude 经度
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
boolean updateDeviceLocationByImei(String deviceImei, String longitude, String latitude);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询设备位置信息
|
||||||
|
*
|
||||||
|
* @param groupId 设备分组ID
|
||||||
|
* @param deviceType 设备类型
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @return 设备位置信息列表
|
||||||
|
*/
|
||||||
|
List<DeviceLocationVo> getDeviceLocationInfo(Long groupId, Long deviceType, String deviceImei);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,12 +1,15 @@
|
|||||||
package com.fuyuanshen.equipment.service;
|
package com.fuyuanshen.equipment.service;
|
||||||
|
|
||||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.AlarmStatisticsVo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.MonthlyAlarmStatisticsVo;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备告警Service接口
|
* 设备告警Service接口
|
||||||
@ -75,4 +78,24 @@ public interface IDeviceAlarmService {
|
|||||||
DeviceAlarmVo queryLatestByDeviceImei(String deviceImei);
|
DeviceAlarmVo queryLatestByDeviceImei(String deviceImei);
|
||||||
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 获取实时告警列表
|
||||||
|
*
|
||||||
|
* @return 设备告警列表
|
||||||
|
*/
|
||||||
|
List<DeviceAlarmVo> getRealtimeAlarm();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报警统计数据
|
||||||
|
*
|
||||||
|
* @return 报警统计数据
|
||||||
|
*/
|
||||||
|
AlarmStatisticsVo getAlarmStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近一年每月告警统计数据
|
||||||
|
*
|
||||||
|
* @return 每月告警统计数据
|
||||||
|
*/
|
||||||
|
MonthlyAlarmStatisticsVo getMonthlyAlarmStatistics();
|
||||||
|
}
|
||||||
@ -1,7 +1,10 @@
|
|||||||
package com.fuyuanshen.equipment.service;
|
package com.fuyuanshen.equipment.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceGeoFence;
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceGeoFenceBo;
|
import com.fuyuanshen.equipment.domain.bo.DeviceGeoFenceBo;
|
||||||
import com.fuyuanshen.equipment.domain.dto.FenceCheckResponse;
|
import com.fuyuanshen.equipment.domain.dto.FenceCheckResponse;
|
||||||
import com.fuyuanshen.equipment.domain.query.FenceCheckRequest;
|
import com.fuyuanshen.equipment.domain.query.FenceCheckRequest;
|
||||||
@ -16,7 +19,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2025-09-11
|
* @date 2025-09-11
|
||||||
*/
|
*/
|
||||||
public interface IDeviceGeoFenceService {
|
public interface IDeviceGeoFenceService extends IService<DeviceGeoFence> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电子围栏
|
* 查询电子围栏
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.fuyuanshen.equipment.service;
|
||||||
|
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.WeatherInfoVo;
|
||||||
|
|
||||||
|
/**天气信息服务接口
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-2715:26
|
||||||
|
*/
|
||||||
|
public interface IWeatherService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据经纬度获取天气信息
|
||||||
|
*
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @param longitude 经度
|
||||||
|
* @return 天气信息
|
||||||
|
*/
|
||||||
|
WeatherInfoVo getWeatherByCoordinates(Double latitude, Double longitude);
|
||||||
|
|
||||||
|
}
|
||||||
@ -12,7 +12,9 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.AlarmStatisticsVo;
|
||||||
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.MonthlyAlarmStatisticsVo;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
import com.fuyuanshen.equipment.domain.DeviceAlarm;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceAlarmMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceAlarmMapper;
|
||||||
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
|
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
|
||||||
@ -20,6 +22,7 @@ import com.fuyuanshen.equipment.service.IDeviceAlarmService;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备告警Service业务层处理
|
* 设备告警Service业务层处理
|
||||||
@ -161,4 +164,51 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
|
|||||||
return baseMapper.selectLatestByDeviceImei(deviceImei);
|
return baseMapper.selectLatestByDeviceImei(deviceImei);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 获取实时告警列表
|
||||||
|
*
|
||||||
|
* @return 设备告警列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DeviceAlarmVo> getRealtimeAlarm() {
|
||||||
|
return baseMapper.getRealtimeAlarm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报警统计数据
|
||||||
|
*
|
||||||
|
* @return 报警统计数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AlarmStatisticsVo getAlarmStatistics() {
|
||||||
|
return baseMapper.getAlarmStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近一年每月告警统计数据
|
||||||
|
*
|
||||||
|
* @return 每月告警统计数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MonthlyAlarmStatisticsVo getMonthlyAlarmStatistics() {
|
||||||
|
List<Map<String, Object>> result = baseMapper.getMonthlyAlarmStatistics();
|
||||||
|
MonthlyAlarmStatisticsVo vo = new MonthlyAlarmStatisticsVo();
|
||||||
|
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
Map<String, Object> data = result.get(0);
|
||||||
|
Map<String, Integer> monthlyStats = vo.getMonthlyStatistics();
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
Object value = entry.getValue();
|
||||||
|
// 将数据库查询结果转换为Integer类型
|
||||||
|
Integer count = (value != null) ? Integer.valueOf(value.toString()) : 0;
|
||||||
|
monthlyStats.put(key, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.fuyuanshen.equipment.service.impl;
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||||
@ -8,6 +9,7 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceGeoFence;
|
import com.fuyuanshen.equipment.domain.DeviceGeoFence;
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceFenceAccessRecordBo;
|
import com.fuyuanshen.equipment.domain.bo.DeviceFenceAccessRecordBo;
|
||||||
import com.fuyuanshen.equipment.domain.bo.DeviceFenceStatusBo;
|
import com.fuyuanshen.equipment.domain.bo.DeviceFenceStatusBo;
|
||||||
@ -17,6 +19,7 @@ import com.fuyuanshen.equipment.domain.query.FenceCheckRequest;
|
|||||||
import com.fuyuanshen.equipment.domain.vo.DeviceFenceStatusVo;
|
import com.fuyuanshen.equipment.domain.vo.DeviceFenceStatusVo;
|
||||||
import com.fuyuanshen.equipment.domain.vo.DeviceGeoFenceVo;
|
import com.fuyuanshen.equipment.domain.vo.DeviceGeoFenceVo;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceGeoFenceMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceGeoFenceMapper;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
import com.fuyuanshen.equipment.service.IDeviceFenceAccessRecordService;
|
import com.fuyuanshen.equipment.service.IDeviceFenceAccessRecordService;
|
||||||
import com.fuyuanshen.equipment.service.IDeviceFenceStatusService;
|
import com.fuyuanshen.equipment.service.IDeviceFenceStatusService;
|
||||||
import com.fuyuanshen.equipment.service.IDeviceGeoFenceService;
|
import com.fuyuanshen.equipment.service.IDeviceGeoFenceService;
|
||||||
@ -38,7 +41,7 @@ import java.util.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class DeviceGeoFenceServiceImpl implements IDeviceGeoFenceService {
|
public class DeviceGeoFenceServiceImpl extends ServiceImpl<DeviceGeoFenceMapper, DeviceGeoFence> implements IDeviceGeoFenceService {
|
||||||
|
|
||||||
private final DeviceGeoFenceMapper baseMapper;
|
private final DeviceGeoFenceMapper baseMapper;
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||||
|
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
@ -19,11 +20,10 @@ import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
|||||||
import com.fuyuanshen.customer.domain.Customer;
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
import com.fuyuanshen.customer.mapper.CustomerMapper;
|
import com.fuyuanshen.customer.mapper.CustomerMapper;
|
||||||
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.*;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
import com.fuyuanshen.equipment.domain.bo.DeviceFenceAccessRecordBo;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
|
||||||
import com.fuyuanshen.equipment.domain.DeviceTypeGrants;
|
|
||||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.FenceCheckResponse;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery;
|
import com.fuyuanshen.equipment.domain.query.DeviceAssignmentQuery;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
@ -32,13 +32,8 @@ import com.fuyuanshen.equipment.domain.vo.*;
|
|||||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||||
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
|
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
import com.fuyuanshen.equipment.mapper.*;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
import com.fuyuanshen.equipment.service.*;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
|
||||||
import com.fuyuanshen.equipment.service.DeviceAssignmentsService;
|
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeGrantsService;
|
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
||||||
import com.fuyuanshen.system.service.ISysOssService;
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
@ -88,6 +83,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
private final DeviceTypeGrantsService deviceTypeGrantsService;
|
private final DeviceTypeGrantsService deviceTypeGrantsService;
|
||||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||||
|
|
||||||
|
private final DeviceFenceAccessRecordMapper deviceFenceAccessRecordMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询设备
|
* 分页查询设备
|
||||||
@ -703,4 +700,120 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
return baseMapper.selectDeviceByImei(deviceImei);
|
return baseMapper.selectDeviceByImei(deviceImei);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备总览
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeviceOverviewVo getDeviceOverview() {
|
||||||
|
return deviceMapper.getDeviceOverview();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备通讯方式统计
|
||||||
|
*
|
||||||
|
* @return 设备通讯方式统计列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DeviceCommunicationModeStatisticsVo> getDeviceCommunicationModeStatistics() {
|
||||||
|
return deviceMapper.getDeviceCommunicationModeStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(int days) {
|
||||||
|
return deviceMapper.getDeviceUsageFrequency(days);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备IMEI更新设备的经纬度信息
|
||||||
|
*
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @param longitude 经度
|
||||||
|
* @param latitude 纬度
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean updateDeviceLocationByImei(String deviceImei, String longitude, String latitude) {
|
||||||
|
// 根据设备IMEI查询设备
|
||||||
|
Device device = deviceMapper.selectDeviceByImei(deviceImei);
|
||||||
|
if (device == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新设备的经纬度信息
|
||||||
|
device.setLongitude(longitude);
|
||||||
|
device.setLatitude(latitude);
|
||||||
|
|
||||||
|
// 更新数据库中的设备信息
|
||||||
|
return deviceMapper.updateById(device) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询设备位置信息
|
||||||
|
*
|
||||||
|
* @param groupId 设备分组ID
|
||||||
|
* @param deviceType 设备类型
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
* @return 设备位置信息列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DeviceLocationVo> getDeviceLocationInfo(Long groupId, Long deviceType, String deviceImei) {
|
||||||
|
// 构建查询条件
|
||||||
|
DeviceQueryCriteria criteria = new DeviceQueryCriteria();
|
||||||
|
criteria.setGroupId(groupId);
|
||||||
|
criteria.setDeviceType(deviceType);
|
||||||
|
criteria.setDeviceImei(deviceImei);
|
||||||
|
|
||||||
|
// 查询符合条件的设备
|
||||||
|
List<Device> devices = deviceMapper.findDevices(criteria);
|
||||||
|
|
||||||
|
// 构建返回结果
|
||||||
|
List<DeviceLocationVo> result = new ArrayList<>();
|
||||||
|
|
||||||
|
// 注入电子围栏服务
|
||||||
|
IDeviceGeoFenceService geoFenceService = SpringUtils.getBean(IDeviceGeoFenceService.class);
|
||||||
|
|
||||||
|
for (Device device : devices) {
|
||||||
|
DeviceLocationVo vo = new DeviceLocationVo();
|
||||||
|
vo.setDeviceId(device.getId());
|
||||||
|
vo.setDeviceName(device.getDeviceName());
|
||||||
|
vo.setLongitude(device.getLongitude());
|
||||||
|
vo.setLatitude(device.getLatitude());
|
||||||
|
|
||||||
|
// 检查设备是否在电子围栏内
|
||||||
|
if (StringUtils.isNotBlank(device.getLongitude()) && StringUtils.isNotBlank(device.getLatitude())) {
|
||||||
|
// 查询设备最新的围栏进出记录
|
||||||
|
DeviceFenceAccessRecordVo latestRecord = deviceFenceAccessRecordMapper.selectLatestRecordByDeviceId(String.valueOf(device.getId()));
|
||||||
|
|
||||||
|
// 判断是否在围栏内
|
||||||
|
if (latestRecord != null) {
|
||||||
|
// 如果最新的记录是进入围栏(事件类型为1),则设备在围栏内
|
||||||
|
if (latestRecord.getEventType() != null && latestRecord.getEventType() == 1L) {
|
||||||
|
vo.setInFence(true);
|
||||||
|
|
||||||
|
// 获取围栏完整信息
|
||||||
|
DeviceGeoFence fenceInfo = geoFenceService.getById(latestRecord.getFenceId());
|
||||||
|
if (fenceInfo != null) {
|
||||||
|
vo.setFenceInfo(fenceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vo.setInFence(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vo.setInFence(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vo.setInFence(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,82 @@
|
|||||||
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.WeatherInfoVo;
|
||||||
|
import com.fuyuanshen.equipment.service.IWeatherService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**天气信息服务实现类
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-09-2715:26
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class WeatherServiceImpl implements IWeatherService {
|
||||||
|
|
||||||
|
// 这里使用OpenWeatherMap API作为示例
|
||||||
|
private static final String WEATHER_API_URL = "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={appid}&units=metric&lang=zh_cn";
|
||||||
|
|
||||||
|
// 需要在配置文件中配置API密钥
|
||||||
|
private final String apiKey = ""; // 从配置文件获取
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WeatherInfoVo getWeatherByCoordinates(Double latitude, Double longitude) {
|
||||||
|
try {
|
||||||
|
// 注意:实际使用时需要配置API密钥并启用以下代码
|
||||||
|
/*
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String url = WEATHER_API_URL.replace("{lat}", latitude.toString())
|
||||||
|
.replace("{lon}", longitude.toString())
|
||||||
|
.replace("{appid}", apiKey);
|
||||||
|
|
||||||
|
// 调用第三方API获取天气数据
|
||||||
|
// 这里需要根据实际API返回的数据结构进行解析
|
||||||
|
// 以下为示例代码,实际实现需要根据API文档调整
|
||||||
|
|
||||||
|
WeatherInfoVo weatherInfo = new WeatherInfoVo();
|
||||||
|
weatherInfo.setLatitude(latitude);
|
||||||
|
weatherInfo.setLongitude(longitude);
|
||||||
|
weatherInfo.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
// 模拟数据,实际应从API获取
|
||||||
|
weatherInfo.setWeatherCondition("晴");
|
||||||
|
weatherInfo.setDescription("晴朗");
|
||||||
|
weatherInfo.setTemperature(25.0);
|
||||||
|
weatherInfo.setFeelsLike(26.0);
|
||||||
|
weatherInfo.setHumidity(60);
|
||||||
|
weatherInfo.setPressure(1013.0);
|
||||||
|
weatherInfo.setVisibility(10000);
|
||||||
|
weatherInfo.setWindSpeed(2.5);
|
||||||
|
weatherInfo.setWindDirection(180);
|
||||||
|
weatherInfo.setCloudiness(0);
|
||||||
|
|
||||||
|
return weatherInfo;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 临时返回模拟数据
|
||||||
|
WeatherInfoVo weatherInfo = new WeatherInfoVo();
|
||||||
|
weatherInfo.setLatitude(latitude);
|
||||||
|
weatherInfo.setLongitude(longitude);
|
||||||
|
weatherInfo.setWeatherCondition("晴");
|
||||||
|
weatherInfo.setDescription("晴朗");
|
||||||
|
weatherInfo.setTemperature(25.0);
|
||||||
|
weatherInfo.setFeelsLike(26.0);
|
||||||
|
weatherInfo.setHumidity(60);
|
||||||
|
weatherInfo.setPressure(1013.0);
|
||||||
|
weatherInfo.setVisibility(10000);
|
||||||
|
weatherInfo.setWindSpeed(2.5);
|
||||||
|
weatherInfo.setWindDirection(180);
|
||||||
|
weatherInfo.setCloudiness(0);
|
||||||
|
weatherInfo.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
return weatherInfo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取天气信息失败,经纬度: {},{}", latitude, longitude, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,7 +14,8 @@
|
|||||||
left join device_type dt on dt.id = d.device_type
|
left join device_type dt on dt.id = d.device_type
|
||||||
<where>
|
<where>
|
||||||
<if test="bo.content != null">
|
<if test="bo.content != null">
|
||||||
and d.device_name like concat('%', #{bo.content}, '%') or dt.type_name like concat('%', #{bo.content}, '%')
|
and d.device_name like concat('%', #{bo.content}, '%') or dt.type_name like concat('%', #{bo.content},
|
||||||
|
'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="bo.deviceName != null">
|
<if test="bo.deviceName != null">
|
||||||
and d.device_name like concat('%', #{bo.deviceName}, '%')
|
and d.device_name like concat('%', #{bo.deviceName}, '%')
|
||||||
@ -51,4 +52,52 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
<!-- 获取实时告警列表 -->
|
||||||
|
<select id="getRealtimeAlarm" resultType="com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo">
|
||||||
|
select da.*,
|
||||||
|
d.device_mac as deviceMac,
|
||||||
|
d.device_imei as deviceImei,
|
||||||
|
d.device_name as deviceName,
|
||||||
|
d.device_type as deviceType,
|
||||||
|
d.type_name as deviceTypeName,
|
||||||
|
d.device_pic as devicePic
|
||||||
|
from device_alarm da
|
||||||
|
left join device d on da.device_id = d.id
|
||||||
|
left join device_type dt on dt.id = d.device_type
|
||||||
|
WHERE da.treatment_state = 1
|
||||||
|
order by da.create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取报警统计数据 -->
|
||||||
|
<select id="getAlarmStatistics" resultType="com.fuyuanshen.equipment.domain.vo.AlarmStatisticsVo">
|
||||||
|
SELECT
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 1) AS activeAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm) AS totalAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) AS processedAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE device_action = 0) AS forcedAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE device_action = 1) AS intrusionImpactAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE device_action = 2) AS manualAlarms,
|
||||||
|
(SELECT COUNT(1) FROM device_alarm WHERE device_action = 3) AS geoFenceAlarms
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取最近一年每月告警统计数据 -->
|
||||||
|
<select id="getMonthlyAlarmStatistics" resultType="map">
|
||||||
|
SELECT
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 1 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m1,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 2 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m2,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 3 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m3,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 4 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m4,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 5 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m5,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 6 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m6,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 7 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m7,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 8 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m8,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 9 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m9,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 10 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m10,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 11 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m11,
|
||||||
|
COUNT(CASE WHEN MONTH(create_time) = 12 AND create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH) THEN 1 END) AS m12
|
||||||
|
FROM device_alarm
|
||||||
|
WHERE create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -92,4 +92,15 @@
|
|||||||
ORDER BY r.event_time DESC
|
ORDER BY r.event_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询设备最新的围栏记录 -->
|
||||||
|
<select id="selectLatestRecordByDeviceId" resultType="com.fuyuanshen.equipment.domain.vo.DeviceFenceAccessRecordVo">
|
||||||
|
SELECT *
|
||||||
|
FROM device_fence_access_record
|
||||||
|
WHERE device_id = #{deviceId}
|
||||||
|
ORDER BY event_time DESC
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?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" >
|
<!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">
|
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.Device">
|
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.Device">
|
||||||
<id column="id" property="id"/>
|
<id column="id" property="id"/>
|
||||||
@ -319,6 +319,32 @@
|
|||||||
a.create_time DESC
|
a.create_time DESC
|
||||||
</select>
|
</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&蓝牙'
|
||||||
|
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 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,
|
||||||
@ -423,6 +449,17 @@
|
|||||||
AND MONTH (dl.create_time) = #{month}
|
AND MONTH (dl.create_time) = #{month}
|
||||||
</select>
|
</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查询设备 -->
|
<!-- 根据设备IMEI查询设备 -->
|
||||||
<select id="selectDeviceByImei" resultType="com.fuyuanshen.equipment.domain.Device">
|
<select id="selectDeviceByImei" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|||||||
Reference in New Issue
Block a user