@ -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 . g etCacheObject ( 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 . s etAddress ( 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 ) ) ;
}
}