|
@@ -1,6 +1,9 @@
|
|
|
package org.jetlinks.pro.media.gb28181.message;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
|
|
+import com.fasterxml.jackson.annotation.JsonAnySetter;
|
|
|
+import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
|
|
import lombok.Getter;
|
|
|
import lombok.Setter;
|
|
@@ -22,33 +25,48 @@ import java.util.Optional;
|
|
|
@ToString
|
|
|
public class Alarm implements SipDeviceMessage {
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="DeviceID")
|
|
|
+ @JacksonXmlProperty(localName = "DeviceID")
|
|
|
private String deviceId;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="AlarmPriority")
|
|
|
+ @JacksonXmlProperty(localName = "AlarmPriority")
|
|
|
private String alarmPriority;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="AlarmTime")
|
|
|
+ @JacksonXmlProperty(localName = "AlarmTime")
|
|
|
private String alarmTime;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="AlarmMethod")
|
|
|
+ @JacksonXmlProperty(localName = "AlarmMethod")
|
|
|
private String alarmMethod;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="Longitude")
|
|
|
+ @JacksonXmlProperty(localName = "Longitude")
|
|
|
private Float longitude;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="Latitude")
|
|
|
+ @JacksonXmlProperty(localName = "Latitude")
|
|
|
private Float latitude;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="AlarmDescription")
|
|
|
+ @JacksonXmlProperty(localName = "AlarmDescription")
|
|
|
private String description;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="Info")
|
|
|
+ @JacksonXmlProperty(localName = "Info")
|
|
|
private Info info;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="SN")
|
|
|
+ @JacksonXmlProperty(localName = "SN")
|
|
|
private String sn;
|
|
|
|
|
|
+ @JsonIgnore
|
|
|
+ private Map<String, Object> others;
|
|
|
+
|
|
|
+ @JsonAnyGetter
|
|
|
+ public Map<String, Object> getOthers() {
|
|
|
+ return others;
|
|
|
+ }
|
|
|
+
|
|
|
+ @JsonAnySetter
|
|
|
+ public void setOther(String key, Object value) {
|
|
|
+ if (others == null) {
|
|
|
+ others = new HashMap<>();
|
|
|
+ }
|
|
|
+ others.put(key, value);
|
|
|
+ }
|
|
|
|
|
|
@Getter
|
|
|
@Setter
|
|
@@ -57,11 +75,25 @@ public class Alarm implements SipDeviceMessage {
|
|
|
@JacksonXmlProperty(localName = "AlarmType")
|
|
|
private String alarmType;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="AlarmTypeParam")
|
|
|
+ @JacksonXmlProperty(localName = "AlarmTypeParam")
|
|
|
private AlarmTypeParam alarmTypeParam;
|
|
|
|
|
|
- @JacksonXmlProperty(localName ="ImageUrl")
|
|
|
- private String imageUrl;
|
|
|
+ @JsonIgnore
|
|
|
+ private Map<String, Object> others;
|
|
|
+
|
|
|
+ @JsonAnyGetter
|
|
|
+ public Map<String, Object> getOthers() {
|
|
|
+ return others;
|
|
|
+ }
|
|
|
+
|
|
|
+ @JsonAnySetter
|
|
|
+ public void setOther(String key, Object value) {
|
|
|
+ if (others == null) {
|
|
|
+ others = new HashMap<>();
|
|
|
+ }
|
|
|
+ others.put(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public Optional<AlarmType> getAlarmTypeEnum(AlarmMethod method) {
|
|
|
return AlarmType.of(method, alarmType);
|
|
@@ -70,13 +102,11 @@ public class Alarm implements SipDeviceMessage {
|
|
|
public Optional<AlarmType> getAlarmTypeEnum(String method) {
|
|
|
return AlarmType.of(method, alarmType);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Getter
|
|
|
@Setter
|
|
|
- public static class AlarmTypeParam{
|
|
|
+ public static class AlarmTypeParam {
|
|
|
//1-进入区域;2-离开区域
|
|
|
@JacksonXmlProperty(localName = "EventType")
|
|
|
private String eventType;
|
|
@@ -97,13 +127,22 @@ public class Alarm implements SipDeviceMessage {
|
|
|
if (longitude != null && latitude != null) {
|
|
|
data.put("lonlat", new GeoPoint(longitude, latitude));
|
|
|
}
|
|
|
+
|
|
|
+ if (this.others != null) {
|
|
|
+ data.putAll(this.others);
|
|
|
+ }
|
|
|
+
|
|
|
if (info != null) {
|
|
|
info.getAlarmTypeEnum(alarmMethod)
|
|
|
.ifPresent(type -> data.put("AlarmTypeText", type.getText()));
|
|
|
data.put("AlarmType", info.alarmType);
|
|
|
data.put("AlarmTypeParam", JSON.toJSON(info.alarmTypeParam));
|
|
|
- data.put("imageUrl", info.getImageUrl());
|
|
|
+ if (info.getOthers() != null) {
|
|
|
+ data.putAll(info.getOthers());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
event.setData(data);
|
|
|
return Flux.just(event);
|
|
|
}
|