hby100japp功能3
This commit is contained in:
@ -55,6 +55,31 @@ public class AppDeviceHBY100JController extends BaseController {
|
|||||||
return R.ok();
|
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());
|
log.info("HBY100J警示灯LED亮度调节,消息负载:{}", context.getPayloadDict());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
|
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
|
||||||
// context.getDeviceImei() + ":brightness";
|
context.getDeviceImei() + ":brightness";
|
||||||
//
|
|
||||||
// Map<String, Object> payloadDict = context.getPayloadDict();
|
Map<String, Object> payloadDict = context.getPayloadDict();
|
||||||
// if (payloadDict != null) {
|
if (payloadDict != null) {
|
||||||
// RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
|
RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
|
||||||
// }
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("HBY100J警示灯LED亮度调节失败", e);
|
log.error("HBY100J警示灯LED亮度调节失败", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,5 +52,7 @@ public class FunctionType3LocationReport {
|
|||||||
*/
|
*/
|
||||||
@JsonProperty("latitude")
|
@JsonProperty("latitude")
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
|
|
||||||
|
private String address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,40 +134,71 @@ public class DeviceHBY100JBizService {
|
|||||||
// 获取电量
|
// 获取电量
|
||||||
if (StringUtils.isNotBlank(deviceStatus)) {
|
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||||
vo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
|
vo.setBatteryPercentage(jsonObject.getString("level"));
|
||||||
vo.setChargeState(jsonObject.getString("chargeState"));
|
vo.setChargeState(jsonObject.getString("charge"));
|
||||||
} else {
|
} else {
|
||||||
vo.setBatteryPercentage("0");
|
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);
|
Integer voiceBroadcast = data.getVoiceBroadcast();
|
||||||
if (StringUtils.isNotBlank(lightBrightnessStatus)) {
|
if(voiceBroadcast != null && voiceBroadcast == 1){
|
||||||
vo.setLightBrightness(lightBrightnessStatus);
|
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 locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
|
||||||
String locationInfo = RedisUtils.getCacheObject(locationKey);
|
String locationInfo = RedisUtils.getCacheObject(locationKey);
|
||||||
// if (StringUtils.isNotBlank(locationInfo)) {
|
if (StringUtils.isNotBlank(locationInfo)) {
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(locationInfo);
|
FunctionType3LocationReport locationReport = JSONObject.parseObject(locationInfo,FunctionType3LocationReport.class);
|
||||||
// vo.setLongitude(jsonObject.get("longitude").toString());
|
if(locationReport != null){
|
||||||
// vo.setLatitude(jsonObject.get("latitude").toString());
|
FunctionType3LocationReport.Data data = locationReport.getData();
|
||||||
// vo.setAddress((String) jsonObject.get("address"));
|
if(data != null){
|
||||||
// }
|
vo.setLongitude(data.getLongitude().toString());
|
||||||
|
vo.setLatitude(data.getLatitude().toString());
|
||||||
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
vo.setAddress(data.getAddress());
|
||||||
if (StringUtils.isNotBlank(alarmStatus)) {
|
}
|
||||||
vo.setVoiceStrobeAlarm(alarmStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,19 +221,6 @@ public class DeviceHBY100JBizService {
|
|||||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
// 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();
|
FuncType12ForceAudioRequest request = new FuncType12ForceAudioRequest();
|
||||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||||
request.setImei(deviceObj.getDeviceImei());
|
request.setImei(deviceObj.getDeviceImei());
|
||||||
@ -212,9 +230,8 @@ public class DeviceHBY100JBizService {
|
|||||||
data.setVoiceStrobeAlarm(bo.getVoiceStrobeAlarm());
|
data.setVoiceStrobeAlarm(bo.getVoiceStrobeAlarm());
|
||||||
data.setMode(bo.getMode());
|
data.setMode(bo.getMode());
|
||||||
request.setData(data);
|
request.setData(data);
|
||||||
log.info("HBY100J更新语音,参数:{}", request);
|
log.info("HBY100J强制报警,下发设备参数:{}", request);
|
||||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// recordDeviceLog(deviceId, deviceObj.getDeviceName(), "强制报警激活", "强制报警激活", loginUser.getUserId());
|
// recordDeviceLog(deviceId, deviceObj.getDeviceName(), "强制报警激活", "强制报警激活", loginUser.getUserId());
|
||||||
@ -264,7 +281,6 @@ public class DeviceHBY100JBizService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void strobeMode(AppDeviceHBY100JController.HBY100JStrobeModeDto params) {
|
public void strobeMode(AppDeviceHBY100JController.HBY100JStrobeModeDto params) {
|
||||||
log.info("HBY100J爆闪模式开启/关闭,请求参数:{}", params);
|
|
||||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||||
@ -303,7 +319,6 @@ public class DeviceHBY100JBizService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void strobeFrequency(AppDeviceHBY100JController.HBY100JStrobeFrequencyDto params) {
|
public void strobeFrequency(AppDeviceHBY100JController.HBY100JStrobeFrequencyDto params) {
|
||||||
log.info("HBY100J爆闪频率,请求参数:{}", params);
|
|
||||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||||
@ -316,12 +331,11 @@ public class DeviceHBY100JBizService {
|
|||||||
FuncType11FrequencyRequest.Data data = new FuncType11FrequencyRequest.Data();
|
FuncType11FrequencyRequest.Data data = new FuncType11FrequencyRequest.Data();
|
||||||
data.setFrequency(params.getFrequency());
|
data.setFrequency(params.getFrequency());
|
||||||
request.setData(data);
|
request.setData(data);
|
||||||
log.info("HBY100J灯光调节,下发设备参数:{}", request);
|
log.info("HBY100J爆闪频率,下发设备参数:{}", request);
|
||||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVolume(AppDeviceHBY100JController.HBY100JUpdateVolumeDto params) {
|
public void updateVolume(AppDeviceHBY100JController.HBY100JUpdateVolumeDto params) {
|
||||||
log.info("HBY100J更新音量,请求参数:{}", params);
|
|
||||||
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
Device deviceObj = deviceMapper.selectById(params.getDeviceId());
|
||||||
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
// if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||||
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
// throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||||
@ -337,4 +351,18 @@ public class DeviceHBY100JBizService {
|
|||||||
log.info("HBY100J更新音量,下发设备参数:{}", JSON.toJSONString(request));
|
log.info("HBY100J更新音量,下发设备参数:{}", JSON.toJSONString(request));
|
||||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class AppDeviceHBY100JDetailVo implements Serializable {
|
|||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
// 亮度
|
// 亮度
|
||||||
private String lightBrightness;
|
private Integer lightBrightness;
|
||||||
|
|
||||||
// 音量
|
// 音量
|
||||||
private Integer volume;
|
private Integer volume;
|
||||||
@ -85,20 +85,29 @@ public class AppDeviceHBY100JDetailVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String voiceResource;
|
private String voiceResource;
|
||||||
|
|
||||||
// 报警模式 0公安,1 消防,2应急,3交警,4 市政,5 铁路,6 医疗,7 部队,8 水利,9 语音
|
// 报警模式 0公安,1 消防,2应急,3交警,4 市政,5 铁路,6 医疗,7 部队,8 水利
|
||||||
private String alarmMode;
|
private Integer alarmMode;
|
||||||
|
|
||||||
// 强制报警开关: 0 关闭, 1开启
|
// 强制报警开关: 0 关闭, 1开启
|
||||||
private String voiceStrobeAlarm;
|
private Integer voiceStrobeAlarm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0 红色爆闪,1 蓝色爆闪,2 黄色爆闪,3,红色顺时针旋转爆闪,4黄色顺时针旋转爆闪,5,红蓝顺时针旋转爆闪,6 红蓝交替爆闪
|
* 0 红色爆闪,1 蓝色爆闪,2 黄色爆闪,3,红色顺时针旋转爆闪,4黄色顺时针旋转爆闪,5,红蓝顺时针旋转爆闪,6 红蓝交替爆闪
|
||||||
*/
|
*/
|
||||||
private Integer strobeMode;
|
private Integer strobeMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "enable": 0爆闪关闭, 1爆闪开启
|
||||||
|
*/
|
||||||
|
private Integer strobeEnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 爆闪频率
|
* 爆闪频率
|
||||||
*/
|
*/
|
||||||
private Integer strobeFrequency;
|
private Integer strobeFrequency;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音播报0 关闭, 1开启
|
||||||
|
*/
|
||||||
|
private Integer voiceBroadcast;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user