Commit 6e318a8f by wangnb

包活干V1.9.0获取工单地址经纬度--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27255 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 5464ed9e
package com.glsx.common.utils.map; package com.glsx.common.utils.map;
import java.util.HashMap; import com.alibaba.fastjson.JSON;
import java.util.Map; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.gavaghan.geodesy.Ellipsoid; import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator; import org.gavaghan.geodesy.GeodeticCalculator;
...@@ -11,21 +14,16 @@ import org.gavaghan.geodesy.GlobalCoordinates; ...@@ -11,21 +14,16 @@ import org.gavaghan.geodesy.GlobalCoordinates;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON; import java.util.HashMap;
import com.alibaba.fastjson.JSONArray; import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
/** /**
* * @author zhanghj
* @version 1.0.0
* @Title AMapUtils.java * @Title AMapUtils.java
* @Package com.glsx.common.utils.map * @Package com.glsx.common.utils.map
* @Description TODO 高德地图相关api * @Description TODO 高德地图相关api
* @author zhanghj
* @date 2019年4月22日 下午5:03:01 * @date 2019年4月22日 下午5:03:01
* @version 1.0.0
*/ */
public class AMapUtils { public class AMapUtils {
...@@ -57,13 +55,12 @@ public class AMapUtils { ...@@ -57,13 +55,12 @@ public class AMapUtils {
map.put("adcode", geocode.getString("adcode")); map.put("adcode", geocode.getString("adcode"));
String location = geocode.getString("location"); String location = geocode.getString("location");
map.put("longitude", location.substring(0, location.indexOf(","))); map.put("longitude", location.substring(0, location.indexOf(",")));
map.put("latitude", location.substring(location.indexOf(",") + 1, location.length())); map.put("latitude", location.substring(location.indexOf(",") + 1));
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block
logger.error("通过高德地图获取区域编码错误", e); logger.error("通过高德地图获取区域编码错误", e);
} }
return map; return map;
...@@ -100,11 +97,11 @@ public class AMapUtils { ...@@ -100,11 +97,11 @@ public class AMapUtils {
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block
logger.error("获取高德定位地址错误", e); logger.error("获取高德定位地址错误", e);
} }
return null; return null;
} }
public static void main2(String[] args) { public static void main2(String[] args) {
// 西丽新屋村工业大厦 // 西丽新屋村工业大厦
......
...@@ -133,28 +133,8 @@ public class OraOrderServiceImpl implements OraOrderService { ...@@ -133,28 +133,8 @@ public class OraOrderServiceImpl implements OraOrderService {
if (object != null) { if (object != null) {
return object; return object;
} }
//获取经纬度
String address = sysOrder.getAddress(); this.getLongitudeAndLatitude(sysOrder);
Integer district = sysOrder.getDistrict();
String longitude = "";
String latitude = "";
//调用高德地图接口,解析拿到所在地方的区行政编码
if (org.springframework.util.StringUtils.isEmpty(district)) {
try {
Map<String, String> map = AMapUtils.parseAddress(address);
if (!map.isEmpty()) {
district = Integer.parseInt(map.get("adcode"));
longitude = map.get("longitude");
latitude = map.get("latitude");
}
} catch (Exception e) {
logger.error("渠道派单,调用高德地图接口,解析拿到所在地方的区行政编码错误{}", e);
district = -1;
}
}
sysOrder.setDistrict(district);
sysOrder.setLatitude(latitude);
sysOrder.setLongitude(longitude);
//获取对应渠道的根组织id //获取对应渠道的根组织id
SysChannelOrg channelOrg = orderChannelService.getOrgByChannel(sysOrder.getChannel()); SysChannelOrg channelOrg = orderChannelService.getOrgByChannel(sysOrder.getChannel());
Integer groupId = null; Integer groupId = null;
...@@ -166,6 +146,7 @@ public class OraOrderServiceImpl implements OraOrderService { ...@@ -166,6 +146,7 @@ public class OraOrderServiceImpl implements OraOrderService {
//校验对应的商户 //校验对应的商户
String serviceType = null; String serviceType = null;
Integer shopId = null; Integer shopId = null;
Integer district = sysOrder.getDistrict();
String merchantName = sysOrder.getMerchantName(); String merchantName = sysOrder.getMerchantName();
JSONObject obj = userClient.getMerchantList(groupId, merchantName, Constants.SYS_USER_STATUS_NORMAL); JSONObject obj = userClient.getMerchantList(groupId, merchantName, Constants.SYS_USER_STATUS_NORMAL);
if (obj != null && obj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) { if (obj != null && obj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
...@@ -204,26 +185,7 @@ public class OraOrderServiceImpl implements OraOrderService { ...@@ -204,26 +185,7 @@ public class OraOrderServiceImpl implements OraOrderService {
return object; return object;
} }
//门店地址解析 //门店地址解析
Integer district = sysOrder.getDistrict(); this.getLongitudeAndLatitude(sysOrder);
String address = sysOrder.getAddress();
String longitude = "";
String latitude = "";
if (org.springframework.util.StringUtils.isEmpty(district)) {
try {
Map<String, String> map = AMapUtils.parseAddress(address); //调用高德地图接口,解析拿到所在地方的区行政编码
if (!map.isEmpty()) {
district = Integer.parseInt(map.get("adcode"));
longitude = map.get("longitude");
latitude = map.get("latitude");
}
} catch (Exception e) {
logger.error("渠道派单,调用高德地图接口,解析拿到所在地方的区行政编码错误{}", e);
district = -1;
}
}
sysOrder.setDistrict(district);
sysOrder.setLatitude(latitude);
sysOrder.setLongitude(longitude);
//获取对应渠道的根组织id //获取对应渠道的根组织id
SysChannelOrg channelOrg = orderChannelService.getOrgByChannel(sysOrder.getChannel()); SysChannelOrg channelOrg = orderChannelService.getOrgByChannel(sysOrder.getChannel());
Integer groupId = null; Integer groupId = null;
...@@ -235,6 +197,7 @@ public class OraOrderServiceImpl implements OraOrderService { ...@@ -235,6 +197,7 @@ public class OraOrderServiceImpl implements OraOrderService {
//校验对应的商户 //校验对应的商户
String serviceType = null; String serviceType = null;
Integer shopId = null; Integer shopId = null;
Integer district = sysOrder.getDistrict();
String merchantName = sysOrder.getMerchantName(); String merchantName = sysOrder.getMerchantName();
JSONObject obj = userClient.getMerchantList(groupId, merchantName, Constants.SYS_USER_STATUS_NORMAL); JSONObject obj = userClient.getMerchantList(groupId, merchantName, Constants.SYS_USER_STATUS_NORMAL);
if (obj != null && obj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) { if (obj != null && obj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
...@@ -308,6 +271,24 @@ public class OraOrderServiceImpl implements OraOrderService { ...@@ -308,6 +271,24 @@ public class OraOrderServiceImpl implements OraOrderService {
} }
/** /**
* 通过高德地图获取经纬度
* @param sysOrder
*/
private void getLongitudeAndLatitude(SysOrder sysOrder){
String district = sysAreaMapper.getFullAreaByDistrictId(sysOrder.getDistrict());
StringBuffer buffer = new StringBuffer(district).append(sysOrder.getAddress());
String detailAddress = buffer.toString();
logger.info("工单详细地址{}通过高德地图获取经纬度", detailAddress);
//调用高德地图接口,解析拿到所在地方的区行政编码
Map<String, String> map = AMapUtils.parseAddress(detailAddress);
if (!map.isEmpty()) {
// Integer district = Integer.parseInt(map.get("adcode"));
sysOrder.setLongitude(map.get("longitude"));
sysOrder.setLatitude(map.get("latitude"));
}
}
/**
* 插入订单类型处理 * 插入订单类型处理
* 包活干V1.9.0只支持安装单 * 包活干V1.9.0只支持安装单
* *
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!