Sfoglia il codice sorgente

添加mqtt依赖,完成10个设备类型事件agbox对接

zhaojinyu 2 giorni fa
parent
commit
3aed249482
45 ha cambiato i file con 1547 aggiunte e 7 eliminazioni
  1. 14 0
      service-sas/service-sas-biz/pom.xml
  2. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasAcquisitionEvent.java
  3. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasAlarsasEvent.java
  4. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasCollectionEvent.java
  5. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasEntranceEvent.java
  6. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasParkingEvent.java
  7. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasPatrolEvent.java
  8. 49 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasPerceptionEvent.java
  9. 51 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasRoadblockEvent.java
  10. 2 1
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasSnapEvent.java
  11. 59 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasUsbEvent.java
  12. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasPerceptionEventMapper.java
  13. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasRoadblockEventMapper.java
  14. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasUsbEventMapper.java
  15. 735 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/MqttService.java
  16. 30 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/AcquisitionEventMessage.java
  17. 37 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/AlarsasEventMessage.java
  18. 32 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/CollectionEventMessage.java
  19. 42 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/EntranceEventMessage.java
  20. 44 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/ParkingEventMessage.java
  21. 42 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/PatrolEventMessage.java
  22. 31 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/PerceptionEventMessage.java
  23. 38 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/RoadblockEventMessage.java
  24. 45 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/SnapEventMessage.java
  25. 41 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/UsbEventMessage.java
  26. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasAcquisitionEventService.java
  27. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasAlarsasEventService.java
  28. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasCollectionEventService.java
  29. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasEntranceEventService.java
  30. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasParkingEventService.java
  31. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasPatrolEventService.java
  32. 7 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasPerceptionEventService.java
  33. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasRoadblockEventService.java
  34. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasSnapEventService.java
  35. 10 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasUsbEventService.java
  36. 11 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasAcquisitionEventServiceImpl.java
  37. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasAlarsasEventServiceImpl.java
  38. 11 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasCollectionEventServiceImpl.java
  39. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasEntranceEventServiceImpl.java
  40. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasParkingEventServiceImpl.java
  41. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasPatrolEventServiceImpl.java
  42. 11 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasPerceptionEventServiceImpl.java
  43. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasRoadblockEventServiceImpl.java
  44. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasSnapEventServiceImpl.java
  45. 14 0
      service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasUsbEventServiceImpl.java

+ 14 - 0
service-sas/service-sas-biz/pom.xml

@@ -50,6 +50,20 @@
             <version>4.1.0</version>
         </dependency>
 
+        <!-- MQTT -->
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.5</version>
+        </dependency>
+
+        <!-- 工具类 -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.20</version>
+        </dependency>
+
         <dependency>
             <groupId>com.usky</groupId>
             <artifactId>ruoyi-common-swagger</artifactId>

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasAcquisitionEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -19,7 +20,7 @@ public class SasAcquisitionEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasAlarsasEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +19,7 @@ public class SasAlarsasEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasCollectionEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -19,7 +20,7 @@ public class SasCollectionEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasEntranceEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +19,7 @@ public class SasEntranceEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasParkingEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +19,7 @@ public class SasParkingEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasPatrolEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +19,7 @@ public class SasPatrolEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 49 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasPerceptionEvent.java

@@ -0,0 +1,49 @@
+package com.usky.sas.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 状态感知探测事件表
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("sas_perception_event")
+public class SasPerceptionEvent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "event_id", type = IdType.INPUT)
+    private String eventId;
+
+    private String deviceId;
+
+    private Integer channel;
+
+    private LocalDateTime triggerTime;
+
+    private Integer eventCode;
+
+    private String note;
+
+    private String picId;
+
+    private String gisId;
+
+    private String relPerson;
+
+    private String dealPerson;
+
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+
+    private Integer eventSystem;
+
+}

+ 51 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasRoadblockEvent.java

