80 Commits

Author SHA1 Message Date
801b0267e6 设备分享3 2025-09-09 17:01:51 +08:00
5e3307d2b0 设备分享2 2025-09-09 10:29:51 +08:00
040e44984e Merge branch 'dyf-device' into 6170
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java
2025-09-09 10:01:26 +08:00
f7a82ef138 设备操作记录 分页 2025-09-09 09:55:58 +08:00
91f787eec7 pageQuery 2025-09-08 17:37:01 +08:00
870f94b2d4 开始时间 2025-09-08 16:12:02 +08:00
395b2957c1 Merge remote-tracking branch 'origin/6170' into 6170 2025-09-06 16:19:35 +08:00
64a4485ced 设备分享 2025-09-06 16:19:12 +08:00
1e4ee840a3 Merge branch 'dyf-device' into 6170 2025-09-06 11:48:00 +08:00
374a03b83d 管理员 2025-09-06 11:46:13 +08:00
b945420446 离线状态变更3 2025-09-05 13:32:32 +08:00
c057af7cd0 离线状态变更2 2025-09-05 11:46:29 +08:00
452c37c4ca 离线状态变更 2025-09-04 18:40:08 +08:00
429c0f1307 Merge branch 'dyf-device' into 6170 2025-09-04 11:29:55 +08:00
ff4db34e2a 型号字典用于APP页面跳转 2025-09-04 11:29:07 +08:00
377579dd14 Merge branch 'dyf-device' into 6170 2025-09-03 15:57:21 +08:00
00e345d5e5 Merge branch 'main' into dyf-device 2025-09-03 15:56:30 +08:00
dyf
1a2f35a092 Merge pull request 'jingquan' (#9) from liwenlong/fys-Multi-tenant:jingquan into main
Reviewed-on: #9
2025-09-03 15:55:27 +08:00
bdbbd5a12f feat(equipment): 添加设备维修图片功能并优化维修记录相关接口- 新增 DeviceRepairImages 相关实体、Mapper 和 XML 文件- 重构 DeviceRepairRecords 相关接口和实现类,支持图片上传
- 新增 RepairImageType 枚举类
- 优化 DeviceRepairRecordsVo,增加图片列表和设备名称字段
2025-09-03 15:17:39 +08:00
98cb67b136 修改获取经纬度 2025-09-03 15:11:24 +08:00
d97928b38a 分配客户 接口注释 2025-09-03 09:45:17 +08:00
1d37bfb719 首页数据 2025-09-02 15:08:53 +08:00
98ef841f18 通讯方式 2025-09-02 10:32:17 +08:00
8462fed747 merge upstream 2025-09-02 09:06:54 +08:00
0787e4b205 Merge remote-tracking branch 'origin/dyf-device' into 6170
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java
#	fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/LocationHistoryDetailVo.java
2025-09-02 08:51:41 +08:00
eca113d388 首页数据 2025-09-02 08:49:42 +08:00
127e26e0d4 首页数据 2025-09-01 16:03:46 +08:00
dfb5d8ac65 修改获取实时状态类型 2025-08-30 13:53:41 +08:00
896c501cd6 报警持续时间 2025-08-30 11:07:04 +08:00
d8686e3cbd Merge branch 'dyf-device' into 6170 2025-08-30 09:40:51 +08:00
c2ce9679c4 设备充放电记录 2025-08-30 09:39:41 +08:00
d66fb7d2c2 设备告警 2025-08-29 18:58:16 +08:00
400c53030a Merge remote-tracking branch 'origin/6170' into 6170 2025-08-29 16:49:44 +08:00
b5565da752 web端控制中心4 2025-08-29 16:49:16 +08:00
e17a64ad57 查询设备告警列表 2025-08-29 13:59:23 +08:00
3969e50566 查询设备分享列表(web) 2025-08-29 10:29:53 +08:00
760738bcdd 设备告警记录 2025-08-28 13:30:50 +08:00
765e0f8509 设备告警 2025-08-28 11:26:00 +08:00
2c565f5c2d 设备告警 2025-08-28 11:22:04 +08:00
7aa02635f2 feat(device): 优化设备人员信息发送逻辑
- 调整人员信息的顺序,符合兴汉设备接收数据的要求
- 添加设备上报人员登记信息的日志,方便问题追踪
2025-08-27 17:30:00 +08:00
626296adbc merge upstream 2025-08-27 15:28:40 +08:00
9bbed77170 refactor(fys-demo): 优化视频上传接口并修复 MQTT 报警信息发送逻辑
- 移除了 VideoUploadController 中的 @SaIgnore 注解,恢复权限控制- 优化了 XinghanSendAlarmMessageRule 中的 Redis 数据检查逻辑
2025-08-27 15:27:19 +08:00
837953bf3d 设备类型ID 2025-08-27 10:20:37 +08:00
8b25fd9ba4 设备操作记录 2025-08-27 09:25:08 +08:00
8a7565459b Merge branch '6170' of http://47.107.152.87:3000/dyf/fys-Multi-tenant into 6170 2025-08-27 09:09:20 +08:00
0bbac2b497 设备用户详情 2025-08-27 09:08:27 +08:00
364574eeae web端控制中心3 2025-08-27 08:59:29 +08:00
a5b8cdffec refactor(device): 优化设备发送告警信息功能
- 批量查询设备,减少数据库交互次数
- 优化设备状态检查逻辑,提高效率
- 封装单个设备发送告警信息的逻辑,提高代码可读性- 使用 Redis 和 MQTT 时增加异常处理,提高系统稳定性
- 优化日志记录和异常提示,便于问题排查
2025-08-26 17:12:36 +08:00
f9d9dadf08 绑定设备分组 2025-08-26 10:00:35 +08:00
e4df695f5e 绑定设备分组 2025-08-26 09:26:33 +08:00
f839883f82 feat(device): 新增发送紧急通知功能
- 在 AppDeviceXinghanController 中添加 sendAlarmMessage接口
- 在 DeviceXinghanBizService 中实现 sendAlarmMessage 方法
- 新增 XinghanSendAlarmMessageRule 类用于处理紧急通知发送逻辑
- 在 DeviceRedisKeyConstants 中添加 DEVICE_ALARM_MESSAGE_KEY_PREFIX 常量
- 修改 XinghanDeviceDataRule 和 XinghanSendMsgRule 中的相关逻辑
2025-08-25 14:18:54 +08:00
74cefe9cc3 设备详情 2025-08-25 13:42:24 +08:00
9b476e98ba 型号字典用于PC页面跳转 2025-08-25 11:40:59 +08:00
d962c6ead5 查询分享用户数 2025-08-25 10:19:57 +08:00
1246ac5cf7 @Schema(title = "ID", hidden = true) 2025-08-23 17:33:35 +08:00
7607a0c9c0 Merge remote-tracking branch 'origin/6170' into 6170
# Conflicts:
#	fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java
2025-08-23 16:40:42 +08:00
8811c30a97 web端控制中心2 2025-08-23 16:39:30 +08:00
d05e046112 Merge branch 'main' into dyf-device 2025-08-22 18:28:40 +08:00
dyf
e86eff48ee Merge pull request 'jingquan' (#8) from liwenlong/fys-Multi-tenant:jingquan into main
Reviewed-on: #8
2025-08-22 18:26:44 +08:00
aef16cf6b4 Merge remote-tracking branch 'liwenlong-fys/jingquan' into jingquan 2025-08-22 18:10:10 +08:00
95aa01e1c2 feat(device): 新增星汉设备控制功能
- 添加星汉设备控制器 AppDeviceXinghanController- 实现星汉设备业务逻辑 DeviceXinghanBizService
- 增加开机 LOGO 下发规则 XinghanBootLogoRule
- 添加设备发送消息规则 XinghanSendMsgRule
- 更新 MQTT 命令类型常量 XingHanCommandTypeConstants
- 修改设备状态 JSON 结构 MqttXinghanJson
2025-08-22 18:09:08 +08:00
2965b454cf web:设备分组 接口文档 2025-08-22 16:37:58 +08:00
b83be496b6 出厂日期 2025-08-22 09:58:27 +08:00
4965d78c51 设备所属分组 2025-08-22 09:40:52 +08:00
9dee7ad102 管理员 2025-08-21 17:55:59 +08:00
dyf
e9542c70e9 Merge pull request 'jingquan' (#7) from liwenlong/fys-Multi-tenant:jingquan into dyf-device
Reviewed-on: #7
2025-08-21 17:54:48 +08:00
dyf
51297f269d Merge branch 'dyf-device' into jingquan 2025-08-21 17:54:39 +08:00
4077fd303f merge upstream 2025-08-21 17:44:57 +08:00
f1a19f95f5 feat(mqtt): 新增星汉设备数据处理规则和解析逻辑- 添加 MqttXinghanCommandType 枚举类,用于识别和处理星汉设备的命令类型
- 新增 MqttXinghanJson 类,用于解析星汉设备的 JSON 数据
- 在 ReceiverMessageHandler 中集成星汉设备数据的处理逻辑
- 添加 XingHanCommandTypeConstants 常量类,定义星汉设备的命令类型常量
- 实现 XinghanDeviceDataRule 类,处理星汉设备主动上报的数据命令
2025-08-21 17:44:06 +08:00
e6d0e883fb 管理员 2025-08-21 16:51:17 +08:00
5b6927729f WebApp用户信息 2025-08-21 15:17:11 +08:00
bb11bc4dfa WEB端解绑设备 2025-08-20 15:13:43 +08:00
7f65ebedc2 数据字典信息 2025-08-20 13:31:54 +08:00
34ee4cceca web端控制中心 2025-08-19 13:58:48 +08:00
9a6bf05c4b 根据mac地址查询设备详情 2025-08-18 11:04:23 +08:00
b51e88052f 设备分享3 2025-08-16 16:40:58 +08:00
6d9e75d4fa Merge branch '6170' of http://47.107.152.87:3000/dyf/fys-Multi-tenant into 6170 2025-08-16 14:19:19 +08:00
58814fe312 Merge branch 'main' into 6170 2025-08-16 14:18:49 +08:00
6d6db190b9 设备分享2 2025-08-16 11:30:06 +08:00
f8c53451c0 修改灯光上报状态 2025-08-15 18:16:37 +08:00
127 changed files with 6774 additions and 482 deletions

View File

@ -87,7 +87,7 @@ public class AppDeviceController extends BaseController {
* 根据mac查询设备信息
*/
@GetMapping("/getDeviceInfoByDeviceMac")
public R<Device> getDeviceInfo(String deviceMac) {
public R<AppDeviceVo> getDeviceInfo(String deviceMac) {
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
}
}

View File

@ -16,6 +16,7 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.web.service.DeviceShareService;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

View File

@ -43,7 +43,7 @@ public class AppDeviceBJQController extends BaseController {
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
@FunctionAccessAnnotation("registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
@ -52,7 +52,7 @@ public class AppDeviceBJQController extends BaseController {
* 发送信息
*/
@PostMapping(value = "/sendMessage")
@FunctionAccessBatcAnnotation("sendMessage")
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendMessage(bo));
}
@ -61,7 +61,7 @@ public class AppDeviceBJQController extends BaseController {
* 发送报警信息
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation("sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
@ -86,7 +86,7 @@ public class AppDeviceBJQController extends BaseController {
* 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式
*/
@FunctionAccessAnnotation("lightModeSettings")
// @FunctionAccessAnnotation("lightModeSettings")
@PostMapping("/lightModeSettings")
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
@ -110,7 +110,7 @@ public class AppDeviceBJQController extends BaseController {
*
*/
@PostMapping("/laserModeSettings")
@FunctionAccessAnnotation("laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings")
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.laserModeSettings(params);
return R.ok();

View File

@ -0,0 +1,119 @@
package com.fuyuanshen.app.controller.device;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* HBY210设备控制类
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/hby/device")
public class AppDeviceHBYController extends BaseController {
private final DeviceBJQBizService appDeviceService;
/**
* 获取设备详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(appDeviceService.getInfo(id));
}
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
/**
* 发送信息
*/
@PostMapping(value = "/sendMessage")
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendMessage(bo));
}
/**
* 发送报警信息
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式
*/
// @FunctionAccessAnnotation("lightModeSettings")
@PostMapping("/lightModeSettings")
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.lightModeSettings(params);
return R.ok();
}
/**
* 灯光亮度设置
*
*/
// @FunctionAccessAnnotation("lightBrightnessSettings")
@PostMapping("/lightBrightnessSettings")
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.lightBrightnessSettings(params);
return R.ok();
}
/**
* 激光模式设置
*
*/
@PostMapping("/laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings")
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.laserModeSettings(params);
return R.ok();
}
}

View File

@ -0,0 +1,107 @@
package com.fuyuanshen.app.controller.device;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* HBY670设备控制类
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/xinghan/device")
public class AppDeviceXinghanController extends BaseController {
private final DeviceXinghanBizService appDeviceService;
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
/**
* 发送紧急通知
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 静电预警档位
* 3,2,1,0,分别表示高档/中档/低挡/关闭
*/
@PostMapping("/DetectGradeSettings")
public R<Void> DetectGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.upDetectGradeSettings(params);
return R.ok();
}
/**
* 照明档位
* 照明档位2,1,0,分别表示弱光/强光/关闭
*/
@PostMapping("/LightGradeSettings")
public R<Void> LightGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.upLightGradeSettings(params);
return R.ok();
}
/**
* SOS档位s
* SOS档位2,1,0, 分别表示红蓝模式/爆闪模式/关闭
*/
@PostMapping("/SOSGradeSettings")
public R<Void> SOSGradeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.upSOSGradeSettings(params);
return R.ok();
}
/**
* 静止报警状态
* 静止报警状态0-未静止报警1-正在静止报警。
*/
@PostMapping("/ShakeBitSettings")
public R<Void> ShakeBitSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.upShakeBitSettings(params);
return R.ok();
}
}

View File

@ -0,0 +1,47 @@
package com.fuyuanshen.app.controller.device;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* BJQ6170设备控制类
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/test")
public class TestController extends BaseController {
private final DeviceBJQBizService appDeviceService;
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo2(bo);
return R.ok();
}
}

View File

@ -14,4 +14,5 @@ public class AppDeviceLogoUploadDto {
*/
private MultipartFile file;
private Integer chunkSize;
}

View File

