Commit 09765eb9 by zhengxj

finish 获取两点间距离 on 20191011 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24189 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent c4783bc7
...@@ -96,6 +96,11 @@ ...@@ -96,6 +96,11 @@
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
<version>2.0.6.RELEASE</version> <version>2.0.6.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.gavaghan</groupId>
<artifactId>geodesy</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -4,6 +4,10 @@ import java.util.HashMap; ...@@ -4,6 +4,10 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -29,13 +33,15 @@ public class AMapUtils { ...@@ -29,13 +33,15 @@ public class AMapUtils {
public static final String GEOCODES_URL = "https://restapi.amap.com/v3/geocode/geo"; public static final String GEOCODES_URL = "https://restapi.amap.com/v3/geocode/geo";
public static Integer getDistrictCodeByAddress(String address) {
Integer district = null; public static Map<String, String> parseAddress(String address) {
Map<String, String> map = new HashMap<String, String>(4);
String key = PropertiesUtil.getProperty(Constants.AMAP_USER_KEY); String key = PropertiesUtil.getProperty(Constants.AMAP_USER_KEY);
//String key = "4d8b3b5fc398f2f79f4329b5d07732fb"; // String key = "4d8b3b5fc398f2f79f4329b5d07732fb";
Map<String ,String> params = new HashMap<String, String>(); Map<String ,String> params = new HashMap<String, String>();
params.put("address", address); params.put("address", address);
params.put("key", key); params.put("key", key);
try { try {
String result = HttpUtils.get(GEOCODES_URL, params); String result = HttpUtils.get(GEOCODES_URL, params);
logger.info("获取高德行政编码返回结果:" + result); logger.info("获取高德行政编码返回结果:" + result);
...@@ -45,8 +51,12 @@ public class AMapUtils { ...@@ -45,8 +51,12 @@ public class AMapUtils {
int status = json.getIntValue("status"); int status = json.getIntValue("status");
if (status == 1) { if (status == 1) {
JSONArray geocodes = json.getJSONArray("geocodes"); JSONArray geocodes = json.getJSONArray("geocodes");
JSONObject geocode = geocodes.getJSONObject(0); JSONObject geocode = geocodes.getJSONObject(0);
district = geocode.getInteger("adcode"); map.put("adcode", geocode.getString("adcode"));
String location = geocode.getString("location");
map.put("latitude", location.substring(0, location.indexOf(",")));
map.put("longitude", location.substring(location.indexOf(",") + 1, location.length()));
} }
} }
} }
...@@ -54,12 +64,34 @@ public class AMapUtils { ...@@ -54,12 +64,34 @@ public class AMapUtils {
// TODO Auto-generated catch block // TODO Auto-generated catch block
logger.error("通过高德地图获取区域编码错误", e); logger.error("通过高德地图获取区域编码错误", e);
} }
return district; return map;
} }
public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo) {
// 创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离
GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, gpsFrom, gpsTo);
return geoCurve.getEllipsoidalDistance();
}
public static void main2(String[] args) {
GlobalCoordinates source = new GlobalCoordinates(22.573316, 113.975012);
GlobalCoordinates target = new GlobalCoordinates(22.554243, 113.950922);
double meter1 = getDistanceMeter(source, target);
// double meter2 = getDistanceMeter(source, target, Ellipsoid.WGS84);
// sphere坐标系与百度地图和高德地图较为接近
System.out.println("Sphere坐标系计算结果:" + meter1 + "米");
// System.out.println("WGS84坐标系计算结果:" + meter2 + "米");
}
public static void main(String[] args) { public static void main(String[] args) {
String address = "广东省深圳市南山区科兴科学园"; String address = "广东省深圳市南山区科兴科学园C3栋";
Integer district = getDistrictCodeByAddress(address); Map<String, String> map = parseAddress(address);
System.out.println("district="+district ); System.out.println("district=" + map);
} }
} }
...@@ -328,13 +328,14 @@ public class WechatUtils { ...@@ -328,13 +328,14 @@ public class WechatUtils {
String prefix = "data:image/png;base64,"; String prefix = "data:image/png;base64,";
String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID); String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID);
String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET); String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET);
// TODO 待前端开发技工注册的跳转页面
String page = "pages/index"; String page = "pages/index";
String accessToken = null; String accessToken = null;
try { try {
accessToken = this.getWechatToken(appid, secret); accessToken = this.getWechatToken(appid, secret);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block logger.error("获取小程序access_token请求异常!");
e.printStackTrace(); throw new RuntimeException(e);
} }
// 二维码存放路径 // 二维码存放路径
// String filePath = "C:/Users/wangqiulin/Desktop/1.png"; // String filePath = "C:/Users/wangqiulin/Desktop/1.png";
...@@ -343,50 +344,49 @@ public class WechatUtils { ...@@ -343,50 +344,49 @@ public class WechatUtils {
// InputStream inputStream = null; // InputStream inputStream = null;
// OutputStream outputStream = null; // OutputStream outputStream = null;
String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken); String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("scene", sceneStr); param.put("scene", sceneStr);
// param.put("page", page); param.put("page", page);
param.put("width", 430); param.put("width", 430);
param.put("auto_color", false); param.put("auto_color", false);
Map<String, Object> line_color = new HashMap<>(); Map<String, Object> line_color = new HashMap<>();
line_color.put("r", 0); line_color.put("r", 0);
line_color.put("g", 0); line_color.put("g", 0);
line_color.put("b", 0); line_color.put("b", 0);
param.put("line_color", line_color); param.put("line_color", line_color);
logger.info("调用生成微信URL接口传参:" + param); logger.info("调用生成微信URL接口传参:" + param);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
HttpEntity requestEntity = new HttpEntity(param, headers); HttpEntity requestEntity = new HttpEntity(param, headers);
ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
new Object[0]); logger.info("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody());
logger.info("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody()); byte[] result = entity.getBody();
byte[] result = entity.getBody();
String img = Base64.encodeBase64String(result);
String img = Base64.encodeBase64String(result);
if (img.startsWith("/9j/")) {
if (img.startsWith("/9j/")) { // 二维码生成成功
// 二维码生成成功 logger.info(Base64.encodeBase64String(result));
logger.info(Base64.encodeBase64String(result)); returnMap.put("img", prefix + img);
returnMap.put("img", prefix + img); returnMap.put("code", "200");
returnMap.put("code", "200");
}
}
// inputStream = new ByteArrayInputStream(result);
// inputStream = new ByteArrayInputStream(result); //
// // File file = new File(filePath);
// File file = new File(filePath); // if (!file.exists()) {
// if (!file.exists()) { // file.createNewFile();
// file.createNewFile(); // }
// } // outputStream = new FileOutputStream(file);
// outputStream = new FileOutputStream(file); // int len = 0;
// int len = 0; // byte[] buf = new byte[1024];
// byte[] buf = new byte[1024]; // while ((len = inputStream.read(buf, 0, 1024)) != -1) {
// while ((len = inputStream.read(buf, 0, 1024)) != -1) { // outputStream.write(buf, 0, len);
// outputStream.write(buf, 0, len); // }
// } // outputStream.flush();
// outputStream.flush();
logger.error("调用小程序生成微信永久小程序码URL接口异常!所传page页面不存在,或者小程序没有发布!");
logger.error("调用小程序生成微信永久小程序码URL接口异常");
// finally { // finally {
// if (inputStream != null) { // if (inputStream != null) {
......
...@@ -767,7 +767,7 @@ public class OrderController extends BaseController { ...@@ -767,7 +767,7 @@ public class OrderController extends BaseController {
* *
* *
* @author Zheng Xiajun * @author Zheng Xiajun
* @Title: getCount * @Title: getCountByStatus
* @Description: 根据订单状态统计单量 * @Description: 根据订单状态统计单量
* @param @param * @param @param
* request * request
...@@ -784,4 +784,35 @@ public class OrderController extends BaseController { ...@@ -784,4 +784,35 @@ public class OrderController extends BaseController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
orderService.countByOrderStatusAndUserType(oueryOrderReq)); orderService.countByOrderStatusAndUserType(oueryOrderReq));
} }
/**
*
*
* @author Zheng Xiajun
* @Title: getMechanicList
* @Description: 订单管理--指派/改派技工页面--技工列表
* @param @param
* request
* @param @param
* id 订单id
* @param @param
* merchantId 服务商id
* @param @param
* orderBy 排序字段
* @param @return
* 设定文件
* @return ResultObject 返回类型
*
*/
@AuthCheck
@RequestMapping(value = "/getMechanicListBySpId", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getMechanicList(HttpServletRequest request, @RequestParam(required = true) Integer id,
@RequestParam(required = true) Integer merchantId, Integer district, String orderBy) {
// orderBy:c按单量排序,d按距离排序,t按时效排序
return null;
}
} }
package com.glsx.ordercenter.dto; package com.glsx.ordercenter.dto;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @author duanht * @author duanht
...@@ -27,6 +28,16 @@ public class MechanicBusiness implements Serializable { ...@@ -27,6 +28,16 @@ public class MechanicBusiness implements Serializable {
*/ */
private String name; private String name;
/**
* 手机号
*/
private String phone;
/**
* 手机号
*/
private String address;
/** /**
*技工单量 *技工单量
*/ */
...@@ -37,6 +48,16 @@ public class MechanicBusiness implements Serializable { ...@@ -37,6 +48,16 @@ public class MechanicBusiness implements Serializable {
*/ */
private Double rise; private Double rise;
/**
* 距离幅
*/
private String distance;
/**
* 时效
*/
private String timeliness;
public Integer getMechanicId() { public Integer getMechanicId() {
return mechanicId; return mechanicId;
} }
...@@ -68,4 +89,37 @@ public class MechanicBusiness implements Serializable { ...@@ -68,4 +89,37 @@ public class MechanicBusiness implements Serializable {
public void setRise(Double rise) { public void setRise(Double rise) {
this.rise = rise; this.rise = rise;
} }
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
public String getTimeliness() {
return timeliness;
}
public void setTimeliness(String timeliness) {
this.timeliness = timeliness;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
} }
...@@ -263,7 +263,7 @@ public class StandardOrderServiceImpl implements StandardOrderService { ...@@ -263,7 +263,7 @@ public class StandardOrderServiceImpl implements StandardOrderService {
*/ */
if (org.springframework.util.StringUtils.isEmpty(district)) { if (org.springframework.util.StringUtils.isEmpty(district)) {
try { try {
district = AMapUtils.getDistrictCodeByAddress(address); district = Integer.parseInt(AMapUtils.parseAddress(address).get("adcode"));
} catch (Exception e) { } catch (Exception e) {
logger.error("渠道派单,调用高德地图接口,解析拿到所在地方的区行政编码错误", e); logger.error("渠道派单,调用高德地图接口,解析拿到所在地方的区行政编码错误", e);
district = -1; district = -1;
...@@ -447,7 +447,7 @@ public class StandardOrderServiceImpl implements StandardOrderService { ...@@ -447,7 +447,7 @@ public class StandardOrderServiceImpl implements StandardOrderService {
*/ */
if (org.springframework.util.StringUtils.isEmpty(district)) { if (org.springframework.util.StringUtils.isEmpty(district)) {
try { try {
district = AMapUtils.getDistrictCodeByAddress(address); district = Integer.parseInt(AMapUtils.parseAddress(address).get("adcode"));
} catch (Exception e) { } catch (Exception e) {
logger.error("渠道修改单,调用高德地图接口,解析拿到所在地方的区行政编码错误", e); logger.error("渠道修改单,调用高德地图接口,解析拿到所在地方的区行政编码错误", e);
district = -1; district = -1;
......
...@@ -1165,6 +1165,7 @@ ...@@ -1165,6 +1165,7 @@
select select
DISTINCT DISTINCT
so.id id, so.id id,
so.district district,
so.order_sn orderSn, so.order_sn orderSn,
so.active_status activeStatus, so.active_status activeStatus,
so.canceled canceled, so.canceled canceled,
...@@ -1387,7 +1388,6 @@ ...@@ -1387,7 +1388,6 @@
<when test="orderStatus != null and orderStatus==20"> <when test="orderStatus != null and orderStatus==20">
and so.canceled = 0 and so.canceled = 0
</when> </when>
<when test="orderStatus != null and orderStatus<20"> <when test="orderStatus != null and orderStatus<20">
and so.active_status = #{orderStatus} and so.active_status = #{orderStatus}
and so.canceled = 1 and so.canceled = 1
...@@ -1629,8 +1629,7 @@ ...@@ -1629,8 +1629,7 @@
</choose> </choose>
</otherwise> </otherwise>
</choose> </choose>
and so.order_type != 4 and so.order_type != 4
order by so.create_time desc
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!