fix
longz
2026-04-30 83ff381c5c0e62c98cb9e3dd8e1d82771b1dc23f
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/SiteServiceImpl.java
@@ -200,25 +200,37 @@
        if (lon == null || lat == null) {
            return null;
        }
        String adCode = getAdCodeByLonLat(lon, lat);
        String lonLat = lon + "," + lat;
        List<Site> siteList = this.selectList(new EntityWrapper<Site>().eq("state", 1).orderBy("id", true));
        if (siteList == null || siteList.size() <= 0) {
            return null;
        }
        Site nearest = null;
        Double minDistance = null;
        for (Site site : siteList) {
            if (site == null || site.getId() == null) {
                continue;
            }
            List<Map<String, Object>> locations = queryLocation(site.getId());
            if (locations == null || locations.size() <= 0) {
            if (site.getDefaultPointLon() == null || site.getDefaultPointLat() == null) {
                continue;
            }
            if (matchAreaType1(locations, adCode) || matchAreaType2(site.getId(), lonLat)) {
                return site;
            double distance = calcDistanceMeters(lat, lon, site.getDefaultPointLat(), site.getDefaultPointLon());
            if (minDistance == null || distance < minDistance) {
                minDistance = distance;
                nearest = site;
            }
        }
        return null;
        return nearest;
    }
    private double calcDistanceMeters(double lat1, double lon1, double lat2, double lon2) {
        double earthRadius = 6371000D;
        double dLat = Math.toRadians(lat2 - lat1);
        double dLon = Math.toRadians(lon2 - lon1);
        double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
                + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
                * Math.sin(dLon / 2) * Math.sin(dLon / 2);
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        return earthRadius * c;
    }
    private boolean matchAreaType1(List<Map<String, Object>> locations, String adCode) {