@ -14,7 +14,7 @@ public class AppRealTimeStatusDto {
private String deviceImei;
/**
* 设备类型
* 获取实时状态类型FunctionAccessBatchStatusRule 批量 FunctionAccessStatusRule 单个
*/
private String typeName;

View File

@ -2,7 +2,6 @@ package com.fuyuanshen.app.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -14,11 +13,8 @@ import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
import com.fuyuanshen.common.core.utils.MessageUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
@ -47,7 +43,7 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
public class AppDeviceShareService {
private final AppDeviceShareMapper appDeviceShareMapper;
private final DeviceMapper deviceMapper;
private final DeviceTypeMapper deviceTypeMapper;
@ -64,33 +60,43 @@ public class AppDeviceShareService {
return TableDataInfo.build(result);
}
public TableDataInfo<AppDeviceShareVo> queryWebPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
// Long userId = AppLoginHelper.getUserId();
// bo.setCreateBy(userId);
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(AppDeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
private static void buildDeviceStatus(AppDeviceShareVo item) {
//设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
item.setOnlineStatus(1);
}else{
} else {
item.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
item.setBattery(jsonObject.getString("batteryPercentage"));
}else{
} else {
item.setBattery("0");
}
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_LOCATION_KEY_PREFIX);
if(StringUtils.isNotBlank(location)){
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
if (StringUtils.isNotBlank(location)) {
JSONObject jsonObject = JSONObject.parseObject(location);
item.setLatitude(jsonObject.getString("latitude"));
item.setLongitude(jsonObject.getString("longitude"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
if(StringUtils.isNotBlank(alarmStatus)){
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
item.setAlarmStatus(alarmStatus);
}
}
@ -100,7 +106,7 @@ public class AppDeviceShareService {
LambdaQueryWrapper<AppDeviceShare> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AppDeviceShare::getId, id);
List<AppDeviceShareVo> appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper);
if(appDeviceShareVos==null || appDeviceShareVos.isEmpty()){
if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) {
return null;
}
@ -117,7 +123,7 @@ public class AppDeviceShareService {
shareDetailVo.setDeviceMac(device.getDeviceMac());
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
if(deviceType!=null){
if (deviceType != null) {
shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
}
shareDetailVo.setDevicePic(device.getDevicePic());
@ -129,40 +135,53 @@ public class AppDeviceShareService {
LambdaQueryWrapper<AppPersonnelInfo> qw = new LambdaQueryWrapper<>();
qw.eq(AppPersonnelInfo::getDeviceId, device.getId());
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
if(appPersonnelInfoVos!=null && !appPersonnelInfoVos.isEmpty()){
if (appPersonnelInfoVos != null && !appPersonnelInfoVos.isEmpty()) {
shareDetailVo.setPersonnelInfo(appPersonnelInfoVos.get(0));
}
//设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
shareDetailVo.setOnlineStatus(1);
}else{
} else {
shareDetailVo.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
shareDetailVo.setMainLightMode(jsonObject.getString("mainLightMode"));
shareDetailVo.setLaserLightMode(jsonObject.getString("laserLightMode"));
shareDetailVo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
shareDetailVo.setChargeState(jsonObject.getString("chargeState"));
shareDetailVo.setBatteryRemainingTime(jsonObject.getString("batteryRemainingTime"));
}else{
} else {
shareDetailVo.setBatteryPercentage("0");
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);
if(StringUtils.isNotBlank(locationInfo)){
if (StringUtils.isNotBlank(locationInfo)) {
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
shareDetailVo.setLongitude(jsonObject.get("longitude").toString());
shareDetailVo.setLatitude(jsonObject.get("latitude").toString());
shareDetailVo.setAddress((String)jsonObject.get("address"));
shareDetailVo.setAddress((String) jsonObject.get("address"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
shareDetailVo.setAlarmStatus(alarmStatus);
}
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if (StringUtils.isNotBlank(lightBrightness)) {
shareDetailVo.setLightBrightness(lightBrightness);
}
return shareDetailVo;
}
/**
* 校验短信验证码
*/
@ -173,14 +192,15 @@ public class AppDeviceShareService {
}
return code.equals(smsCode);
}
public int deviceShare(AppDeviceShareBo bo) {
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
if(!flag){
if (!flag) {
throw new ServiceException("验证码错误");
}
Device device = deviceMapper.selectById(bo.getDeviceId());
if(device==null){
if (device == null) {
throw new ServiceException("设备不存在");
}
Long userId = AppLoginHelper.getUserId();
@ -188,7 +208,7 @@ public class AppDeviceShareService {
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
Long count = appDeviceShareMapper.selectCount(lqw);
if(count>0){
if (count > 0) {
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
uw.eq("device_id", bo.getDeviceId());
@ -198,7 +218,7 @@ public class AppDeviceShareService {
uw.set("update_time", new Date());
return appDeviceShareMapper.update(uw);
}else {
} else {
AppDeviceShare appDeviceShare = new AppDeviceShare();
appDeviceShare.setDeviceId(bo.getDeviceId());
appDeviceShare.setPhonenumber(bo.getPhonenumber());
@ -224,4 +244,19 @@ public class AppDeviceShareService {
}
/**
* 查询设备分享列表(web)
*
* @param bo
* @param pageQuery
* @return
*/
public TableDataInfo<AppDeviceShareVo> queryWebList(AppDeviceShareBo bo, PageQuery pageQuery) {
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(AppDeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
}

View File

@ -1,5 +1,9 @@
package com.fuyuanshen.global.mqtt.base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.Comparator;
@ -11,7 +15,10 @@ import java.util.List;
*/
@Component
public class MqttRuleEngine {
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final LinkedHashMap<String, MqttMessageRule> rulesMap = new LinkedHashMap<>();
public MqttRuleEngine(List<MqttMessageRule> rules) {
@ -30,7 +37,7 @@ public class MqttRuleEngine {
int commandType = context.getCommandType();
MqttMessageRule mqttMessageRule = rulesMap.get("Light_"+commandType);
if (mqttMessageRule != null) {
mqttMessageRule.execute(context);
threadPoolTaskExecutor.execute(() -> mqttMessageRule.execute(context));
return true;
}

View File

@ -0,0 +1,65 @@
package com.fuyuanshen.global.mqtt.base;
import cn.hutool.core.lang.Dict;
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.Collections;
import org.springframework.stereotype.Component;
@Component
public final class MqttXinghanCommandType {
private MqttXinghanCommandType() {}
public enum XinghanCommandTypeEnum {
/**
* 星汉设备主动上报数据
*/
GRADE_INFO(101),
/**
* 星汉开机LOGO
*/
PIC_TRANS(102),
/**
* 星汉设备发送消息 (XingHan send msg)
*/
TEX_TRANS(103),
BREAK_NEWS(104),
UNKNOWN(0);
private final int value;
XinghanCommandTypeEnum(int value) { this.value = value; }
public int getValue() { return value; }
}
private static final Map<String, XinghanCommandTypeEnum> KEY_TO_TYPE;
static {
LinkedHashMap<String, XinghanCommandTypeEnum> map = new LinkedHashMap<>();
map.put("sta_DetectGrade", XinghanCommandTypeEnum.GRADE_INFO);
map.put("sta_PowerTime", XinghanCommandTypeEnum.GRADE_INFO);
map.put("sta_longitude", XinghanCommandTypeEnum.GRADE_INFO);
map.put("sta_latitude", XinghanCommandTypeEnum.GRADE_INFO);
map.put("sta_PicTrans", XinghanCommandTypeEnum.PIC_TRANS);
map.put("sta_TexTrans", XinghanCommandTypeEnum.TEX_TRANS);
map.put("sta_BreakNews", XinghanCommandTypeEnum.BREAK_NEWS);
KEY_TO_TYPE = Collections.unmodifiableMap(map);
}
public static int computeVirtualCommandType(Dict payloadDict) {
if (payloadDict == null) {
return XinghanCommandTypeEnum.UNKNOWN.getValue();
}
try {
for (String key : KEY_TO_TYPE.keySet()) {
if (payloadDict.containsKey(key)) {
return KEY_TO_TYPE.get(key).getValue();
}
}
} catch (Exception ex) {
return XinghanCommandTypeEnum.UNKNOWN.getValue();
}
return XinghanCommandTypeEnum.UNKNOWN.getValue();
}
}

View File

@ -0,0 +1,65 @@
package com.fuyuanshen.global.mqtt.base;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonProperty;
@Data
public class MqttXinghanJson {
/**
* 第一键值对静电预警档位3,2,1,0,分别表示高档/中档/低挡/关闭.
*/
@JsonProperty("sta_DetectGrade")
private Integer staDetectGrade;
/**
* 第二键值对照明档位2,1,0,分别表示弱光/强光/关闭
*/
@JsonProperty("sta_LightGrade")
private Integer staLightGrade;
/**
* 第三键值对SOS档位2,1,0, 分别表示红蓝模式/爆闪模式/关闭
*/
@JsonProperty("sta_SOSGrade")
public Integer staSOSGrade;
/**
* 第四键值对剩余照明时间0-5999单位分钟。
*/
@JsonProperty("sta_PowerTime")
public Integer staPowerTime;
/**
* 第五键值对剩余电量百分比0-100
*/
@JsonProperty("sta_PowerPercent")
public Integer staPowerPercent;
/**
* 第六键值对, 近电预警级别, 0-无预警1-弱预警2-中预警3-强预警4-非常强预警。
*/
@JsonProperty("sta_DetectResult")
public Integer staDetectResult;
/**
* 第七键值对, 静止报警状态0-未静止报警1-正在静止报警。
*/
@JsonProperty("staShakeBit")
public Integer sta_ShakeBit;
/**
* 第八键值对, 4G信号强度0-32数值越大信号越强。
*/
@JsonProperty("sta_4gSinal")
public Integer sta4gSinal;
/**
* 第九键值对IMIE卡号
*/
@JsonProperty("sta_imei")
public String staimei;
/**
* 第十键值对,经度
*/
@JsonProperty("sta_longitude")
public String stalongitude;
/**
* 第十一键值对,纬度
*/
@JsonProperty("sta_latitude")
public String stalatitude;
}

View File

@ -47,4 +47,9 @@ public class DeviceRedisKeyConstants {
* 告警
*/
public static final String DEVICE_ALARM_KEY_PREFIX = ":alarm";
/**
* 告警信息
*/
public static final String DEVICE_ALARM_MESSAGE_KEY_PREFIX = ":alarmMessage";
}

View File

@ -0,0 +1,20 @@
package com.fuyuanshen.global.mqtt.constants;
public class XingHanCommandTypeConstants {
/**
* 星汉设备主动上报数据 (XingHan Device Data)
*/
public static final String XingHan_DEVICE_DATA = "Light_101";
/**
* 星汉开机LOGO (XingHan Boot Logo)
*/
public static final String XingHan_BOOT_LOGO = "Light_102";
/**
* 星汉设备发送消息 (XingHan send msg)
*/
public static final String XingHan_ESEND_MSG = "Light_103";
/**
* 星汉设备发送紧急通知 (XingHan break news)
*/
public static final String XingHan_BREAK_NEWS = "Light_104";
}

View File

@ -1,23 +1,44 @@
package com.fuyuanshen.global.mqtt.listener;
import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.lock.LockInfo;
import com.baomidou.lock.LockTemplate;
import com.baomidou.lock.executor.RedissonLockExecutor;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_TIMEOUT_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX;
@Component
@Slf4j
public class RedisKeyExpirationListener implements MessageListener {
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private LockTemplate lockTemplate;
@Override
public void onMessage(Message message, byte[] pattern) {
String expiredKey = new String(message.getBody());
@ -26,8 +47,44 @@ public class RedisKeyExpirationListener implements MessageListener {
String element = expiredKey.substring(FUNCTION_ACCESS_KEY.length());
handleFunctionAccessExpired(element);
}
}
if(expiredKey.endsWith(DEVICE_ONLINE_STATUS_KEY_PREFIX)) {
// threadPoolTaskExecutor.execute(() -> {
// log.info("设备离线:{}", expiredKey);
// String element = expiredKey.substring(GlobalConstants.GLOBAL_REDIS_KEY.length() + DEVICE_KEY_PREFIX.length(), expiredKey.length() - DEVICE_ONLINE_STATUS_KEY_PREFIX.length());
// UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
// deviceUpdateWrapper.eq("device_imei", element);
// deviceUpdateWrapper.set("online_status", 0);
// deviceMapper.update(deviceUpdateWrapper);
// });
threadPoolTaskExecutor.execute(() -> {
log.info("设备离线:{}", expiredKey);
String element = expiredKey.substring(GlobalConstants.GLOBAL_REDIS_KEY.length() + DEVICE_KEY_PREFIX.length(), expiredKey.length() - DEVICE_ONLINE_STATUS_KEY_PREFIX.length());
// 构造设备锁键
String deviceLockKey = GlobalConstants.GLOBAL_REDIS_KEY + ":device_lock:" + element;
// 尝试获取Redis锁
LockInfo lockInfo = lockTemplate.lock(deviceLockKey, 30000L, 5000L, RedissonLockExecutor.class); // 30秒过期
if (lockInfo != null) {
try {
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
deviceUpdateWrapper.eq("device_imei", element);
deviceUpdateWrapper.set("online_status", 0);
deviceMapper.update(deviceUpdateWrapper);
} finally {
//释放锁
lockTemplate.releaseLock(lockInfo);
}
} else {
log.warn("无法获取设备锁,跳过设备离线处理: {}", element);
}
});
}
}
/**
* 访问key过期事件
* @param element 批次ID

View File

@ -8,7 +8,9 @@ import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.base.MqttRuleEngine;
import com.fuyuanshen.global.mqtt.base.MqttXinghanCommandType;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.global.queue.MqttMessageQueueConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
@ -50,6 +52,9 @@ public class ReceiverMessageHandler implements MessageHandler {
//在线状态
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(62));
// String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
// String dedupKey = MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY;
// RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24));
}
String state = payloadDict.getStr("state");
@ -69,5 +74,19 @@ public class ReceiverMessageHandler implements MessageHandler {
log.warn("未找到匹配的规则来处理命令类型: {}", val1);
}
}
/* ===== 追加:根据报文内容识别格式并统一解析 ===== */
int intType = MqttXinghanCommandType.computeVirtualCommandType(payloadDict);
if (intType > 0) {
MqttRuleContext newCtx = new MqttRuleContext();
newCtx.setCommandType((byte) intType);
newCtx.setDeviceImei(deviceImei);
newCtx.setPayloadDict(payloadDict);
boolean ok = ruleEngine.executeRule(newCtx);
if (!ok) {
log.warn("新规则引擎未命中, imei={}", deviceImei);
}
}
}
}

View File

@ -15,8 +15,7 @@ import org.springframework.stereotype.Component;
import java.time.Duration;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
/**
* 灯光模式订阅设备回传消息
@ -37,19 +36,15 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
try {
Object[] convertArr = context.getConvertArr();
String mainLightMode = convertArr[1].toString();
if(StringUtils.isNotBlank(mainLightMode)){
if("0".equals(mainLightMode)){
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0", Duration.ofSeconds(60*15));
}
String mode = convertArr[1].toString();
if(StringUtils.isNotBlank(mode)){
// 发送设备状态和位置信息到Redis
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode);
}
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
} catch (Exception e) {
log.error("处理光模式命令时出错", e);
log.error("处理光模式命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30));
}
}
@ -65,7 +60,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
// });
try {
// 将设备状态信息存储到Redis中
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LIGHT_MODE_KEY_PREFIX;
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LASER_MODE_KEY_PREFIX;
// 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString());

View File

@ -117,28 +117,28 @@ public class BjqLocationDataRule implements MqttMessageRule {
if(StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)){
return;
}
String[] latArr = latitude.split("\\.");
String[] lonArr = longitude.split("\\.");
// 将位置信息存储到Redis中
// String[] latArr = latitude.split("\\.");
// String[] lonArr = longitude.split("\\.");
// // 将位置信息存储到Redis中
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX;
String redisObj = RedisUtils.getCacheObject(redisKey);
JSONObject jsonOBj = JSONObject.parseObject(redisObj);
if(jsonOBj != null){
String str1 = latArr[0] +"."+ latArr[1].substring(0,4);
String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4);
String cacheLatitude = jsonOBj.getString("wgs84_latitude");
String cacheLongitude = jsonOBj.getString("wgs84_longitude");
String[] latArr1 = cacheLatitude.split("\\.");
String[] lonArr1 = cacheLongitude.split("\\.");
String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4);
String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4);
if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){
log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
return;
}
}
// String redisObj = RedisUtils.getCacheObject(redisKey);
// JSONObject jsonOBj = JSONObject.parseObject(redisObj);
// if(jsonOBj != null){
// String str1 = latArr[0] +"."+ latArr[1].substring(0,4);
// String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4);
//
// String cacheLatitude = jsonOBj.getString("wgs84_latitude");
// String cacheLongitude = jsonOBj.getString("wgs84_longitude");
// String[] latArr1 = cacheLatitude.split("\\.");
// String[] lonArr1 = cacheLongitude.split("\\.");
//
// String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4);
// String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4);
// if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){
// log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
// return;
// }
// }
// 构造位置信息对象
Map<String, Object> locationInfo = new LinkedHashMap<>();

View File

@ -16,8 +16,7 @@ import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
/**
* 灯光模式订阅设备回传消息
@ -39,6 +38,7 @@ public class BjqModeRule implements MqttMessageRule {
Object[] convertArr = context.getConvertArr();
String mainLightMode = convertArr[1].toString();
String batteryRemainingTime = convertArr[2].toString();
if(StringUtils.isNotBlank(mainLightMode)){
if("0".equals(mainLightMode)){
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
@ -46,6 +46,10 @@ public class BjqModeRule implements MqttMessageRule {
}
// 发送设备状态和位置信息到Redis
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
// 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime);
}
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
} catch (Exception e) {

View File

@ -0,0 +1,155 @@
package com.fuyuanshen.global.mqtt.rule.xinghan;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fuyuanshen.common.core.utils.ImageToCArrayConverter;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.LightingCommandTypeConstants;
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
import com.fuyuanshen.global.mqtt.constants.XingHanCommandTypeConstants;
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.CRC32;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.common.core.utils.ImageToCArrayConverter.convertHexToDecimal;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_BOOT_LOGO_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/**
* 星汉设备开机 LOGO 下发规则:
* <p>
* 1. 设备上行 sta_PicTarns=great! => 仅标记成功<br>
* 2. 设备上行 sta_PicTarns=数字 => 下发第 N 块数据256B/块,带 CRC32
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class XinghanBootLogoRule implements MqttMessageRule {
private final MqttGateway mqttGateway;
private final ObjectMapper objectMapper;
@Override
public String getCommandType() {
return XingHanCommandTypeConstants.XingHan_BOOT_LOGO;
}
@Override
public void execute(MqttRuleContext ctx) {
final String functionAccessKey = FUNCTION_ACCESS_KEY + ctx.getDeviceImei();
try {
MqttXinghanLogoJson payload = objectMapper.convertValue(
ctx.getPayloadDict(), MqttXinghanLogoJson.class);
String respText = payload.getStaPicTrans();
log.warn("设备上报LOGO{}", respText);
// 1. great! —— 成功标记
if ("great!".equalsIgnoreCase(respText)) {
RedisUtils.setCacheObject(functionAccessKey,
FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
log.info("设备 {} 开机 LOGO 写入成功", ctx.getDeviceImei());
return;
}
// 2. 数字 —— 下发数据块
int blockIndex;
try {
blockIndex = Integer.parseInt(respText);
} catch (NumberFormatException ex) {
log.warn("设备 {} LOGO 上报非法块号:{}", ctx.getDeviceImei(), respText);
return;
}
String hexImage = RedisUtils.getCacheObject(
GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + ctx.getDeviceImei() + DEVICE_BOOT_LOGO_KEY_PREFIX);
if (StringUtils.isEmpty(hexImage)) {
return;
}
byte[] fullBin = ImageToCArrayConverter.convertStringToByteArray(hexImage);
byte[] chunk = ImageToCArrayConverter.getChunk(fullBin, blockIndex - 1, CHUNK_SIZE);
log.info("设备 {} 第 {} 块数据长度: {} bytes", ctx.getDeviceImei(), blockIndex, chunk.length);
// 组装下发数据
ArrayList<Integer> dataFrame = new ArrayList<>();
dataFrame.add(blockIndex); // 块号
ImageToCArrayConverter.buildArr(convertHexToDecimal(chunk), dataFrame);
dataFrame.addAll(crc32AsList(chunk)); // CRC32
Map<String, Object> pub = new HashMap<>();
pub.put("ins_PicTrans", dataFrame);
String topic = MqttConstants.GLOBAL_PUB_KEY + ctx.getDeviceImei();
String json = JsonUtils.toJsonString(pub);
mqttGateway.sendMsgToMqtt(topic, 1, json);
log.info("下发开机 LOGO 数据 => topic:{}, payload:{}", topic, json);
} catch (Exception e) {
log.error("处理设备 {} 开机 LOGO 失败", ctx.getDeviceImei(), e);
RedisUtils.setCacheObject(functionAccessKey,
FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));
}
}
/* ---------- 内部工具 ---------- */
private static final int CHUNK_SIZE = 256;
/**
* 计算数据的CRC32校验值并将结果转换为整数列表
*
* @param data 需要计算CRC32校验值的字节数组
* @return 包含CRC32校验值的整数列表每个字节对应一个无符号整数
*/
private static ArrayList<Integer> crc32AsList(byte[] data) {
// 计算CRC32校验值
CRC32 crc = new CRC32();
crc.update(data);
// 将CRC32值转换为字节数组
byte[] crcBytes = ByteBuffer.allocate(4)
.order(ByteOrder.BIG_ENDIAN)
.putInt((int) crc.getValue())
.array();
// 将字节数组转换为无符号整数列表
ArrayList<Integer> list = new ArrayList<>(4);
for (byte b : crcBytes) {
list.add(Byte.toUnsignedInt(b));
}
return list;
}
/* ---------- DTO ---------- */
@Data
private static class MqttXinghanLogoJson {
/**
* 设备上行:
* 数字 -> 请求对应块号
* great! -> 写入成功
*/
@JsonProperty("sta_PicTrans")
private String staPicTrans;
}
}

View File

@ -0,0 +1,217 @@
package com.fuyuanshen.global.mqtt.rule.xinghan;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil;
import com.fuyuanshen.equipment.utils.map.LngLonUtil;
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.base.MqttXinghanJson;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.global.mqtt.constants.LightingCommandTypeConstants;
import com.fuyuanshen.global.mqtt.constants.XingHanCommandTypeConstants;
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/**
* 主动上报设备数据命令处理
* 第一键值对静电预警档位3,2,1,0,分别表示高档/中档/低挡/关闭.
* 第二键值对照明档位2,1,0,分别表示弱光/强光/关闭
* 第三键值对SOS档位2,1,0, 分别表示红蓝模式/爆闪模式/关闭
* 第四键值对剩余照明时间0-5999单位分钟。
* 第五键值对, 剩余电量百分比0-100。
* 第六键值对, 近电预警级别, 0-无预警1-弱预警2-中预警3-强预警4-非常强预警。
* 第七键值对, 静止报警状态0-未静止报警1-正在静止报警。
* 第八键值对, 4G信号强度0-32数值越大信号越强。
* 第九键值对IMIE卡号
* 第十键值对,经度
* 第十一键值对,纬度
*/
@Component
@RequiredArgsConstructor
@Slf4j
public class XinghanDeviceDataRule implements MqttMessageRule {
@Override
public String getCommandType() {
return XingHanCommandTypeConstants.XingHan_DEVICE_DATA;
}
@Autowired
private ObjectMapper objectMapper;
@Override
public void execute(MqttRuleContext context) {
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
try {
// Latitude, longitude
//主灯档位,激光灯档位,电量百分比,充电状态,电池剩余续航时间
MqttXinghanJson deviceStatus = objectMapper.convertValue(context.getPayloadDict(), MqttXinghanJson.class);
// 发送设备状态和位置信息到Redis
asyncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),deviceStatus);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
} catch (Exception e) {
log.error("处理上报数据命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));
}
}
/**
* 发送设备状态信息和位置信息到Redis
*
* @param deviceImei 设备IMEI
* @param deviceStatus 机器主动上报的状态信息
*/
public void asyncSendDeviceDataToRedisWithFuture(String deviceImei, MqttXinghanJson deviceStatus) {
CompletableFuture.runAsync(() -> {
try {
// 将设备状态信息存储到Redis中
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_STATUS_KEY_PREFIX;
String deviceInfoJson = JsonUtils.toJsonString(deviceStatus);
// 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, deviceInfoJson);
log.info("设备状态信息已异步发送到Redis: device={}, deviceInfoJson={}",
deviceImei, deviceInfoJson);
//设备坐标缓存KEY
String functionAccess = FUNCTION_ACCESS_KEY + deviceImei;
// 异步发送经纬度到Redis
asyncSendLocationToRedisWithFuture(deviceImei, deviceStatus.getStalatitude(), deviceStatus.getStalongitude());
} catch (Exception e) {
log.error("异步发送设备信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
}
});
}
/**
* 异步发送位置信息到Redis使用CompletableFuture
*
* @param deviceImei 设备IMEI
* @param latitude 纬度
* @param longitude 经度
*/
public void asyncSendLocationToRedisWithFuture(String deviceImei, String latitude, String longitude) {
CompletableFuture.runAsync(() -> {
try {
if(StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)){
return;
}
String[] latArr = latitude.split("\\.");
String[] lonArr = longitude.split("\\.");
// 将位置信息存储到Redis中
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX;
String redisObj = RedisUtils.getCacheObject(redisKey);
JSONObject jsonOBj = JSONObject.parseObject(redisObj);
if(jsonOBj != null){
String str1 = latArr[0] +"."+ latArr[1].substring(0,4);
String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4);
String cacheLatitude = jsonOBj.getString("wgs84_latitude");
String cacheLongitude = jsonOBj.getString("wgs84_longitude");
String[] latArr1 = cacheLatitude.split("\\.");
String[] lonArr1 = cacheLongitude.split("\\.");
String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4);
String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4);
if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){
log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
return;
}
}
// 构造位置信息对象
Map<String, Object> locationInfo = new LinkedHashMap<>();
double[] doubles = LngLonUtil.gps84_To_Gcj02(Double.parseDouble(latitude), Double.parseDouble(longitude));
locationInfo.put("deviceImei", deviceImei);
locationInfo.put("latitude", doubles[0]);
locationInfo.put("longitude", doubles[1]);
locationInfo.put("wgs84_latitude", latitude);
locationInfo.put("wgs84_longitude", longitude);
String address = GetAddressFromLatUtil.getAdd(String.valueOf(doubles[1]), String.valueOf(doubles[0]));
locationInfo.put("address", address);
locationInfo.put("timestamp", System.currentTimeMillis());
String locationJson = JsonUtils.toJsonString(locationInfo);
// 存储到Redis
RedisUtils.setCacheObject(redisKey, locationJson);
// 存储到一个列表中,保留历史位置信息
// String locationHistoryKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_LOCATION_HISTORY_KEY_PREFIX + deviceImei;
// RedisUtils.addCacheList(locationHistoryKey, locationJson);
// RedisUtils.expire(locationHistoryKey, Duration.ofDays(90));
storeDeviceTrajectoryWithSortedSet(deviceImei, locationJson);
log.info("位置信息已异步发送到Redis: device={}, lat={}, lon={}", deviceImei, latitude, longitude);
} catch (Exception e) {
log.error("异步发送位置信息到Redis时出错: device={}, error={}", deviceImei, e.getMessage(), e);
}
});
}
/**
* 存储设备30天历史轨迹到Redis (使用Sorted Set)
*/
public void storeDeviceTrajectoryWithSortedSet(String deviceImei, String locationJson) {
try {
String trajectoryKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + deviceImei + DeviceRedisKeyConstants.DEVICE_LOCATION_HISTORY_KEY_PREFIX;
// String trajectoryKey = "device:trajectory:zset:" + deviceImei;
// String locationJson = JsonUtils.toJsonString(locationInfo);
long timestamp = System.currentTimeMillis();
// 添加到Sorted Set使用时间戳作为score
RedisUtils.zAdd(trajectoryKey, locationJson, timestamp);
// // 设置30天过期时间
// RedisUtils.expire(trajectoryKey, Duration.ofDays(30));
// 清理30天前的数据冗余保护
long thirtyDaysAgo = System.currentTimeMillis() - (7L * 24 * 60 * 60 * 1000);
RedisUtils.zRemoveRangeByScore(trajectoryKey, 0, thirtyDaysAgo);
} catch (Exception e) {
log.error("存储设备轨迹到Redis(ZSet)失败: device={}, error={}", deviceImei, e.getMessage(), e);
}
}
private Map<String, Object> buildLocationDataMap(String latitude, String longitude) {
String[] latArr = latitude.split("\\.");
String[] lonArr = longitude.split("\\.");
ArrayList<Integer> intData = new ArrayList<>();
intData.add(11);
intData.add(Integer.parseInt(latArr[0]));
String str1 = latArr[1];
intData.add(Integer.parseInt(str1.substring(0,4)));
String str2 = lonArr[1];
intData.add(Integer.parseInt(lonArr[0]));
intData.add(Integer.parseInt(str2.substring(0,4)));
Map<String, Object> map = new HashMap<>();
map.put("instruct", intData);
return map;
}
}

View File

@ -0,0 +1,118 @@
package com.fuyuanshen.global.mqtt.rule.xinghan;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
import com.fuyuanshen.global.mqtt.constants.XingHanCommandTypeConstants;
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ALARM_MESSAGE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/**
* 星汉设备发送紧急通知 下发规则:
* <p>
* 1. 设备上行 sta_BreakNews=cover! => 仅标记成功<br>
* 2. 设备上行 sta_BreakNews=数字 => GBK编码每行文字为一包一共4包第一字节为包序号
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class XinghanSendAlarmMessageRule implements MqttMessageRule {
private final MqttGateway mqttGateway;
private final ObjectMapper objectMapper;
@Override
public String getCommandType() {
return XingHanCommandTypeConstants.XingHan_BREAK_NEWS;
}
@Override
public void execute(MqttRuleContext ctx) {
String functionAccess = FUNCTION_ACCESS_KEY + ctx.getDeviceImei();
try {
XinghanSendAlarmMessageRule.MqttXinghanAlarmMsgJson payload = objectMapper.convertValue(
ctx.getPayloadDict(), XinghanSendAlarmMessageRule.MqttXinghanAlarmMsgJson.class);
String respText = payload.getStaBreakNews();
log.info("设备上报紧急通知握手: {} ", respText);
// 1. cover! —— 成功标记
if ("cover!".equalsIgnoreCase(respText)) {
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
log.info("设备 {} 发送紧急通知完成", ctx.getDeviceImei());
return;
}
// 2. 数字 —— 下发数据块
int blockIndex;
try {
blockIndex = Integer.parseInt(respText);
} catch (NumberFormatException ex) {
log.warn("设备 {} 紧急通知上报非法块号:{}", ctx.getDeviceImei(), respText);
return;
}
// 将发送的信息原文本以List<String>形式存储在Redis中
String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + ctx.getDeviceImei() + DEVICE_ALARM_MESSAGE_KEY_PREFIX);
if (data == null || data.isEmpty()) {
return;
}
//
ArrayList<Integer> intData = new ArrayList<>();
intData.add(blockIndex);
// 获取块原内容 转成GBK 再转成无符号十进制整数
String blockTxt = data.split("\\|")[blockIndex-1];
// 再按 GBK 编码把字符串转成字节数组,并逐个转为无符号十进制整数
for (byte b : blockTxt.getBytes(GBK)) {
intData.add(b & 0xFF); // b & 0xFF 得到 0~255 的整数
}
Map<String, Object> map = new HashMap<>();
map.put("ins_BreakNews", intData);
String topic = MqttConstants.GLOBAL_PUB_KEY + ctx.getDeviceImei();
String json = JsonUtils.toJsonString(map);
mqttGateway.sendMsgToMqtt(topic, 1, json);
log.info("发送设备紧急通知=>topic:{},payload:{}",
MqttConstants.GLOBAL_PUB_KEY + ctx.getDeviceImei(),
JsonUtils.toJsonString(map));
} catch (Exception e) {
log.error("处理发送设备紧急通知时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));
}
}
private static final Charset GBK = Charset.forName("GBK");
/* ---------- DTO ---------- */
@Data
private static class MqttXinghanAlarmMsgJson {
/**
* 设备上行:
* 数字 -> 请求对应块号
* cover! -> 写入成功
*/
@JsonProperty("sta_BreakNews")
private String staBreakNews;
}
}

View File

@ -0,0 +1,118 @@
package com.fuyuanshen.global.mqtt.rule.xinghan;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
import com.fuyuanshen.global.mqtt.constants.XingHanCommandTypeConstants;
import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/**
* 星汉设备发送消息 下发规则:
* <p>
* 1. 设备上行 sta_TexTarns=genius! => 仅标记成功<br>
* 2. 设备上行 sta_TexTarns=数字 => GBK编码每行文字为一包一共4包第一字节为包序号
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class XinghanSendMsgRule implements MqttMessageRule {
private final MqttGateway mqttGateway;
private final ObjectMapper objectMapper;
@Override
public String getCommandType() {
return XingHanCommandTypeConstants.XingHan_ESEND_MSG;
}
@Override
public void execute(MqttRuleContext ctx) {
String functionAccess = FUNCTION_ACCESS_KEY + ctx.getDeviceImei();
try {
XinghanSendMsgRule.MqttXinghanMsgJson payload = objectMapper.convertValue(
ctx.getPayloadDict(), XinghanSendMsgRule.MqttXinghanMsgJson.class);
String respText = payload.getStaTexTrans();
log.info("设备上报人员信息: {} ", respText);
// 1. genius! —— 成功标记
if ("genius!".equalsIgnoreCase(respText)) {
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
log.info("设备 {} 发送消息完成", ctx.getDeviceImei());
return;
}
// 2. 数字 —— 下发数据块
int blockIndex;
try {
blockIndex = Integer.parseInt(respText);
} catch (NumberFormatException ex) {
log.warn("设备 {} 消息上报非法块号:{}", ctx.getDeviceImei(), respText);
return;
}
// 将发送的信息原文本以List<String>形式存储在Redis中
List<String> data = RedisUtils.getCacheList(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + ctx.getDeviceImei() + ":app_send_message_data");
if (data.isEmpty()) {
return;
}
//
ArrayList<Integer> intData = new ArrayList<>();
intData.add(blockIndex);
// 获取块原内容 转成GBK 再转成无符号十进制整数
String blockTxt = data.get(blockIndex-1);
log.warn("设备上报人员登记信息:{}", blockTxt);
// 再按 GBK 编码把字符串转成字节数组,并逐个转为无符号十进制整数
for (byte b : blockTxt.getBytes(GBK)) {
intData.add(b & 0xFF); // b & 0xFF 得到 0~255 的整数
}
Map<String, Object> map = new HashMap<>();
map.put("ins_TexTrans", intData);
String topic = MqttConstants.GLOBAL_PUB_KEY + ctx.getDeviceImei();
String json = JsonUtils.toJsonString(map);
mqttGateway.sendMsgToMqtt(topic, 1, json);
log.info("发送设备信息数据到设备消息=>topic:{},payload:{}",
MqttConstants.GLOBAL_PUB_KEY + ctx.getDeviceImei(),
JsonUtils.toJsonString(map));
} catch (Exception e) {
log.error("处理发送设备信息时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));
}
}
private static final Charset GBK = Charset.forName("GBK");
/* ---------- DTO ---------- */
@Data
private static class MqttXinghanMsgJson {
/**
* 设备上行:
* 数字 -> 请求对应块号
* genius! -> 写入成功
*/
@JsonProperty("sta_TexTrans")
private String staTexTrans;
}
}

View File

@ -0,0 +1,110 @@
package com.fuyuanshen.global.queue;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
public class MqttMessageConsumer {
@Autowired
private DeviceMapper deviceMapper;
// 创建两个线程池:一个用于消息获取,一个用于业务处理
private ExecutorService messageConsumerPool = Executors.newFixedThreadPool(3);
private ExecutorService messageProcessorPool = Executors.newFixedThreadPool(10);
// 初始化方法,启动消息监听
// @PostConstruct
public void start() {
log.info("启动MQTT消息消费者...");
// 启动消息获取线程
for (int i = 0; i < 3; i++) {
messageConsumerPool.submit(this::consumeMessages);
}
}
// 销毁方法,关闭线程池
@PreDestroy
public void stop() {
log.info("关闭MQTT消息消费者...");
shutdownExecutorService(messageConsumerPool);
shutdownExecutorService(messageProcessorPool);
}
private void shutdownExecutorService(ExecutorService executorService) {
if (executorService != null && !executorService.isShutdown()) {
executorService.shutdown();
try {
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
executorService.shutdownNow();
}
} catch (InterruptedException e) {
executorService.shutdownNow();
Thread.currentThread().interrupt();
}
}
}
// 消费者方法 - 专门负责从队列获取消息
public void consumeMessages() {
String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
String threadName = Thread.currentThread().getName();
log.info("消息消费者线程 {} 开始监听队列: {}", threadName, queueKey);
try {
while (!Thread.currentThread().isInterrupted() && !messageConsumerPool.isShutdown()) {
// 阻塞式获取队列中的消息
String message = RedisUtils.pollDeduplicated(
queueKey,
MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY,
1,
TimeUnit.SECONDS
);
if (message != null) {
log.info("线程 {} 从队列中获取到消息,提交到处理线程池: {}", threadName, message);
// 将消息处理任务提交到处理线程池
messageProcessorPool.submit(() -> processMessage(message));
}
}
} catch (Exception e) {
log.error("线程 {} 消费消息时发生错误", threadName, e);
}
log.info("消息消费者线程 {} 停止监听队列", threadName);
}
// 处理具体业务逻辑的方法
private void processMessage(String message) {
String threadName = Thread.currentThread().getName();
try {
log.info("业务处理线程 {} 开始处理消息: {}", threadName, message);
// 实现具体的业务逻辑
// 例如更新数据库、发送通知等
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("device_imei", message)
.set("online_status", 1);
deviceMapper.update(updateWrapper);
// 模拟业务处理耗时
Thread.sleep(200);
log.info("业务处理线程 {} 完成消息处理: {}", threadName, message);
} catch (Exception e) {
log.error("业务处理线程 {} 处理消息时发生错误: {}", threadName, message, e);
}
}
}

View File

@ -0,0 +1,8 @@
package com.fuyuanshen.global.queue;
import com.fuyuanshen.common.core.constant.GlobalConstants;
public class MqttMessageQueueConstants {
public static final String MQTT_MESSAGE_QUEUE_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:queue";
public static final String MQTT_MESSAGE_DEDUP_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:dedup";
}

View File

@ -0,0 +1,107 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 设备告警
*
* @author Lion Li
* @date 2025-08-28
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("api/equipment/alarm")
public class DeviceAlarmController extends BaseController {
private final IDeviceAlarmService deviceAlarmService;
/**
* 查询设备告警列表
*/
// @SaCheckPermission("equipment:alarm:list")
@GetMapping("/list")
public TableDataInfo<DeviceAlarmVo> list(DeviceAlarmBo bo, PageQuery pageQuery) {
return deviceAlarmService.queryPageList(bo, pageQuery);
}
/**
* 导出设备告警列表
*/
// @SaCheckPermission("equipment:alarm:export")
@Log(title = "导出设备告警列表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DeviceAlarmBo bo, HttpServletResponse response) {
List<DeviceAlarmVo> list = deviceAlarmService.queryList(bo);
ExcelUtil.exportExcel(list, "设备告警", DeviceAlarmVo.class, response);
}
/**
* 获取设备告警详细信息
*
* @param id 主键
*/
// @SaCheckPermission("equipment:alarm:query")
@GetMapping("/{id}")
public R<DeviceAlarmVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(deviceAlarmService.queryById(id));
}
/**
* 新增设备告警
*/
// @SaCheckPermission("equipment:alarm:add")
@Log(title = "设备告警", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DeviceAlarmBo bo) {
return toAjax(deviceAlarmService.insertByBo(bo));
}
/**
* 修改设备告警
*/
// @SaCheckPermission("equipment:alarm:edit")
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DeviceAlarmBo bo) {
return toAjax(deviceAlarmService.updateByBo(bo));
}
/**
* 删除设备告警
*
* @param ids 主键串
*/
// @SaCheckPermission("equipment:alarm:remove")
@Log(title = "设备告警", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(deviceAlarmService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -0,0 +1,119 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* web后台:设备控制类
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/bjq/device")
public class DeviceBJQController extends BaseController {
private final DeviceBJQBizService appDeviceService;
/**
* 获取设备详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(appDeviceService.getInfo(id));
}
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
/**
* 发送信息
*/
@PostMapping(value = "/sendMessage")
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendMessage(bo));
}
/**
* 发送报警信息
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式
*/
// @FunctionAccessAnnotation("lightModeSettings")
@PostMapping("/lightModeSettings")
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.lightModeSettings(params);
return R.ok();
}
/**
* 灯光亮度设置
*
*/
// @FunctionAccessAnnotation("lightBrightnessSettings")
@PostMapping("/lightBrightnessSettings")
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.lightBrightnessSettings(params);
return R.ok();
}
/**
* 激光模式设置
*
*/
@PostMapping("/laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings")
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.laserModeSettings(params);
return R.ok();
}
}

View File

@ -0,0 +1,107 @@
package com.fuyuanshen.web.controller.device;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
import com.fuyuanshen.equipment.service.IDeviceChargeDischargeService;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
/**
* 设备充放电记录
*
* @author Lion Li
* @date 2025-08-30
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/equipment/chargeDischarge")
public class DeviceChargeDischargeController extends BaseController {
private final IDeviceChargeDischargeService deviceChargeDischargeService;
/**
* 查询设备充放电记录列表
*/
// @SaCheckPermission("equipment:chargeDischarge:list")
@GetMapping("/list")
public TableDataInfo<DeviceChargeDischargeVo> list(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
return deviceChargeDischargeService.queryPageList(bo, pageQuery);
}
/**
* 设备充放电记录列表
*/
// @SaCheckPermission("equipment:chargeDischarge:export")
@Log(title = "设备充放电记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) {
List<DeviceChargeDischargeVo> list = deviceChargeDischargeService.queryList(bo);
ExcelUtil.exportExcel(list, "设备充放电记录", DeviceChargeDischargeVo.class, response);
}
/**
* 获取设备充放电记录详细信息
*
* @param id 主键
*/
// @SaCheckPermission("equipment:chargeDischarge:query")
@GetMapping("/{id}")
public R<DeviceChargeDischargeVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(deviceChargeDischargeService.queryById(id));
}
/**
* 新增设备充放电记录
*/
// @SaCheckPermission("equipment:chargeDischarge:add")
@Log(title = "设备充放电记录", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DeviceChargeDischargeBo bo) {
return toAjax(deviceChargeDischargeService.insertByBo(bo));
}
/**
* 修改设备充放电记录
*/
// @SaCheckPermission("equipment:chargeDischarge:edit")
@Log(title = "设备充放电记录", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DeviceChargeDischargeBo bo) {
return toAjax(deviceChargeDischargeService.updateByBo(bo));
}
/**
* 删除设备充放电记录
*
* @param ids 主键串
*/
// @SaCheckPermission("equipment:chargeDischarge:remove")
@Log(title = "设备充放电记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -1,210 +1,150 @@
package com.fuyuanshen.web.controller.device;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.*;
import com.fuyuanshen.web.service.device.DeviceBizService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author: 默苍璃
* @date: 2025-08-0810:40
* web后台:设备控制中心
*/
@Slf4j
@Tag(name = "web后台:设备控制中心", description = "web后台:设备控制中心")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/device/controlCenter")
public class DeviceControlCenterController {
@RequestMapping("/api/device")
public class DeviceControlCenterController extends BaseController {
private final DeviceBizService appDeviceService;
/**
* 获取设备基本信息
* @param deviceId 设备ID
* @return 设备基本信息
* 查询设备列表
*/
@GetMapping("/info/{deviceId}")
public ResponseEntity<Map<String, Object>> getDeviceInfo(@PathVariable String deviceId) {
// 实际应用中这里会从数据库查询设备信息
Map<String, Object> deviceInfo = new HashMap<>();
deviceInfo.put("deviceName", "6170零零一");
deviceInfo.put("deviceModel", "BJQ6170");
deviceInfo.put("deviceId", deviceId);
deviceInfo.put("status", "在线");
deviceInfo.put("batteryLevel", 85);
return ResponseEntity.ok(deviceInfo);
@GetMapping("/list")
public TableDataInfo<WebDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
return appDeviceService.queryWebDeviceList(bo, pageQuery);
}
/**
* 设置灯光模式
* @param lightModeRequest 灯光模式请求
* @return 操作结果
* 绑定设备
*/
@PostMapping("/light-mode")
public ResponseEntity<Map<String, Object>> setLightMode(@RequestBody LightModeRequest lightModeRequest) {
// 实际应用中这里会控制设备灯光
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
// response.put("message", "灯光模式已设置为: " + lightModeRequest.getMode());
// response.put("deviceId", lightModeRequest.getDeviceId());
// response.put("mode", lightModeRequest.getMode());
@PostMapping("/bind")
public R<Void> bind(@RequestBody AppDeviceBo bo) {
return toAjax(appDeviceService.bindDevice(bo));
}
return ResponseEntity.ok(response);
/**
* 解绑设备
*/
@DeleteMapping("/unBind")
public R<Void> unBind(Long id) {
return toAjax(appDeviceService.unBindDevice(id));
}
/**
* 更新人员信息
* @param personInfo 人员信息
* @return 操作结果
* 查询设备类型列表
*/
@PostMapping("/person-info")
public ResponseEntity<Map<String, Object>> updatePersonInfo(@RequestBody PersonInfo personInfo) {
// 实际应用中这里会更新数据库
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
response.put("message", "人员信息已更新");
// response.put("unit", personInfo.getUnit());
// response.put("position", personInfo.getPosition());
return ResponseEntity.ok(response);
@GetMapping(value = "/typeList")
public R<List<APPDeviceTypeVo>> getTypeList() {
List<APPDeviceTypeVo> typeList = appDeviceService.getTypeList();
return R.ok(typeList);
}
/**
* 管理开机画面内容
* @param bootScreenRequest 开机画面请求
* @return 操作结果
* 重命名设备
*
* @param reNameDTO
* @return
*/
@PostMapping("/boot-screen")
public ResponseEntity<Map<String, Object>> manageBootScreen(@RequestBody BootScreenRequest bootScreenRequest) {
// 实际应用中这里会更新设备开机画面
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
response.put("message", "开机画面内容已更新");
// response.put("deviceId", bootScreenRequest.getDeviceId());
// response.put("screens", bootScreenRequest.getScreens());
@PostMapping(value = "/reName")
public R<String> reName(@Validated @RequestBody APPReNameDTO reNameDTO) {
appDeviceService.reName(reNameDTO);
return R.ok("重命名成功!!!");
}
return ResponseEntity.ok(response);
@GetMapping("/realTimeStatus")
public R<Map<String, Object>> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
Map<String, Object> status = appDeviceService.getRealTimeStatus(statusDto);
return R.ok(status);
}
/**
* 设置灯光亮度
* @param brightnessRequest 亮度请求
* @return 操作结果
* 根据mac查询设备信息
*/
@PostMapping("/brightness")
public ResponseEntity<Map<String, Object>> setBrightness(@RequestBody BrightnessRequest brightnessRequest) {
// 实际应用中这里会控制设备亮度
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
// response.put("message", "灯光亮度已设置为: " + brightnessRequest.getBrightness() + "%");
// response.put("deviceId", brightnessRequest.getDeviceId());
// response.put("brightness", brightnessRequest.getBrightness());
// response.put("forceAlarm", brightnessRequest.isForceAlarm());
return ResponseEntity.ok(response);
@GetMapping("/getDeviceInfoByDeviceMac")
public R<AppDeviceVo> getDeviceInfo(String deviceMac) {
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
}
/**
* 获取设备位置信息
* @param deviceId 设备ID
* @return 位置信息
* 指令下发记录
*/
@GetMapping("/location/{deviceId}")
public ResponseEntity<Map<String, Object>> getLocation(@PathVariable String deviceId) {
// 实际应用中这里会从设备获取实时位置
Map<String, Object> locationInfo = new HashMap<>();
locationInfo.put("deviceId", deviceId);
locationInfo.put("longitude", "114°7'E");
locationInfo.put("latitude", "30'28'N");
locationInfo.put("address", "湖北省武汉市洪山区光谷大道国际企业中心");
locationInfo.put("timestamp", new Date());
return ResponseEntity.ok(locationInfo);
@GetMapping("/instructionRecord")
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto dto, PageQuery pageQuery) {
return appDeviceService.getInstructionRecord(dto,pageQuery);
}
/**
* 发送紧急消息
* @param messageRequest 消息请求
* @return 操作结果
* 导出
*/
@PostMapping("/send-message")
public ResponseEntity<Map<String, Object>> sendMessage(@RequestBody MessageRequest messageRequest) {
// 实际应用中这里会向设备发送消息
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
response.put("message", "消息已发送");
// response.put("deviceId", messageRequest.getDeviceId());
// response.put("content", messageRequest.getContent());
response.put("timestamp", new Date());
@GetMapping("/export")
public void export(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
pageQuery.setPageNum(1);
pageQuery.setPageSize(2000);
TableDataInfo<InstructionRecordVo> instructionRecord = appDeviceService.getInstructionRecord(dto, pageQuery);
if(instructionRecord.getRows() == null){
return;
}
ExcelUtil.exportExcel(instructionRecord.getRows(), "设备操作日志", InstructionRecordVo.class, response);
}
return ResponseEntity.ok(response);
/**
* 历史轨迹查询
*/
@GetMapping("/locationHistory")
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto dto, PageQuery pageQuery) {
return appDeviceService.getLocationHistory(dto,pageQuery);
}
/**
* 管理操作视频
* @param videoRequest 视频请求
* @return 操作结果
* 历史轨迹导出
*/
@PostMapping("/operation-video")
public ResponseEntity<Map<String, Object>> manageOperationVideo(@RequestBody VideoRequest videoRequest) {
// 实际应用中这里会更新设备操作视频
Map<String, Object> response = new HashMap<>();
response.put("code", 200);
response.put("message", "操作视频已更新");
// response.put("deviceId", videoRequest.getDeviceId());
// response.put("videoUrl", videoRequest.getVideoUrl());
return ResponseEntity.ok(response);
@GetMapping("/locationHistoryExport")
public void locationHistoryExport(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
pageQuery.setPageNum(1);
pageQuery.setPageSize(2000);
TableDataInfo<LocationHistoryVo> result = appDeviceService.getLocationHistory(dto, pageQuery);
if(result.getRows() == null){
return;
}
ExcelUtil.exportExcel(result.getRows(), "历史轨迹记录", LocationHistoryVo.class, response);
}
// 请求对象类定义
public static class LightModeRequest {
private String deviceId;
private String mode; // 强光、弱光、爆闪、泛光、激光
// Getters and Setters
/**
* 历史轨迹播放
*/
@GetMapping("/getLocationHistoryDetail")
public R<List<LocationHistoryDetailVo>> getLocationHistoryDetail(Long id) {
return R.ok(appDeviceService.getLocationHistoryDetail(id));
}
public static class PersonInfo {
private String deviceId;
private String unit; // 单位
private String position; // 职位
// Getters and Setters
}
public static class BootScreenRequest {
private String deviceId;
private List<String> screens; // 产品参数、操作说明等
// Getters and Setters
}
public static class BrightnessRequest {
private String deviceId;
private int brightness; // 0-100
private boolean forceAlarm; // 强制报警
// Getters and Setters
}
public static class MessageRequest {
private String deviceId;
private String content; // 消息内容
// Getters and Setters
}
public static class VideoRequest {
private String deviceId;
private String videoUrl; // 视频链接
// Getters and Setters
}
}

View File

@ -1,25 +1,27 @@
package com.fuyuanshen.web.controller.device;
import java.util.List;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.equipment.service.IDeviceGroupService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 设备分组
@ -27,6 +29,7 @@ import com.fuyuanshen.equipment.service.IDeviceGroupService;
* @author Lion Li
* @date 2025-08-08
*/
@Tag(name = "web:设备分组", description = "web:设备分组")
@Validated
@RequiredArgsConstructor
@RestController
@ -39,6 +42,7 @@ public class DeviceGroupController extends BaseController {
/**
* 查询设备分组列表
*/
@Operation(summary = "查询设备分组列表")
@SaCheckPermission("fys-equipment:group:list")
@GetMapping("/list")
public R<List<DeviceGroupVo>> list(DeviceGroupBo bo) {
@ -47,6 +51,24 @@ public class DeviceGroupController extends BaseController {
}
/**
* 查询设备分组列表(分页)
*/
@Operation(summary = "查询设备分组列表(分页)")
@SaCheckPermission("fys-equipment:group:list")
@GetMapping("/listPage")
public TableDataInfo<DeviceGroupVo> listPage(DeviceGroupBo bo) {
List<DeviceGroupVo> list = deviceGroupService.queryList(bo);
// return R.ok(list);
return null;
}
// @GetMapping("/list")
// public TableDataInfo<DeviceAlarmVo> list(DeviceAlarmBo bo, PageQuery pageQuery) {
// return deviceAlarmService.queryPageList(bo, pageQuery);
// }
/**
* 导出设备分组列表
*/
@ -64,6 +86,7 @@ public class DeviceGroupController extends BaseController {
*
* @param id 主键
*/
@Operation(summary = "获取设备分组详细信息")
@SaCheckPermission("fys-equipment:group:query")
@GetMapping("/{id}")
public R<DeviceGroupVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
@ -74,6 +97,7 @@ public class DeviceGroupController extends BaseController {
/**
* 新增设备分组
*/
@Operation(summary = "新增设备分组")
@SaCheckPermission("fys-equipment:group:add")
@Log(title = "设备分组", businessType = BusinessType.INSERT)
@RepeatSubmit()
@ -86,6 +110,7 @@ public class DeviceGroupController extends BaseController {
/**
* 修改设备分组
*/
@Operation(summary = "修改设备分组")
@SaCheckPermission("fys-equipment:group:edit")
@Log(title = "设备分组", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@ -99,11 +124,43 @@ public class DeviceGroupController extends BaseController {
*
* @param ids 主键串
*/
@Operation(summary = "删除设备分组")
@SaCheckPermission("fys-equipment:group:remove")
@Log(title = "设备分组", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
public R<Void> remove(@NotNull(message = "主键不能为空") @PathVariable Long[] ids) {
return toAjax(deviceGroupService.deleteWithValidByIds(List.of(ids), true));
}
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
*/
@Operation(summary = "绑定设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "绑定设备分组", businessType = BusinessType.DELETE)
@GetMapping("/groupId/{groupId}/{deviceId}")
public R<Void> bindingDevice(@NotNull(message = "分组id 不能为空") @PathVariable Long groupId,
@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
return toAjax(deviceGroupService.bindingDevice(groupId, deviceId));
}
/**
* 解绑设备分组
*
* @param deviceId 设备id
*/
@Operation(summary = "解绑设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "解绑设备分组", businessType = BusinessType.DELETE)
@GetMapping("/groupUnbind/{deviceId}")
public R<Void> groupUnbind(@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
return toAjax(deviceGroupService.groupUnbind(deviceId));
}
}

View File

@ -0,0 +1,105 @@
package com.fuyuanshen.web.controller.device;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.RandomUtil;
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.web.service.DeviceShareService;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.dromara.sms4j.api.SmsBlend;
import org.dromara.sms4j.api.entity.SmsResponse;
import org.dromara.sms4j.core.factory.SmsFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.Duration;
import java.util.LinkedHashMap;
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
/**
* 设备分享管理
*
* @author Lion Li
* @date 2025-08-28
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("api/equipment/share")
public class DeviceShareController extends BaseController {
private final DeviceShareService deviceShareService;
/**
* 分享管理列表
*/
@GetMapping("/deviceShareList")
public TableDataInfo<AppDeviceShareVo> list(AppDeviceShareBo bo, PageQuery pageQuery) {
return deviceShareService.queryWebPageList(bo, pageQuery);
}
/**
* 新增设备分享
*/
@RepeatSubmit()
@PostMapping("/deviceShare")
public R<Void> deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
return toAjax(deviceShareService.deviceShare(bo));
}
/**
* 权限管理
*/
@RepeatSubmit()
@PostMapping("/permission")
public R<Void> permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
return toAjax(deviceShareService.permission(bo));
}
/**
* 移除分享用户
*
* @param ids 主键串
*/
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(deviceShareService.remove(ids));
}
/**
* 短信验证码
*
* @param phonenumber 用户手机号
*/
@SaIgnore
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
@GetMapping("/sms/code")
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
String key = DEVICE_SHARE_CODES_KEY + phonenumber;
String code = RandomUtil.randomNumbers(4);
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
map.put("code", code);
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map);
if (!smsResponse.isSuccess()) {
return R.fail(smsResponse.getData().toString());
}
return R.ok();
}
}

View File

@ -0,0 +1,73 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.equipment.domain.vo.AlarmInformationVo;
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
import com.fuyuanshen.equipment.domain.vo.EquipmentClassificationVo;
import com.fuyuanshen.equipment.service.DeviceService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 首页数据
*
* @author: 默苍璃
* @date: 2025-09-0113:46
*/
@Tag(name = "首页数据", description = "首页数据")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/device/homepage")
public class HomePageController {
private final DeviceService deviceService;
/**
* 获取 数据总览
* DataOverview
*/
@GetMapping("/getDataOverview")
public R<DataOverviewVo> getDataOverview() {
return R.ok(deviceService.getDataOverview());
}
/**
* 获取 设备分类
* DataOverview
*/
@GetMapping("/getEquipmentClassification")
public R<EquipmentClassificationVo> getEquipmentClassification() {
return R.ok(deviceService.getEquipmentClassification());
}
/**
* 获取 报警信息
* DataOverview
*/
@GetMapping("/getAlarmInformation")
public R<AlarmInformationVo> getAlarmInformation() {
return R.ok(deviceService.getAlarmInformation());
}
/**
* 获取设备使用数据
*
* @param deviceId 设备ID
* @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表
*/
@GetMapping("/getEquipmentUsageData/{deviceId}/{range}")
public R<List<Map<String, Object>>> getEquipmentUsageData(@PathVariable Long deviceId, @PathVariable Integer range) {
return R.ok(deviceService.getEquipmentUsageData(deviceId, range));
}
}

View File

@ -1,16 +1,22 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.service.WEBDeviceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description:
@ -41,6 +47,71 @@ public class WEBDeviceController extends BaseController {
}
/**
* 设备详情
*
* @param id
* @return
*/
@Operation(summary = "设备详情")
@GetMapping(value = "/pc/detail/{id}")
public R<WebDeviceVo> getDeviceDetail(@PathVariable Long id) {
WebDeviceVo device = deviceService.getDevice(id);
return R.ok(device);
}
/**
* 设备用户详情
*
* @param deviceId
* @return
*/
@Operation(summary = "设备用户详情")
@GetMapping(value = "/getDeviceUser/{deviceId}")
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long deviceId) {
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(deviceId);
return R.ok(device);
}
/**
* 设备操作记录
*
* @param deviceId
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@Operation(summary = "设备操作记录")
@GetMapping(value = "/getOperationRecord/{deviceId}")
public TableDataInfo<DeviceLog> getOperationRecord(@PathVariable Long deviceId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
PageQuery pageQuery) {
TableDataInfo<DeviceLog> device = deviceService.getOperationRecord(deviceId, startTime, endTime,pageQuery);
return device;
}
/**
* 设备告警记录
*
* @param deviceId
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@Operation(summary = "设备告警记录")
@GetMapping(value = "/getAlarmRecord/{deviceId}")
public TableDataInfo<DeviceAlarmVo> getAlarmRecord(@PathVariable Long deviceId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
PageQuery pageQuery) {
return deviceService.getAlarmRecord(deviceId, startTime, endTime, pageQuery);
}
}

View File

@ -0,0 +1,312 @@
package com.fuyuanshen.web.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.app.domain.AppPersonnelInfo;
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo;
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceType;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
@RequiredArgsConstructor
@Slf4j
@Service
public class DeviceShareService {
private final AppDeviceShareMapper appDeviceShareMapper;
private final DeviceMapper deviceMapper;
private final DeviceTypeMapper deviceTypeMapper;
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
public TableDataInfo<AppDeviceShareVo> queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
Long userId = AppLoginHelper.getUserId();
bo.setCreateBy(userId);
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectAppDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(DeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
public TableDataInfo<AppDeviceShareVo> queryWebPageList(AppDeviceShareBo bo, PageQuery pageQuery) {
// Long userId = AppLoginHelper.getUserId();
// bo.setCreateBy(userId);
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(DeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
private static void buildDeviceStatus(AppDeviceShareVo item) {
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
item.setOnlineStatus(1);
} else {
item.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
item.setBattery(jsonObject.getString("batteryPercentage"));
} else {
item.setBattery("0");
}
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
if (StringUtils.isNotBlank(location)) {
JSONObject jsonObject = JSONObject.parseObject(location);
item.setLatitude(jsonObject.getString("latitude"));
item.setLongitude(jsonObject.getString("longitude"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
item.setAlarmStatus(alarmStatus);
}
}
public AppDeviceShareDetailVo getInfo(Long id) {
LambdaQueryWrapper<AppDeviceShare> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AppDeviceShare::getId, id);
List<AppDeviceShareVo> appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper);
if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) {
return null;
}
AppDeviceShareVo shareVo = appDeviceShareVos.get(0);
AppDeviceShareDetailVo shareDetailVo = new AppDeviceShareDetailVo();
shareDetailVo.setId(shareVo.getId());
shareDetailVo.setDeviceId(shareVo.getDeviceId());
shareDetailVo.setPhonenumber(shareVo.getPhonenumber());
shareDetailVo.setPermission(shareVo.getPermission());
Device device = deviceMapper.selectById(shareVo.getDeviceId());
shareDetailVo.setDeviceName(device.getDeviceName());
shareDetailVo.setDeviceImei(device.getDeviceImei());
shareDetailVo.setDeviceMac(device.getDeviceMac());
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
if (deviceType != null) {
shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
}
shareDetailVo.setDevicePic(device.getDevicePic());
shareDetailVo.setTypeName(deviceType.getTypeName());
shareDetailVo.setBluetoothName(device.getBluetoothName());
shareDetailVo.setDeviceStatus(device.getDeviceStatus());
shareDetailVo.setSendMsg(device.getSendMsg());
LambdaQueryWrapper<AppPersonnelInfo> qw = new LambdaQueryWrapper<>();
qw.eq(AppPersonnelInfo::getDeviceId, device.getId());
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
if (appPersonnelInfoVos != null && !appPersonnelInfoVos.isEmpty()) {
shareDetailVo.setPersonnelInfo(appPersonnelInfoVos.get(0));
}
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
shareDetailVo.setOnlineStatus(1);
} else {
shareDetailVo.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
shareDetailVo.setMainLightMode(jsonObject.getString("mainLightMode"));
shareDetailVo.setLaserLightMode(jsonObject.getString("laserLightMode"));
shareDetailVo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
shareDetailVo.setChargeState(jsonObject.getString("chargeState"));
shareDetailVo.setBatteryRemainingTime(jsonObject.getString("batteryRemainingTime"));
} else {
shareDetailVo.setBatteryPercentage("0");
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);
if (StringUtils.isNotBlank(locationInfo)) {
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
shareDetailVo.setLongitude(jsonObject.get("longitude").toString());
shareDetailVo.setLatitude(jsonObject.get("latitude").toString());
shareDetailVo.setAddress((String) jsonObject.get("address"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
shareDetailVo.setAlarmStatus(alarmStatus);
}
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if (StringUtils.isNotBlank(lightBrightness)) {
shareDetailVo.setLightBrightness(lightBrightness);
}
return shareDetailVo;
}
/**
* 校验短信验证码
*/
private boolean validateSmsCode(String phonenumber, String smsCode) {
String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber);
if (StringUtils.isBlank(code)) {
throw new ServiceException("验证码失效");
}
return code.equals(smsCode);
}
public int deviceShare(AppDeviceShareBo bo) {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
boolean flag = validateSmsCode( bo.getPhonenumber(), bo.getSmsCode());
if (!flag) {
throw new ServiceException("验证码错误");
}
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
if (bindRecord == null) {
throw new ServiceException("设备未绑定");
}
Long userId = bindRecord.getBindingUserId();
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
Long count = appDeviceShareMapper.selectCount(lqw);
if (count > 0) {
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
uw.eq("device_id", bo.getDeviceId());
uw.eq("phonenumber", bo.getPhonenumber());
uw.set("permission", bo.getPermission());
uw.set("update_by", userId);
uw.set("update_time", new Date());
return appDeviceShareMapper.update(uw);
} else {
AppDeviceShare appDeviceShare = new AppDeviceShare();
appDeviceShare.setDeviceId(bo.getDeviceId());
appDeviceShare.setPhonenumber(bo.getPhonenumber());
appDeviceShare.setPermission(bo.getPermission());
appDeviceShare.setCreateBy(userId);
return appDeviceShareMapper.insert(appDeviceShare);
}
}
public int permission(AppDeviceShareBo bo) {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
if (bindRecord == null) {
throw new ServiceException("设备未绑定");
}
Long userId = bindRecord.getBindingUserId();
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
Long count = appDeviceShareMapper.selectCount(lqw);
if (count > 0) {
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
uw.eq("device_id", bo.getDeviceId());
uw.eq("phonenumber", bo.getPhonenumber());
uw.set("permission", bo.getPermission());
uw.set("update_by", userId);
uw.set("update_time", new Date());
return appDeviceShareMapper.update(uw);
} else {
AppDeviceShare appDeviceShare = new AppDeviceShare();
appDeviceShare.setDeviceId(bo.getDeviceId());
appDeviceShare.setPhonenumber(bo.getPhonenumber());
appDeviceShare.setPermission(bo.getPermission());
appDeviceShare.setCreateBy(userId);
return appDeviceShareMapper.insert(appDeviceShare);
}
}
public int remove(Long[] ids) {
return appDeviceShareMapper.deleteByIds(Arrays.asList(ids));
}
public TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) {
String username = AppLoginHelper.getUsername();
bo.setPhonenumber(username);
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
IPage<AppDeviceShareVo> result = appDeviceShareMapper.otherDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(DeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
/**
* 查询设备分享列表(web)
*
* @param bo
* @param pageQuery
* @return
*/
public TableDataInfo<AppDeviceShareVo> queryWebList(AppDeviceShareBo bo, PageQuery pageQuery) {
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(DeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
}

View File

@ -2,14 +2,18 @@ package com.fuyuanshen.web.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.form.DeviceForm;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import java.io.IOException;
import java.util.List;
@ -29,4 +33,41 @@ public interface WEBDeviceService extends IService<Device> {
*/
int webUnBindDevice(Long id, Long userId);
/**
* WEB端设备详情
*
* @param id
* @return
*/
WebDeviceVo getDevice(Long id);
/**
* 设备用户详情
*
* @param id
* @return
*/
List<AppPersonnelInfoRecords> getDeviceUser(Long id);
/**
* 设备操作记录
*
* @param deviceId
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
/**
* 设备告警记录
*
* @param deviceId
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
TableDataInfo<DeviceAlarmVo> getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery);
}

View File

@ -1,16 +1,19 @@
package com.fuyuanshen.web.service.device;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.AppPersonnelInfo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.*;
@ -19,6 +22,7 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceType;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.equipment.enums.LightModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
@ -49,6 +53,7 @@ public class DeviceBJQBizService {
private final DeviceMapper deviceMapper;
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
private final AppPersonnelInfoRecordsMapper appPersonnelInfoRecordsMapper;
private final DeviceTypeMapper deviceTypeMapper;
private final MqttGateway mqttGateway;
private final DeviceLogMapper deviceLogMapper;
@ -63,13 +68,16 @@ public class DeviceBJQBizService {
if (device == null) {
throw new ServiceException("设备不存在" + deviceId);
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
try {
ClassPathResource resource = new ClassPathResource("image/background.png");
InputStream inputStream = resource.getInputStream();
byte[] largeData = ImageWithTextGenerate.generate160x80ImageWithText2(bo.getSendMsg(), inputStream, 25600);
int[] ints = convertHexToDecimal(largeData);
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + ":app_send_message_data" , Arrays.toString(ints), Duration.ofSeconds(30 * 60L));
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + ":app_send_message_data" , Arrays.toString(ints), Duration.ofSeconds(5 * 60L));
String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + ":app_send_message_data");
@ -92,9 +100,9 @@ public class DeviceBJQBizService {
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", deviceId)
.eq("binding_user_id", AppLoginHelper.getUserId())
.set("send_msg", bo.getSendMsg());
deviceMapper.update(updateWrapper);
recordDeviceLog(deviceId, device.getDeviceName(), "发送信息", bo.getSendMsg(), AppLoginHelper.getUserId());
} catch (Exception e) {
log.info("发送信息设备发送信息失败:{}" ,deviceId);
@ -137,6 +145,7 @@ public class DeviceBJQBizService {
if (device == null) {
throw new RuntimeException("请先将设备入库!!!");
}
AppDeviceDetailVo vo = new AppDeviceDetailVo();
vo.setDeviceId(device.getId());
vo.setDeviceName(device.getDeviceName());
@ -180,6 +189,22 @@ public class DeviceBJQBizService {
vo.setBatteryPercentage("0");
}
String lightModeStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
vo.setMainLightMode(lightModeStatus);
}
String lightBrightnessStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if(StringUtils.isNotBlank(lightBrightnessStatus)){
vo.setLightBrightness(lightBrightnessStatus);
}
String laserLightMode = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LASER_MODE_KEY_PREFIX);
if(StringUtils.isNotBlank(laserLightMode)){
vo.setLaserLightMode(laserLightMode);
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);
@ -211,6 +236,9 @@ public class DeviceBJQBizService {
if (deviceObj == null) {
throw new RuntimeException("请先将设备入库!!!");
}
if(getDeviceStatus(deviceObj.getDeviceImei())){
throw new ServiceException(deviceObj.getDeviceName()+",设备已断开连接");
}
QueryWrapper<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
.eq("device_id", deviceId);
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
@ -233,10 +261,18 @@ public class DeviceBJQBizService {
map.put("instruct", intData);
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), 1, JSON.toJSONString(map));
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), bo);
recordDeviceLog(deviceId, deviceObj.getDeviceName(), "人员信息登记", JSON.toJSONString(bo), AppLoginHelper.getUserId());
String logContent = "单位:"+bo.getUnitName()+",职位:"+bo.getPosition()+",姓名:"+bo.getName()+",ID"+bo.getCode();
recordDeviceLog(deviceId, deviceObj.getDeviceName(), "人员信息登记", logContent, AppLoginHelper.getUserId());
if (ObjectUtils.length(appPersonnelInfoVos) == 0) {
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
AppPersonnelInfoRecords appPersonnelInfoRecords = new AppPersonnelInfoRecords();
BeanUtil.copyProperties(appPersonnelInfo, appPersonnelInfoRecords);
appPersonnelInfoRecords.setId(null);
appPersonnelInfoRecords.setPersonnelId(appPersonnelInfo.getId());
appPersonnelInfoRecordsMapper.insert(appPersonnelInfoRecords);
} else {
UpdateWrapper<AppPersonnelInfo> uw = new UpdateWrapper<>();
uw.eq("device_id", deviceId)
@ -244,16 +280,61 @@ public class DeviceBJQBizService {
.set("position", bo.getPosition())
.set("unit_name", bo.getUnitName())
.set("code", bo.getCode());
return appPersonnelInfoMapper.update(null, uw) > 0;
appPersonnelInfoMapper.update(null, uw);
AppPersonnelInfoVo personnelInfoVo = appPersonnelInfoVos.get(0);
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
AppPersonnelInfoRecords appPersonnelInfoRecords = new AppPersonnelInfoRecords();
BeanUtil.copyProperties(appPersonnelInfo, appPersonnelInfoRecords);
appPersonnelInfoRecords.setId(null);
appPersonnelInfoRecords.setPersonnelId(personnelInfoVo.getId());
appPersonnelInfoRecordsMapper.insert(appPersonnelInfoRecords);
}
return true;
}
public void uploadDeviceLogo2(AppDeviceLogoUploadDto bo) {
try {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
MultipartFile file = bo.getFile();
byte[] largeData = ImageToCArrayConverter.convertImageToCArray(file.getInputStream(), 160, 80, 25600);
log.info("长度:" + largeData.length);
// 在获取 largeData 后,将其与前缀合并
byte[] prefix = new byte[]{0x50, 0x49, 0x43, 0x54, 0x55, 0x52, 0x45}; // "PICTURE"
byte[] combinedData = new byte[prefix.length + largeData.length];
System.arraycopy(prefix, 0, combinedData, 0, prefix.length);
System.arraycopy(largeData, 0, combinedData, prefix.length, largeData.length);
// 将 combinedData 转换为十六进制表示
String[] hexArray = new String[combinedData.length];
for (int i = 0; i < combinedData.length; i++) {
hexArray[i] = String.format("0x%02X", combinedData[i]);
}
// Map<String, Object> map = new HashMap<>();
// map.put("instruct", combinedData);
String[] specificChunk = ImageToCArrayConverter.getChunk2(hexArray, 0, bo.getChunkSize());
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , Arrays.toString(specificChunk));
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),Arrays.toString(specificChunk));
recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", "上传开机画面", AppLoginHelper.getUserId());
} catch (Exception e){
e.printStackTrace();
throw new ServiceException("发送指令失败");
}
}
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
try {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
MultipartFile file = bo.getFile();
byte[] largeData = ImageToCArrayConverter.convertImageToCArray(file.getInputStream(), 160, 80, 25600);
@ -262,7 +343,7 @@ public class DeviceBJQBizService {
log.info("原始数据大小: {} 字节", largeData.length);
int[] ints = convertHexToDecimal(largeData);
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() +DEVICE_BOOT_LOGO_KEY_PREFIX, Arrays.toString(ints), Duration.ofSeconds(30 * 60L));
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() +DEVICE_BOOT_LOGO_KEY_PREFIX, Arrays.toString(ints), Duration.ofSeconds(5 * 60L));
String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_BOOT_LOGO_KEY_PREFIX);
@ -303,6 +384,9 @@ public class DeviceBJQBizService {
if(device == null){
throw new ServiceException("设备不存在");
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
Integer instructValue = Integer.parseInt(params.getInstructValue());
ArrayList<Integer> intData = new ArrayList<>();
intData.add(1);
@ -314,6 +398,8 @@ public class DeviceBJQBizService {
map.put("instruct", intData);
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , JSON.toJSONString(map));
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),JSON.toJSONString(map));
LightModeEnum modeEnum = LightModeEnum.getByCode(instructValue);
recordDeviceLog(device.getId(), device.getDeviceName(), "灯光模式", modeEnum!=null?modeEnum.getName():null, AppLoginHelper.getUserId());
} catch (Exception e){
e.printStackTrace();
throw new ServiceException("发送指令失败");
@ -328,6 +414,9 @@ public class DeviceBJQBizService {
if(device == null){
throw new ServiceException("设备不存在");
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
String instructValue = params.getInstructValue();
ArrayList<Integer> intData = new ArrayList<>();
intData.add(5);
@ -347,6 +436,7 @@ public class DeviceBJQBizService {
map.put("instruct", intData);
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , JSON.toJSONString(map));
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),JSON.toJSONString(map));
} catch (Exception e){
e.printStackTrace();
throw new ServiceException("发送指令失败");
@ -361,6 +451,9 @@ public class DeviceBJQBizService {
if(device == null){
throw new ServiceException("设备不存在");
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
Integer instructValue = Integer.parseInt(params.getInstructValue());
ArrayList<Integer> intData = new ArrayList<>();
intData.add(4);
@ -372,6 +465,12 @@ public class DeviceBJQBizService {
map.put("instruct", intData);
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , JSON.toJSONString(map));
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),JSON.toJSONString(map));
// 1代表开启激光灯此时主灯关闭主灯控件为关机状态为0代表关闭激光灯
if("1".equals(params.getInstructValue())){
recordDeviceLog(device.getId(), device.getDeviceName(), "激光模式设置", "开启激光灯", AppLoginHelper.getUserId());
}else{
recordDeviceLog(device.getId(), device.getDeviceName(), "激光模式设置", "关闭激光灯", AppLoginHelper.getUserId());
}
} catch (Exception e){
e.printStackTrace();
throw new ServiceException("发送指令失败");
@ -394,13 +493,17 @@ public class DeviceBJQBizService {
if (deviceIds == null || deviceIds.isEmpty()) {
throw new ServiceException("请选择设备");
}
for (Long deviceId : deviceIds) {
Device device = deviceMapper.selectById(deviceId);
if (device == null) {
throw new ServiceException("设备不存在" + deviceId);
}
if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接");
}
try {
ArrayList<Integer> intData = new ArrayList<>();
intData.add(7);
intData.add(Integer.parseInt(bo.getInstructValue()));
@ -418,16 +521,22 @@ public class DeviceBJQBizService {
.eq("binding_user_id", AppLoginHelper.getUserId())
.set("send_msg", bo.getSendMsg());
deviceMapper.update(updateWrapper);
recordDeviceLog(device.getId(), device.getDeviceName(), "发送告警信息", bo.getSendMsg(), AppLoginHelper.getUserId());
} catch (Exception e) {
log.info("设备发送信息失败:{}" ,deviceId);
throw new ServiceException("设备发送信息失败");
log.info("设备发送告警信息信息失败:{}" ,deviceId);
throw new ServiceException("设备发送告警信息信息失败");
}
}
} catch (Exception e){
e.printStackTrace();
throw new ServiceException("发送指令失败");
throw new ServiceException("发送告警信息指令失败");
}
return 1;
}
private boolean getDeviceStatus(String deviceImei) {
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null;
}
}

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.web.service.device;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -14,7 +15,6 @@ import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
import com.fuyuanshen.common.core.exception.ServiceException;
@ -26,14 +26,13 @@ import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.*;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.web.service.device.status.base.DeviceStatusRule;
import com.fuyuanshen.web.service.device.status.base.RealTimeStatusEngine;
@ -41,9 +40,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.time.*;
import java.util.*;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
@ -123,6 +121,47 @@ public class DeviceBizService {
return TableDataInfo.build(result);
}
public TableDataInfo<WebDeviceVo> queryWebDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
Page<WebDeviceVo> result = deviceMapper.queryWebDeviceList(pageQuery.build(), bo);
List<WebDeviceVo> records = result.getRecords();
if(records != null && !records.isEmpty()){
records.forEach(item -> {
if(item.getCommunicationMode()!=null && item.getCommunicationMode() == 0){
//设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){
item.setOnlineStatus(1);
}else{
item.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
item.setBattery(jsonObject.getString("batteryPercentage"));
}else{
item.setBattery("0");
}
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_LOCATION_KEY_PREFIX);
if(StringUtils.isNotBlank(location)){
JSONObject jsonObject = JSONObject.parseObject(location);
item.setLatitude(jsonObject.getString("latitude"));
item.setLongitude(jsonObject.getString("longitude"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
if(StringUtils.isNotBlank(alarmStatus)){
item.setAlarmStatus(alarmStatus);
}
}
});
}
return TableDataInfo.build(result);
}
public int bindDevice(AppDeviceBo bo) {
Integer mode = bo.getCommunicationMode();
Long userId = AppLoginHelper.getUserId();
@ -272,8 +311,8 @@ public class DeviceBizService {
public Map<String, Object> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
try {
String commandType = statusDto.getTypeName()+"_" + statusDto.getFunctionMode();
DeviceStatusRule rule = realTimeStatusEngine.getDeviceStatusRule(commandType);
// String commandType = statusDto.getTypeName()+"_" + statusDto.getFunctionMode();"FunctionAccessBatchStatusRule"
DeviceStatusRule rule = realTimeStatusEngine.getDeviceStatusRule(statusDto.getTypeName());
if(rule == null){
throw new ServiceException("未匹配到处理命令");
}
@ -284,13 +323,74 @@ public class DeviceBizService {
return null;
}
public Device getDeviceInfo(String deviceMac) {
QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("device_mac", deviceMac);
List<Device> devices = deviceMapper.selectList(queryWrapper);
if(ObjectUtils.length(devices) ==0){
public AppDeviceVo getDeviceInfo(String deviceMac) {
// QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("device_mac", deviceMac);
// List<Device> devices = deviceMapper.selectList(queryWrapper);
return deviceMapper.getDeviceInfo(deviceMac);
}
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto bo, PageQuery pageQuery) {
Page<InstructionRecordVo> result = deviceLogMapper.getInstructionRecord(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto bo, PageQuery pageQuery) {
Page<LocationHistoryVo> result = deviceMapper.getLocationHistory(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
public List<LocationHistoryDetailVo> getLocationHistoryDetail(Long id) {
Device device = deviceMapper.selectById(id);
if (device == null) {
throw new ServiceException("设备不存在");
}
// 计算七天前的凌晨时间戳
LocalDateTime sevenDaysAgo = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIDNIGHT);
long startTime = sevenDaysAgo.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
// 计算今天的凌晨时间戳
LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
long endTime = today.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
String deviceImei = device.getDeviceImei();
String a = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX + ":history";
Collection<String> list = RedisUtils.zRangeByScore(a, startTime, endTime);
if (CollectionUtil.isEmpty(list)) {
return null;
}
return devices.get(0);
Map<String, List<JSONObject>> map = new LinkedHashMap<>();
for (String obj : list){
JSONObject jsonObject = JSONObject.parseObject(obj);
Long timestamp = jsonObject.getLong("timestamp");
LocalDate date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).toLocalDate();
if (map.containsKey(date.toString())) {
map.get(date.toString()).add(jsonObject);
} else {
ArrayList<JSONObject> jsonList = new ArrayList<>();
jsonList.add(jsonObject);
map.put(date.toString(), jsonList);
}
}
List<LocationHistoryDetailVo> result = new ArrayList<>();
for (Map.Entry<String, List<JSONObject>> entry : map.entrySet()) {
LocationHistoryDetailVo detailVo = new LocationHistoryDetailVo();
detailVo.setDate(entry.getKey());
detailVo.setDeviceName(device.getDeviceName());
detailVo.setStartLocation(entry.getValue().get(0).getString("address"));
detailVo.setEndLocation(entry.getValue().get(entry.getValue().size()-1).getString("address"));
String jsonString = JSONArray.toJSONString(entry.getValue());
List<Object> strings = JSONArray.parseArray(jsonString);
detailVo.setDetailList(strings);
result.add(detailVo);
}
return result;
}
}

View File

@ -0,0 +1,367 @@
package com.fuyuanshen.web.service.device;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.AppPersonnelInfo;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.ImageToCArrayConverter;
import com.fuyuanshen.common.core.utils.MapstructUtils;
import com.fuyuanshen.common.core.utils.ObjectUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.equipment.enums.LightModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.time.Duration;
import java.util.*;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.buildArr;
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.generateFixedBitmapData;
import static com.fuyuanshen.common.core.utils.ImageToCArrayConverter.convertHexToDecimal;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
@Slf4j
@Service
@RequiredArgsConstructor
public class DeviceXinghanBizService {
private final DeviceMapper deviceMapper;
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
private final DeviceTypeMapper deviceTypeMapper;
private final MqttGateway mqttGateway;
private final DeviceLogMapper deviceLogMapper;
/**
* 所有档位的描述表
* key : 指令类型,如 "ins_DetectGrade"、"ins_LightGrade" ……
* value : Map<Integer,String> 值 -> 描述
*/
private static final Map<String, Map<Integer, String>> GRADE_DESC = Map.of(
"ins_DetectGrade", Map.of(1, "低档", 2, "中档", 3, "高档"),
"ins_LightGrade", Map.of(1, "强光", 2, "弱光"),
"ins_SOSGrade", Map.of(1, "爆闪模式", 2, "红蓝模式"),
"ins_ShakeBit", Map.of(1, "开启报警")
// 再加 4、5、6…… 档,直接往 Map 里塞即可
);
/**
* 根据指令类型和值,返回中文描述
*/
private static String resolveGradeDesc(String type, int value) {
return GRADE_DESC.getOrDefault(type, Map.of())
.getOrDefault(value, "关闭");
}
/**
* 设置静电预警档位
*/
public void upDetectGradeSettings(DeviceInstructDto dto) {
sendCommand(dto, "ins_DetectGrade","静电预警档位");
}
/**
* 设置照明档位
*/
public void upLightGradeSettings(DeviceInstructDto dto) {
sendCommand(dto, "ins_LightGrade","照明档位");
}
/**
* 设置SOS档位
*/
public void upSOSGradeSettings(DeviceInstructDto dto) {
sendCommand(dto, "ins_SOSGrade","SOS档位");
}
/**
* 设置强制报警
*/
public void upShakeBitSettings(DeviceInstructDto dto) {
sendCommand(dto, "ins_ShakeBit","强制报警");
}
/**
* 上传设备logo
*/
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
try {
Device device = deviceMapper.selectById(bo.getDeviceId());
if (device == null) {
throw new ServiceException("设备不存在");
}
if (isDeviceOffline(device.getDeviceImei())) {
throw new ServiceException("设备已断开连接:" + device.getDeviceName());
}
MultipartFile file = bo.getFile();
byte[] largeData = ImageToCArrayConverter.convertImageToCArray(file.getInputStream(), 160, 80, 25600);
log.info("长度:" + largeData.length);
log.info("原始数据大小: {} 字节", largeData.length);
int[] ints = convertHexToDecimal(largeData);
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() +DEVICE_BOOT_LOGO_KEY_PREFIX, Arrays.toString(ints), Duration.ofSeconds(5 * 60L));
Map<String, Object> payload = Map.of("ins_PicTrans",
Collections.singletonList(0));
String topic = MqttConstants.GLOBAL_PUB_KEY + device.getDeviceImei();
String json = JsonUtils.toJsonString(payload);
try {
mqttGateway.sendMsgToMqtt(topic, 1, json);
} catch (Exception e) {
log.error("上传开机画面失败, topic={}, payload={}", topic, json, e);
throw new ServiceException("上传LOGO失败" + e.getMessage());
}
log.info("发送上传开机画面到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),json);
recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", "上传开机画面", AppLoginHelper.getUserId());
} catch (Exception e){
throw new ServiceException("发送指令失败");
}
}
/**
* 人员登记
* @param bo
*/
public boolean registerPersonInfo(AppPersonnelInfoBo bo) {
Long deviceId = bo.getDeviceId();
Device deviceObj = deviceMapper.selectById(deviceId);
if (deviceObj == null) {
throw new RuntimeException("请先将设备入库!!!");
}
if (isDeviceOffline(deviceObj.getDeviceImei())) {
throw new ServiceException("设备已断开连接:" + deviceObj.getDeviceName());
}
QueryWrapper<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
.eq("device_id", deviceId);
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
List<String> list = new ArrayList<>();
list.add(bo.getName());
list.add(bo.getPosition());
list.add(bo.getUnitName());
list.add(bo.getCode());
RedisUtils.setCacheList(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + deviceObj.getDeviceImei() + ":app_send_message_data", list);
RedisUtils.expire(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + deviceObj.getDeviceImei() + ":app_send_message_data", Duration.ofSeconds(5 * 60L));
Map<String, Object> payload = Map.of("ins_TexTrans",
Collections.singletonList(0));
String topic = MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei();
String json = JsonUtils.toJsonString(payload);
try {
mqttGateway.sendMsgToMqtt(topic, 1, json);
} catch (Exception e) {
log.error("人员信息登记失败, topic={}, payload={}", topic, json, e);
throw new ServiceException("人员信息登记失败:" + e.getMessage());
}
log.info("发送人员信息登记到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), bo);
recordDeviceLog(deviceId, deviceObj.getDeviceName(), "人员信息登记", JSON.toJSONString(bo), AppLoginHelper.getUserId());
if (ObjectUtils.length(appPersonnelInfoVos) == 0) {
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
} else {
UpdateWrapper<AppPersonnelInfo> uw = new UpdateWrapper<>();
uw.eq("device_id", deviceId)
.set("name", bo.getName())
.set("position", bo.getPosition())
.set("unit_name", bo.getUnitName())
.set("code", bo.getCode());
return appPersonnelInfoMapper.update(null, uw) > 0;
}
}
/**
* 发送报警信息
* @param bo
* @return
*/
public int sendAlarmMessage(AppDeviceSendMsgBo bo) {
List<Long> deviceIds = bo.getDeviceIds();
// 1. 简化非空检查和抛出异常
if (deviceIds == null || deviceIds.isEmpty()) {
throw new ServiceException("请选择设备");
}
QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
// 使用 in 语句根据id集合查询
queryWrapper.in("id", deviceIds);
// 2. 将批量查询设备,减少数据库交互次数
List<Device> devices = deviceMapper.selectList(queryWrapper);
if (devices.size() != deviceIds.size()) {
// 如果查询回来的设备数量不一致,说明有设备不存在,此处可以优化为更详细的提示
throw new ServiceException("部分设备不存在");
}
try {
for (Device device : devices) {
String deviceImei = device.getDeviceImei();
String deviceName = device.getDeviceName();
// 3. 在循环中进行设备状态检查,快速失败
if (isDeviceOffline(deviceImei)) {
// 如果设备离线,可以选择继续处理下一个设备,或者抛出异常。这里选择抛出异常。
throw new ServiceException(deviceName + ", 设备已断开连接");
}
// 4. 将Redis和MQTT操作封装在一个方法中提高可读性
sendSingleAlarmMessage(device, bo.getSendMsg());
// 5. 批量更新设备状态,提高效率
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", device.getId())
.eq("binding_user_id", AppLoginHelper.getUserId())
.set("send_msg", bo.getSendMsg());
deviceMapper.update(updateWrapper);
// 6. 记录操作日志
recordDeviceLog(device.getId(), deviceName, "发送紧急通知", bo.getSendMsg(), AppLoginHelper.getUserId());
}
} catch (ServiceException e) {
// 捕获并重新抛出自定义异常,避免内层异常被外层泛化捕获
log.error("发送告警信息指令失败: {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
log.error("发送告警信息指令发生未知错误", e);
throw new ServiceException("发送告警信息指令失败");
}
return 1;
}
/* ---------------------------------- 私有通用方法 ---------------------------------- */
/**
* 封装单个设备发送告警信息的逻辑
*/
private void sendSingleAlarmMessage(Device device, String message) {
String deviceImei = device.getDeviceImei();
// 缓存告警消息到Redis
RedisUtils.setCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + deviceImei + DEVICE_ALARM_MESSAGE_KEY_PREFIX, message, Duration.ofSeconds(5 * 60L));
// 构建并发送MQTT消息
Map<String, Object> payload = Map.of("ins_BreakNews", Collections.singletonList(0));
String topic = MqttConstants.GLOBAL_PUB_KEY + deviceImei;
String json = JsonUtils.toJsonString(payload);
try {
mqttGateway.sendMsgToMqtt(topic, 1, json);
log.info("发送紧急通知成功 => topic:{}, payload:{}", topic, json);
} catch (Exception e) {
log.error("发送紧急通知失败, topic={}, payload={}", topic, json, e);
throw new ServiceException("发送紧急通知失败:" + e.getMessage());
}
}
/**
* 发送设备控制指令
*
* @param dto 设备指令数据传输对象包含设备ID和指令值等信息
* @param payloadKey 指令负载数据的键名
* @param deviceAction 设备操作类型描述
*/
private void sendCommand(DeviceInstructDto dto, String payloadKey, String deviceAction) {
long deviceId = dto.getDeviceId();
// 1. 使用Optional简化空值检查使代码更简洁
Device device = Optional.ofNullable(deviceMapper.selectById(deviceId))
.orElseThrow(() -> new ServiceException("设备不存在"));
String deviceImei = device.getDeviceImei();
String deviceName = device.getDeviceName();
// 2. 提前进行设备状态检查,逻辑更清晰
if (isDeviceOffline(deviceImei)) {
throw new ServiceException("设备已断开连接:" + deviceName);
}
// 3. 统一处理类型转换异常避免在业务逻辑中混杂try-catch
int value;
try {
value = Integer.parseInt(dto.getInstructValue());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("指令值格式不正确,必须为整数。", e);
}
// 4. 使用Map.of()或Map.ofEntries()创建不可变Map更简洁且线程安全
Map<String, List<Integer>> payload = Map.of(payloadKey, List.of(value));
String topic = MqttConstants.GLOBAL_PUB_KEY + deviceImei;
String json = JsonUtils.toJsonString(payload);
try {
mqttGateway.sendMsgToMqtt(topic, 1, json);
log.info("发送指令成功 => topic:{}, payload:{}", topic, json);
} catch (Exception e) {
log.error("发送指令失败, topic={}, payload={}", topic, json, e);
throw new ServiceException("发送指令失败:" + e.getMessage());
}
// 5. 将日志记录和描述解析放在try-catch块之外确保无论是否成功发送指令都能执行
String content = resolveGradeDesc("ins_DetectGrade", value);
recordDeviceLog(device.getId(),
deviceName,
deviceAction,
content,
AppLoginHelper.getUserId());
}
// private boolean isDeviceOffline(String imei) {
// // 原方法名语义相反,这里取反,使含义更清晰
// return getDeviceStatus(imei);
// }
/**
* 记录设备操作日志
* @param deviceId 设备ID
* @param content 日志内容
* @param operator 操作人
*/
private void recordDeviceLog(Long deviceId,String deviceName, String deviceAction, String content, Long operator) {
try {
// 创建设备日志实体
com.fuyuanshen.equipment.domain.DeviceLog deviceLog = new com.fuyuanshen.equipment.domain.DeviceLog();
deviceLog.setDeviceId(deviceId);
deviceLog.setDeviceAction(deviceAction);
deviceLog.setContent(content);
deviceLog.setCreateBy(operator);
deviceLog.setDeviceName(deviceName);
deviceLog.setCreateTime(new Date());
// 插入日志记录
deviceLogMapper.insert(deviceLog);
} catch (Exception e) {
log.error("记录设备操作日志失败: {}", e.getMessage(), e);
}
}
private boolean isDeviceOffline(String deviceImei) {
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey)==null;
}
}

View File

@ -22,7 +22,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCES
public class FunctionAccessBatchStatusRule implements DeviceStatusRule {
@Override
public String getCommandType() {
return DeviceTypeConstants.TYPE_BJQ6170+"_2";
return "FunctionAccessBatchStatusRule";
}
@Override

View File

@ -21,7 +21,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCES
public class FunctionAccessStatusRule implements DeviceStatusRule {
@Override
public String getCommandType() {
return DeviceTypeConstants.TYPE_BJQ6170+"_1";
return "FunctionAccessStatusRule";
}
@Override

View File

@ -1,15 +1,38 @@
package com.fuyuanshen.web.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.domain.DeviceAssignments;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.mapper.DeviceAlarmMapper;
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.web.service.WEBDeviceService;
import com.fuyuanshen.web.service.device.DeviceBizService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Description:
@ -21,10 +44,16 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements WEBDeviceService {
private final DeviceBizService appDeviceService;
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
private final AppPersonnelInfoRecordsMapper infoRecordsMapper;
private final DeviceLogMapper deviceLogMapper;
private final DeviceAlarmMapper deviceAlarmMapper;
private final DeviceMapper deviceMapper;
private final AppDeviceShareMapper appDeviceShareMapper;
/**
* WEB端解绑设备
@ -33,6 +62,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
* @return
*/
@Override
@Transactional
public int webUnBindDevice(Long id, Long userId) {
// 设备端解绑 0:设备端解绑 1:web端解绑
int type = 1;
@ -44,8 +74,104 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
id = deviceAssignments.getDeviceId();
type = 0;
}
return appDeviceService.unBindDevice(id, userId, type);
QueryWrapper<AppDeviceBindRecord> deviceId = new QueryWrapper<AppDeviceBindRecord>().eq("device_id", id);
// appDeviceService.unBindDevice(id, userId, type);
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
deviceUpdateWrapper.eq("id", id)
.set("binding_user_id", null)
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
.set("binding_time", null);
deviceMapper.update(null, deviceUpdateWrapper);
return appDeviceBindRecordMapper.delete(deviceId);
}
/**
* WEB端设备详情
*
* @param id
* @return
*/
@Override
public WebDeviceVo getDevice(Long id) {
Device device = deviceMapper.selectById(id);
if (device != null) {
WebDeviceVo webDeviceVo = new WebDeviceVo();
BeanUtil.copyProperties(device, webDeviceVo);
// 查询分享用户数
Long count = appDeviceShareMapper.selectCount(new QueryWrapper<AppDeviceShare>().eq("device_id", id));
webDeviceVo.setShareUsersNumber(Math.toIntExact(count));
return webDeviceVo;
}
return null;
}
/**
* 设备用户详情
*
* @param id
* @return
*/
@Override
public List<AppPersonnelInfoRecords> getDeviceUser(Long id) {
List<AppPersonnelInfoRecords> appPersonnelInfoRecords = infoRecordsMapper.selectList(
new QueryWrapper<AppPersonnelInfoRecords>().eq("device_id", id)
.orderByDesc("create_time"));
return appPersonnelInfoRecords;
}
/**
* 设备操作记录
*
* @param deviceId
* @return
*/
@Override
public TableDataInfo<DeviceLog> getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
Page<DeviceLog> page = pageQuery.build();
QueryWrapper<DeviceLog> queryWrapper = new QueryWrapper<DeviceLog>().eq("device_id", deviceId);
if (StrUtil.isNotEmpty(startTime)) {
queryWrapper.ge("create_time", startTime);
}
if (StrUtil.isNotEmpty(endTime)) {
queryWrapper.le("create_time", endTime);
}
queryWrapper.orderByDesc("create_time");
IPage<DeviceLog> logList = deviceLogMapper.selectPage(page, queryWrapper);
return TableDataInfo.build(logList);
}
/**
* 设备告警记录
*
* @param deviceId
* @return
*/
@Override
public TableDataInfo getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) {
Page<DeviceAlarm> page = pageQuery.build();
QueryWrapper<DeviceAlarm> queryWrapper = new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId);
if (StrUtil.isNotEmpty(startTime)) {
queryWrapper.ge("start_time", startTime);
}
if (StrUtil.isNotEmpty(endTime)) {
queryWrapper.le("start_time", endTime);
}
queryWrapper.orderByDesc("start_time");
IPage<DeviceAlarm> alarmPage = deviceAlarmMapper.selectPage(page, queryWrapper);
// List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmPage.getRecords(), DeviceAlarmVo.class);
return TableDataInfo.build(alarmPage);
}
}

View File

@ -219,6 +219,8 @@ springdoc:
packages-to-scan: com.fuyuanshen.customer
- group: APP模块
packages-to-scan: com.fuyuanshen.app
- group: 设备分组
packages-to-scan: com.fuyuanshen.web.controller.device
# 防止XSS攻击
xss:
@ -232,7 +234,7 @@ xss:
# 如使用JDK21请直接使用虚拟线程 不要开启此配置
thread-pool:
# 是否开启线程池
enabled: false
enabled: true
# 队列最大长度
queueCapacity: 128
# 线程池维护线程所允许的空闲时间

View File

@ -88,6 +88,24 @@ public class ImageToCArrayConverter {
return chunk;
}
public static String[] getChunk2(String[] data, int chunkIndex, int chunkSize) {
if (data == null || chunkSize <= 0 || chunkIndex < 0) {
return new String[0];
}
int start = chunkIndex * chunkSize;
if (start >= data.length) {
return new String[0]; // 索引超出范围
}
int end = Math.min(start + chunkSize, data.length);
int length = end - start;
String[] chunk = new String[length];
System.arraycopy(data, start, chunk, 0, length);
return chunk;
}
public static void buildArr(int[] data,List<Integer> intData){
for (int datum : data) {
intData.add(datum);

View File

@ -39,8 +39,8 @@ public class EncryptUtilsTest {
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
loginBody.setGrantType("password");
loginBody.setTenantId("894078");
loginBody.setCode("9");
loginBody.setUuid("d5be31eac1244cee851a9903f358bc6a");
loginBody.setCode("0");
loginBody.setUuid("1d6615668c7f410da77c4e002c601073");
// loginBody.setUsername("admin");
// loginBody.setPassword("admin123");
loginBody.setUsername("dyf");

View File

@ -8,4 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionAccessAnnotation {
String value() default "";
long timeOut() default 30;
}

View File

@ -8,4 +8,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionAccessBatcAnnotation {
String value() default "";
long timeOut() default 30;
long batchMaxTimeOut() default 40;
}

View File

@ -28,6 +28,7 @@ public class FunctionAccessAspect {
// 获取方法参数查找设备ID
Object[] args = joinPoint.getArgs();
deviceImei = extractDeviceImei(args);
long timeout = functionAccessAnnotation.timeOut();
if (StringUtils.isNotBlank(deviceImei)) {
// 生成全局Redis key
@ -37,7 +38,7 @@ public class FunctionAccessAspect {
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
}
//
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofSeconds(30));
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofSeconds(timeout));
}
// 执行原方法

View File

@ -41,10 +41,10 @@ public class FunctionAccessBatchAspect {
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
}
deviceImeiList.forEach(item->{
RedisUtils.setCacheObject(FUNCTION_ACCESS_KEY + item, "ACTIVE", Duration.ofSeconds(30));
RedisUtils.setCacheObject(FUNCTION_ACCESS_KEY + item, "ACTIVE", Duration.ofSeconds(functionAccessBatchAspect.timeOut()));
});
String deviceImeiListStr = JSONUtil.toJsonStr(deviceImeiList);
RedisUtils.setCacheObject(redisKey, deviceImeiListStr , Duration.ofSeconds(40));
RedisUtils.setCacheObject(redisKey, deviceImeiListStr , Duration.ofSeconds(functionAccessBatchAspect.batchMaxTimeOut()));
}
// 执行原方法

View File

@ -11,6 +11,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -373,6 +374,28 @@ public class RedisUtils {
return 0;
}
}
/**
* 根据时间范围查询Sorted Set中的元素(重载方法,适用于时间戳查询)
*
* @param key 键
* @param startTime 开始时间戳
* @param endTime 结束时间戳
* @return 指定时间范围内的元素集合
*/
public static Collection<String> zRangeByScore(String key, Long startTime, Long endTime) {
try {
RScoredSortedSet<String> sortedSet = CLIENT.getScoredSortedSet(key);
return sortedSet.valueRange(startTime, true, endTime, true);
} catch (Exception e) {
// 记录错误日志(如果项目中有日志工具的话)
// log.error("根据时间范围查询Sorted Set中的元素失败: key={}, startTime={}, endTime={}, error={}",
// key, startTime, endTime, e.getMessage(), e);
return null;
}
}
/**
* 追加缓存Set数据
*
@ -614,4 +637,73 @@ public class RedisUtils {
RKeys rKeys = CLIENT.getKeys();
return rKeys.countExists(key) > 0;
}
/**
* 向去重阻塞队列中添加元素
*
* @param queueKey 队列键
* @param dedupKey 去重集合键
* @param value 消息值
* @param timeout 过期时间
* @return 是否添加成功
*/
public static boolean offerDeduplicated(String queueKey, String dedupKey, String value, Duration timeout) {
// String jsonValue = value instanceof String ? (String) value : JsonUtils.toJsonString(value);
RLock lock = CLIENT.getLock("lock:" + queueKey);
try {
lock.lock();
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
if (dedupSet.contains(value)) {
return false; // 元素已存在,不重复添加
}
// 添加到去重集合
dedupSet.add(value);
// 添加到阻塞队列
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
boolean offered = queue.offer(value);
// 设置过期时间
if (timeout != null) {
queue.expire(timeout);
dedupSet.expire(timeout);
}
return offered;
} finally {
lock.unlock();
}
}
/**
* 从去重阻塞队列中消费元素
*
* @param queueKey 队列键
* @param dedupKey 去重集合键
* @param timeout 超时时间
* @param timeUnit 时间单位
* @return 消息值
*/
public static String pollDeduplicated(String queueKey, String dedupKey, long timeout, TimeUnit timeUnit) {
try {
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
String value = queue.poll(timeout, timeUnit);
// 从去重集合中移除
if (value != null) {
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
dedupSet.remove(value);
}
return value;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return null;
}
}
}

View File

@ -0,0 +1,105 @@
package com.fuyuanshen.app.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoRecordsVo;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoRecordsBo;
import com.fuyuanshen.app.service.IAppPersonnelInfoRecordsService;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
/**
* 人员信息登记记录
*
* @author CYT
* @date 2025-08-22
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/personnelInfoRecords")
public class AppPersonnelInfoRecordsController extends BaseController {
private final IAppPersonnelInfoRecordsService appPersonnelInfoRecordsService;
/**
* 查询人员信息登记记录列表
*/
@SaCheckPermission("app:personnelInfoRecords:list")
@GetMapping("/list")
public TableDataInfo<AppPersonnelInfoRecordsVo> list(AppPersonnelInfoRecordsBo bo, PageQuery pageQuery) {
return appPersonnelInfoRecordsService.queryPageList(bo, pageQuery);
}
/**
* 导出人员信息登记记录列表
*/
@SaCheckPermission("app:personnelInfoRecords:export")
@Log(title = "人员信息登记记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(AppPersonnelInfoRecordsBo bo, HttpServletResponse response) {
List<AppPersonnelInfoRecordsVo> list = appPersonnelInfoRecordsService.queryList(bo);
ExcelUtil.exportExcel(list, "人员信息登记记录", AppPersonnelInfoRecordsVo.class, response);
}
/**
* 获取人员信息登记记录详细信息
*
* @param id 主键
*/
@SaCheckPermission("app:personnelInfoRecords:query")
@GetMapping("/{id}")
public R<AppPersonnelInfoRecordsVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(appPersonnelInfoRecordsService.queryById(id));
}
/**
* 新增人员信息登记记录
*/
@SaCheckPermission("app:personnelInfoRecords:add")
@Log(title = "人员信息登记记录", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoRecordsBo bo) {
return toAjax(appPersonnelInfoRecordsService.insertByBo(bo));
}
/**
* 修改人员信息登记记录
*/
@SaCheckPermission("app:personnelInfoRecords:edit")
@Log(title = "人员信息登记记录", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppPersonnelInfoRecordsBo bo) {
return toAjax(appPersonnelInfoRecordsService.updateByBo(bo));
}
/**
* 删除人员信息登记记录
*
* @param ids 主键串
*/
@SaCheckPermission("app:personnelInfoRecords:remove")
@Log(title = "人员信息登记记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(appPersonnelInfoRecordsService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -24,7 +24,7 @@ import com.fuyuanshen.app.service.IAppUserService;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
/**
* APP用户信息
* WebApp用户信息
*
* @author Lion Li
* @date 2025-06-27
@ -32,8 +32,8 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/user")
public class AppUserController extends BaseController {
@RequestMapping("/WebApp/user")
public class WebAppUserController extends BaseController {
private final IAppUserService appUserService;

View File

@ -0,0 +1,66 @@
package com.fuyuanshen.app.domain;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 人员信息登记记录对象 app_personnel_info_records
*
* @author CYT
* @date 2025-08-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("app_personnel_info_records")
public class AppPersonnelInfoRecords extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id")
private Long id;
/**
* 设备id
*/
private Long deviceId;
/**
* 主键
*/
private Long personnelId;
/**
* 人员姓名
*/
private String name;
/**
* 职位
*/
private String position;
/**
* 单位名称
*/
private String unitName;
/**
* ID号
*/
private String code;
/**
* 发送信息
*/
private String sendMsg;
}

View File

@ -1,5 +1,7 @@
package com.fuyuanshen.app.domain.bo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
@ -7,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
/**
* 设备分享业务对象 app_device_share
*
@ -35,10 +39,16 @@ public class AppDeviceShareBo extends BaseEntity {
/**
* 功能权限1灯光模式2激光模式3开机画面4人员信息登记5发送信息6产品信息
以逗号分隔
* 以逗号分隔
*/
private String permission;
/**
* 分享用户
* share_user
*/
private String shareUser;
/**
* 备注
*/
@ -46,4 +56,11 @@ public class AppDeviceShareBo extends BaseEntity {
private String smsCode;
/**
* 分享时间
*/
private String shareStartTime;
private String shareEndTime;
}

View File

@ -0,0 +1,67 @@
package com.fuyuanshen.app.domain.bo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* 人员信息登记记录业务对象 app_personnel_info_records
*
* @author CYT
* @date 2025-08-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = AppPersonnelInfoRecords.class, reverseConvertGenerate = false)
public class AppPersonnelInfoRecordsBo extends BaseEntity {
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
private Long id;
/**
* 设备id
*/
@NotNull(message = "设备id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long deviceId;
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long personnelId;
/**
* 人员姓名
*/
private String name;
/**
* 职位
*/
private String position;
/**
* 单位名称
*/
private String unitName;
/**
* ID号
*/
private String code;
/**
* 发送信息
*/
private String sendMsg;
}

View File

@ -138,4 +138,7 @@ public class AppDeviceShareDetailVo implements Serializable {
* 告警状态(0解除告警1告警)
*/
private String alarmStatus;
// 灯光亮度
private String lightBrightness;
}

View File

@ -109,4 +109,9 @@ public class AppDeviceShareVo implements Serializable {
* 告警状态(0解除告警1告警)
*/
private String alarmStatus;
/**
* 创建时间
*/
private String createTime;
}

View File

@ -0,0 +1,80 @@
package com.fuyuanshen.app.domain.vo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 人员信息登记记录视图对象 app_personnel_info_records
*
* @author CYT
* @date 2025-08-22
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = AppPersonnelInfoRecords.class)
public class AppPersonnelInfoRecordsVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long id;
/**
* 设备id
*/
@ExcelProperty(value = "设备id")
private Long deviceId;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long personnelId;
/**
* 人员姓名
*/
@ExcelProperty(value = "人员姓名")
private String name;
/**
* 职位
*/
@ExcelProperty(value = "职位")
private String position;
/**
* 单位名称
*/
@ExcelProperty(value = "单位名称")
private String unitName;
/**
* ID号
*/
@ExcelProperty(value = "ID号")
private String code;
/**
* 发送信息
*/
@ExcelProperty(value = "发送信息")
private String sendMsg;
}

View File

@ -18,5 +18,13 @@ import org.apache.ibatis.annotations.Param;
public interface AppDeviceShareMapper extends BaseMapperPlus<AppDeviceShare, AppDeviceShareVo> {
IPage<AppDeviceShareVo> otherDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
Page<AppDeviceShareVo> selectAppDeviceShareList(@Param("bo") AppDeviceShareBo bo,Page<AppDeviceShareVo> page);
Page<AppDeviceShareVo> selectAppDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
/**
* 查询设备分享列表(web)
*
* @param bo 设备分享
* @return 设备分享
*/
Page<AppDeviceShareVo> selectWebDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
}

View File

@ -0,0 +1,15 @@
package com.fuyuanshen.app.mapper;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoRecordsVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 人员信息登记记录Mapper接口
*
* @author CYT
* @date 2025-08-22
*/
public interface AppPersonnelInfoRecordsMapper extends BaseMapperPlus<AppPersonnelInfoRecords, AppPersonnelInfoRecordsVo> {
}

View File

@ -0,0 +1,68 @@
package com.fuyuanshen.app.service;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoRecordsVo;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoRecordsBo;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 人员信息登记记录Service接口
*
* @author CYT
* @date 2025-08-22
*/
public interface IAppPersonnelInfoRecordsService {
/**
* 查询人员信息登记记录
*
* @param id 主键
* @return 人员信息登记记录
*/
AppPersonnelInfoRecordsVo queryById(Long id);
/**
* 分页查询人员信息登记记录列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 人员信息登记记录分页列表
*/
TableDataInfo<AppPersonnelInfoRecordsVo> queryPageList(AppPersonnelInfoRecordsBo bo, PageQuery pageQuery);
/**
* 查询符合条件的人员信息登记记录列表
*
* @param bo 查询条件
* @return 人员信息登记记录列表
*/
List<AppPersonnelInfoRecordsVo> queryList(AppPersonnelInfoRecordsBo bo);
/**
* 新增人员信息登记记录
*
* @param bo 人员信息登记记录
* @return 是否新增成功
*/
Boolean insertByBo(AppPersonnelInfoRecordsBo bo);
/**
* 修改人员信息登记记录
*
* @param bo 人员信息登记记录
* @return 是否修改成功
*/
Boolean updateByBo(AppPersonnelInfoRecordsBo bo);
/**
* 校验并批量删除人员信息登记记录信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -0,0 +1,138 @@
package com.fuyuanshen.app.service.impl;
import com.fuyuanshen.common.core.utils.MapstructUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoRecordsBo;
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoRecordsVo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.app.service.IAppPersonnelInfoRecordsService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 人员信息登记记录Service业务层处理
*
* @author CYT
* @date 2025-08-22
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class AppPersonnelInfoRecordsServiceImpl implements IAppPersonnelInfoRecordsService {
private final AppPersonnelInfoRecordsMapper baseMapper;
/**
* 查询人员信息登记记录
*
* @param id 主键
* @return 人员信息登记记录
*/
@Override
public AppPersonnelInfoRecordsVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询人员信息登记记录列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 人员信息登记记录分页列表
*/
@Override
public TableDataInfo<AppPersonnelInfoRecordsVo> queryPageList(AppPersonnelInfoRecordsBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<AppPersonnelInfoRecords> lqw = buildQueryWrapper(bo);
Page<AppPersonnelInfoRecordsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的人员信息登记记录列表
*
* @param bo 查询条件
* @return 人员信息登记记录列表
*/
@Override
public List<AppPersonnelInfoRecordsVo> queryList(AppPersonnelInfoRecordsBo bo) {
LambdaQueryWrapper<AppPersonnelInfoRecords> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<AppPersonnelInfoRecords> buildQueryWrapper(AppPersonnelInfoRecordsBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<AppPersonnelInfoRecords> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(AppPersonnelInfoRecords::getId);
lqw.eq(bo.getDeviceId() != null, AppPersonnelInfoRecords::getDeviceId, bo.getDeviceId());
lqw.eq(bo.getPersonnelId() != null, AppPersonnelInfoRecords::getPersonnelId, bo.getPersonnelId());
lqw.like(StringUtils.isNotBlank(bo.getName()), AppPersonnelInfoRecords::getName, bo.getName());
lqw.eq(StringUtils.isNotBlank(bo.getPosition()), AppPersonnelInfoRecords::getPosition, bo.getPosition());
lqw.like(StringUtils.isNotBlank(bo.getUnitName()), AppPersonnelInfoRecords::getUnitName, bo.getUnitName());
lqw.eq(StringUtils.isNotBlank(bo.getCode()), AppPersonnelInfoRecords::getCode, bo.getCode());
lqw.eq(StringUtils.isNotBlank(bo.getSendMsg()), AppPersonnelInfoRecords::getSendMsg, bo.getSendMsg());
return lqw;
}
/**
* 新增人员信息登记记录
*
* @param bo 人员信息登记记录
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(AppPersonnelInfoRecordsBo bo) {
AppPersonnelInfoRecords add = MapstructUtils.convert(bo, AppPersonnelInfoRecords.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改人员信息登记记录
*
* @param bo 人员信息登记记录
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(AppPersonnelInfoRecordsBo bo) {
AppPersonnelInfoRecords update = MapstructUtils.convert(bo, AppPersonnelInfoRecords.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(AppPersonnelInfoRecords entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除人员信息登记记录信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -1,27 +1,27 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.app.mapper.AppDeviceShareMapper">
<select id="otherDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
select d.device_name,
d.device_mac,
d.device_sn,
d.device_imei,
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.model_dictionary detailPageUrl,
d.bluetooth_name,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from
app_device_share ad
left join device d on ad.device_id = d.id
left join app_user u on ad.create_by = u.user_id
inner join device_type dt on d.device_type = dt.id
inner join app_device_bind_record c on d.id = c.device_id
d.device_mac,
d.device_sn,
d.device_imei,
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name,
c.binding_time,
ad.*,
u.user_name otherPhonenumber
from app_device_share ad
left join device d on ad.device_id = d.id
left join app_user u on ad.create_by = u.user_id
inner join device_type dt on d.device_type = dt.id
inner join app_device_bind_record c on d.id = c.device_id
where ad.phonenumber = #{bo.phonenumber}
</select>
<select id="selectAppDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from
@ -47,4 +47,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ad.device_id = #{bo.deviceId}
</if>
</select>
<!-- 查询设备分享列表(web) -->
<select id="selectWebDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
select d.device_name,
d.device_mac,
d.device_sn,
d.device_imei,
d.device_pic,
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.app_model_dictionary detailPageUrl,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from
app_device_share ad
left join device d on ad.device_id = d.id
left join app_user u on ad.create_by = u.user_id
inner join device_type dt on d.device_type = dt.id
inner join app_device_bind_record c on d.id = c.device_id
<where>
<if test="bo.deviceId != null">
and ad.device_id = #{bo.deviceId}
</if>
<if test="bo.shareUser != null">
and ad.phonenumber like concat('%',#{bo.shareUser},'%')
</if>
<if test="bo.phonenumber != null">
and ad.phonenumber like concat('%',#{bo.phonenumber},'%')
</if>
<if test="bo.shareStartTime != null and bo.shareEndTime != null">
and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,7 @@
<?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.app.mapper.AppPersonnelInfoRecordsMapper">
</mapper>

View File

@ -36,7 +36,6 @@ public class VideoUploadController {
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@SaIgnore
public R<List<String>> upload(@RequestParam("file") MultipartFile file) {
if (file == null || file.isEmpty()) {
return R.fail("上传文件不能为空");

View File

@ -126,26 +126,26 @@ public class DeviceController extends BaseController {
// @Log("分配客户")
@Operation(summary = "分配客户")
@PutMapping(value = "/assignCustomer")
public R<Void> assignCustomer(@Validated @RequestBody CustomerVo customerVo) {
deviceService.assignCustomer(customerVo);
return R.ok();
}
// @Operation(summary = "分配客户")
// @PutMapping(value = "/assignCustomer")
// public R<Void> assignCustomer(@Validated @RequestBody CustomerVo customerVo) {
// deviceService.assignCustomer(customerVo);
// return R.ok();
// }
// @Log("撤回设备")
@Operation(summary = "撤回分配设备")
@PostMapping(value = "/withdraw")
public R<Void> withdrawDevice(@RequestBody List<Long> ids) {
try {
deviceService.withdrawDevice(ids);
} catch (Exception e) {
log.error("updateDevice error: " + e.getMessage());
return R.fail(e.getMessage());
}
return R.ok();
}
// @Operation(summary = "撤回分配设备")
// @PostMapping(value = "/withdraw")
// public R<Void> withdrawDevice(@RequestBody List<Long> ids) {
// try {
// deviceService.withdrawDevice(ids);
// } catch (Exception e) {
// log.error("updateDevice error: " + e.getMessage());
// return R.fail(e.getMessage());
// }
// return R.ok();
// }
//
// /**

View File

@ -2,6 +2,11 @@ package com.fuyuanshen.equipment.controller;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
import com.fuyuanshen.equipment.domain.DeviceType;
import com.fuyuanshen.equipment.domain.query.DeviceRepairRecordsQueryCriteria;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
@ -41,8 +46,10 @@ public class DeviceRepairRecordsController extends BaseController {
*/
@SaCheckPermission("equipment:repairRecords:list")
@GetMapping("/list")
public TableDataInfo<DeviceRepairRecordsVo> list(DeviceRepairRecordsBo bo, PageQuery pageQuery) {
return deviceRepairRecordsService.queryPageList(bo, pageQuery);
@Operation(summary = "分页查询维修记录列表")
public TableDataInfo<DeviceRepairRecordsVo> list(DeviceRepairRecordsQueryCriteria criteria) {
Page<DeviceRepairRecords> page = new Page<>(criteria.getPageNum(), criteria.getPageSize());
return deviceRepairRecordsService.queryPageList(criteria, page);
}
/**
@ -51,7 +58,7 @@ public class DeviceRepairRecordsController extends BaseController {
@SaCheckPermission("equipment:repairRecords:export")
@Log(title = "设备维修记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DeviceRepairRecordsBo bo, HttpServletResponse response) {
public void export(DeviceRepairRecordsQueryCriteria bo, HttpServletResponse response) {
List<DeviceRepairRecordsVo> list = deviceRepairRecordsService.queryList(bo);
ExcelUtil.exportExcel(list, "设备维修记录", DeviceRepairRecordsVo.class, response);
}
@ -74,8 +81,8 @@ public class DeviceRepairRecordsController extends BaseController {
@SaCheckPermission("equipment:repairRecords:add")
@Log(title = "设备维修记录", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DeviceRepairRecordsBo bo) {
@PostMapping(consumes = "multipart/form-data")
public R<Void> add(@Validated(AddGroup.class) DeviceRepairRecordsBo bo) {
return toAjax(deviceRepairRecordsService.insertByBo(bo));
}
@ -85,8 +92,8 @@ public class DeviceRepairRecordsController extends BaseController {
@SaCheckPermission("equipment:repairRecords:edit")
@Log(title = "设备维修记录", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DeviceRepairRecordsBo bo) {
@PutMapping(consumes = "multipart/form-data")
public R<Void> edit(@Validated(EditGroup.class) DeviceRepairRecordsBo bo) {
return toAjax(deviceRepairRecordsService.updateByBo(bo));
}

View File

@ -1,9 +1,6 @@
package com.fuyuanshen.equipment.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import io.swagger.v3.oas.annotations.media.Schema;
@ -25,80 +22,94 @@ public class Device extends TenantEntity {
* id
*/
@TableId(value = "id", type = IdType.AUTO)
@Schema(name = "ID")
@Schema(title = "ID")
private Long id;
@Schema(name = "设备记录ID")
/**
* 设备ID
*/
@TableField(exist = false)
@Schema(title = "设备ID")
private Long deviceId;
@Schema(title = "设备记录ID")
@TableField(exist = false)
private Long assignId;
/**
* 设备分组
* group_id
*/
@Schema(title = "设备分组")
private Long groupId;
/**
* device_type
*/
@Schema(name = "设备类型")
@Schema(title = "设备类型")
private Long deviceType;
@Schema(name = "设备类型名称")
@Schema(title = "设备类型名称")
private String typeName;
@Schema(name = "客户号")
@Schema(title = "客户号")
private Long customerId;
@Schema(name = "所属客户")
@Schema(title = "所属客户")
private String customerName;
/**
* 当前所有者
* current_owner_id
*/
@Schema(name = "当前所有者")
@Schema(title = "当前所有者")
private Long currentOwnerId;
/**
* 原始所有者(创建者)
* original_owner_id
*/
@Schema(name = "原始所有者(创建者)")
@Schema(title = "原始所有者(创建者)")
private Long originalOwnerId;
/**
* 原始设备
*/
@Schema(name = "原始设备")
@Schema(title = "原始设备")
private Long originalDeviceId;
@Schema(name = "设备编号")
@Schema(title = "设备编号")
private String deviceNo;
@Schema(name = "设备名称")
@Schema(title = "设备名称")
private String deviceName;
@Schema(name = "设备图片")
@Schema(title = "设备图片")
private String devicePic;
@Schema(name = "设备MAC")
@Schema(title = "设备MAC")
private String deviceMac;
@Schema(name = "蓝牙名称")
@Schema(title = "蓝牙名称")
private String bluetoothName;
/**
* 设备IMEI
* device_imei
*/
@Schema(name = "设备IMEI")
@Schema(title = "设备IMEI")
private String deviceImei;
@Schema(name = "设备SN")
@Schema(title = "设备SN")
private String deviceSn;
@Schema(name = "经度")
@Schema(title = "经度")
private String longitude;
@Schema(name = "纬度")
@Schema(title = "纬度")
private String latitude;
@Schema(name = "备注")
@Schema(title = "备注")
private String remark;
/**
@ -106,7 +117,7 @@ public class Device extends TenantEntity {
* 0 失效
* 1 正常
*/
@Schema(name = "设备状态")
@Schema(title = "设备状态")
private Integer deviceStatus;
/**
@ -114,7 +125,7 @@ public class Device extends TenantEntity {
* 0 未绑定
* 1 已绑定
*/
@Schema(name = "绑定状态")
@Schema(title = "绑定状态")
private Integer bindingStatus;
/**
@ -143,4 +154,15 @@ public class Device extends TenantEntity {
*/
private String subTopic;
/**
* 出厂日期
* production_date
*/
@Schema(title = "出厂日期")
private Date productionDate;
/**
* 在线状态(0离线1在线,2异常)
*/
private Integer onlineStatus;
}

View File

@ -0,0 +1,103 @@
package com.fuyuanshen.equipment.domain;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
/**
* 设备告警对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("device_alarm")
public class DeviceAlarm extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(value = "id")
private Long id;
/**
* 设备ID
*/
private Long deviceId;
/**
* 报警事项
* 0-强制报警1-撞击闯入2-手动报警3-电子围栏告警4-强制告警
* device_action
*/
private Integer deviceAction;
/**
* 设备名称
*/
private String deviceName;
/**
* 数据来源
*/
private String dataSource;
/**
* 内容
*/
private String content;
/**
* 设备类型
*/
private Long deviceType;
/**
* 经度
*/
private Long longitude;
/**
* 纬度
*/
private Long latitude;
/**
* 报警位置
*/
private String location;
/**
* 报警开始时间
*/
private Date startTime;
/**
* 报警结束时间
*/
private Date finishTime;
/**
* 报警持续时间
*/
private String durationTime;
/**
* 0已处理1未处理
* treatment_state
*/
private Long treatmentState;
}

View File

@ -0,0 +1,108 @@
package com.fuyuanshen.equipment.domain;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
/**
* 设备充放电记录对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("device_charge_discharge")
public class DeviceChargeDischarge extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 记录唯一标识
*/
@TableId(value = "id")
private Long id;
/**
* 设备唯一标识
*/
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
private Long operationType;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
private Long finalSoc;
/**
* 充放电量(kWh)
*/
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
private Long powerRating;
/**
* 电压(V)
*/
private Long voltage;
/**
* 电流(A)
*/
private Long current;
/**
* 温度(℃)
*/
private Long temperature;
/**
* 当前状态
*/
private Long status;
/**
* 错误代码
*/
private String errorCode;
/**
* 记录创建时间
*/
private Date createdAt;
/**
* 记录更新时间
*/
private Date updatedAt;
}

View File

@ -0,0 +1,41 @@
package com.fuyuanshen.equipment.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.fuyuanshen.equipment.enums.RepairImageType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 设备维修图片对象 device_repair_images
*
*
* @date 2025-09-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("device_repair_images")
public class DeviceRepairImages extends TenantEntity {
/**
* 维修图片ID
*/
@TableId(value = "image_id", type = IdType.AUTO)
@TableField(insertStrategy = FieldStrategy.NEVER)
private Long imageId;
/**
* 维修记录ID
*/
@Schema(title = "维修记录ID")
private Long recordId;
/**
* 图片类型(维修前/维修后)
*/
@Schema(title = "图片类型(维修前/维修后)")
private RepairImageType imageType;
/**
* 图片存储路径
*/
@Schema(title = "图片存储路径")
private String imageUrl;
}

View File

@ -26,7 +26,8 @@ public class DeviceRepairRecords extends TenantEntity {
/**
* 维修记录ID
*/
@TableId(value = "record_id")
@TableId(value = "record_id", type = IdType.AUTO)
@TableField(insertStrategy = FieldStrategy.NEVER)
private Long recordId;
/**

View File

@ -18,42 +18,48 @@ import lombok.Data;
public class DeviceType extends TenantEntity {
@TableId(value = "id", type = IdType.AUTO)
@Schema(name = "ID", hidden = true)
@Schema(title = "ID", hidden = true)
private Long id;
@Schema(name = "客户号")
/**
* 设备类型ID
*/
@TableField(exist = false)
private Long deviceTypeId;
@Schema(title = "客户号")
private Long customerId;
@Schema(name = "创建该类型的客户")
@Schema(title = "创建该类型的客户")
private Long ownerCustomerId;
/**
* 原始所有者(创建者)
* original_owner_id
*/
@Schema(name = "原始所有者(创建者)")
@Schema(title = "原始所有者(创建者)")
private Long originalOwnerId;
/**
* 原始设备
*/
@Schema(name = "原始设备类型")
@Schema(title = "原始设备类型")
private Long originalDeviceId;
@NotBlank(message = "设备类型名称不能为空")
@Schema(name = "类型名称", required = true)
@Schema(title = "类型名称", required = true)
private String typeName;
@Schema(name = "是否支持蓝牙")
@Schema(title = "是否支持蓝牙")
private Boolean isSupportBle;
@Schema(name = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
@Schema(title = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
private String locateMode;
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
@Schema(title = "联网方式", example = "0:无;1:4G;2:WIFI")
private String networkWay;
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
@Schema(title = "通讯方式", example = "0:4G;1:蓝牙,2 4G&蓝牙")
private String communicationMode;
/**
@ -67,9 +73,17 @@ public class DeviceType extends TenantEntity {
/**
* 型号字典用于APP页面跳转
* app_model_dictionary
*/
@Schema(name = "型号字典用于APP页面跳转")
private String modelDictionary;
@Schema(title = "型号字典用于APP页面跳转")
private String appModelDictionary;
/**
* 型号字典用于PC页面跳转
* pc_model_dictionary
*/
@Schema(title = "型号字典用于PC页面跳转")
private String pcModelDictionary;
}

View File

@ -0,0 +1,116 @@
package com.fuyuanshen.equipment.domain.bo;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 设备告警业务对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceAlarm.class, reverseConvertGenerate = false)
public class DeviceAlarmBo extends BaseEntity {
/**
* ID
*/
@NotNull(message = "ID不能为空", groups = {EditGroup.class})
private Long id;
/**
* 设备ID
*/
private Long deviceId;
/**
* 报警事项
* device_action
*/
private Integer deviceAction;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
* device_mac
*/
private String deviceMac;
/**
* 设备IMEI
* device_imei
*/
private String deviceImei;
/**
* 数据来源
*/
private String dataSource;
/**
* 内容
*/
private String content;
/**
* 设备类型
* device_type
*/
private Long deviceType;
/**
* 经度
*/
private Long longitude;
/**
* 纬度
*/
private Long latitude;
/**
* 报警位置
*/
private String location;
/**
* 报警开始时间
*/
private Date startTime;
/**
* 报警结束时间
*/
private Date finishTime;
/**
* 报警持续时间
*/
private Long durationTime;
/**
* 报警查询时间
*/
private String queryTime1;
private String queryTime2;
/**
* 0已处理1未处理
*/
private Integer treatmentState;
}

View File

@ -0,0 +1,110 @@
package com.fuyuanshen.equipment.domain.bo;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 设备充放电记录业务对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceChargeDischarge.class, reverseConvertGenerate = false)
public class DeviceChargeDischargeBo extends BaseEntity {
/**
* 记录唯一标识
*/
@NotNull(message = "记录唯一标识不能为空", groups = { EditGroup.class })
private Long id;
/**
* 设备唯一标识
*/
@NotBlank(message = "设备唯一标识不能为空", groups = { AddGroup.class, EditGroup.class })
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
@NotNull(message = "操作类型: 0 charge-充电, 1 discharge-放电不能为空", groups = { AddGroup.class, EditGroup.class })
private Long operationType;
/**
* 开始时间
*/
@NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
private Long finalSoc;
/**
* 充放电量(kWh)
*/
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
private Long powerRating;
/**
* 电压(V)
*/
private Long voltage;
/**
* 电流(A)
*/
private Long current;
/**
* 温度(℃)
*/
private Long temperature;
/**
* 当前状态
*/
private Long status;
/**
* 错误代码
*/
private String errorCode;
/**
* 记录创建时间
*/
private Date createdAt;
/**
* 记录更新时间
*/
private Date updatedAt;
}

View File

@ -30,18 +30,21 @@ public class DeviceGroupBo extends BaseEntity {
/**
* 分组名称
*/
@Schema(title = "分组名称")
@NotBlank(message = "分组名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String groupName;
/**
* 状态0-禁用1-正常
*/
@Schema(title = "状态0-禁用1-正常")
// @NotNull(message = "状态0-禁用1-正常不能为空", groups = { AddGroup.class, EditGroup.class })
private Long status;
/**
* 父分组ID
*/
@Schema(title = "父分组ID")
private Long parentId;
/**
@ -56,10 +59,10 @@ public class DeviceGroupBo extends BaseEntity {
private Long isDeleted;
@Schema(name = "页码", example = "1")
@Schema(title = "页码", example = "1")
private Integer pageNum = 1;
@Schema(name = "每页数据量", example = "10")
@Schema(title = "每页数据量", example = "10")
private Integer pageSize = 10;
}

View File

@ -1,15 +1,19 @@
package com.fuyuanshen.equipment.domain.bo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
/**
* 设备维修记录业务对象 device_repair_records
@ -37,6 +41,7 @@ public class DeviceRepairRecordsBo extends BaseEntity {
/**
* 维修时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message = "维修时间不能为空", groups = { AddGroup.class, EditGroup.class })
private Date repairTime;
@ -58,5 +63,11 @@ public class DeviceRepairRecordsBo extends BaseEntity {
@NotBlank(message = "维修人员不能为空", groups = { AddGroup.class, EditGroup.class })
private String repairPerson;
@Schema(title = "维修前图片")
@JsonIgnore
private MultipartFile beforeFile;
@Schema(title = "维修后图片")
@JsonIgnore
private MultipartFile afterFile;
}

View File

@ -0,0 +1,43 @@
package com.fuyuanshen.equipment.domain.dto;
import lombok.Data;
@Data
public class InstructionRecordDto {
/**
* 设备类型
*/
private String deviceType;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* content
*/
private String content;
/**
* 操作时间-开始时间
*/
private String startTime;
/**
* 操作时间-结束时间
*/
private String endTime;
/**
* 分组id
*/
private Long groupId;
}

View File

@ -40,7 +40,7 @@ public class DeviceForm {
@Schema(title = "设备MAC")
private String deviceMac;
@Schema(name = "蓝牙名称")
@Schema(title = "蓝牙名称")
private String bluetoothName;

View File

@ -11,28 +11,42 @@ import lombok.Data;
@Data
public class DeviceTypeForm {
@Schema(name = "ID", hidden = true)
@Schema(title = "ID", hidden = true)
private Long id;
@Schema(name = "类型名称", required = true)
@Schema(title = "类型名称", required = true)
private String typeName;
@Schema(name = "是否支持蓝牙")
@Schema(title = "是否支持蓝牙")
private Boolean isSupportBle;
@Schema(name = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
@Schema(title = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
private String locateMode;
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
@Schema(title = "联网方式", example = "0:无;1:4G;2:WIFI")
private String networkWay;
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
@Schema(title = "通讯方式", example = "0:4G;1:蓝牙")
private String communicationMode;
/**
* 型号字典用于APP页面跳转
*/
@Schema(name = "型号字典用于APP页面跳转")
@Schema(title = "型号字典用于APP页面跳转")
private String modelDictionary;
/**
* 型号字典用于APP页面跳转
* app_model_dictionary
*/
@Schema(title = "型号字典用于APP页面跳转")
private String appModelDictionary;
/**
* 型号字典用于PC页面跳转
* pc_model_dictionary
*/
@Schema(title = "型号字典用于PC页面跳转")
private String pcModelDictionary;
}

View File

@ -18,22 +18,34 @@ import java.util.Set;
@Data
public class DeviceQueryCriteria extends BaseEntity {
@Schema(name = "设备id")
/**
* 设备id
*/
private Long deviceId;
@Schema(name = "设备名称")
/**
* 设备名称
*/
private String deviceName;
@Schema(name = "设备类型")
/**
* 设备类型
*/
private Long deviceType;
@Schema(name = "设备MAC")
/**
* 设备MAC
*/
private String deviceMac;
@Schema(name = "设备IMEI")
/**
* 设备IMEI
*/
private String deviceImei;
@Schema(name = "设备SN")
/**
* 设备SN
*/
private String deviceSn;
/**
@ -41,28 +53,71 @@ public class DeviceQueryCriteria extends BaseEntity {
* 0 失效
* 1 正常
*/
@Schema(name = "设备状态 0 失效 1 正常 ")
private Integer deviceStatus;
@Schema(name = "页码", example = "1")
/**
* 页码
*/
private Integer pageNum = 1;
@Schema(name = "每页数据量", example = "10")
/**
* 每页数据量
*/
private Integer pageSize = 10;
@Schema(name = "客户id")
/**
* 客户id
*/
private Long customerId;
private Set<Long> customerIds;
@Schema(name = "当前所有者")
/**
* 当前所有者
*/
private Long currentOwnerId;
@Schema(name = "租户ID")
/**
* 租户ID
*/
private String tenantId;
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
/**
* 通讯方式 0:4G;1:蓝牙
* communication_mode
*/
private Integer communicationMode;
/* app绑定用户id */
private Long bindingUserId;
/**
* 使用人员
*/
private String personnelBy;
/**
* 是否为管理员
*/
private Boolean isAdmin = false;
/**
* 设备所属分组
*/
private Long groupId;
/**
* 设备地区
*/
private String area;
private String content;
/**
* 设备在线状态
* 0:离线;1:在线
*/
private Integer onlineStatus;
}

View File

@ -0,0 +1,72 @@
package com.fuyuanshen.equipment.domain.query;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
/**
* 设备维修记录查询
*
* @Description:
* @Author: WY
* @Date: 2025/5/16
**/
@Data
public class DeviceRepairRecordsQueryCriteria extends BaseEntity {
/**
* 维修记录ID
*/
private Long recordId;
/**
* 设备ID
*/
private String deviceId;
/**
* 维修时间
*/
private Date repairTime;
/**
* 维修部位
*/
private String repairPart;
/**
* 维修原因
*/
private String repairReason;
/**
* 维修人员
*/
private String repairPerson;
@Schema(title = "维修开始时间")
private Date repairBeginTime;
@Schema(title = "维修结束时间")
private Date repairEndTime;
@Schema(title = "所属客户")
private Long customerId;
@Schema(title = "com.fuyuanshen")
private Long tenantId;
/**
* 页码
*/
private Integer pageNum = 1;
/**
* 每页数据量
*/
private Integer pageSize = 10;
}

View File

@ -15,24 +15,30 @@ import java.util.Set;
@Data
public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable {
@Schema(name = "设备类型id")
@Schema(title = "设备类型id")
private Long deviceTypeId;
@Schema(name = "型号名称")
@Schema(title = "型号名称")
private String typeName;
@Schema(name = "所属客户")
@Schema(title = "所属客户")
private Set<Long> customerIds;
@Schema(name = "所属客户")
@Schema(title = "所属客户")
private Long customerId;
@Schema(name = "com.fuyuanshen")
@Schema(title = "com.fuyuanshen")
private Long tenantId;
@Schema(name = "页码", example = "1")
@Schema(title = "页码", example = "1")
private Integer pageNum = 1;
@Schema(name = "每页数据量", example = "10")
@Schema(title = "每页数据量", example = "10")
private Integer pageSize = 10;
/* 是否为管理员 */
private Boolean isAdmin = false;
}

View File

@ -0,0 +1,44 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 报警信息
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class AlarmInformationVo {
/**
* 报警总数
*/
private Integer alarmsTotal = 0;
/**
* 总处理报警
*/
private Integer processingAlarm = 0;
/**
* 强制报警
*/
private Integer alarmForced = 0;
/**
* 撞击闯入
*/
private Integer intrusionImpact = 0;
/**
* 手动报警
*/
private Integer alarmManual = 0;
/**
* 电子围栏
*/
private Integer fenceElectronic = 0;
}

View File

@ -16,11 +16,11 @@ import java.util.List;
@Validated
public class CustomerVo {
@Schema(name = "客户ID")
@Schema(title = "客户ID")
@NotNull(message = "客户ID不能为空")
private Long customerId;
@Schema(name = "设备ID")
@Schema(title = "设备ID")
@NotNull(message = "设备ID不能为空")
private List<Long> deviceIds;

View File

@ -0,0 +1,34 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 数据总览
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class DataOverviewVo {
/**
* 设备数据量
*/
private Integer devicesNumber = 0;
/**
* 在线设备
*/
private Integer equipmentOnline = 0;
/**
* 新增绑定设备
*/
private Integer bindingNew = 0;
/**
* 异常设备
*/
private Integer equipmentAbnormal = 0;
}

View File

@ -0,0 +1,137 @@
package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 设备告警视图对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceAlarm.class)
public class DeviceAlarmVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@ExcelProperty(value = "ID")
private Long id;
/**
* 设备ID
*/
@ExcelProperty(value = "设备ID")
private Long deviceId;
/**
* 报警事项
* 0-强制报警1-撞击闯入2-手动报警3-电子围栏告警4-强制告警
*/
@ExcelProperty(value = "报警事项")
private Integer deviceAction;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 数据来源
*/
@ExcelProperty(value = "数据来源")
private String dataSource;
/**
* 内容
*/
@ExcelProperty(value = "内容")
private String content;
/**
* 设备类型
*/
@ExcelProperty(value = "设备类型")
private Long deviceType;
private String deviceTypeName;
/**
* 经度
*/
@ExcelProperty(value = "经度")
private Long longitude;
/**
* 纬度
*/
@ExcelProperty(value = "纬度")
private Long latitude;
/**
* 报警位置
*/
@ExcelProperty(value = "报警位置")
private String location;
/**
* 报警开始时间
*/
@ExcelProperty(value = "报警开始时间")
private Date startTime;
/**
* 报警结束时间
*/
@ExcelProperty(value = "报警结束时间")
private Date finishTime;
/**
* 报警持续时间
*/
@ExcelProperty(value = "报警持续时间")
private String durationTime;
/**
* 0已处理1未处理
*/
@ExcelProperty(value = "0已处理1未处理")
private Integer treatmentState;
/**
* 设备图片
* device_pic
*/
@Schema(name = "设备图片")
private String devicePic;
}

View File

@ -0,0 +1,130 @@
package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 设备充放电记录视图对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceChargeDischarge.class)
public class DeviceChargeDischargeVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 记录唯一标识
*/
@ExcelProperty(value = "记录唯一标识")
private Long id;
/**
* 设备唯一标识
*/
@ExcelProperty(value = "设备唯一标识")
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
@ExcelProperty(value = "操作类型: 0 charge-充电, 1 discharge-放电")
private Long operationType;
/**
* 开始时间
*/
@ExcelProperty(value = "开始时间")
private Date startTime;
/**
* 结束时间
*/
@ExcelProperty(value = "结束时间")
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
@ExcelProperty(value = "起始电量百分比(0-100)")
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
@ExcelProperty(value = "结束电量百分比(0-100)")
private Long finalSoc;
/**
* 充放电量(kWh)
*/
@ExcelProperty(value = "充放电量(kWh)")
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
@ExcelProperty(value = "设备额定功率(kW)")
private Long powerRating;
/**
* 电压(V)
*/
@ExcelProperty(value = "电压(V)")
private Long voltage;
/**
* 电流(A)
*/
@ExcelProperty(value = "电流(A)")
private Long current;
/**
* 温度(℃)
*/
@ExcelProperty(value = "温度(℃)")
private Long temperature;
/**
* 当前状态
*/
@ExcelProperty(value = "当前状态")
private Long status;
/**
* 错误代码
*/
@ExcelProperty(value = "错误代码")
private String errorCode;
/**
* 记录创建时间
*/
@ExcelProperty(value = "记录创建时间")
private Date createdAt;
/**
* 记录更新时间
*/
@ExcelProperty(value = "记录更新时间")
private Date updatedAt;
}

View File

@ -0,0 +1,48 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import com.fuyuanshen.equipment.domain.DeviceRepairImages;
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
import com.fuyuanshen.equipment.enums.RepairImageType;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 设备维修图片视图对象 device_repair_records
*
* @author Lion Li
* @date 2025-09-01
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceRepairImages.class)
public class DeviceRepairImagesVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 维修图片ID
*/
@Schema(title = "维修图片ID")
private Long imageId;
/**
* 维修记录ID
*/
@Schema(title = "维修记录ID")
private Long recordId;
/**
* 图片类型(维修前/维修后)
*/
@Schema(title = "图片类型(维修前/维修后)")
private RepairImageType imageType;
/**
* 图片存储路径
*/
@Schema(title = "图片存储路径")
private String imageUrl;
}

View File

@ -2,6 +2,7 @@ package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
@ -13,7 +14,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -25,7 +26,7 @@ import java.util.Date;
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceRepairRecords.class)
public class DeviceRepairRecordsVo implements Serializable {
public class DeviceRepairRecordsVo extends TenantEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ -65,6 +66,12 @@ public class DeviceRepairRecordsVo implements Serializable {
*/
@ExcelProperty(value = "维修人员")
private String repairPerson;
/**
* 维修人员
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
private List<DeviceRepairImagesVo> images;
}

View File

@ -0,0 +1,29 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 设备分类
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class EquipmentClassificationVo {
/**
* 4G设备
*/
private Integer equipment4G = 0;
/**
* 蓝牙设备
*/
private Integer deviceBluetooth = 0;
/**
* 4G & 蓝牙 设备
*/
private Integer devices4GAndBluetooth = 0;
}

View File

@ -0,0 +1,39 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class InstructionRecordVo {
private Long id;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备类型
*/
@ExcelProperty(value = "设备型号")
private String deviceType;
/**
* 操作模块
*/
@ExcelProperty(value = "操作模块")
private String deviceAction;
/**
* 操作内容
*/
@ExcelProperty(value = "操作内容")
private String content;
/**
* 操作时间
*/
@ExcelProperty(value = "操作时间")
private String createTime;
}

View File

@ -0,0 +1,41 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
import java.util.List;
@Data
public class LocationHistoryDetailVo {
/**
* 日期
*/
@ExcelProperty(value = "日期")
private String date;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 初始地点
*/
@ExcelProperty(value = "初始地点")
private String startLocation;
/**
* 结束地点
*/
@ExcelProperty(value = "结束地点")
private String endLocation;
/**
* 轨迹详情
*/
@ExcelProperty(value = "轨迹详情")
private List<Object> detailList;
}

View File

@ -0,0 +1,39 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class LocationHistoryVo {
private Long id;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备类型
*/
private String deviceType;
/**
* 设备类型
*/
@ExcelProperty(value = "设备型号")
private String deviceTypeName;
/**
* 设备IMEI
*/
@ExcelProperty(value = "设备IMEI")
private String deviceImei;
/**
* 设备MAC
*/
@ExcelProperty(value = "设备MAC")
private String deviceMac;
}

View File

@ -0,0 +1,101 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class WebDeviceVo implements Serializable {
private Long id;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 通讯方式 0:4G;1:蓝牙
*/
private Integer communicationMode;
/**
* 设备图片
*/
private String devicePic;
/**
* 设备类型
*/
private String typeName;
/**
* 蓝牙名称
*/
private String bluetoothName;
/**
* 使用人员
*/
private String personnelBy;
/**
* 设备状态
* 0 失效
* 1 正常
*/
private Integer deviceStatus;
/**
* 绑定时间
*/
private Date bindingTime;
/**
* 在线状态(0离线1在线)
*/
private Integer onlineStatus;
/**
* 电量 百分比
*/
private String battery;
/**
* 纬度
*/
private String latitude;
/**
* 经度
*/
private String longitude;
/**
* 告警状态(0解除告警1告警)
*/
private String alarmStatus;
/**
* 设备详情页面
*/
private String detailPageUrl;
/**
* 分享用户数量
*/
private Integer shareUsersNumber;
}

View File

@ -0,0 +1,72 @@
package com.fuyuanshen.equipment.enums;
/**
* 灯光模式枚举
*/
public enum LightModeEnum {
/**
* 关灯模式
*/
OFF(0, "关灯"),
/**
* 强光模式
*/
HIGH_BEAM(1, "开启强光模式"),
/**
* 弱光模式
*/
LOW_BEAM(2, "开启弱光模式"),
/**
* 爆闪模式
*/
STROBE(3, "开启爆闪模式"),
/**
* 泛光模式
*/
FLOOD(4, "开启泛光模式");
private final Integer code;
private final String name;
LightModeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
/**
* 根据编号获取枚举
* @param code 编号
* @return 对应的枚举值
*/
public static LightModeEnum getByCode(Integer code) {
for (LightModeEnum mode : LightModeEnum.values()) {
if (mode.getCode().equals(code)) {
return mode;
}
}
return null;
}
/**
* 根据编号获取名称
* @param code 编号
* @return 对应的名称
*/
public static String getNameByCode(Integer code) {
LightModeEnum mode = getByCode(code);
return mode != null ? mode.getName() : null;
}
}

View File

@ -0,0 +1,23 @@
package com.fuyuanshen.equipment.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum RepairImageType {
BEFORE(1, "维修前"),
AFTER(2, "维修后");
private final int code;
private final String desc;
public static RepairImageType of(Integer code) {
return Arrays.stream(values())
.filter(e -> e.getCode() == code)
.findFirst()
.orElse(null);
}
}

View File

@ -0,0 +1,28 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
/**
* 设备告警Mapper接口
*
* @author Lion Li
* @date 2025-08-28
*/
public interface DeviceAlarmMapper extends BaseMapperPlus<DeviceAlarm, DeviceAlarmVo> {
/**
* 查询设备告警列表
*
* @param bo 设备告警
* @return 设备告警
*/
Page<DeviceAlarmVo> selectVoPage( Page pageQuery,@Param("bo") DeviceAlarmBo bo);
}

View File

@ -0,0 +1,15 @@
package com.fuyuanshen.equipment.mapper;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 设备充放电记录Mapper接口
*
* @author Lion Li
* @date 2025-08-30
*/
public interface DeviceChargeDischargeMapper extends BaseMapperPlus<DeviceChargeDischarge, DeviceChargeDischargeVo> {
}

View File

@ -1,8 +1,12 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.vo.DeviceLogVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import org.apache.ibatis.annotations.Param;
/**
* 设备日志Mapper接口
@ -12,4 +16,5 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface DeviceLogMapper extends BaseMapperPlus<DeviceLog, DeviceLogVo> {
Page<InstructionRecordVo> getInstructionRecord(Page<InstructionRecordVo> page,@Param("bo") InstructionRecordDto bo);
}

View File

@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @Description:
@ -67,4 +69,44 @@ public interface DeviceMapper extends BaseMapper<Device> {
*/
List<Device> findByOriginalDeviceId(Long originalDeviceId);
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build, @Param("criteria") DeviceQueryCriteria criteria);
Page<LocationHistoryVo> getLocationHistory(Page<Object> build, @Param("bo") InstructionRecordDto criteria);
/**
* 获取数据总览
*
* @return
*/
DataOverviewVo getDataOverview();
/**
* 获取设备分类
*
* @return
*/
EquipmentClassificationVo getEquipmentClassification();
/**
* 获取告警信息
*
* @return
*/
AlarmInformationVo getAlarmInformation();
/**
* 获取设备使用数据
*
* @param deviceId 设备ID
* @param range 时间范围 1:半年 2:一年
* @return 每月使用数据列表
*/
List<Map<String, Object>> getEquipmentUsageData(Long deviceId, Integer range);
// 在DeviceMapper.java中添加方法
int getUsageDataForMonth(@Param("deviceId") Long deviceId,
@Param("year") int year,
@Param("month") int month);
}

Some files were not shown because too many files have changed in this diff Show More