| 
					
				 | 
			
			
				@@ -1,37 +1,39 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.huashe.park.application.engine.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.LinkedBlockingQueue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.annotation.PostConstruct; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.huashe.park.core.redis.RedisProxy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.ObjectUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.locationtech.jts.geom.Polygon; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson2.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson2.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.huashe.park.common.DateTimeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.huashe.park.common.consts.BDConst; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.huashe.park.common.consts.enums.EvtStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.huashe.park.common.consts.enums.EvtType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.huashe.park.common.geo.GeoUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.huashe.park.application.engine.EvtFusionEngine; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.huashe.park.application.engine.LocationInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.huashe.park.application.socket.server.FenceVioEvtSocketServer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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.EvtStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.huashe.park.common.consts.enums.EvtType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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.core.service.IBdFenceVioEvtService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.huashe.park.domain.entity.BdFenceInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.huashe.park.domain.entity.BdFenceVioEvt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ruoyi.common.core.redis.RedisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.ObjectUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.locationtech.jts.geom.Polygon; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import javax.annotation.PostConstruct; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.LinkedBlockingQueue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @ConditionalOnBean(MqttCfg.class) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,15 +46,14 @@ public class FenceBreakInEngine extends EvtFusionEngine { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IBdFenceVioEvtService vioEvtService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private RedisCache redisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisProxy redisService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private MqttClientTemplate client; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * The constant MAX_EVT_TIME_GAP. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 单位:秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * The constant MAX_EVT_TIME_GAP. 单位:秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @author chen.cheng 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -67,16 +68,19 @@ public class FenceBreakInEngine extends EvtFusionEngine { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         super.init(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.setEngineName("室外围栏闯禁事件融合"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!redisCache.hasKey(BDConst.REDIS_KEY.FENCE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<BdFenceInfo> bdFenceInfos = fenceInfoService.selectBdFenceInfoList(new BdFenceInfo() {{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                setFenceType(FenceType.OUT_SIDE_FENCE_IN.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!redisService.hasKey(BDConst.REDIS_KEY.FENCE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<BdFenceInfo> bdFenceInfos = fenceInfoService.selectBdFenceInfoList(new BdFenceInfo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    setFenceType(FenceType.OUT_SIDE_FENCE_IN.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (CollectionUtils.isEmpty(bdFenceInfos)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            bdFenceInfos.removeIf(item -> ObjectUtils.isEmpty(item.getPoly()) || ObjectUtils.isEmpty(GeoUtils.getPolygon(item.getPoly()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bdFenceInfos.removeIf(item -> ObjectUtils.isEmpty(item.getPoly()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                || ObjectUtils.isEmpty(GeoUtils.getPolygon(item.getPoly()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            redisCache.setCacheList(BDConst.REDIS_KEY.FENCE, bdFenceInfos); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisService.setCacheList(BDConst.REDIS_KEY.FENCE, bdFenceInfos); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -101,7 +105,6 @@ public class FenceBreakInEngine extends EvtFusionEngine { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return BDConst.REDIS_KEY.FENCE_BREAK_IN_KEY + msg.getMsg().getString("deviceId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void getBizId(LocationInfo msg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BdFenceVioEvt bdFenceVioEvt = new BdFenceVioEvt(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -132,7 +135,7 @@ public class FenceBreakInEngine extends EvtFusionEngine { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void generateEvt(JSONObject msg, byte[] payload) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<BdFenceInfo> cacheList = redisCache.getCacheList(BDConst.REDIS_KEY.FENCE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<BdFenceInfo> cacheList = redisService.getCacheList(BDConst.REDIS_KEY.FENCE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (CollectionUtils.isEmpty(cacheList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 |