|
@@ -13,7 +13,7 @@ import com.xy.service.DeviceChargingServiceImpl;
|
|
import com.xy.service.DeviceErrorsRecordServiceImpl;
|
|
import com.xy.service.DeviceErrorsRecordServiceImpl;
|
|
import com.xy.service.DeviceInfoServiceImpl;
|
|
import com.xy.service.DeviceInfoServiceImpl;
|
|
import com.xy.utils.SysDictUtils;
|
|
import com.xy.utils.SysDictUtils;
|
|
-import com.xy.utils.enums.DeviceErrorTypesEnum;
|
|
|
|
|
|
+import com.xy.utils.enums.DeviceErrorRecordTypesEnum;
|
|
import com.xy.utils.enums.DictEnum;
|
|
import com.xy.utils.enums.DictEnum;
|
|
import com.xy.utils.enums.DictSonEnum;
|
|
import com.xy.utils.enums.DictSonEnum;
|
|
import com.xy.work.SpiDeviceService;
|
|
import com.xy.work.SpiDeviceService;
|
|
@@ -53,20 +53,20 @@ public class SpiDeviceServiceImpl implements SpiDeviceService {
|
|
//查询设备信息
|
|
//查询设备信息
|
|
DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(deviceAlarmNotifyDTO.getTerminalId()));
|
|
DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(deviceAlarmNotifyDTO.getTerminalId()));
|
|
String faultCode = deviceAlarmNotifyDTO.getFaultCode();
|
|
String faultCode = deviceAlarmNotifyDTO.getFaultCode();
|
|
- DeviceErrorTypesEnum deviceErrorTypesEnum = faultCode.equals("DeviceOffline") ? DeviceErrorTypesEnum.DEVICE_ERROR_TYPES_1
|
|
|
|
- : faultCode.equals("DoorOpenedOnNoTrade") ? DeviceErrorTypesEnum.DEVICE_ERROR_TYPES_2
|
|
|
|
|
|
+ DeviceErrorRecordTypesEnum deviceErrorRecordTypesEnum = faultCode.equals("DeviceOffline") ? DeviceErrorRecordTypesEnum.NET
|
|
|
|
+ : faultCode.equals("DoorOpenedOnNoTrade") ? DeviceErrorRecordTypesEnum.DOOR_LOCK
|
|
: null;
|
|
: null;
|
|
- if (deviceErrorTypesEnum == null) {
|
|
|
|
|
|
+ if (deviceErrorRecordTypesEnum == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//添加设备异常记录
|
|
//添加设备异常记录
|
|
DeviceErrorsRecordDto.Save save = new DeviceErrorsRecordDto.Save()
|
|
DeviceErrorsRecordDto.Save save = new DeviceErrorsRecordDto.Save()
|
|
.setDeviceId(deviceInfo.getDeviceId());
|
|
.setDeviceId(deviceInfo.getDeviceId());
|
|
- save.setErrorType(deviceErrorTypesEnum.getKey());
|
|
|
|
- save.setErrorDescript(deviceErrorTypesEnum.getMsg());
|
|
|
|
|
|
+ save.setCode(deviceErrorRecordTypesEnum.getCode());
|
|
|
|
+ save.setErrorMsg(deviceAlarmNotifyDTO.getFaultMsg());
|
|
deviceErrorsRecordService.save(save);
|
|
deviceErrorsRecordService.save(save);
|
|
//修改设备为离线
|
|
//修改设备为离线
|
|
- if (deviceErrorTypesEnum.getKey() == DeviceErrorTypesEnum.DEVICE_ERROR_TYPES_1.getKey()) {
|
|
|
|
|
|
+ if (deviceErrorRecordTypesEnum.getCode() == DeviceErrorRecordTypesEnum.NET.getCode()) {
|
|
JSONObject jsonObject = new JSONObject().set("clientid", deviceInfo.getDeviceId());
|
|
JSONObject jsonObject = new JSONObject().set("clientid", deviceInfo.getDeviceId());
|
|
disconnectedProducer.sendToMqtt(jsonObject.toString(), DisconnectedMqttConfiguration.TOPIC, 1);
|
|
disconnectedProducer.sendToMqtt(jsonObject.toString(), DisconnectedMqttConfiguration.TOPIC, 1);
|
|
}
|
|
}
|