forked from dyf/fys-Multi-tenant
设备分享2
This commit is contained in:
@ -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));
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class AppDeviceBJQController extends BaseController {
|
||||
* 发送报警信息
|
||||
*/
|
||||
@PostMapping(value = "/sendAlarmMessage")
|
||||
@FunctionAccessBatcAnnotation("sendAlarmMessage")
|
||||
// @FunctionAccessBatcAnnotation("sendAlarmMessage")
|
||||
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();
|
||||
|
@ -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;
|
||||
}
|
||||
/**
|
||||
|
@ -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<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
|
||||
.eq("device_id", deviceId);
|
||||
List<AppPersonnelInfoVo> 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;
|
||||
}
|
||||
|
@ -138,4 +138,7 @@ public class AppDeviceShareDetailVo implements Serializable {
|
||||
* 告警状态(0解除告警,1告警)
|
||||
*/
|
||||
private String alarmStatus;
|
||||
|
||||
// 灯光亮度
|
||||
private String lightBrightness;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user