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] =?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; + } +}