Browse Source

告警数据同步代码

jichaobo 2 years ago
parent
commit
f418b35973

+ 15 - 12
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/mqtt/alarm/Alarm.java

@@ -87,11 +87,14 @@ public class Alarm implements MqttStrategy {
             switch (list1.get(0).getSystemType()) {
                 case 1:
                     AlarmFire alarmFire = new AlarmFire();
+                    String deviceName = map.get("deviceName").toString();
                     alarmFire.setDeviceCode(map.get("devId").toString());
                     alarmFire.setDeviceName(map.get("deviceName").toString());
                     alarmFire.setAlarmType(OnlineMethod.getAlarmType(dp.get(0).get("property").toString(), list.get(0).getDeviceType()));
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    String timestamp1 = map.get("timeStamp").toString();
+                    if (StringUtils.isNotBlank(timestamp1)) {
+                        long timestamp = Long.valueOf(timestamp1).longValue();
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.ofHours(8));
                         alarmFire.setAlarmTime(time2);
                     }
 //                    alarmFire.setAddress();
@@ -176,8 +179,8 @@ public class Alarm implements MqttStrategy {
                     alarmSprayWater.setDeviceCode(map.get("devId").toString());
                     alarmSprayWater.setDeviceName(map.get("deviceName").toString());
                     alarmSprayWater.setAlarmType(OnlineMethod.getAlarmType(dp.get(0).get("property").toString(), list.get(0).getDeviceType()));
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    if (StringUtils.isNotBlank(map.get("timeStamp").toString())) {
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timeStamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
                         alarmSprayWater.setAlarmTime(time2);
                     }
 //                    alarmSprayWater.setAddress();
@@ -197,8 +200,8 @@ public class Alarm implements MqttStrategy {
                     alarmHydrantWater.setDeviceCode(map.get("devId").toString());
                     alarmHydrantWater.setDeviceName(map.get("deviceName").toString());
                     alarmHydrantWater.setAlarmType(OnlineMethod.getAlarmType(dp.get(0).get("property").toString(), list.get(0).getDeviceType()));
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    if (StringUtils.isNotBlank(map.get("timeStamp").toString())) {
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timeStamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
                         alarmHydrantWater.setAlarmTime(time2);
                     }
 //                    alarmHydrantWater.setAddress();
@@ -218,8 +221,8 @@ public class Alarm implements MqttStrategy {
                     alarmSmokeControl.setDeviceCode(map.get("devId").toString());
                     alarmSmokeControl.setDeviceName(map.get("deviceName").toString());
                     alarmSmokeControl.setAlarmType(OnlineMethod.getAlarmType(dp.get(0).get("property").toString(), list.get(0).getDeviceType()));
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    if (StringUtils.isNotBlank(map.get("timeStamp").toString())) {
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timeStamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
                         alarmSmokeControl.setAlarmTime(time2);
                     }
 //                    alarmSmokeControl.setAddress();
@@ -239,8 +242,8 @@ public class Alarm implements MqttStrategy {
                     alarmElectricalFire.setDeviceCode(map.get("devId").toString());
                     alarmElectricalFire.setDeviceName(map.get("deviceName").toString());
                     alarmElectricalFire.setAlarmType(OnlineMethod.getAlarmType(dp.get(0).get("property").toString(), list.get(0).getDeviceType()));
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    if (StringUtils.isNotBlank(map.get("timeStamp").toString())) {
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timeStamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
                         alarmElectricalFire.setAlarmTime(time2);
                     }
 //                    alarmElectricalFire.setAddress();
@@ -260,8 +263,8 @@ public class Alarm implements MqttStrategy {
                     alarmVideo.setDeviceCode(map.get("devId").toString());
                     alarmVideo.setDeviceName(map.get("deviceName").toString());
                     alarmVideo.setAlarmType(dp.get(0).get("property").toString());
-                    if (StringUtils.isBlank(map.get("timestamp").toString())) {
-                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timestamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
+                    if (StringUtils.isNotBlank(map.get("timeStamp").toString())) {
+                        LocalDateTime time2 = LocalDateTime.ofEpochSecond(Long.valueOf(map.get("timeStamp").toString()).longValue(), 0, ZoneOffset.ofHours(8));
                         alarmVideo.setAlarmTime(time2);
                     }
 //                    alarmVideo.setAddress();