|
|
@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.template.model.mqtt.MqttConfiguration;
|
|
|
import com.template.model.mqtt.MqttPushClient;
|
|
|
import com.template.model.mqtt.SpringUtil;
|
|
|
-import com.template.model.pojo.*;
|
|
|
+import com.template.model.pojo.HouseLock;
|
|
|
+import com.template.model.pojo.HouseNumber;
|
|
|
+import com.template.model.pojo.UnlockingRecord;
|
|
|
import com.template.services.impl.AlarmMessageServiceImpl;
|
|
|
import com.template.services.impl.HouseLockServiceImpl;
|
|
|
import com.template.services.impl.HouseNumberServiceImpl;
|
|
|
@@ -14,7 +16,6 @@ import com.template.services.impl.UnlockingRecordServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eclipse.paho.client.mqttv3.*;
|
|
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -101,6 +102,7 @@ public class SubscribeSample{
|
|
|
// 设备消息上报
|
|
|
if ("2".equals(protocol)) {
|
|
|
UnlockingRecord unlockingRecord = new UnlockingRecord();
|
|
|
+ unlockingRecord.setType("消息类型");
|
|
|
String data = s.getString("data");
|
|
|
System.out.println("data = " + data);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
@@ -163,7 +165,9 @@ public class SubscribeSample{
|
|
|
unlockingRecordService.getSave(unlockingRecord);
|
|
|
|
|
|
} else if ("3".equals(protocol)) {
|
|
|
- AlarmMessage alarmMessage = new AlarmMessage();
|
|
|
+// AlarmMessage alarmMessage = new AlarmMessage();
|
|
|
+ UnlockingRecord alarmMessage = new UnlockingRecord();
|
|
|
+ alarmMessage.setType("预警类型");
|
|
|
String data = s.getString("data");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
|
|
|
@@ -174,7 +178,7 @@ public class SubscribeSample{
|
|
|
String messageTime = jsonObject.getString("messageTime");
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String format = sdf.format(Long.valueOf(messageTime));
|
|
|
- alarmMessage.setMessageTime(format);
|
|
|
+ alarmMessage.setDateTime(format);
|
|
|
|
|
|
// 房间luid
|
|
|
String luid = jsonObject.getString("luid");
|
|
|
@@ -189,18 +193,19 @@ public class SubscribeSample{
|
|
|
if (ObjectUtils.isNotEmpty(byId)) {
|
|
|
String roomNumber = byId.getRoomNumber();
|
|
|
alarmMessage.setRoomNumber(roomNumber);
|
|
|
+ alarmMessage.setHouseNumberId(houseNumberId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if ("5".equals(messageType)) {
|
|
|
// 低电量
|
|
|
- alarmMessage.setMessageType("低电量");
|
|
|
+ alarmMessage.setUnlockType("低电量");
|
|
|
|
|
|
} else if ("1".equals(messageType)) {
|
|
|
- alarmMessage.setMessageType("密码错误(连续失败五次)");
|
|
|
+ alarmMessage.setUnlockType("密码错误(连续失败五次)");
|
|
|
} else if ("4".equals(messageType)) {
|
|
|
- alarmMessage.setMessageType("防拆告警");
|
|
|
+ alarmMessage.setUnlockType("防拆告警");
|
|
|
}
|
|
|
|
|
|
DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -209,7 +214,7 @@ public class SubscribeSample{
|
|
|
alarmMessage.setCreateUser("1");
|
|
|
alarmMessage.setUpdateUser("1");
|
|
|
|
|
|
- alarmMessageService.getSave(alarmMessage);
|
|
|
+ unlockingRecordService.getSave(alarmMessage);
|
|
|
|
|
|
}
|
|
|
|