ソースを参照

提交修改分析程序

zk 3 ヶ月 前
コミット
6051040f8a

+ 270 - 0
src/main/java/com/shcd/boat/config/RedisCache.java

@@ -0,0 +1,270 @@
+package com.shcd.boat.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.BoundSetOperations;
+import org.springframework.data.redis.core.HashOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * spring redis 工具类
+ *
+ * @author shcd
+ **/
+@SuppressWarnings(value = { "unchecked", "rawtypes" })
+@Component
+public class RedisCache
+{
+    @Autowired
+    public RedisTemplate redisTemplate;
+
+    /**
+     * 缓存基本的对象,Integer、String、实体类等
+     *
+     * @param key 缓存的键值
+     * @param value 缓存的值
+     */
+    public <T> void setCacheObject(final String key, final T value)
+    {
+        redisTemplate.opsForValue().set(key, value);
+    }
+
+    /**
+     * 缓存基本的对象,Integer、String、实体类等
+     *
+     * @param key 缓存的键值
+     * @param value 缓存的值
+     * @param timeout 时间
+     * @param timeUnit 时间颗粒度
+     */
+    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
+    {
+        redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
+    }
+
+    /**
+     * 设置有效时间
+     *
+     * @param key Redis键
+     * @param timeout 超时时间
+     * @return true=设置成功;false=设置失败
+     */
+    public boolean expire(final String key, final long timeout)
+    {
+        return expire(key, timeout, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 设置有效时间
+     *
+     * @param key Redis键
+     * @param timeout 超时时间
+     * @param unit 时间单位
+     * @return true=设置成功;false=设置失败
+     */
+    public boolean expire(final String key, final long timeout, final TimeUnit unit)
+    {
+        return redisTemplate.expire(key, timeout, unit);
+    }
+
+    /**
+     * 获取有效时间
+     *
+     * @param key Redis键
+     * @return 有效时间
+     */
+    public long getExpire(final String key)
+    {
+        return redisTemplate.getExpire(key);
+    }
+
+    /**
+     * 判断 key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public Boolean hasKey(String key)
+    {
+        return redisTemplate.hasKey(key);
+    }
+
+    /**
+     * 获得缓存的基本对象。
+     *
+     * @param key 缓存键值
+     * @return 缓存键值对应的数据
+     */
+    public <T> T getCacheObject(final String key)
+    {
+        ValueOperations<String, T> operation = redisTemplate.opsForValue();
+        return operation.get(key);
+    }
+
+    /**
+     * 删除单个对象
+     *
+     * @param key
+     */
+    public boolean deleteObject(final String key)
+    {
+        return redisTemplate.delete(key);
+    }
+
+    /**
+     * 删除集合对象
+     *
+     * @param collection 多个对象
+     * @return
+     */
+    public boolean deleteObject(final Collection collection)
+    {
+        return redisTemplate.delete(collection) > 0;
+    }
+
+    /**
+     * 缓存List数据
+     *
+     * @param key 缓存的键值
+     * @param dataList 待缓存的List数据
+     * @return 缓存的对象
+     */
+    public <T> long setCacheList(final String key, final List<T> dataList)
+    {
+        Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
+        return count == null ? 0 : count;
+    }
+
+    /**
+     * 获得缓存的list对象
+     *
+     * @param key 缓存的键值
+     * @return 缓存键值对应的数据
+     */
+    public <T> List<T> getCacheList(final String key)
+    {
+        return redisTemplate.opsForList().range(key, 0, -1);
+    }
+
+    /**
+     * 缓存Set
+     *
+     * @param key 缓存键值
+     * @param dataSet 缓存的数据
+     * @return 缓存数据的对象
+     */
+    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
+    {
+        BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
+        Iterator<T> it = dataSet.iterator();
+        while (it.hasNext())
+        {
+            setOperation.add(it.next());
+        }
+        return setOperation;
+    }
+
+    /**
+     * 获得缓存的set
+     *
+     * @param key
+     * @return
+     */
+    public <T> Set<T> getCacheSet(final String key)
+    {
+        return redisTemplate.opsForSet().members(key);
+    }
+
+    /**
+     * 缓存Map
+     *
+     * @param key
+     * @param dataMap
+     */
+    public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
+    {
+        if (dataMap != null) {
+            redisTemplate.opsForHash().putAll(key, dataMap);
+        }
+    }
+
+    /**
+     * 获得缓存的Map
+     *
+     * @param key
+     * @return
+     */
+    public <T> Map<String, T> getCacheMap(final String key)
+    {
+        return redisTemplate.opsForHash().entries(key);
+    }
+
+    /**
+     * 往Hash中存入数据
+     *
+     * @param key Redis键
+     * @param hKey Hash键
+     * @param value 值
+     */
+    public <T> void setCacheMapValue(final String key, final String hKey, final T value)
+    {
+        redisTemplate.opsForHash().put(key, hKey, value);
+    }
+
+    /**
+     * 获取Hash中的数据
+     *
+     * @param key Redis键
+     * @param hKey Hash键
+     * @return Hash中的对象
+     */
+    public <T> T getCacheMapValue(final String key, final String hKey)
+    {
+        HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
+        return opsForHash.get(key, hKey);
+    }
+
+    /**
+     * 获取多个Hash中的数据
+     *
+     * @param key Redis键
+     * @param hKeys Hash键集合
+     * @return Hash对象集合
+     */
+    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
+    {
+        return redisTemplate.opsForHash().multiGet(key, hKeys);
+    }
+
+    /**
+     * 删除Hash中的某条数据
+     *
+     * @param key Redis键
+     * @param hKey Hash键
+     * @return 是否成功
+     */
+    public boolean deleteCacheMapValue(final String key, final String hKey)
+    {
+        return redisTemplate.opsForHash().delete(key, hKey) > 0;
+    }
+
+    public Long getIncrement(final String key, final long delta)
+    {
+        return redisTemplate.opsForValue().increment(key, delta);
+    }
+
+    /**
+     * 获得缓存的基本对象列表
+     *
+     * @param pattern 字符串前缀
+     * @return 对象列表
+     */
+    public Collection<String> keys(final String pattern)
+    {
+        return redisTemplate.keys(pattern);
+    }
+}

+ 1 - 0
src/main/java/com/shcd/boat/config/RedisUtilTemplate.java

@@ -20,6 +20,7 @@ public class RedisUtilTemplate {
 
 
     // 设置 私有静态 redisTemplate
+
     private static RedisTemplate<String, Object> redisTemplate;
 
     // redisTemplate 赋值(注入)

+ 3 - 0
src/main/java/com/shcd/boat/entity/BoatInfoEntity.java

@@ -43,6 +43,9 @@ public class BoatInfoEntity {
     //初始进入航道 或所属航道
     private String inChannel;
 
+
+    //预警航道
+    private String warningChannel;
     //当前状态
     private String cunState;
 

+ 1 - 1
src/main/java/com/shcd/boat/entity/gh/GHAisInfo.java

@@ -20,7 +20,7 @@ public class GHAisInfo  {
    private String  boatNameEn;
    private String  deviCeid;
    private BigDecimal  direction;
-   @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+//   @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date gpsTime ;
    private BigDecimal  latitude;
    private BigDecimal  longitude;

+ 1 - 1
src/main/java/com/shcd/boat/mapper/ShipSealOffSpaceMapper.java

@@ -21,7 +21,7 @@ import java.util.List;
 @Mapper
 public interface ShipSealOffSpaceMapper extends BaseMapper<ShipSealOffSpace> {
 
- List<Boolean> getAllInOut(@Param("ghAisInfos")List<GHAisInfo> ghAisInfos);
+ List<GHAisInfo> getAllInOut(@Param("ghAisInfos")List<GHAisInfo> ghAisInfos);
 
 
 

+ 85 - 28
src/main/java/com/shcd/boat/service/impl/ShipSealOffServiceImpl.java

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.shanghaigeography.Util.DateUtils;
+import com.shcd.boat.config.RedisCache;
 import com.shcd.boat.config.RedisUtilTemplate;
 import com.shcd.boat.config.SnowConfig;
 import com.shcd.boat.entity.*;
@@ -15,6 +17,7 @@ import com.shcd.boat.mapper.ShipSealOffPointsMapper;
 import com.shcd.boat.mapper.ShipSealOffSpaceMapper;
 import com.shcd.boat.service.IShipSealOffInfoService;
 import com.shcd.boat.service.ShipSealOffService;
+import com.shcd.boat.sms.MASSMSService;
 import com.shcd.boat.utils.GhjgRpcUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +46,8 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
 //    3.在范围内查看是否【缓存】已有点位  没有点位加,有点位小于2也加,大于2 且船速>1 开始预警
 //    4.
 
+    @Autowired
+    private MASSMSService massmsService;
     /**
      * 获取市港航数据
      * @return
@@ -124,7 +129,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
     @Resource
     private ShipSealOffPointsMapper offPointsMapper;
     @Autowired
-    private RedisUtilTemplate redisUtilTemplate;
+    private RedisCache redisUtilTemplate;
 
     /**
      * 分析点位
@@ -157,16 +162,12 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
             log.info("==   2.3 右部区域符合点位个数:"+rightPoints.size());
             aisInfosAll.addAll(rightPoints);
         }
-        log.info("==      全部区域符合点位个数:"+aisInfosAll.size());
-       List<Boolean>booleans= shipSealOffSpaceMapper.getAllInOut(aisInfosAll);
-       for (int i=0;i<booleans.size()-1;i++)
-       {
-           GHAisInfo ghAisInfo= aisInfosAll.get(i);
-           ghAisInfo.setInAll(booleans.get(i));
-       }
-        List<GHAisInfo>  inAll=aisInfosAll.stream().filter(i->i.getInAll()!=null && i.getInAll()).collect(Collectors.toList());
+        log.info("==   2.4 全部区域符合点位个数:"+aisInfosAll.size());
+       List<GHAisInfo> newAisInfosAll= shipSealOffSpaceMapper.getAllInOut(aisInfosAll);
+        log.info("==   2.5 所在范围情况:"+newAisInfosAll.toString());
+        List<GHAisInfo>  inAll=newAisInfosAll.stream().filter(i->i.getInAll()!=null && i.getInAll()).collect(Collectors.toList());
         //处理在范围内的船
-        List<GHAisInfo>  notInAll=aisInfosAll.stream().filter(i->i.getInAll()!=null && !i.getInAll()).collect(Collectors.toList());
+        List<GHAisInfo>  notInAll=newAisInfosAll.stream().filter(i->i.getInAll()!=null && !i.getInAll()).collect(Collectors.toList());
        if (inAll!=null && inAll.size()>0)
        {
            log.info("==  3.处理在区域范围内的船舶个数:"+inAll.size());
@@ -174,11 +175,13 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
        }
        if (notInAll!=null && notInAll.size()>0)
        {
-           log.info("==  4.处理不在区域范围内的船舶个数:"+inAll.size());
+           log.info("==  4.处理不在区域范围内的船舶个数:"+notInAll.size());
            saveAllNotData(notInAll);
        }
 
 
+
+
     }
 
     @Autowired
@@ -222,8 +225,10 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
         List<ShipSealOffInfo> insertNeedList =new ArrayList<>();
         List<ShipSealOffInfo> updateNeedList =new ArrayList<>();
         List<ShipSealOffPoints> sealOffPoints=new ArrayList<>();
+        Map<String,BoatInfoEntity> redisDataMap=new HashMap<>();
+
         mapAll.keySet().forEach(i-> {
-            Object result = redisUtilTemplate.get(i);
+            Object result = redisUtilTemplate.getCacheObject(i);
             if (!ObjectUtils.isEmpty(result)) {
                 //已经在监控了
                 //缓存需更新数据
@@ -234,12 +239,13 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                 if (redisData.getLastAisTime().hashCode() != thisGpsTime.hashCode())  //只处理时间不同的
                 {
                     //没产生过预警,且已经有一个船速大于1的点位  需要产生预警
-                      if (!redisData.getIsWarning() && redisData.getPointWarningNum() > 2 && thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
+                      if (!redisData.getIsWarning() && redisData.getPointWarningNum() > 1 && thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
                                     ShipSealOffInfo info = new ShipSealOffInfo();
                                     info.setSealId(redisData.getId());
                                     info.setMmsi(i);
                                     info.setWarningVerifyStatus("待核实");
                                     info.setWarningTime(new Date());
+                                    redisData.setWarningChannel(getInChannelForThisAIS(thisAisPoint));
                                     info.setWarningChannel(redisData.getInChannel());
                                     info.setShipBreadth(thisAisPoint.getShipBreadth());
                                     info.setShipLength(thisAisPoint.getShipLength());
@@ -248,8 +254,8 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                                         info.setWarningStatus("航行中");
                                         redisData.setCunState("航行中");
                                     } else {
-                                        info.setWarningStatus("已停");
-                                        redisData.setCunState("已停");
+                                        info.setWarningStatus("已停");
+                                        redisData.setCunState("已停");
                                     }
                                     info.setStartWarning(redisData.getBeginTime());
                                     insertNeedList.add(info);
@@ -289,8 +295,8 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                                     info.setWarningStatus("航行中");
                                     redisData.setCunState("航行中");
                                 } else {
-                                    info.setWarningStatus("已停");
-                                    redisData.setCunState("已停");
+                                    info.setWarningStatus("已停");
+                                    redisData.setCunState("已停");
                                 }
                                 info.getWarningStatus();
                                 updateNeedList.add(info);
@@ -317,8 +323,9 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                        redisData.setPointNum((redisData.getPointNum() + 1));
                        String dtoJSON = JSON.toJSONString(redisData);
                        // 将JSON字符串存入Redis
-                       redisUtilTemplate.set(i, dtoJSON);
+                       redisUtilTemplate.setCacheObject(i, dtoJSON);
                  }
+                redisDataMap.put(i,redisData);
             }
             else
                 {   //还没监控 且船速大于1 头一回列入  只添加到缓存,不做任何处理
@@ -330,6 +337,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                         thisAis.setPointNum(1);
                         thisAis.setBeginTime(thisAisPoint.getGpsTime());
                         thisAis.setPointWarningNum(1);
+                        thisAis.setIsWarning(false);
                         //设置初始航道
                         thisAis.setInChannel(getInChannelForThisAIS(thisAisPoint));
                         List<GHAisInfo> aisInfos = new ArrayList<>();
@@ -337,7 +345,8 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                         aisInfos.add(thisAisPoint);
                         thisAis.setAisData(aisInfos);
                         String dtoJSON = JSON.toJSONString(thisAis);
-                        redisUtilTemplate.set(i, dtoJSON);
+                        redisUtilTemplate.setCacheObject(i, dtoJSON);
+                        redisDataMap.put(i,thisAis);
                     }
             }
         });
@@ -393,15 +402,17 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
           List<String> strings=  insertNeedList.stream().map(ShipSealOffInfo::getMmsi).collect(Collectors.toList());
             log.info("==  3.2.1  调整缓存点为已预警:"+strings.toString());
             strings.stream().forEach(i->{
-                Object result = redisUtilTemplate.get(i);
+                Object result = redisUtilTemplate.getCacheObject(i);
                 if (!ObjectUtils.isEmpty(result)) {
                     BoatInfoEntity redisData = JSON.parseObject((String) result, BoatInfoEntity.class);
                     redisData.setIsWarning(true);
                     String dtoJSON = JSON.toJSONString(redisData);
                     // 将JSON字符串存入Redis
-                    redisUtilTemplate.set(i, dtoJSON);
+                    log.info("===   3.2.1.1 开始处理:"+i+"设置状态为"+redisData.getIsWarning());
+                    redisUtilTemplate.setCacheObject(i, dtoJSON);
                 }
             });
+            sendSMSData(insertNeedList);
         }
         if (updateNeedList!=null && updateNeedList.size()>0) {
             log.info("==  3.3 其中需要更新船舶:"+updateNeedList.size()+"个:"+updateNeedList.toString());
@@ -421,14 +432,48 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
 
         Map<String,GHAisInfo> mapAll=notInAll.stream().collect(Collectors.toMap(GHAisInfo::getDeviCeid, Function.identity()));
         log.info("== 离开区域范围内的船舶个数:"+notInAll.size()+",离开的详细信息:"+mapAll.keySet());
+
+        List<String> sealIds=new ArrayList<>();
+
         mapAll.keySet().forEach(i->{
-            Object result = redisUtilTemplate.get(i);
+            Object result = redisUtilTemplate.getCacheObject(i);
             if (!ObjectUtils.isEmpty(result)) {  //已经在监控了
-                redisUtilTemplate.del(i);
+                BoatInfoEntity redisData = JSON.parseObject((String) result, BoatInfoEntity.class);
+                sealIds.add(redisData.getId());
+                redisUtilTemplate.deleteObject(i);
             }
         });
+        if(sealIds!=null && sealIds.size()>0) {
 
-    }
+            LambdaUpdateWrapper<ShipSealOffInfo> sealOffInfoLambdaUpdateWrapper = new LambdaUpdateWrapper();
+            sealOffInfoLambdaUpdateWrapper.set(ShipSealOffInfo::getWarningStatus, "已离开电子围栏");
+            sealOffInfoLambdaUpdateWrapper.in(ShipSealOffInfo::getSealId, sealIds);
+            shipSealOffInfoService.update(sealOffInfoLambdaUpdateWrapper);
+
+            LambdaQueryWrapper<ShipSealOffInfo> lastPoint = new LambdaQueryWrapper<>();
+            lastPoint.in(ShipSealOffInfo::getSealId, sealIds);
+            List<ShipSealOffInfo> has = shipSealOffInfoService.list(lastPoint);
+            if (has != null && has.size() > 0) {
+                Map<String, String> hasMMSI = has.stream().filter(i -> !StringUtils.isEmpty(i.getMmsi())).collect(Collectors.toMap(ShipSealOffInfo::getMmsi, ShipSealOffInfo::getSealId));
+                List<ShipSealOffPoints> lastPoints = new ArrayList<>();
+                hasMMSI.keySet().forEach(i -> {
+                    GHAisInfo aisInfo = mapAll.get(i);
+                    ShipSealOffPoints sealOffPoints1 = new ShipSealOffPoints();
+                    sealOffPoints1.setId(snowflakeConfig.snowflakeStringId());
+                    sealOffPoints1.setMmsi(i);
+                    sealOffPoints1.setShipName(aisInfo.getBoatName());
+                    sealOffPoints1.setSourceType("市港航AIS");
+                    sealOffPoints1.setSealId(hasMMSI.get(i));
+                    sealOffPoints1.setAisTime(aisInfo.getGpsTime());
+                    sealOffPoints1.setPointJson(JSON.toJSONString(aisInfo));
+                    sealOffPoints1.setPointGeom(aisInfo.getMapx().toString() + " " + aisInfo.getMapy().toString());
+                    lastPoints.add(sealOffPoints1);
+                });
+                offPointsMapper.saveAll(lastPoints, 3857);
+            }
+        }
+
+        }
 
 
 
@@ -437,11 +482,11 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
      */
     void getDBAllDataForNeed()
     {
-        Set<String> keys=redisUtilTemplate.findKeys("*");
-        if (keys!=null && keys.size()>0) {
+        Collection<String> cacheKeys  =redisUtilTemplate.keys("*");
+        if (cacheKeys!=null && cacheKeys.size()>0) {
             LambdaQueryWrapper<ShipSealOffInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.ne(ShipSealOffInfo::getWarningVerifyStatus, "待核实");
-            lambdaQueryWrapper.in(ShipSealOffInfo::getMmsi, keys);
+            lambdaQueryWrapper.in(ShipSealOffInfo::getMmsi, cacheKeys);
             lambdaQueryWrapper.eq(ShipSealOffInfo::getDelFlag, "0");
             List<ShipSealOffInfo> shipSealOffInfos= shipSealOffInfoService.list(lambdaQueryWrapper);
             if (shipSealOffInfos!=null && shipSealOffInfos.size()>0)
@@ -449,7 +494,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                 List<String> mmsis=shipSealOffInfos.stream().map(ShipSealOffInfo::getMmsi).collect(Collectors.toList());
                 log.info("=== 1.1 查询到 存在缓存中的数据已经确认过的数据,开始清除相关缓存,清除船舶为:"+mmsis.toString());
                 mmsis.forEach(i->{
-                    redisUtilTemplate.del(i);
+                    redisUtilTemplate.deleteObject(i);
                 });
             }
         }
@@ -457,4 +502,16 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
     }
 
 
+    /**
+     * 短信发送
+     */
+    void sendSMSData( List<ShipSealOffInfo> inAll){
+        inAll.stream().forEach(i->{
+            String message="【"+DateUtils.dateToString(i.getWarningTime(),DateUtils.DATE_FORMAT_19)+"】,发现【"+i.getShipName()+"】违规输入封航区域,请尽快核实。";
+            massmsService.commonSend("13393931806",message);
+            massmsService.commonSend("18202163836",message);
+//            massmsService.commonSend("13393931806",message);
+        });
+
+    }
 }

+ 23 - 8
src/main/resources/mapper/ShipSealOffSpaceMapper.xml

@@ -3,15 +3,30 @@
 <mapper namespace="com.shcd.boat.mapper.ShipSealOffSpaceMapper">
 
 
-    <select id="getAllInOut" resultType="java.lang.Boolean">
-        SELECT
-        ST_Contains((select  ST_AsText(polygon_geom)  from pdhw_dev.pdhw_space.ship_seal_off_space ems  where seal_off_name  ='全域'), v.point_geom) AS is_inside
-        FROM (
-        VALUES
-        <foreach collection="ghAisInfos" item="iteam" index="index" separator=",">
-            (ST_GeomFromText('POINT(${iteam.mapx} ${iteam.mapy})'))
+    <select id="getAllInOut" resultType="com.shcd.boat.entity.gh.GHAisInfo">
+
+        <foreach collection="ghAisInfos" item="iteam" index="index" separator="union">
+            select
+            (ST_Contains((select  ST_AsText(polygon_geom)  from pdhw_dev.pdhw_space.ship_seal_off_space ems  where seal_off_name  ='全域'),
+            ST_GeomFromText('POINT(${iteam.mapx} ${iteam.mapy})'))) AS inAll
+            , #{iteam.deviCeid} as deviCeid
+            , #{iteam.boatName} as boatName
+            , #{iteam.boatNameEn} as boatNameEn
+            , #{iteam.deviCeid} as deviCeid
+            , #{iteam.direction} as direction
+            , #{iteam.gpsTime} as gpsTime
+            , #{iteam.latitude} as latitude
+            , #{iteam.longitude} as longitude
+            , #{iteam.mapx} as mapx
+            , #{iteam.mapy} as mapy
+            , #{iteam.shipBreadth} as shipBreadth
+            , #{iteam.shipDepth} as shipDepth
+            , #{iteam.shipLength} as shipLength
+            , #{iteam.velocity} as velocity
+            , #{iteam.inAll} as inAll
+            , #{iteam.inchannel} as inchannel
+
         </foreach>
-        ) AS v(point_geom);
     </select>
 
     <select id="getInChannel" resultType="com.shcd.boat.entity.AISInChannel">

+ 28 - 19
src/test/java/com/shcd/boat/service/BoatRedisTest.java

@@ -2,12 +2,16 @@ package com.shcd.boat.service;
 
 import com.shcd.boat.entity.BoatInfoEntity;
 import com.shcd.boat.entity.PointInfoEntity;
+import com.shcd.boat.entity.gh.GHAisInfo;
+import com.shcd.boat.mapper.ShipSealOffSpaceMapper;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -27,28 +31,33 @@ public class BoatRedisTest {
     private BoatRedisService boatRedisService;
 
 
+    @Resource
+    private ShipSealOffSpaceMapper shipSealOffSpaceMapper;
 
     @Test
     public void method(){
-//        List<PointInfoEntity> list = new ArrayList<>();
-//        PointInfoEntity pointInfoEntity = PointInfoEntity.builder()
-//                .id(UUID.randomUUID().toString())
-//                .point("111,12155")
-//                .currentPointTime(new Date())
-//                .mmsi("91000")
-//                .boatLength("123456")
-//                .build();
-//        list.add(pointInfoEntity);
-//        System.out.println(list);
-//        BoatInfoEntity boatInfoEntity = BoatInfoEntity.builder()
-//                .id(UUID.randomUUID().toString())
-//                .pointNum(1)
-//                .aisData(list)
-//                .build();
-//        System.out.println("-------------------------");
-//        System.out.println(boatInfoEntity);
-//        boolean b = boatRedisService.saveBoatInfo(boatInfoEntity);
-//        System.out.println(b);
+        List<GHAisInfo> aisInfosAll=new ArrayList<>();
+        GHAisInfo ghAisInfo=new GHAisInfo();
+        ghAisInfo.setMapx(new BigDecimal("10078.548"));
+        ghAisInfo.setMapy(new BigDecimal("5942.117"));
+        ghAisInfo.setDeviCeid("a11111111111111111111111");
+        ghAisInfo.setBoatName("a22222222222222222222");
+        ghAisInfo.setGpsTime(new Date());
+        aisInfosAll.add(ghAisInfo);
+        GHAisInfo ghAisInfo1=new GHAisInfo();
+        ghAisInfo1.setMapx(new BigDecimal("10999.548"));
+        ghAisInfo1.setMapy(new BigDecimal("5902.117"));
+        ghAisInfo1.setDeviCeid("b11111111111111111111111");
+        ghAisInfo1.setBoatName("b22222222222222222222");
+        aisInfosAll.add(ghAisInfo1);
+        GHAisInfo ghAisInfo2=new GHAisInfo();
+        ghAisInfo2.setMapx(new BigDecimal("10080.548"));
+        ghAisInfo2.setMapy(new BigDecimal("7042.117"));
+        ghAisInfo2.setDeviCeid("c11111111111111111111111");
+        ghAisInfo2.setBoatName("c22222222222222222222");
+        aisInfosAll.add(ghAisInfo2);
+        List<GHAisInfo> booleans= shipSealOffSpaceMapper.getAllInOut(aisInfosAll);
+        System.out.println(booleans.toString());
     }
 
     @Test