Browse Source

视频ai感知事件存储完善

develop
xiepufeng 1 year ago
parent
commit
cae4e3e8a1
  1. 12
      zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java
  2. 29
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

12
zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java

@ -70,6 +70,16 @@ public enum WarningSubclassEnum {
}
public static String getDecorateInfo(String code) {
return ENUM_BY_CODE.get(code).getDecorateInfo();
if (code == null) {
return "";
}
WarningSubclassEnum warningSubclassEnum = ENUM_BY_CODE.get(code);
if (warningSubclassEnum == null) {
return "";
}
return warningSubclassEnum.getDecorateInfo();
}
}

29
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -19,6 +19,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -119,8 +123,11 @@ public class DeviceMessageHandler {
String stakeMarkDescription = data.getString("stakeMarkDescription");
String title = stakeMarkDescription + WarningSubclassEnum.getDecorateInfo(warningSubclass);
// 标题
dcWarning.setWarningTitle(stakeMarkDescription + WarningSubclassEnum.getDecorateInfo(warningSubclass));
dcWarning.setWarningTitle(title);
dcWarning.setRemark(convertTimestampToString(captureTime) + " " + title);
// 影响车道
dcWarning.setLane(String.valueOf(data.getInteger("relatedLaneNo")));
@ -146,4 +153,24 @@ public class DeviceMessageHandler {
}
/**
* 将毫秒级时间戳转换为"yyyy-MM-dd HH:mm:ss"格式的字符串
*
* @param timestampInMillis 毫秒级时间戳
* @return 格式化后的日期时间字符串
*/
public static String convertTimestampToString(long timestampInMillis) {
// 转换为Instant对象
Instant instant = Instant.ofEpochMilli(timestampInMillis);
// 转换为LocalDateTime(默认时区)
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
// 创建DateTimeFormatter实例并指定输出格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化LocalDateTime对象为字符串
return localDateTime.format(formatter);
}
}

Loading…
Cancel
Save