From f72ae151cc12b219cb5f39eea3ec0ea089a6ef2a Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 27 八月 2025 23:53:05 +0800 Subject: [PATCH] 修改bug --- DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SiteServiceImpl.java | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SiteServiceImpl.java b/DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SiteServiceImpl.java index e6d0e05..da0f88b 100644 --- a/DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SiteServiceImpl.java +++ b/DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SiteServiceImpl.java @@ -9,12 +9,18 @@ import com.stylefeng.guns.modular.system.service.IDispatchService; import com.stylefeng.guns.modular.system.service.ISiteService; import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; +import com.stylefeng.guns.modular.system.util.model.GeoFencingPolygon; import com.stylefeng.guns.modular.system.warpper.SiteWarpper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.geo.GeoJsonPoint; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; @Service @@ -31,6 +37,9 @@ @Autowired private IDispatchService dispatchService; + + @Autowired + private MongoTemplate mongoTemplate; @@ -135,8 +144,14 @@ } } if(Integer.valueOf(map.get("type").toString()) == 2){//电子围栏 - List<String> list1 = gdMapElectricFenceUtil.monitorElectricFenc("", lonLat); - return list1.size() > 0 ? true : false; + String[] split = lonLat.split(","); + GeoJsonPoint point = new GeoJsonPoint(Double.valueOf(split[0]), Double.valueOf(split[1])); + Query query = Query.query(Criteria.where("geoJsonPolygon").intersects(point)); + List<GeoFencingPolygon> geoFencingPolygons = mongoTemplate.find(query, GeoFencingPolygon.class); + List<Integer> s_sites = geoFencingPolygons.stream().map(GeoFencingPolygon::getSiteId).collect(Collectors.toList()); + if(s_sites.contains(siteId)){ + return true; + } } } return false; -- Gitblit v1.7.1