Commit e89e1dae by 张新旗
parents cc4348c3 e51c4966
...@@ -569,6 +569,8 @@ public class WeixinServiceImpl { ...@@ -569,6 +569,8 @@ public class WeixinServiceImpl {
if(StringUtils.isNotEmpty(lng)&&StringUtils.isNotEmpty(lat)){ if(StringUtils.isNotEmpty(lng)&&StringUtils.isNotEmpty(lat)){
String aa = AppServiceImpl.GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat())); String aa = AppServiceImpl.GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
shop1.setDistance(aa); shop1.setDistance(aa);
double realDistance = AppServiceImpl.GetRealDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
shop1.setRealDistance(realDistance);
}else{ }else{
shop1.setDistance("-1"); shop1.setDistance("-1");
} }
......
...@@ -87,6 +87,8 @@ public class Shop extends BaseEntity ...@@ -87,6 +87,8 @@ public class Shop extends BaseEntity
private String distance; private String distance;
private double realDistance;
private String machieStatus; private String machieStatus;
/** 创建时间 */ /** 创建时间 */
...@@ -293,6 +295,14 @@ public class Shop extends BaseEntity ...@@ -293,6 +295,14 @@ public class Shop extends BaseEntity
return isDefault; return isDefault;
} }
public double getRealDistance() {
return realDistance;
}
public void setRealDistance(double realDistance) {
this.realDistance = realDistance;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
...@@ -45,14 +45,7 @@ public class AppServiceImpl { ...@@ -45,14 +45,7 @@ public class AppServiceImpl {
*/ */
public static String GetDistance(double lng1, double lat1, double lng2, double lat2) public static String GetDistance(double lng1, double lat1, double lng2, double lat2)
{ {
double radLat1 = rad(lat1); double s = GetRealDistance(lng1, lat1, lng2, lat2);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
String distance = null; String distance = null;
if(s>1000&&s<10000){ if(s>1000&&s<10000){
DecimalFormat df = new DecimalFormat("######0.0"); DecimalFormat df = new DecimalFormat("######0.0");
...@@ -69,6 +62,18 @@ public class AppServiceImpl { ...@@ -69,6 +62,18 @@ public class AppServiceImpl {
return aDouble.intValue()+"m"; return aDouble.intValue()+"m";
} }
} }
public static double GetRealDistance(double lng1, double lat1, double lng2, double lat2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s;
}
private static double rad(double d) private static double rad(double d)
{ {
......
...@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isDeleted != null and isDeleted != ''"> and is_deleted = #{isDeleted}</if> <if test="isDeleted != null and isDeleted != ''"> and is_deleted = #{isDeleted}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
order by createdAt desc
</where> </where>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment