|
@@ -68,10 +68,6 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
@ApiOperation("上报信息")
|
|
@ApiOperation("上报信息")
|
|
public R up(DeviceStatusDto.Up up) {
|
|
public R up(DeviceStatusDto.Up up) {
|
|
log.info("设备信息上报:{}", JSONUtil.toJsonStr(up));
|
|
log.info("设备信息上报:{}", JSONUtil.toJsonStr(up));
|
|
- DeviceStatus deviceStatus = getById(up.getDeviceId());
|
|
|
|
- if (deviceStatus == null) {
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_STATUS_UP, 4)
|
|
ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_STATUS_UP, 4)
|
|
.execute(() -> {
|
|
.execute(() -> {
|
|
//修改状态信息
|
|
//修改状态信息
|
|
@@ -79,15 +75,15 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
})
|
|
})
|
|
.execute(() -> {
|
|
.execute(() -> {
|
|
//上报关门
|
|
//上报关门
|
|
- if (!Emptys.check(deviceStatus.getDoorStateL())) {
|
|
|
|
|
|
+ if (!Emptys.check(up.getDoorStateL())) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Integer value = SysDictUtils.getValue(EnumDevcieDoorStatus.Code.CODE.getCode(), EnumDevcieDoorStatus.LOCKED.getCode(), Integer.class);
|
|
Integer value = SysDictUtils.getValue(EnumDevcieDoorStatus.Code.CODE.getCode(), EnumDevcieDoorStatus.LOCKED.getCode(), Integer.class);
|
|
- if (!deviceStatus.getDoorStateL().equals(value)) {
|
|
|
|
|
|
+ if (!up.getDoorStateL().equals(value)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
activityInfoService.abort(new ActivityInfoDto.Abort()
|
|
activityInfoService.abort(new ActivityInfoDto.Abort()
|
|
- .setDeviceId(deviceStatus.getDeviceId())
|
|
|
|
|
|
+ .setDeviceId(up.getDeviceId())
|
|
.setWorkType(2)
|
|
.setWorkType(2)
|
|
.setTimeout(60 * 1)
|
|
.setTimeout(60 * 1)
|
|
);
|
|
);
|
|
@@ -97,17 +93,17 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
if (!Emptys.check(up.getTempValue())) {
|
|
if (!Emptys.check(up.getTempValue())) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- DeviceSysinfo deviceSysinfo = deviceSysinfoService.getById(deviceStatus.getDeviceId());
|
|
|
|
|
|
+ DeviceSysinfo deviceSysinfo = deviceSysinfoService.getById(up.getDeviceId());
|
|
//添加设备温度日志
|
|
//添加设备温度日志
|
|
if (!deviceSysinfo.getIsHaveTemp()) {
|
|
if (!deviceSysinfo.getIsHaveTemp()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
DeviceTempRecordsDto.Save save = new DeviceTempRecordsDto.Save()
|
|
DeviceTempRecordsDto.Save save = new DeviceTempRecordsDto.Save()
|
|
- .setDeviceId(deviceStatus.getDeviceId());
|
|
|
|
|
|
+ .setDeviceId(up.getDeviceId());
|
|
save.setTempValue(up.getTempValue());
|
|
save.setTempValue(up.getTempValue());
|
|
deviceTempRecordsService.save(save);
|
|
deviceTempRecordsService.save(save);
|
|
//查询设备配置
|
|
//查询设备配置
|
|
- DeviceConfig deviceConfig = deviceConfigService.getById(deviceStatus.getDeviceId());
|
|
|
|
|
|
+ DeviceConfig deviceConfig = deviceConfigService.getById(up.getDeviceId());
|
|
int tempMax, tempMin;
|
|
int tempMax, tempMin;
|
|
if (deviceConfig == null) {
|
|
if (deviceConfig == null) {
|
|
Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumDeviceTempConfig.Code.CODE.getCode());
|
|
Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumDeviceTempConfig.Code.CODE.getCode());
|
|
@@ -118,7 +114,7 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
tempMin = deviceConfig.getTempMin();
|
|
tempMin = deviceConfig.getTempMin();
|
|
}
|
|
}
|
|
//温度有异常
|
|
//温度有异常
|
|
- String key = String.format("device_temp_error:%d", deviceStatus.getDeviceId());
|
|
|
|
|
|
+ String key = String.format("device_temp_error:%d", up.getDeviceId());
|
|
if (up.getTempValue() > tempMax || up.getTempValue() < tempMin) {
|
|
if (up.getTempValue() > tempMax || up.getTempValue() < tempMin) {
|
|
//校验异常次数
|
|
//校验异常次数
|
|
Integer errorSize = SysDictUtils.getValue(EnumDeviceTempConfig.Code.CODE.getCode(), EnumDeviceTempConfig.ERROR_SIZE.getCode(), Integer.class);
|
|
Integer errorSize = SysDictUtils.getValue(EnumDeviceTempConfig.Code.CODE.getCode(), EnumDeviceTempConfig.ERROR_SIZE.getCode(), Integer.class);
|
|
@@ -128,7 +124,7 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
//添加事件
|
|
//添加事件
|
|
String msg = "温度异常-温度阈值%d - %d,当前温度%d";
|
|
String msg = "温度异常-温度阈值%d - %d,当前温度%d";
|
|
DeviceEventMsgDto.Save deviceEventMsg = new DeviceEventMsgDto.Save()
|
|
DeviceEventMsgDto.Save deviceEventMsg = new DeviceEventMsgDto.Save()
|
|
- .setDeviceId(deviceStatus.getDeviceId());
|
|
|
|
|
|
+ .setDeviceId(up.getDeviceId());
|
|
deviceEventMsg.setCode(DeviceErrorRecordTypesEnum.T.getCode());
|
|
deviceEventMsg.setCode(DeviceErrorRecordTypesEnum.T.getCode());
|
|
deviceEventMsg.setMsg(String.format(msg, tempMin, tempMax, up.getTempValue()));
|
|
deviceEventMsg.setMsg(String.format(msg, tempMin, tempMax, up.getTempValue()));
|
|
deviceEventMsgService.save(deviceEventMsg);
|
|
deviceEventMsgService.save(deviceEventMsg);
|
|
@@ -150,7 +146,7 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
LambdaQueryWrapper<DeviceVersionUp> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceVersionUp>()
|
|
LambdaQueryWrapper<DeviceVersionUp> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceVersionUp>()
|
|
- .eq(DeviceVersionUp::getDeviceId, deviceStatus.getDeviceId())
|
|
|
|
|
|
+ .eq(DeviceVersionUp::getDeviceId, up.getDeviceId())
|
|
.ge(DeviceVersionUp::getDeviceVersion, upInfo.getVersion())
|
|
.ge(DeviceVersionUp::getDeviceVersion, upInfo.getVersion())
|
|
.eq(DeviceVersionUp::getStatus, 4)
|
|
.eq(DeviceVersionUp::getStatus, 4)
|
|
.eq(DeviceVersionUp::getProgress, 100);
|
|
.eq(DeviceVersionUp::getProgress, 100);
|
|
@@ -172,7 +168,7 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
|
|
.set(src, upInfo.getSrc());
|
|
.set(src, upInfo.getSrc());
|
|
templet.set("data", data);
|
|
templet.set("data", data);
|
|
CommandMqtt commandMqtt = new CommandMqtt()
|
|
CommandMqtt commandMqtt = new CommandMqtt()
|
|
- .setDeviceId(deviceStatus.getDeviceId())
|
|
|
|
|
|
+ .setDeviceId(up.getDeviceId())
|
|
.setTemplet(templet);
|
|
.setTemplet(templet);
|
|
mqttService.senCommand(Arrays.asList(commandMqtt));
|
|
mqttService.senCommand(Arrays.asList(commandMqtt));
|
|
});
|
|
});
|