@@ -0,0 +1,51 @@
+package com.usky.sas.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 阻车路障探测事件表
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("sas_roadblock_event")
+public class SasRoadblockEvent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 手动指定ID,与其他事件保持一致
+    @TableId(value = "event_id", type = IdType.INPUT)
+    private String eventId;
+
+    private String deviceId;
+
+    private Integer channel;
+
+    private LocalDateTime triggerTime;
+
+    private Integer eventCode;
+
+    private String note;
+
+    private String picId;
+
+    private String scenePic;
+
+    private BigDecimal val;
+
+    private String gisId;
+
+    private BigDecimal total;
+
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+
+}

+ 2 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasSnapEvent.java

@@ -1,5 +1,6 @@
 package com.usky.sas.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +19,7 @@ public class SasSnapEvent implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "event_id")
+    @TableId(value = "event_id", type = IdType.INPUT)
     private String eventId;
 
     private String deviceId;

+ 59 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasUsbEvent.java

@@ -0,0 +1,59 @@
+package com.usky.sas.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * USB防插拔事件表
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("sas_usb_event")
+public class SasUsbEvent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 关键修改:指定 IdType 为 INPUT(手动输入)
+    @TableId(value = "event_id", type = IdType.INPUT)
+    private String eventId;
+
+    private String deviceId;
+
+    private Integer channel;
+
+    private Integer certifiedType;
+
+    private String certifiedNo;
+
+    private String name;
+
+    private String phone;
+
+    private LocalDateTime triggerTime;
+
+    private Integer eventCode;
+
+    private Integer certifiedTypeCode;
+
+    private String cardId;
+
+    private String visit;
+
+    private String houseCode;
+
+    private Integer similarity;
+
+    private String note;
+
+    private String picId;
+
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasPerceptionEventMapper.java

