diff --git a/src/main/java/com/xkrs/model/entity/FirePointEntity.java b/src/main/java/com/xkrs/model/entity/FirePointEntity.java index 8eefb60..666f65c 100644 --- a/src/main/java/com/xkrs/model/entity/FirePointEntity.java +++ b/src/main/java/com/xkrs/model/entity/FirePointEntity.java @@ -7,7 +7,7 @@ import java.io.Serializable; * @author XinYi Song */ @Entity -@Table(name="fire_point") +@Table(name = "fire_point") public class FirePointEntity implements Serializable { /** @@ -15,13 +15,13 @@ public class FirePointEntity implements Serializable { */ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_seq_gen") - @SequenceGenerator(name = "fire_point_seq_gen", sequenceName = "fire_point_id_seq",allocationSize = 1) + @SequenceGenerator(name = "fire_point_seq_gen", sequenceName = "fire_point_id_seq", allocationSize = 1) private Integer id; /** * 火点编码 */ - @Column( length = 32,unique = true,columnDefinition = "varchar(32)") + @Column(length = 32, unique = true, columnDefinition = "varchar(32)") private String fireCode; /** @@ -43,7 +43,7 @@ public class FirePointEntity implements Serializable { /** * 省市区的名称 */ - @Column( columnDefinition = "varchar(64)") + @Column(columnDefinition = "varchar(64)") private String countyName; /** @@ -54,13 +54,13 @@ public class FirePointEntity implements Serializable { /** * 卫星的类型 */ - @Column( columnDefinition = "varchar(64)") + @Column(columnDefinition = "varchar(64)") private String satelliteType; /** * 植被类型 */ - @Column( columnDefinition = "varchar(64)") + @Column(columnDefinition = "varchar(64)") private String landType; /** @@ -105,31 +105,15 @@ public class FirePointEntity implements Serializable { */ private String afterFireImage; - + /** + * 街道编码 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String streetCode; public FirePointEntity() { } - public FirePointEntity(Integer id, String fireCode, double longitude, double latitude, String countyCode, String countyName, String satelliteTime, String satelliteType, String landType, String addTime, String confidence, String firePointAddress, String fireType, String fireImage, String satelliteImage, String beforeFireImage, String afterFireImage) { - this.id = id; - this.fireCode = fireCode; - this.longitude = longitude; - this.latitude = latitude; - this.countyCode = countyCode; - this.countyName = countyName; - this.satelliteTime = satelliteTime; - this.satelliteType = satelliteType; - this.landType = landType; - this.addTime = addTime; - this.confidence = confidence; - this.firePointAddress = firePointAddress; - this.fireType = fireType; - this.fireImage = fireImage; - this.satelliteImage = satelliteImage; - this.beforeFireImage = beforeFireImage; - this.afterFireImage = afterFireImage; - } - public Integer getId() { return id; } @@ -266,6 +250,14 @@ public class FirePointEntity implements Serializable { this.afterFireImage = afterFireImage; } + public String getStreetCode() { + return streetCode; + } + + public void setStreetCode(String streetCode) { + this.streetCode = streetCode; + } + @Override public String toString() { return "FirePointEntity{" + @@ -286,6 +278,7 @@ public class FirePointEntity implements Serializable { ", satelliteImage='" + satelliteImage + '\'' + ", beforeFireImage='" + beforeFireImage + '\'' + ", afterFireImage='" + afterFireImage + '\'' + + ", streetCode='" + streetCode + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/model/vo/GaoDeIgGeocodeVo.java b/src/main/java/com/xkrs/model/vo/GaoDeIgGeocodeVo.java index f7a6ac9..38ee1fe 100644 --- a/src/main/java/com/xkrs/model/vo/GaoDeIgGeocodeVo.java +++ b/src/main/java/com/xkrs/model/vo/GaoDeIgGeocodeVo.java @@ -48,596 +48,598 @@ public class GaoDeIgGeocodeVo { public void setRegeocodes(List regeocodes) { this.regeocodes = regeocodes; } -} -class Regeocode { - private String formatted_address; - private List addressComponent; - private List pois; - private List roads; - private List roadinters; - private List aois; + public static class Regeocode { + private String formatted_address; + private List addressComponent; + private List pois; + private List roads; + private List roadinters; + private List aois; - public Regeocode() { + public Regeocode() { + } + + public String getFormatted_address() { + return formatted_address; + } + + public void setFormatted_address(String formatted_address) { + this.formatted_address = formatted_address; + } + + public List getAddressComponent() { + return addressComponent; + } + + public void setAddressComponent(List addressComponent) { + this.addressComponent = addressComponent; + } + + public List getPois() { + return pois; + } + + public void setPois(List pois) { + this.pois = pois; + } + + public List getRoads() { + return roads; + } + + public void setRoads(List roads) { + this.roads = roads; + } + + public List getRoadinters() { + return roadinters; + } + + public void setRoadinters(List roadinters) { + this.roadinters = roadinters; + } + + public List getAois() { + return aois; + } + + public void setAois(List aois) { + this.aois = aois; + } } - public String getFormatted_address() { - return formatted_address; + public static class AddressComponent { + private String country; + private String province; + private String city; + private String citycode; + private String district; + private String adcode; + private String township; + private String towncode; + private String seaArea; + private Neighborhood neighborhood; + private Building building; + private StreetNumber streetNumber; + private List businessAreas; + + public AddressComponent() { + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCitycode() { + return citycode; + } + + public void setCitycode(String citycode) { + this.citycode = citycode; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getAdcode() { + return adcode; + } + + public void setAdcode(String adcode) { + this.adcode = adcode; + } + + public String getTownship() { + return township; + } + + public void setTownship(String township) { + this.township = township; + } + + public String getTowncode() { + return towncode; + } + + public void setTowncode(String towncode) { + this.towncode = towncode; + } + + public String getSeaArea() { + return seaArea; + } + + public void setSeaArea(String seaArea) { + this.seaArea = seaArea; + } + + public Neighborhood getNeighborhood() { + return neighborhood; + } + + public void setNeighborhood(Neighborhood neighborhood) { + this.neighborhood = neighborhood; + } + + public Building getBuilding() { + return building; + } + + public void setBuilding(Building building) { + this.building = building; + } + + public StreetNumber getStreetNumber() { + return streetNumber; + } + + public void setStreetNumber(StreetNumber streetNumber) { + this.streetNumber = streetNumber; + } + + public List getBusinessAreas() { + return businessAreas; + } + + public void setBusinessAreas(List businessAreas) { + this.businessAreas = businessAreas; + } } - public void setFormatted_address(String formatted_address) { - this.formatted_address = formatted_address; + public static class Neighborhood { + private String name; + private String type; + + public Neighborhood() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } - public List getAddressComponent() { - return addressComponent; + public static class Building { + private String name; + private String type; + + public Building() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } - public void setAddressComponent(List addressComponent) { - this.addressComponent = addressComponent; + public static class StreetNumber { + private String street; + private String number; + private String location; + private String direction; + private String distance; + + public StreetNumber() { + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } } - public List getPois() { - return pois; + public static class BusinessArea { + private String businessArea; + private String location; + private String name; + private String id; + + public BusinessArea() { + } + + public String getBusinessArea() { + return businessArea; + } + + public void setBusinessArea(String businessArea) { + this.businessArea = businessArea; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } } - public void setPois(List pois) { - this.pois = pois; + public static class Road { + private String id; + private String name; + private String distance; + private String direction; + private String location; + + public Road() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } } - public List getRoads() { - return roads; + public static class Roadinter { + private String distance; + private String direction; + private String location; + private String first_id; + private String first_name; + private String second_id; + private String second_name; + + public Roadinter() { + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getFirst_id() { + return first_id; + } + + public void setFirst_id(String first_id) { + this.first_id = first_id; + } + + public String getFirst_name() { + return first_name; + } + + public void setFirst_name(String first_name) { + this.first_name = first_name; + } + + public String getSecond_id() { + return second_id; + } + + public void setSecond_id(String second_id) { + this.second_id = second_id; + } + + public String getSecond_name() { + return second_name; + } + + public void setSecond_name(String second_name) { + this.second_name = second_name; + } } - public void setRoads(List roads) { - this.roads = roads; + public static class Poi { + private String id; + private String name; + private String type; + private String tel; + private String distance; + private String direction; + private String address; + private String location; + private String businessarea; + + public Poi() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getBusinessarea() { + return businessarea; + } + + public void setBusinessarea(String businessarea) { + this.businessarea = businessarea; + } } - public List getRoadinters() { - return roadinters; - } + public static class Aoi { + private String id; + private String name; + private String adcode; + private String location; + private String area; + private String distance; - public void setRoadinters(List roadinters) { - this.roadinters = roadinters; - } + public Aoi() { + } - public List getAois() { - return aois; - } + public String getId() { + return id; + } - public void setAois(List aois) { - this.aois = aois; + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAdcode() { + return adcode; + } + + public void setAdcode(String adcode) { + this.adcode = adcode; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } } } -class AddressComponent { - private String country; - private String province; - private String city; - private String citycode; - private String district; - private String adcode; - private String township; - private String towncode; - private String seaArea; - private Neighborhood neighborhood; - private Building building; - private StreetNumber streetNumber; - private List businessAreas; - public AddressComponent() { - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getProvince() { - return province; - } - - public void setProvince(String province) { - this.province = province; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getCitycode() { - return citycode; - } - - public void setCitycode(String citycode) { - this.citycode = citycode; - } - - public String getDistrict() { - return district; - } - - public void setDistrict(String district) { - this.district = district; - } - - public String getAdcode() { - return adcode; - } - - public void setAdcode(String adcode) { - this.adcode = adcode; - } - - public String getTownship() { - return township; - } - - public void setTownship(String township) { - this.township = township; - } - - public String getTowncode() { - return towncode; - } - - public void setTowncode(String towncode) { - this.towncode = towncode; - } - - public String getSeaArea() { - return seaArea; - } - - public void setSeaArea(String seaArea) { - this.seaArea = seaArea; - } - - public Neighborhood getNeighborhood() { - return neighborhood; - } - - public void setNeighborhood(Neighborhood neighborhood) { - this.neighborhood = neighborhood; - } - - public Building getBuilding() { - return building; - } - - public void setBuilding(Building building) { - this.building = building; - } - - public StreetNumber getStreetNumber() { - return streetNumber; - } - - public void setStreetNumber(StreetNumber streetNumber) { - this.streetNumber = streetNumber; - } - - public List getBusinessAreas() { - return businessAreas; - } - - public void setBusinessAreas(List businessAreas) { - this.businessAreas = businessAreas; - } -} - -class Neighborhood { - private String name; - private String type; - - public Neighborhood() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} - -class Building { - private String name; - private String type; - - public Building() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} - -class StreetNumber { - private String street; - private String number; - private String location; - private String direction; - private String distance; - - public StreetNumber() { - } - - public String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getNumber() { - return number; - } - - public void setNumber(String number) { - this.number = number; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } -} - -class BusinessArea { - private String businessArea; - private String location; - private String name; - private String id; - - public BusinessArea() { - } - - public String getBusinessArea() { - return businessArea; - } - - public void setBusinessArea(String businessArea) { - this.businessArea = businessArea; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} - -class Road { - private String id; - private String name; - private String distance; - private String direction; - private String location; - - public Road() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } -} - -class Roadinter { - private String distance; - private String direction; - private String location; - private String first_id; - private String first_name; - private String second_id; - private String second_name; - - public Roadinter() { - } - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getFirst_id() { - return first_id; - } - - public void setFirst_id(String first_id) { - this.first_id = first_id; - } - - public String getFirst_name() { - return first_name; - } - - public void setFirst_name(String first_name) { - this.first_name = first_name; - } - - public String getSecond_id() { - return second_id; - } - - public void setSecond_id(String second_id) { - this.second_id = second_id; - } - - public String getSecond_name() { - return second_name; - } - - public void setSecond_name(String second_name) { - this.second_name = second_name; - } -} - -class Poi { - private String id; - private String name; - private String type; - private String tel; - private String distance; - private String direction; - private String address; - private String location; - private String businessarea; - - public Poi() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getTel() { - return tel; - } - - public void setTel(String tel) { - this.tel = tel; - } - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getBusinessarea() { - return businessarea; - } - - public void setBusinessarea(String businessarea) { - this.businessarea = businessarea; - } -} - -class Aoi { - private String id; - private String name; - private String adcode; - private String location; - private String area; - private String distance; - - public Aoi() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAdcode() { - return adcode; - } - - public void setAdcode(String adcode) { - this.adcode = adcode; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getArea() { - return area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } -} diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index d2b668f..b6cc12c 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -1,6 +1,5 @@ package com.xkrs.service; -import com.xkrs.dao.FirePointDao; import com.xkrs.model.entity.FirePoint; import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; @@ -18,6 +17,7 @@ public interface FirePointService { /** * 添加火点信息 + * * @param firePointQo * @return */ @@ -25,6 +25,7 @@ public interface FirePointService { /** * 查询今天的火点信息 + * * @param * @return */ @@ -32,6 +33,7 @@ public interface FirePointService { /** * 动态多条件查询火点信息(省) + * * @param proCode * @param cityCode * @param satelliteType @@ -40,43 +42,47 @@ public interface FirePointService { * @param endTime * @return */ - List selectFirePoint(String proCode,String cityCode,String satelliteType,String landType,String startTime,String endTime); + List selectFirePoint(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime); /** * 动态多条件查询火点信息(市) - * @param cityCodeOne 市编码 - * @param cityCode 县编码 + * + * @param cityCodeOne 市编码 + * @param cityCode 县编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - List selectFirePointByCity(String cityCodeOne,String cityCode,String satelliteType,String landType,String startTime,String endTime); + List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime); /** * 动态多条件查询火点信息(县) - * @param cityCode 县编码 + * + * @param cityCode 县编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - List selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime); + List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime); /** * 根据火点编码修改火点的状态(预警) + * * @param fireCode * @param fireType * @param token * @return */ - String updateTypeByFireCode(String fireCode,String fireType,String token); + String updateTypeByFireCode(String fireCode, String fireType, String token); /** * 提交核查任务信息 + * * @param files * @param appTaskBodyVo * @return @@ -86,6 +92,7 @@ public interface FirePointService { /** * 根据火点编码查询任务信息 + * * @param fireCode * @param * @return @@ -95,50 +102,58 @@ public interface FirePointService { /** * 查询近一周天的火点信息 + * * @return */ List selectFirePointBetweenSeven(); /** * 查询近一个月的火点信息 + * * @return */ List selectFirePointByMonth(String countyCode); /** * 查询近一个月的火点数量 + * * @return */ String selectFirePointNumMonth(); /** * 查询近一天的火点数量 + * * @return */ String selectFirePointNumDay(); /** * 查询 + * * @return */ String selectFirePointNumWeek(); /** * 查询该省所有的市 + * * @param code * @return */ - List> selectCityName(String code); + List> selectCityName(String code); /** * 查询市包含的区县和编码 + * * @param code * @return */ - List> selectCountyName(String code); + List> selectCountyName(String code); /** * 测试插入火点信息 + * * @param firePointQo * @return */ @@ -146,6 +161,7 @@ public interface FirePointService { /** * 导入全国省市区 + * * @param file * @throws Exception */ @@ -153,6 +169,7 @@ public interface FirePointService { /** * 查询今日火点信息(测试) + * * @param countyCode * @return */ diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 3f62c00..48dabae 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -7,6 +7,7 @@ import com.xkrs.model.entity.*; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.AppPhotoVo; import com.xkrs.model.vo.AppTaskBodyVo; +import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.service.FirePointService; import com.xkrs.utils.*; import org.slf4j.Logger; @@ -105,6 +106,12 @@ public class FirePointServiceImpl implements FirePointService { firePointEntity.setFireType("0"); firePointEntity.setFireImage(firePointQo.getFireImage()); firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); + try { + bindStreetCode(firePointEntity); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); + } log.info("-------发现新火点"); /*log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); Map map = new HashMap(3); @@ -126,6 +133,17 @@ public class FirePointServiceImpl implements FirePointService { } } + private void bindStreetCode(FirePointEntity firePointEntity) throws Exception { + List locationList = new ArrayList<>(); + locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); + GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList); + String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode(); + if (townCode.length() > 9) { + townCode = townCode.substring(0, 9); + } + firePointEntity.setStreetCode(townCode); + } + /** * 查询今天的火点信息 * diff --git a/src/main/java/com/xkrs/utils/GaoDeApiUtil.java b/src/main/java/com/xkrs/utils/GaoDeApiUtil.java index 8b41514..a8cd161 100644 --- a/src/main/java/com/xkrs/utils/GaoDeApiUtil.java +++ b/src/main/java/com/xkrs/utils/GaoDeApiUtil.java @@ -1,18 +1,14 @@ package com.xkrs.utils; import com.alibaba.fastjson.JSON; -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.controller.GaodeApiController; import com.xkrs.model.vo.GaoDeIgGeocodeVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.RequestBody; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_KEY; import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_URL; import static com.xkrs.utils.HttpClientUtils.sendHttpsGet; @@ -27,18 +23,19 @@ public class GaoDeApiUtil { /** * 逆地理编码 + * * @param location 示例:["116,23", "117,24"] * @return */ - public GaoDeIgGeocodeVo geocode(List location) { + public static GaoDeIgGeocodeVo geocode(List location) { if (location.size() == 0) { - return new GaoDeIgGeocodeVo(){{ + return new GaoDeIgGeocodeVo() {{ setInfo("参数为空"); - setInfocode("-1");}}; + setInfocode("-1"); + }}; } StringBuilder sb = new StringBuilder(); - for (String var : - location) { + for (String var : location) { sb.append(var).append("|"); } String url = INVERSEGEOGRAPHY_URL + "?key=" + INVERSEGEOGRAPHY_KEY + "&radius=1000&extensions=all&batch=true&roadlevel=0&location="; @@ -49,7 +46,7 @@ public class GaoDeApiUtil { } catch (Exception e) { log.error("获取高德天气失败, {}", e.getMessage()); } - return new GaoDeIgGeocodeVo(){{ + return new GaoDeIgGeocodeVo() {{ setInfo("获取高德天气失败"); setInfocode("-1"); }};