|
@@ -36,40 +36,34 @@ public class LpHandlers {
|
|
|
* 基本信息上传
|
|
|
*/
|
|
|
public void deviceInfoHandler(String openNum, MqttDTO mqttDTO) {
|
|
|
- try {
|
|
|
- LpInfoState local = lpInfoStateService.getByOpenNum(openNum);
|
|
|
- //存储历史记录
|
|
|
- LpInfoRecord record = TransformEntity.tsf2LpInfoRecord(openNum, mqttDTO);
|
|
|
- lpInfoRecordService.save(record);
|
|
|
- //远程数据
|
|
|
- LpInfoState remote = BeanUtil.cast(record, LpInfoState.class);
|
|
|
- remote.setUpdateTime(record.getUploadTime());
|
|
|
- //若数据库中不存在设备信息直接插入
|
|
|
- if (local == null) {
|
|
|
- lpInfoStateService.save(remote);
|
|
|
- return;
|
|
|
- }
|
|
|
- setWakeAndThreshLp(openNum, local, remote);
|
|
|
- //更新数据库设备状态信息
|
|
|
- lpInfoStateService.update(remote, new QueryWrapper<LpInfoState>().eq("open_num", openNum));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("路牌上传基本信息异常", e);
|
|
|
+ //本地数据库信息
|
|
|
+ LpInfoState local = lpInfoStateService.getByOpenNum(openNum);
|
|
|
+ //接收远程设备信息
|
|
|
+ LpInfoRecord record = TransformEntity.tsf2LpInfoRecord(openNum, mqttDTO);
|
|
|
+ //存储历史记录
|
|
|
+ lpInfoRecordService.save(record);
|
|
|
+ //转换状态数据
|
|
|
+ LpInfoState remote = BeanUtil.cast(record, LpInfoState.class);
|
|
|
+ remote.setUpdateTime(record.getUploadTime());
|
|
|
+ //若数据库中不存在设备信息直接插入
|
|
|
+ if (local == null) {
|
|
|
+ lpInfoStateService.save(remote);
|
|
|
+ return;
|
|
|
}
|
|
|
+ setWakeAndThreshLp(openNum, local, remote);
|
|
|
+ //更新数据库设备状态信息
|
|
|
+ updateLpInfoStateService(openNum, remote);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 定位信息上传
|
|
|
*/
|
|
|
public void deviceLocationHandler(String openNum, MqttDTO mqttDTO) {
|
|
|
- try {
|
|
|
- LpInfoState device = TransformEntity.tsf2LpInfoState(openNum, mqttDTO);
|
|
|
- //收到定位信息,修改状态为0
|
|
|
- device.setUpdateLocationFlag(0);
|
|
|
- // 更新数据库设备状态信息
|
|
|
- lpInfoStateService.update(device, new QueryWrapper<LpInfoState>().eq("open_num", openNum));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("路牌上传位置信息异常", e);
|
|
|
- }
|
|
|
+ LpInfoState device = TransformEntity.tsf2LpInfoStateLocation(openNum, mqttDTO);
|
|
|
+ //收到定位信息,修改状态为0
|
|
|
+ device.setUpdateLocationFlag(0);
|
|
|
+ // 更新数据库设备状态信息
|
|
|
+ updateLpInfoStateService(openNum, device);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -96,4 +90,13 @@ public class LpHandlers {
|
|
|
dto.setSetf((dto.getWakeInt() != null || dto.getThresh() != null) ? Constant.STATUS.TRUE : Constant.STATUS.FALSE);
|
|
|
postMqttMsgService.setWakeAndThreshLp(dto);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新状态信息
|
|
|
+ */
|
|
|
+ private void updateLpInfoStateService(String openNum, LpInfoState lpInfoState) {
|
|
|
+ //不更新设备码字段
|
|
|
+ lpInfoState.setOpenNum(null);
|
|
|
+ lpInfoStateService.update(lpInfoState, new QueryWrapper<LpInfoState>().eq("open_num", openNum));
|
|
|
+ }
|
|
|
}
|