|
@@ -12,9 +12,11 @@ import com.ruoyi.common.BDConst;
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.enums.EvtStatus;
|
|
|
import com.ruoyi.common.enums.EvtType;
|
|
|
+import com.ruoyi.common.utils.DateTimeUtil;
|
|
|
import com.ruoyi.common.utils.geo.GeoUtils;
|
|
|
import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.locationtech.jts.geom.Polygon;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -49,6 +51,7 @@ public class FenceBreakInEngine extends EvtFusionEngine {
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
+ super.init();
|
|
|
this.setEngineName("围栏闯禁事件融合");
|
|
|
if (!redisCache.hasKey(BDConst.REDIS_KEY.FENCE)) {
|
|
|
List<BdFenceInfo> bdFenceInfos = fenceInfoService.selectBdFenceInfoList(new BdFenceInfo());
|
|
@@ -56,6 +59,7 @@ public class FenceBreakInEngine extends EvtFusionEngine {
|
|
|
bdFenceInfos = new ArrayList<>();
|
|
|
}
|
|
|
bdFenceInfos.removeIf(item -> ObjectUtils.isEmpty(item.getPoly()) || ObjectUtils.isEmpty(GeoUtils.getPolygon(item.getPoly())));
|
|
|
+
|
|
|
redisCache.setCacheList(BDConst.REDIS_KEY.FENCE, bdFenceInfos);
|
|
|
}
|
|
|
}
|
|
@@ -81,6 +85,7 @@ public class FenceBreakInEngine extends EvtFusionEngine {
|
|
|
bdFenceVioEvt.setLng(msg.getLongitude());
|
|
|
bdFenceVioEvt.setEvtStatus(EvtStatus.NEW.getCode());
|
|
|
bdFenceVioEvt.setEvtType(EvtType.FENCE_IN.getCode());
|
|
|
+ bdFenceVioEvt.setEvtTime(DateTimeUtil.getDateFromMills(msg.getSrcTimestamp()));
|
|
|
bdFenceVioEvt.setEvtDesc(String.format("围栏闯禁: %s", msg.getMsg().getString("fenceName")));
|
|
|
vioEvtService.insertBdFenceVioEvt(bdFenceVioEvt);
|
|
|
msg.setBizId(bdFenceVioEvt.getId().toString());
|
|
@@ -98,11 +103,14 @@ public class FenceBreakInEngine extends EvtFusionEngine {
|
|
|
|
|
|
public void generateEvt(JSONObject msg, byte[] payload) {
|
|
|
List<BdFenceInfo> cacheList = redisCache.getCacheList(BDConst.REDIS_KEY.FENCE);
|
|
|
+ Polygon polygon;
|
|
|
for (BdFenceInfo fenceInfo : cacheList) {
|
|
|
- if (GeoUtils.isPointInGeoFence(fenceInfo.getPolygon(), msg.getString("longitude"), msg.getString("latitude"))) {
|
|
|
+ polygon = GeoUtils.getPolygon(fenceInfo.getPoly());
|
|
|
+ if (GeoUtils.isPointInGeoFence(polygon, msg.getString("longitude"), msg.getString("latitude"))) {
|
|
|
msg.put("fenceId", fenceInfo.getId());
|
|
|
msg.put("fenceName", fenceInfo.getDefenceName());
|
|
|
client.publish(BDConst.MQTT_TOPIC.EVT_LOCATION_TOPIC, JSON.toJSONBytes(msg));
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|