|
@@ -1,13 +1,13 @@
|
|
|
package com.huashe.park.application.engine.impl;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
-import com.huashe.park.core.redis.RedisProxy;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.locationtech.jts.geom.Polygon;
|
|
|
import org.slf4j.Logger;
|
|
@@ -19,14 +19,16 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.JSONPath;
|
|
|
import com.huashe.park.application.engine.EvtFusionEngine;
|
|
|
import com.huashe.park.application.engine.LocationInfo;
|
|
|
import com.huashe.park.application.web.core.config.MqttCfg;
|
|
|
+import com.huashe.park.common.DateTimeUtil;
|
|
|
import com.huashe.park.common.consts.BDConst;
|
|
|
-import com.huashe.park.common.consts.enums.FenceType;
|
|
|
import com.huashe.park.common.geo.GeoUtils;
|
|
|
-import com.huashe.park.core.service.IBdFenceInfoService;
|
|
|
-import com.huashe.park.domain.entity.BdFenceInfo;
|
|
|
+import com.huashe.park.core.redis.RedisProxy;
|
|
|
+import com.huashe.park.core.service.IBdCameraInfoService;
|
|
|
+import com.huashe.park.domain.dto.VideoFence;
|
|
|
import com.huashe.park.infrastructure.socket.server.UwbVideoTraceSocketServer;
|
|
|
|
|
|
import cn.hutool.core.lang.UUID;
|
|
@@ -40,7 +42,7 @@ public class VideoTrailEngine extends EvtFusionEngine {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(VideoTrailEngine.class);
|
|
|
|
|
|
@Autowired
|
|
|
- private IBdFenceInfoService fenceInfoService;
|
|
|
+ private IBdCameraInfoService cameraInfoService;
|
|
|
|
|
|
@Resource
|
|
|
private RedisProxy redisService;
|
|
@@ -58,11 +60,7 @@ public class VideoTrailEngine extends EvtFusionEngine {
|
|
|
super.init();
|
|
|
this.setEngineName("视频跟随");
|
|
|
if (!redisService.hasKey(BDConst.REDIS_KEY.FENCE_VIDEO_TRACE)) {
|
|
|
- List<BdFenceInfo> bdFenceInfos = fenceInfoService.selectBdFenceInfoList(new BdFenceInfo() {
|
|
|
- {
|
|
|
- setFenceType(FenceType.VIDEO_FENCE_IN.getCode());
|
|
|
- }
|
|
|
- });
|
|
|
+ List<VideoFence> bdFenceInfos = cameraInfoService.selectBdCameraFence();
|
|
|
if (CollectionUtils.isEmpty(bdFenceInfos)) {
|
|
|
return;
|
|
|
}
|
|
@@ -98,7 +96,8 @@ public class VideoTrailEngine extends EvtFusionEngine {
|
|
|
*/
|
|
|
@Override
|
|
|
public String getKey(LocationInfo msg) {
|
|
|
- return BDConst.REDIS_KEY.FENCE_VIDEO_TRACE_KEY + msg.getMsg().getString("deviceId");
|
|
|
+ return String.format("%s-%s-%s", BDConst.REDIS_KEY.FENCE_VIDEO_TRACE_KEY, msg.getMsg().getString("tagId"),
|
|
|
+ msg.getMsg().getString("fenceId"));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -108,24 +107,36 @@ public class VideoTrailEngine extends EvtFusionEngine {
|
|
|
|
|
|
@Override
|
|
|
public void newEvtCallback(LocationInfo msg) {
|
|
|
- videoTraceSocketServer.sendMessage(msg.getMsg().getString("deviceId"), JSONObject.from(msg));
|
|
|
+ videoTraceSocketServer.sendMessage(msg.getMsg().getString("tagId"), JSONObject.from(msg));
|
|
|
}
|
|
|
|
|
|
- public void generateEvt(JSONObject msg, byte[] payload) {
|
|
|
- List<BdFenceInfo> cacheList = redisService.getCacheList(BDConst.REDIS_KEY.FENCE_VIDEO_TRACE);
|
|
|
+ public void trailTag(JSONObject msg) {
|
|
|
+ List<VideoFence> cacheList = redisService.getCacheList(BDConst.REDIS_KEY.FENCE_VIDEO_TRACE);
|
|
|
if (CollectionUtils.isEmpty(cacheList)) {
|
|
|
return;
|
|
|
}
|
|
|
Polygon polygon;
|
|
|
logger.debug("fence info size: {}", msg);
|
|
|
- for (BdFenceInfo fenceInfo : cacheList) {
|
|
|
+ for (VideoFence fenceInfo : cacheList) {
|
|
|
polygon = GeoUtils.getPolygon(fenceInfo.getPoly());
|
|
|
- if (GeoUtils.isPointInGeoFence(polygon, msg.getString("longitude"), msg.getString("latitude"))) {
|
|
|
- logger.debug("?>>>>>fence info size: {}", msg);
|
|
|
- msg.put("fenceId", fenceInfo.getId());
|
|
|
- msg.put("fenceName", fenceInfo.getDefenceName());
|
|
|
- msg.put("videoId", fenceInfo.getLocationId());
|
|
|
-// client.publish(BDConst.MQTT_TOPIC.EVT_ROOM_LOCATION_TOPIC, JSON.toJSONBytes(msg));
|
|
|
+ JSONObject properties = (JSONObject) JSONPath.eval(msg, "$.data.features.properties");
|
|
|
+ String tagId = properties.getString("tag_id");
|
|
|
+ if (GeoUtils.isPointInGeoFence(polygon, properties.getString("pos_x"), properties.getString("pos_y"))) {
|
|
|
+ logger.debug("?>>>>>fence info size: {}", properties);
|
|
|
+ JSONObject location = new JSONObject();
|
|
|
+ location.put("fenceId", fenceInfo.getId());
|
|
|
+ location.put("fenceName", fenceInfo.getDefenceName());
|
|
|
+ location.put("key", tagId);
|
|
|
+ location.put("srcTimestamp", DateTimeUtil.timestampMillis());
|
|
|
+ location.put("longitude", properties.getString("pos_x"));
|
|
|
+ location.put("latitude", properties.getString("pos_y"));
|
|
|
+ location.put("video", new HashMap<String, Object>() {
|
|
|
+ {
|
|
|
+ put("cameraName", fenceInfo.getCameraName());
|
|
|
+ put("cameraStream", fenceInfo.getCameraStream());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ push(location);
|
|
|
break;
|
|
|
}
|
|
|
}
|