| | |
| | | package com.yc.sdk.shopping.action.api; |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.dao.DataAccessException; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import com.google.gson.JsonArray; |
| | | import com.google.gson.JsonObject; |
| | | import com.yc.action.BaseAction; |
| | |
| | | import com.yc.entity.DataSourceEntity; |
| | | import com.yc.multiData.MultiDataSource; |
| | | import com.yc.multiData.SpObserver; |
| | | import com.yc.sdk.gaodemap.action.GdMapServiceInit; |
| | | import com.yc.sdk.gaodemap.api.GdMapService; |
| | | import com.yc.sdk.gaodemap.entity.GdErrorException; |
| | | import com.yc.sdk.gaodemap.entity.RegeoCodeEntity; |
| | | import com.yc.sdk.map.entity.LocationEntity; |
| | | import com.yc.sdk.map.service.MapService; |
| | | import com.yc.sdk.miniapp.entity.MaCompanyEntity; |
| | | import com.yc.sdk.shopping.entity.DepartmentEntity; |
| | | import com.yc.sdk.shopping.entity.RegionEntity; |
| | |
| | | import com.yc.sdk.shopping.util.SettingKey; |
| | | import com.yc.sdk.weixincp.service.ERPUserIfc; |
| | | import com.yc.utils.SessionKey; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.dao.DataAccessException; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | public class DistributorAddress extends BaseAction{ |
| | |
| | | |
| | | try { |
| | | if (city ==null || "".equals(city)) { |
| | | if (gaoDeWebServiceKey==null || "".equals(gaoDeWebServiceKey)) { |
| | | errJson.addProperty("warning","没有设置高德地图Web服务所需的key,请在 attachment.config.properties 文件中设置主键为 GaoDeWebServiceKey 的键值"); |
| | | json.add("error", errJson); |
| | | this.printJson(response, json.toString()); |
| | | return; |
| | | if (StringUtils.isBlank(longitude) && StringUtils.isBlank(latitude)) { |
| | | if (settingEntity.getLongitude() != null && !"".equals(settingEntity.getLongitude()) && |
| | | settingEntity.getLatitude() != null && !"".equals(settingEntity.getLatitude())) { |
| | | longitude = settingEntity.getLongitude(); |
| | | latitude = settingEntity.getLatitude(); |
| | | } else if (maCompanyEntity.getLongitude() != null && !"".equals(maCompanyEntity.getLongitude()) && |
| | | maCompanyEntity.getLatitude() != null && !"".equals(maCompanyEntity.getLatitude())) { |
| | | longitude = maCompanyEntity.getLongitude(); |
| | | latitude = maCompanyEntity.getLatitude(); |
| | | } else { |
| | | errJson.addProperty("warning", "由于用户未授权小程序使用位置信息,请在 714001 或 110101 功能号中设置 【地理经度】和【地理纬度】"); |
| | | json.add("error", errJson); |
| | | this.printJson(response, json.toString()); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //从高德地图取数 |
| | | GdMapService gdMapService = GdMapServiceInit.getGdMapService(gaoDeWebServiceKey) ; |
| | | if (longitude != null && ! "".equals(longitude) && latitude != null && !"".equals(latitude)) { |
| | | regeoCodeEntity = gdMapService.getRegeo(longitude, latitude) ; |
| | | city = regeoCodeEntity.getCity(); |
| | | province = regeoCodeEntity.getProvince(); |
| | | district = regeoCodeEntity.getDistrict(); |
| | | }else if (settingEntity.getLongitude()!=null&&!"".equals(settingEntity.getLongitude()) && |
| | | settingEntity.getLatitude() != null && !"".equals(settingEntity.getLatitude())) { |
| | | regeoCodeEntity = gdMapService.getRegeo(settingEntity.getLongitude(), settingEntity.getLatitude()) ; |
| | | city = regeoCodeEntity.getCity(); |
| | | province = regeoCodeEntity.getProvince(); |
| | | district = regeoCodeEntity.getDistrict(); |
| | | }else if (maCompanyEntity.getLongitude()!=null&&!"".equals(maCompanyEntity.getLongitude()) && |
| | | maCompanyEntity.getLatitude() != null && !"".equals(maCompanyEntity.getLatitude())){ |
| | | regeoCodeEntity = gdMapService.getRegeo(maCompanyEntity.getLongitude(), maCompanyEntity.getLatitude()) ; |
| | | city = regeoCodeEntity.getCity(); |
| | | province = regeoCodeEntity.getProvince(); |
| | | district = regeoCodeEntity.getDistrict(); |
| | | }else { |
| | | errJson.addProperty("warning","由于用户未授权小程序使用位置信息,请在 714001 或 110101 功能号中设置 【地理经度】和【地理纬度】"); |
| | | json.add("error", errJson); |
| | | this.printJson(response, json.toString()); |
| | | return; |
| | | } |
| | | LocationEntity location = MapService.getMapFactory().reverseGeocode(longitude, latitude, null); |
| | | city = location.getCityName(); |
| | | province = location.getProvinceName(); |
| | | district = location.getSubLocality(); |
| | | } |
| | | }catch (GdErrorException e) { |
| | | e.printStackTrace(); |