| | |
| | | import com.stylefeng.guns.modular.system.model.CompanyCity; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.util.GDMapGeocodingUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Company query1(String lon, String lat) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(lat), Double.valueOf(lon)); |
| | | if(null == reverseGeocode){ |
| | | return null; |
| | | } |
| | | AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos(); |
| | | String[] city = new String[addressComponentsVos.length]; |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | city[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | Company query = this.query(city); |
| | | return query; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据行政编号获取所属企业 |
| | | * @param code |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Company query(String[] city) throws Exception { |
| | | List<Company> query = companyMapper.queryList(city, 3); |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 2); |
| | | } |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 1); |
| | | } |
| | | if(query.size() > 0){ |
| | | return query.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | } |