From c587ef738935bfd0271939d4558bb39ecd9fe03e Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Thu, 14 Aug 2025 18:57:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=A7=A3=E7=BB=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/device/DeviceBizService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java index 82a49649..4d9a8de0 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java @@ -6,12 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 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.dto.APPReNameDTO; import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto; import com.fuyuanshen.app.domain.dto.DeviceInstructDto; 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; import com.fuyuanshen.common.core.utils.ObjectUtils; @@ -55,6 +59,8 @@ public class DeviceBizService { private final AppDeviceBindRecordMapper appDeviceBindRecordMapper; private final RealTimeStatusEngine realTimeStatusEngine; private final DeviceLogMapper deviceLogMapper; + private final AppDeviceShareMapper appDeviceShareMapper; + private final AppUserMapper appUserMapper;; @@ -240,6 +246,15 @@ public class DeviceBizService { appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId())); } + AppUserVo appUserVo = appUserMapper.selectVoById(userId); + QueryWrapper appDeviceShareQueryWrapper = new QueryWrapper<>(); + appDeviceShareQueryWrapper.eq("device_id", device.getId()); + appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber()); + List appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper); + if (CollectionUtil.isNotEmpty(appDeviceShareList)) { + appDeviceShareList.forEach(appDeviceShare -> + appDeviceShareMapper.deleteById(appDeviceShare.getId())); + } return 1; } From 77542f5e763eae4443a25f5e53ed17d596d1af62 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Fri, 15 Aug 2025 09:32:54 +0800 Subject: [PATCH 2/5] commit --- .../mqtt/receiver/ReceiverMessageHandler.java | 2 +- .../service/device/DeviceBJQBizService.java | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/receiver/ReceiverMessageHandler.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/receiver/ReceiverMessageHandler.java index 618758f7..811acd54 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/receiver/ReceiverMessageHandler.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/receiver/ReceiverMessageHandler.java @@ -49,7 +49,7 @@ public class ReceiverMessageHandler implements MessageHandler { if(StringUtils.isNotBlank(deviceImei)){ //在线状态 String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ; - RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(60*15)); + RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(62)); } String state = payloadDict.getStr("state"); diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java index 671fe8ef..7038c8ed 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java @@ -19,6 +19,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.mapper.DeviceLogMapper; import com.fuyuanshen.equipment.mapper.DeviceMapper; import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; import com.fuyuanshen.global.mqtt.config.MqttGateway; @@ -50,6 +51,7 @@ public class DeviceBJQBizService { private final AppPersonnelInfoMapper appPersonnelInfoMapper; private final DeviceTypeMapper deviceTypeMapper; private final MqttGateway mqttGateway; + private final DeviceLogMapper deviceLogMapper; public int sendMessage(AppDeviceSendMsgBo bo) { List deviceIds = bo.getDeviceIds(); @@ -93,15 +95,43 @@ public class DeviceBJQBizService { .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); throw new ServiceException("发送指令失败"); } } + + return 1; } + /** + * 记录设备操作日志 + * @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); + } + } + + public AppDeviceDetailVo getInfo(Long id) { Device device = deviceMapper.selectById(id); if (device == null) { @@ -203,7 +233,7 @@ 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()); if (ObjectUtils.length(appPersonnelInfoVos) == 0) { AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class); return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo); @@ -216,8 +246,6 @@ public class DeviceBJQBizService { .set("code", bo.getCode()); return appPersonnelInfoMapper.update(null, uw) > 0; } - - } public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) { @@ -255,6 +283,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)); + + recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", "上传开机画面", AppLoginHelper.getUserId()); } catch (Exception e){ e.printStackTrace(); throw new ServiceException("发送指令失败"); From 33f3cb5989d867fe0c818a1510cd33f7e8cd3a03 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Fri, 15 Aug 2025 10:14:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?app=E5=A2=9E=E5=8A=A0=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/app/AppDeviceShareMapper.xml | 2 ++ .../java/com/fuyuanshen/equipment/domain/vo/AppDeviceVo.java | 5 +++++ .../src/main/resources/mapper/equipment/DeviceMapper.xml | 2 ++ 3 files changed, 9 insertions(+) diff --git a/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml index 9b3b29c5..c1d1b751 100644 --- a/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml +++ b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml @@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" d.device_pic, dt.type_name, dt.communication_mode, + dt.model_dictionary detailPageUrl, d.bluetooth_name, c.binding_time, ad.*,u.user_name otherPhonenumber @@ -34,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dt.type_name, dt.communication_mode, d.bluetooth_name, + dt.model_dictionary detailPageUrl, c.binding_time, ad.*,u.user_name otherPhonenumber from diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/AppDeviceVo.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/AppDeviceVo.java index 1d0ec238..aafc6fc2 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/AppDeviceVo.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/AppDeviceVo.java @@ -81,4 +81,9 @@ public class AppDeviceVo implements Serializable { * 告警状态(0解除告警,1告警) */ private String alarmStatus; + + /** + * 设备详情页面 + */ + private String detailPageUrl; } diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 8af7215a..37b01927 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -148,6 +148,7 @@ dt.type_name, dt.communication_mode, d.bluetooth_name, + dt.model_dictionary detailPageUrl, c.binding_time from device d inner join device_type dt on d.device_type = dt.id @@ -177,6 +178,7 @@ d.device_pic, dt.type_name, dt.communication_mode, + dt.model_dictionary detailPageUrl, d.bluetooth_name from device d inner join device_type dt on d.device_type = dt.id From f8c53451c05ae277c1b4231c31bcc1b32affd3e9 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Fri, 15 Aug 2025 18:16:37 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=81=AF=E5=85=89?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fuyuanshen/global/mqtt/base/MqttRuleEngine.java | 11 +++++++++-- .../mqtt/rule/bjq/BjqLaserModeSettingsRule.java | 2 +- .../fuyuanshen/global/mqtt/rule/bjq/BjqModeRule.java | 8 ++++++-- fys-admin/src/main/resources/application.yml | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/base/MqttRuleEngine.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/base/MqttRuleEngine.java index 66ea4dc0..b27d57aa 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/base/MqttRuleEngine.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/base/MqttRuleEngine.java @@ -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 rulesMap = new LinkedHashMap<>(); public MqttRuleEngine(List 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; } diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLaserModeSettingsRule.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLaserModeSettingsRule.java index f255b107..b2bb3391 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLaserModeSettingsRule.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLaserModeSettingsRule.java @@ -49,7 +49,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule { 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)); } } diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqModeRule.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqModeRule.java index 7c53d20c..f16b77e4 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqModeRule.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqModeRule.java @@ -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) { diff --git a/fys-admin/src/main/resources/application.yml b/fys-admin/src/main/resources/application.yml index c413dff7..3b4dce13 100644 --- a/fys-admin/src/main/resources/application.yml +++ b/fys-admin/src/main/resources/application.yml @@ -232,7 +232,7 @@ xss: # 如使用JDK21请直接使用虚拟线程 不要开启此配置 thread-pool: # 是否开启线程池 - enabled: false + enabled: true # 队列最大长度 queueCapacity: 128 # 线程池维护线程所允许的空闲时间 From 6d6db190b97fb67ad0307279272cdca41b0fc233 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Sat, 16 Aug 2025 11:30:06 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=86=E4=BA=AB2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/AppDeviceBJQController.java | 8 +-- .../app/service/AppDeviceShareService.java | 12 ++++ .../service/device/DeviceBJQBizService.java | 24 +++++-- .../app/domain/vo/AppDeviceShareDetailVo.java | 3 + .../equipment/enums/LightModeEnum.java | 72 +++++++++++++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/enums/LightModeEnum.java diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceBJQController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceBJQController.java index d6bf411d..51fb810e 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceBJQController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceBJQController.java @@ -43,7 +43,7 @@ public class AppDeviceBJQController extends BaseController { * 人员信息登记 */ @PostMapping(value = "/registerPersonInfo") - @FunctionAccessAnnotation("registerPersonInfo") +// @FunctionAccessAnnotation("registerPersonInfo") public R registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) { return toAjax(appDeviceService.registerPersonInfo(bo)); } @@ -61,7 +61,7 @@ public class AppDeviceBJQController extends BaseController { * 发送报警信息 */ @PostMapping(value = "/sendAlarmMessage") - @FunctionAccessBatcAnnotation("sendAlarmMessage") +// @FunctionAccessBatcAnnotation("sendAlarmMessage") public R 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 lightModeSettings(@RequestBody DeviceInstructDto params) { // params 转 JSONObject @@ -110,7 +110,7 @@ public class AppDeviceBJQController extends BaseController { * */ @PostMapping("/laserModeSettings") - @FunctionAccessAnnotation("laserModeSettings") +// @FunctionAccessAnnotation("laserModeSettings") public R laserModeSettings(@RequestBody DeviceInstructDto params) { appDeviceService.laserModeSettings(params); return R.ok(); diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java index be5986c1..1b60ce6a 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java @@ -161,6 +161,18 @@ public class AppDeviceShareService { 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; } /** diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java index 7038c8ed..1488ed5f 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java @@ -19,6 +19,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; @@ -69,7 +70,7 @@ public class DeviceBJQBizService { 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"); @@ -95,6 +96,7 @@ public class DeviceBJQBizService { .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); @@ -211,6 +213,7 @@ public class DeviceBJQBizService { if (deviceObj == null) { throw new RuntimeException("请先将设备入库!!!"); } + QueryWrapper qw = new QueryWrapper() .eq("device_id", deviceId); List appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw); @@ -233,6 +236,7 @@ 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()); if (ObjectUtils.length(appPersonnelInfoVos) == 0) { AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class); @@ -262,7 +266,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); @@ -314,6 +318,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("发送指令失败"); @@ -347,6 +353,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("发送指令失败"); @@ -372,6 +379,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("发送指令失败"); @@ -418,15 +431,16 @@ 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; } diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java index 89716f64..f9e8483e 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java @@ -138,4 +138,7 @@ public class AppDeviceShareDetailVo implements Serializable { * 告警状态(0解除告警,1告警) */ private String alarmStatus; + + // 灯光亮度 + private String lightBrightness; } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/enums/LightModeEnum.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/enums/LightModeEnum.java new file mode 100644 index 00000000..7394a082 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/enums/LightModeEnum.java @@ -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; + } +}