forked from dyf/fys-Multi-tenant
hby100japp功能3
This commit is contained in:
@ -55,6 +55,31 @@ public class AppDeviceHBY100JController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音播报
|
||||
*
|
||||
*/
|
||||
@PostMapping("/voiceBroadcast")
|
||||
public R<Void> voiceBroadcast(@RequestBody HBY100JVoiceBroadcastDto params) {
|
||||
deviceHBY100JBizService.voiceBroadcast(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class HBY100JVoiceBroadcastDto {
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
Long deviceId;
|
||||
/**
|
||||
* 0 关闭, 1开启
|
||||
*/
|
||||
private Integer voiceBroadcast;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 爆闪模式
|
||||
*/
|
||||
|
||||
@ -29,13 +29,13 @@ public class FuncType13Brightness implements NewMqttMessageRule {
|
||||
log.info("HBY100J警示灯LED亮度调节,消息负载:{}", context.getPayloadDict());
|
||||
|
||||
try {
|
||||
// String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
|
||||
// context.getDeviceImei() + ":brightness";
|
||||
//
|
||||
// Map<String, Object> payloadDict = context.getPayloadDict();
|
||||
// if (payloadDict != null) {
|
||||
// RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
|
||||
// }
|
||||
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
|
||||
context.getDeviceImei() + ":brightness";
|
||||
|
||||
Map<String, Object> payloadDict = context.getPayloadDict();
|
||||
if (payloadDict != null) {
|
||||
RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("HBY100J警示灯LED亮度调节失败", e);
|
||||
}
|
||||
|
||||
@ -52,5 +52,7 @@ public class FunctionType3LocationReport {
|
||||
*/
|
||||
@JsonProperty("latitude")
|
||||
private Double latitude;
|
||||
|
||||
private String address;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,40 +134,71 @@ public class DeviceHBY100JBizService {
|
||||
// 获取电量
|
||||
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||
vo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
|
||||
vo.setChargeState(jsonObject.getString("chargeState"));
|
||||
vo.setBatteryPercentage(jsonObject.getString("level"));
|
||||
vo.setChargeState(jsonObject.getString("charge"));
|
||||
} else {
|
||||
vo.setBatteryPercentage("0");
|
||||
}
|
||||
|
||||
String lightModeStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX);
|
||||
|
||||
String reportStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + ":report");
|
||||
if (StringUtils.isNotBlank(reportStatus)) {
|
||||
FuncType14StatusReport report = JSONObject.parseObject(reportStatus,FuncType14StatusReport.class);
|
||||
FuncType14StatusReport.Data data = report.getData();
|
||||
FuncType14StatusReport.Brightness brightness = data.getBrightness();
|
||||
if(brightness != null){
|
||||
vo.setLightBrightness(brightness.getRed());
|
||||
}
|
||||
|
||||
vo.setVolume(data.getVolume());
|
||||
FuncType14StatusReport.LedStrobe ledStrobe = data.getLedStrobe();
|
||||
if(ledStrobe != null){
|
||||
vo.setStrobeFrequency(ledStrobe.getFrequency());
|
||||
vo.setStrobeMode(ledStrobe.getMode());
|
||||
vo.setStrobeEnable(ledStrobe.getEnable());
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
Integer voiceBroadcast = data.getVoiceBroadcast();
|
||||
if(voiceBroadcast != null && voiceBroadcast == 1){
|
||||
vo.setAlarmMode(9);
|
||||
vo.setVoiceStrobeAlarm(1);
|
||||
}else {
|
||||
FuncType14StatusReport.SirenAlarm sirenAlarm = data.getSirenAlarm();
|
||||
if(sirenAlarm != null){
|
||||
vo.setVoiceStrobeAlarm(sirenAlarm.getEnable());
|
||||
vo.setAlarmMode(sirenAlarm.getMode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取经度纬度
|
||||
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);
|
||||
// vo.setLongitude(jsonObject.get("longitude").toString());
|
||||
// vo.setLatitude(jsonObject.get("latitude").toString());
|
||||
// vo.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)) {
|
||||
vo.setVoiceStrobeAlarm(alarmStatus);
|
||||
if (StringUtils.isNotBlank(locationInfo)) {
|
||||
FunctionType3LocationReport locationReport = JSONObject.parseObject(locationInfo,FunctionType3LocationReport.class);
|
||||
if(locationReport != null){
|
||||
FunctionType3LocationReport.Data data = locationReport.getData();
|
||||
if(data != null){
|
||||
vo.setLongitude(data.getLongitude().toString());
|
||||
vo.setLatitude(data.getLatitude().toString());
|
||||
vo.setAddress(data.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
|
||||
if (StringUtils.isNotBlank(lightBrightness)) {
|
||||
vo.setLightBrightness(lightBrightness);
|
||||
QueryWrapper<AppBusinessFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("business_id", device.getId());
|
||||
queryWrapper.eq("file_type", 3);
|
||||
queryWrapper.eq("use_status", 1);
|
||||
List<AppBusinessFile> appBusinessFiles = appBusinessFileMapper.selectList(queryWrapper);
|
||||
if(appBusinessFiles != null && appBusinessFiles.size() > 0){
|
||||
AppBusinessFile appBusinessFile = appBusinessFiles.get(0);
|
||||
SysOssVo sysOssVo = sysOssMapper.selectVoById(appBusinessFile.getFileId());
|
||||
if(sysOssVo != null){
|
||||
vo.setVoiceResource(sysOssVo.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@ -190,31 +221,17 @@ public class DeviceHBY100JBizService {
|
||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||
// }
|
||||
|
||||
// 语音播报
|
||||
if(bo.getMode() == 9){
|
||||
FuncType6VoicePlayRequest request = new FuncType6VoicePlayRequest();
|
||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||
request.setImei(deviceObj.getDeviceImei());
|
||||
request.setFuncType("6");
|
||||
request.setTimestamp(System.currentTimeMillis());
|
||||
FuncType6VoicePlayRequest.Data data = new FuncType6VoicePlayRequest.Data();
|
||||
data.setVoiceBroadcast(bo.getVoiceStrobeAlarm());
|
||||
request.setData(data);
|
||||
log.info("HBY100J更新语音,参数:{}", request);
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
}else{
|
||||
FuncType12ForceAudioRequest request = new FuncType12ForceAudioRequest();
|
||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||
request.setImei(deviceObj.getDeviceImei());
|
||||
request.setFuncType("12");
|
||||
request.setTimestamp(System.currentTimeMillis());
|
||||
FuncType12ForceAudioRequest.Data data = new FuncType12ForceAudioRequest.Data();
|
||||
data.setVoiceStrobeAlarm(bo.getVoiceStrobeAlarm());
|
||||
data.setMode(bo.getMode());
|
||||
request.setData(data);
|
||||
log.info("HBY100J更新语音,参数:{}", request);
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
}
|
||||
FuncType12ForceAudioRequest request = new FuncType12ForceAudioRequest();
|
||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||
request.setImei(deviceObj.getDeviceImei());
|
||||
request.setFuncType("12");
|
||||
request.setTimestamp(System.currentTimeMillis());
|
||||
FuncType12ForceAudioRequest.Data data = new FuncType12ForceAudioRequest.Data();
|
||||
data.setVoiceStrobeAlarm(bo.getVoiceStrobeAlarm());
|
||||
data.setMode(bo.getMode());
|
||||
request.setData(data);
|
||||
log.info("HBY100J强制报警,下发设备参数:{}", request);
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
|
||||
|
||||
// recordDeviceLog(deviceId, deviceObj.getDeviceName(), "强制报警激活", "强制报警激活", loginUser.getUserId());
|
||||
@ -264,7 +281,6 @@ public class DeviceHBY100JBizService {
|
||||
}
|
||||
|
||||
public void strobeMode(AppDeviceHBY100JController.HBY100JStrobeModeDto params) {
|
||||
log.info("HBY100J爆闪模式开启/关闭,请求参数:{}", params);
|
||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||
@ -303,7 +319,6 @@ public class DeviceHBY100JBizService {
|
||||
}
|
||||
|
||||
public void strobeFrequency(AppDeviceHBY100JController.HBY100JStrobeFrequencyDto params) {
|
||||
log.info("HBY100J爆闪频率,请求参数:{}", params);
|
||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||
@ -316,12 +331,11 @@ public class DeviceHBY100JBizService {
|
||||
FuncType11FrequencyRequest.Data data = new FuncType11FrequencyRequest.Data();
|
||||
data.setFrequency(params.getFrequency());
|
||||
request.setData(data);
|
||||
log.info("HBY100J灯光调节,下发设备参数:{}", request);
|
||||
log.info("HBY100J爆闪频率,下发设备参数:{}", request);
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
}
|
||||
|
||||
public void updateVolume(AppDeviceHBY100JController.HBY100JUpdateVolumeDto params) {
|
||||
log.info("HBY100J更新音量,请求参数:{}", params);
|
||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||
@ -337,4 +351,18 @@ public class DeviceHBY100JBizService {
|
||||
log.info("HBY100J更新音量,下发设备参数:{}", JSON.toJSONString(request));
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
}
|
||||
|
||||
public void voiceBroadcast(AppDeviceHBY100JController.HBY100JVoiceBroadcastDto params) {
|
||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||
FuncType6VoicePlayRequest request = new FuncType6VoicePlayRequest();
|
||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||
request.setImei(deviceObj.getDeviceImei());
|
||||
request.setFuncType("6");
|
||||
request.setTimestamp(System.currentTimeMillis());
|
||||
FuncType6VoicePlayRequest.Data data = new FuncType6VoicePlayRequest.Data();
|
||||
data.setVoiceBroadcast(params.getVoiceBroadcast());
|
||||
request.setData(data);
|
||||
log.info("HBY100J语音播报,下发设备参数:{}", request);
|
||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user