@@ -0,0 +1,7 @@
+package com.usky.sas.mapper;
+
+import com.usky.common.mybatis.core.CrudMapper;
+import com.usky.sas.domain.SasPerceptionEvent;
+
+public interface SasPerceptionEventMapper extends CrudMapper<SasPerceptionEvent> {
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasRoadblockEventMapper.java

@@ -0,0 +1,7 @@
+package com.usky.sas.mapper;
+
+import com.usky.common.mybatis.core.CrudMapper;
+import com.usky.sas.domain.SasRoadblockEvent;
+
+public interface SasRoadblockEventMapper extends CrudMapper<SasRoadblockEvent> {
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasUsbEventMapper.java

@@ -0,0 +1,7 @@
+package com.usky.sas.mapper;
+
+import com.usky.common.mybatis.core.CrudMapper;
+import com.usky.sas.domain.SasUsbEvent;
+
+public interface SasUsbEventMapper extends CrudMapper<SasUsbEvent> {
+}

+ 735 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/MqttService.java

@@ -0,0 +1,735 @@
+package com.usky.sas.mqtt;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.IdUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.usky.sas.domain.*;
+import com.usky.sas.mqtt.dto.*;
+import com.usky.sas.service.*;
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.List;
+
+@Slf4j
+@Service
+public class MqttService {
+
+    @Value("${mqtt.host:localhost}")
+    private String host;
+
+    @Value("${mqtt.port:1883}")
+    private int port;
+
+    @Value("${mqtt.client-id:sas-client-${random.uuid}}")
+    private String clientId;
+
+    @Value("${mqtt.username:}")
+    private String username;
+
+    @Value("${mqtt.password:}")
+    private String password;
+
+    // 修改为 String 类型,逗号分隔
+    @Value("${mqtt.topics:}")
+    private String topics;
+
+    private MqttClient client;
+    private final ObjectMapper mapper = new ObjectMapper();
+    private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    @Autowired
+    private SasUsbEventService usbEventService;
+
+    @Autowired
+    private SasSnapEventService snapEventService;
+
+    @Autowired
+    private SasEntranceEventService entranceEventService;
+
+    @Autowired
+    private SasParkingEventService parkingEventService;
+
+    @Autowired
+    private SasRoadblockEventService roadblockEventService;
+
+    @Autowired
+    private SasAlarsasEventService alarsasEventService;
+
+    @Autowired
+    private SasPatrolEventService patrolEventService;
+
+    @Autowired
+    private SasAcquisitionEventService acquisitionEventService;
+
+    @Autowired
+    private SasPerceptionEventService perceptionEventService;
+
+    @Autowired
+    private SasCollectionEventService collectionEventService;
+
+    /**
+     * 初始化MQTT连接
+     */
+    @PostConstruct
+    public void init() {
+        try {
+            String brokerUrl = "tcp://" + host + ":" + port;
+            client = new MqttClient(brokerUrl, clientId);
+
+            MqttConnectOptions options = new MqttConnectOptions();
+            options.setCleanSession(true);
+            if (!username.isEmpty()) {
+                options.setUserName(username);
+                options.setPassword(password.toCharArray());
+            }
+            options.setConnectionTimeout(60);
+            options.setKeepAliveInterval(60);
+            options.setAutomaticReconnect(true);
+
+            // 设置回调
+            client.setCallback(new MqttCallbackExtended() {
+                @Override
+                public void connectComplete(boolean reconnect, String serverURI) {
+                    log.info("MQTT连接成功, reconnect={}", reconnect);
+                    // 解析并订阅所有主题
+                    parseTopics().forEach(MqttService.this::subscribe);
+                }
+
+                @Override
+                public void connectionLost(Throwable cause) {
+                    log.error("MQTT连接丢失: {}", cause.getMessage());
+                }
+
+                @Override
+                public void messageArrived(String topic, MqttMessage message) throws Exception {
+                    processMessage(topic, message);
+                }
+
+                @Override
+                public void deliveryComplete(IMqttDeliveryToken token) {
+                }
+            });
+
+            client.connect(options);
+            log.info("MQTT客户端初始化完成, clientId={}", clientId);
+
+        } catch (MqttException e) {
+            log.error("MQTT初始化失败: {}", e.getMessage(), e);
+        }
+    }
+
+
+    /**
+     * 解析逗号分隔的主题
+     */
+    private List<String> parseTopics() {
+        return Arrays.asList(topics.split(","));
+    }
+
+    /**
+     * 消息处理分发
+     */
+    private void processMessage(String topic, MqttMessage message) {
+        String payload = new String(message.getPayload());
+        log.info("收到MQTT消息, topic={}, payload={}", topic, payload);
+
+        try {
+            // USB事件
+            if (topic.contains("event/usbalarm")) {
+                handleUsbEvent(payload, topic);
+            }
+            // 抓拍事件
+            else if (topic.contains("event/snap")) {
+                handleSnapEvent(payload, topic);
+            }
+
+            // 出入门禁事件
+            else if (topic.contains("event/entrance")) {
+                handleEntranceEvent(payload, topic);
+            }
+
+            // 停车场车牌抓拍事件
+            else if (topic.contains("event/parking")) {
+                handleParkingEvent(payload, topic);
+            }
+
+            // 阻车路障探测事件
+            else if (topic.contains("event/roadblock")) {
+                handleRoadblockEvent(payload, topic);
+            }
+
+            // 入侵紧急报警事件
+            else if (topic.contains("event/alarm")) {
+                handleAlarsasEvent(payload, topic);
+            }
+
+            // 实时电子巡检事件
+            else if (topic.contains("event/patrol")) {
+                handlePatrolEvent(payload, topic);
+            }
+
+            // 数据采集事件
+            else if (topic.contains("event/acquisition")) {
+                handleAcquisitionEvent(payload, topic);
+            }
+            // 状态感知事件
+            else if (topic.contains("event/perception")) {
+                handlePerceptionEvent(payload, topic);
+            }
+            // 状态采集事件
+            else if (topic.contains("event/collection")) {
+                handleCollectionEvent(payload, topic);
+            }
+
+        } catch (Exception e) {
+            log.error("处理MQTT消息失败, topic={}", topic, e);
+        }
+    }
+
+    /**
+     * 处理USB事件(修复版:确保eventId正确设置)
+     */
+    private void handleUsbEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                UsbEventMessage message = mapper.readValue(payload, UsbEventMessage.class);
+
+                // 关键修复:先创建实体,先生成ID,再复制其他属性
+                SasUsbEvent event = new SasUsbEvent();
+
+                // 步骤1:先生成并设置 eventId(必须在copyProperties之前)
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志:确认eventId已设置
+                log.debug("生成的eventId: {}", eventId);
+                log.debug("设置后event.getEventId(): {}", event.getEventId());
+
+                // 步骤2:复制其他属性,但忽略eventId字段(防止被null覆盖)
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 步骤3:设置其他特殊字段映射
+                event.setCardId(message.getIcId());
+                event.setTriggerTime(parseTime(message.getTriggerTime()));
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存USB事件: eventId={}, deviceId={}, eventCode={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode());
+
+                // 保存到数据库
+                usbEventService.save(event);
+                log.info("USB事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理USB事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理抓拍事件
+     */
+    private void handleSnapEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                SnapEventMessage message = mapper.readValue(payload, SnapEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasSnapEvent event = new SasSnapEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的抓拍事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("抓拍事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存抓拍事件: eventId={}, deviceId={}, eventCode={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode());
+
+                // 保存到数据库
+                snapEventService.save(event);
+                log.info("抓拍事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到抓拍设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理抓拍事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理出入门禁事件
+     */
+    private void handleEntranceEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                EntranceEventMessage message = mapper.readValue(payload, EntranceEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasEntranceEvent event = new SasEntranceEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的门禁事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setCardId(message.getIcId());  // icId映射为cardId(与USB事件一致)
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("门禁事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存门禁事件: eventId={}, deviceId={}, eventCode={}, name={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode(), event.getName());
+
+                // 保存到数据库
+                entranceEventService.save(event);
+                log.info("门禁事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到门禁设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理门禁事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理停车场车牌抓拍事件
+     */
+    private void handleParkingEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                ParkingEventMessage message = mapper.readValue(payload, ParkingEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasParkingEvent event = new SasParkingEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的停车场事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("停车场事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存停车场事件: eventId={}, deviceId={}, plateNo={}, accessType={}",
+                        event.getEventId(), event.getDeviceId(), event.getPlateNo(), event.getAccessType());
+
+                // 保存到数据库
+                parkingEventService.save(event);
+                log.info("停车场事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到停车场设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理停车场事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理阻车路障探测事件
+     */
+    private void handleRoadblockEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                RoadblockEventMessage message = mapper.readValue(payload, RoadblockEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasRoadblockEvent event = new SasRoadblockEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的阻车路障事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("阻车路障事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存阻车路障事件: eventId={}, deviceId={}, eventCode={}, val={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode(), event.getVal());
+
+                // 保存到数据库
+                roadblockEventService.save(event);
+                log.info("阻车路障事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到阻车路障设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理阻车路障事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理入侵紧急报警事件
+     */
+    private void handleAlarsasEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                AlarsasEventMessage message = mapper.readValue(payload, AlarsasEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasAlarsasEvent event = new SasAlarsasEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的入侵报警事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("入侵报警事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存入侵报警事件: eventId={}, deviceId={}, eventCode={}, relPerson={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode(), event.getRelPerson());
+
+                // 保存到数据库
+                alarsasEventService.save(event);
+                log.info("入侵报警事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到入侵报警设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理入侵报警事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理实时电子巡检事件
+     */
+    private void handlePatrolEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                PatrolEventMessage message = mapper.readValue(payload, PatrolEventMessage.class);
+
+                // 1. 创建实体并生成唯一eventId(防止被覆盖)
+                SasPatrolEvent event = new SasPatrolEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 调试日志
+                log.debug("生成的巡检事件eventId: {}", eventId);
+
+                // 2. 复制属性,忽略eventId字段
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 3. 特殊字段映射和转换
+                event.setTriggerTime(parseTime(message.getTriggerTime()));  // 时间字符串转LocalDateTime
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 最终检查:确保eventId不为null
+                if (event.getEventId() == null) {
+                    log.error("巡检事件eventId为null,重新生成");
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 调试日志:保存前的最终状态
+                log.info("保存巡检事件: eventId={}, deviceId={}, eventCode={}, name={}",
+                        event.getEventId(), event.getDeviceId(), event.getEventCode(), event.getName());
+
+                // 保存到数据库
+                patrolEventService.save(event);
+                log.info("巡检事件保存成功, eventId={}", event.getEventId());
+            }
+            else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到巡检设备心跳, deviceId={}", deviceId);
+            }
+
+        } catch (Exception e) {
+            log.error("处理巡检事件失败: {}", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 处理数据采集设备事件
+     */
+    private void handleAcquisitionEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                AcquisitionEventMessage message = mapper.readValue(payload, AcquisitionEventMessage.class);
+
+                // 生成eventId并创建实体
+                SasAcquisitionEvent event = new SasAcquisitionEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 复制属性(忽略eventId)
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 时间转换和通用字段设置
+                event.setTriggerTime(parseTime(message.getTriggerTime()));
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 兜底检查
+                if (event.getEventId() == null) {
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 保存数据
+                acquisitionEventService.save(event);
+                log.info("数据采集事件保存成功, eventId={}, deviceId={}", event.getEventId(), event.getDeviceId());
+            } else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到数据采集设备心跳, deviceId={}", deviceId);
+            }
+        } catch (Exception e) {
+            log.error("处理数据采集事件失败", e);
+        }
+    }
+
+    /**
+     * 处理状态感知探测事件
+     */
+    private void handlePerceptionEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                PerceptionEventMessage message = mapper.readValue(payload, PerceptionEventMessage.class);
+
+                // 生成eventId并创建实体
+                SasPerceptionEvent event = new SasPerceptionEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 复制属性(忽略eventId)
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 时间转换和通用字段设置
+                event.setTriggerTime(parseTime(message.getTriggerTime()));
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 兜底检查
+                if (event.getEventId() == null) {
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 保存数据
+                perceptionEventService.save(event);
+                log.info("状态感知事件保存成功, eventId={}, deviceId={}", event.getEventId(), event.getDeviceId());
+            } else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到状态感知设备心跳, deviceId={}", deviceId);
+            }
+        } catch (Exception e) {
+            log.error("处理状态感知事件失败", e);
+        }
+    }
+
+    /**
+     * 处理状态采集探测事件
+     */
+    private void handleCollectionEvent(String payload, String topic) {
+        try {
+            JsonNode root = mapper.readTree(payload);
+            String method = root.path("method").asText();
+
+            if ("event".equals(method)) {
+                CollectionEventMessage message = mapper.readValue(payload, CollectionEventMessage.class);
+
+                // 生成eventId并创建实体
+                SasCollectionEvent event = new SasCollectionEvent();
+                String eventId = IdUtil.randomUUID();
+                event.setEventId(eventId);
+
+                // 复制属性(忽略eventId)
+                BeanUtil.copyProperties(message, event, "eventId");
+
+                // 时间转换和通用字段设置
+                event.setTriggerTime(parseTime(message.getTriggerTime()));
+                event.setCreateTime(LocalDateTime.now());
+                event.setUpdateTime(LocalDateTime.now());
+
+                // 兜底检查
+                if (event.getEventId() == null) {
+                    event.setEventId(IdUtil.randomUUID());
+                }
+
+                // 保存数据
+                collectionEventService.save(event);
+                log.info("状态采集事件保存成功, eventId={}, deviceId={}", event.getEventId(), event.getDeviceId());
+            } else if ("heart".equals(method)) {
+                String deviceId = extractDeviceId(topic);
+                log.info("收到状态采集设备心跳, deviceId={}", deviceId);
+            }
+        } catch (Exception e) {
+            log.error("处理状态采集事件失败", e);
+        }
+    }
+
+    /**
+     * 从主题提取设备ID
+     */
+    private String extractDeviceId(String topic) {
+        String[] parts = topic.split("/");
+        return parts.length > 0 ? parts[parts.length - 1] : "unknown";
+    }
+
+    /**
+     * 解析时间字符串
+     */
+    private LocalDateTime parseTime(String timeStr) {
+        if (timeStr == null || timeStr.isEmpty()) {
+            return LocalDateTime.now();
+        }
+        try {
+            return LocalDateTime.parse(timeStr, formatter);
+        } catch (Exception e) {
+            log.warn("时间解析失败: {}, 使用当前时间", timeStr);
+            return LocalDateTime.now();
+        }
+    }
+
+    /**
+     * 订阅主题
+     */
+    public void subscribe(String topic) {
+        try {
+            if (client != null && client.isConnected()) {
+                client.subscribe(topic);
+                log.info("订阅主题成功: {}", topic);
+            }
+        } catch (MqttException e) {
+            log.error("订阅主题失败: {}", topic, e);
+        }
+    }
+
+    /**
+     * 断开连接
+     */
+    @PreDestroy
+    public void disconnect() {
+        try {
+            if (client != null && client.isConnected()) {
+                client.disconnect();
+                log.info("MQTT连接已断开");
+            }
+        } catch (MqttException e) {
+            log.error("断开MQTT连接失败", e);
+        }
+    }
+}

+ 30 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/AcquisitionEventMessage.java

@@ -0,0 +1,30 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+/**
+ * 数据采集设备事件消息DTO
+ */
+@Data
+public class AcquisitionEventMessage {
+
+    private String method;          // "event" 或 "heart"
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式时间
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String gisId;
+    private BigDecimal total;
+
+    // 图片信息
+    private PicInfo acquisitionPic;
+
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 37 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/AlarsasEventMessage.java

@@ -0,0 +1,37 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 入侵紧急报警事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class AlarsasEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // 入侵报警事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String gisId;
+    private String relPerson;
+    private String dealPerson;
+    private Integer eventSystem;
+
+    // 图片信息(如果有)
+    private PicInfo alarmPic;
+
+    /**
+     * 图片信息内部类(复用已有结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 32 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/CollectionEventMessage.java

@@ -0,0 +1,32 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+/**
+ * 状态采集探测事件消息DTO
+ */
+@Data
+public class CollectionEventMessage {
+
+    private String method;          // "event" 或 "heart"
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式时间
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String scenePicId;
+    private BigDecimal val;
+    private String gisId;
+    private BigDecimal total;
+
+    // 图片信息
+    private PicInfo collectionPic;
+
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 42 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/EntranceEventMessage.java

@@ -0,0 +1,42 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 出入门禁事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class EntranceEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // 门禁事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private Integer certifiedType;
+    private String certifiedNo;
+    private String name;
+    private String phone;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private Integer certifiedTypeCode;
+    private String icId;            // 卡号(对应cardId,与USB事件保持一致)
+    private String visit;
+    private String houseCode;
+    private Integer similarity;
+    private String note;
+    private String picId;
+
+    // 图片信息(如果有)
+    private PicInfo entrancePic;
+
+    /**
+     * 图片信息内部类(复用已有结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 44 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/ParkingEventMessage.java

@@ -0,0 +1,44 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 停车场车牌抓拍事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class ParkingEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // 停车场事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private String note;
+    private String platePicId;
+    private String eventPicId;
+    private String gisId;
+    private Integer eventSystem;
+    private String entranceCode;
+    private String plateNo;
+    private Integer plateType;
+    private String plateColor;
+    private Integer carType;
+    private Integer accessType;
+    private Integer carTypeCode;
+    private Integer similarity;
+
+    // 图片信息(如果有)
+    private PicInfo platePic;
+
+    /**
+     * 图片信息内部类(复用已有结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 42 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/PatrolEventMessage.java

@@ -0,0 +1,42 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 实时电子巡检事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class PatrolEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // 巡检事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String gisId;
+    private String relPerson;
+    private String dealPerson;
+    private Integer eventSystem;
+    private String name;
+    private Integer credentialType;
+    private String credentialNo;
+    private String userParasasId;
+    private String typeName;
+
+    // 图片信息(如果有)
+    private PicInfo patrolPic;
+
+    /**
+     * 图片信息内部类(复用已有结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 31 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/PerceptionEventMessage.java

@@ -0,0 +1,31 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 状态感知探测事件消息DTO
+ */
+@Data
+public class PerceptionEventMessage {
+
+    private String method;          // "event" 或 "heart"
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式时间
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String gisId;
+    private String relPerson;
+    private String dealPerson;
+    private Integer eventSystem;
+
+    // 图片信息
+    private PicInfo perceptionPic;
+
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 38 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/RoadblockEventMessage.java

@@ -0,0 +1,38 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+/**
+ * 阻车路障探测事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class RoadblockEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // 阻车路障事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private String note;
+    private String picId;
+    private String scenePic;
+    private BigDecimal val;         // 状态值
+    private String gisId;
+    private BigDecimal total;       // 抄表数
+
+    // 图片信息(如果有)
+    private PicInfo roadblockPic;
+
+    /**
+     * 图片信息内部类(复用已有结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 45 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/SnapEventMessage.java

@@ -0,0 +1,45 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * 抓拍事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class SnapEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或其他
+
+    // 抓拍事件特有字段(与数据表字段对应)
+    private String deviceId;
+    private Integer channel;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private String note;
+    private String scenePicId;
+    private String eventPicId;
+    private String gisId;
+    private String relPerson;
+    private String dealPerson;
+    private Integer eventSystem;
+    private Integer similarity;
+    private Integer notify;
+    private String feature;
+    private Integer scene;
+    private String personCode;
+    private String prepersonId;
+    private Integer count;
+
+    // 图片信息(如果有)
+    private PicInfo snapPic;
+
+    /**
+     * 图片信息内部类(复用USB事件的结构)
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 41 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/mqtt/dto/UsbEventMessage.java

@@ -0,0 +1,41 @@
+package com.usky.sas.mqtt.dto;
+
+import lombok.Data;
+
+/**
+ * USB事件消息DTO(对应MQTT报文结构)
+ */
+@Data
+public class UsbEventMessage {
+
+    // MQTT消息基础字段
+    private String method;          // "event" 或 "heart"
+
+    // USB事件特有字段(根据实际MQTT报文调整)
+    private String deviceId;
+    private Integer channel;
+    private Integer certifiedType;
+    private String certifiedNo;
+    private String name;
+    private String phone;
+    private String triggerTime;     // 字符串格式,需要转换
+    private Integer eventCode;
+    private Integer certifiedTypeCode;
+    private String icId;            // 卡号(参考代码中映射为cardId)
+    private String visit;
+    private String houseCode;
+    private Integer similarity;
+    private String note;
+
+    // 图片信息(如果有)
+    private PicInfo eventPic;
+
+    /**
+     * 图片信息内部类
+     */
+    @Data
+    public static class PicInfo {
+        private String url;
+        private String path;
+    }
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasAcquisitionEventService.java

@@ -0,0 +1,7 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasAcquisitionEvent;
+
+public interface SasAcquisitionEventService extends CrudService<SasAcquisitionEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasAlarsasEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasAlarsasEvent;
+
+/**
+ * 入侵紧急报警事件服务接口
+ */
+public interface SasAlarsasEventService extends CrudService<SasAlarsasEvent> {
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasCollectionEventService.java

@@ -0,0 +1,7 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasCollectionEvent;
+
+public interface SasCollectionEventService extends CrudService<SasCollectionEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasEntranceEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasEntranceEvent;
+
+/**
+ * 出入门禁事件服务接口
+ */
+public interface SasEntranceEventService extends CrudService<SasEntranceEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasParkingEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasParkingEvent;
+
+/**
+ * 停车场车牌抓拍事件服务接口
+ */
+public interface SasParkingEventService extends CrudService<SasParkingEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasPatrolEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasPatrolEvent;
+
+/**
+ * 实时电子巡检事件服务接口
+ */
+public interface SasPatrolEventService extends CrudService<SasPatrolEvent> {
+}

+ 7 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasPerceptionEventService.java

@@ -0,0 +1,7 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasPerceptionEvent;
+
+public interface SasPerceptionEventService extends CrudService<SasPerceptionEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasRoadblockEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasRoadblockEvent;
+
+/**
+ * 阻车路障探测事件服务接口
+ */
+public interface SasRoadblockEventService extends CrudService<SasRoadblockEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasSnapEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasSnapEvent;
+
+/**
+ * 抓拍事件服务接口
+ */
+public interface SasSnapEventService extends CrudService<SasSnapEvent> {
+}

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasUsbEventService.java

@@ -0,0 +1,10 @@
+package com.usky.sas.service;
+
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.sas.domain.SasUsbEvent;
+
+/**
+ * USB事件服务接口
+ */
+public interface SasUsbEventService extends CrudService<SasUsbEvent> {
+}

+ 11 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasAcquisitionEventServiceImpl.java

@@ -0,0 +1,11 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasAcquisitionEvent;
+import com.usky.sas.mapper.SasAcquisitionEventMapper;
+import com.usky.sas.service.SasAcquisitionEventService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SasAcquisitionEventServiceImpl extends AbstractCrudService<SasAcquisitionEventMapper, SasAcquisitionEvent> implements SasAcquisitionEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasAlarsasEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasAlarsasEvent;
+import com.usky.sas.mapper.SasAlarsasEventMapper;
+import com.usky.sas.service.SasAlarsasEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 入侵紧急报警事件服务实现
+ */
+@Service
+public class SasAlarsasEventServiceImpl extends AbstractCrudService<SasAlarsasEventMapper, SasAlarsasEvent> implements SasAlarsasEventService {
+}

+ 11 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasCollectionEventServiceImpl.java

@@ -0,0 +1,11 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasCollectionEvent;
+import com.usky.sas.mapper.SasCollectionEventMapper;
+import com.usky.sas.service.SasCollectionEventService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SasCollectionEventServiceImpl extends AbstractCrudService<SasCollectionEventMapper, SasCollectionEvent> implements SasCollectionEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasEntranceEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasEntranceEvent;
+import com.usky.sas.mapper.SasEntranceEventMapper;
+import com.usky.sas.service.SasEntranceEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 出入门禁事件服务实现
+ */
+@Service
+public class SasEntranceEventServiceImpl extends AbstractCrudService<SasEntranceEventMapper, SasEntranceEvent> implements SasEntranceEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasParkingEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasParkingEvent;
+import com.usky.sas.mapper.SasParkingEventMapper;
+import com.usky.sas.service.SasParkingEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 停车场车牌抓拍事件服务实现
+ */
+@Service
+public class SasParkingEventServiceImpl extends AbstractCrudService<SasParkingEventMapper, SasParkingEvent> implements SasParkingEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasPatrolEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasPatrolEvent;
+import com.usky.sas.mapper.SasPatrolEventMapper;
+import com.usky.sas.service.SasPatrolEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 实时电子巡检事件服务实现
+ */
+@Service
+public class SasPatrolEventServiceImpl extends AbstractCrudService<SasPatrolEventMapper, SasPatrolEvent> implements SasPatrolEventService {
+}

+ 11 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasPerceptionEventServiceImpl.java

@@ -0,0 +1,11 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasPerceptionEvent;
+import com.usky.sas.mapper.SasPerceptionEventMapper;
+import com.usky.sas.service.SasPerceptionEventService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SasPerceptionEventServiceImpl extends AbstractCrudService<SasPerceptionEventMapper, SasPerceptionEvent> implements SasPerceptionEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasRoadblockEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasRoadblockEvent;
+import com.usky.sas.mapper.SasRoadblockEventMapper;
+import com.usky.sas.service.SasRoadblockEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 阻车路障探测事件服务实现
+ */
+@Service
+public class SasRoadblockEventServiceImpl extends AbstractCrudService<SasRoadblockEventMapper, SasRoadblockEvent> implements SasRoadblockEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasSnapEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasSnapEvent;
+import com.usky.sas.mapper.SasSnapEventMapper;
+import com.usky.sas.service.SasSnapEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 抓拍事件服务实现
+ */
+@Service
+public class SasSnapEventServiceImpl extends AbstractCrudService<SasSnapEventMapper, SasSnapEvent> implements SasSnapEventService {
+}

+ 14 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasUsbEventServiceImpl.java

@@ -0,0 +1,14 @@
+package com.usky.sas.service.impl;
+
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.sas.domain.SasUsbEvent;
+import com.usky.sas.mapper.SasUsbEventMapper;
+import com.usky.sas.service.SasUsbEventService;
+import org.springframework.stereotype.Service;
+
+/**
+ * USB事件服务实现
+ */
+@Service
+public class SasUsbEventServiceImpl extends AbstractCrudService<SasUsbEventMapper, SasUsbEvent> implements SasUsbEventService {
+}