记得上下班打卡 | git大法好,push需谨慎

Commit 6fabec83 authored by jiangxiulong's avatar jiangxiulong

adam演出列表 计算距离

parent 385f27e6
......@@ -47,6 +47,8 @@ public class PerformanceVo {
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "场地距离当前位置距离")
private String diffDistance;
@ApiModelProperty(value = "搭售id")
private String projectId;
@ApiModelProperty(value = "巡演id")
......
......@@ -37,6 +37,13 @@
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!-- 计算经纬度距离 -->
<dependency>
<groupId>org.gavaghan</groupId>
<artifactId>geodesy</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -103,8 +103,12 @@ public class KylinPerformancesController {
@GetMapping("{performancesId}")
@ApiOperation("演出详情")
public ResponseDto<HashMap<String, Object>> detail(@PathVariable("performancesId") String performancesId) {
HashMap<String, Object> result = kylinPerformancesService.detail(performancesId);
public ResponseDto<HashMap<String, Object>> detail(
@PathVariable("performancesId") String performancesId,
@RequestParam("latitudeFrom") Double latitudeFrom,
@RequestParam("longitudeFrom") Double longitudeFrom
) {
HashMap<String, Object> result = kylinPerformancesService.detail(performancesId, latitudeFrom, longitudeFrom);
if (result.size() > 0) {
return ResponseDto.success(result);
} else {
......
......@@ -11,6 +11,9 @@ import com.liquidnet.service.kylin.mapper.KylinPerformancesMapper;
import com.liquidnet.service.kylin.service.IKylinPerformancesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.bson.Document;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -174,7 +177,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
return recommendList;
}
public HashMap<String, Object> detail(String performancesId) {
public HashMap<String, Object> detail(String performancesId, double latitudeFrom, double longitudeFrom) {
HashMap<String, Object> info = new HashMap<>();
PerformanceVo performancesInfo = (PerformanceVo) redisUtil.hget(KylinRedisConst.PERFORMANCES, performancesId);
......@@ -226,6 +229,33 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
}
performancesInfo.setMessage(KylinPerformanceStatusEnum.getName(performancesInfo.getAppStatus()));
// 处理距离
GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom);
GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(performancesInfo.getLatitude()), Double.valueOf(performancesInfo.getLongitude()));
double diffDistanceDouble = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, source, target).getEllipsoidalDistance();
int diffDistanceInt = (int) diffDistanceDouble;
String diffDistance;
if (diffDistanceInt > 1000) {
diffDistanceInt = diffDistanceInt / 1000;
diffDistance = String.valueOf(diffDistanceInt) + "km";
} else {
diffDistance = String.valueOf(diffDistanceInt) + "m";
}
performancesInfo.setDiffDistance(diffDistance);
for (PerformanceVo road : roadList) {
GlobalCoordinates targetRoad = new GlobalCoordinates(Double.valueOf(road.getLatitude()), Double.valueOf(road.getLongitude()));
double diffDistanceDoubleRoad = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, source, targetRoad).getEllipsoidalDistance();
int diffDistanceIntRoad = (int) diffDistanceDoubleRoad;
String diffDistanceRoad;
if (diffDistanceIntRoad > 1000) {
diffDistanceIntRoad = diffDistanceIntRoad / 1000;
diffDistanceRoad = String.valueOf(diffDistanceIntRoad) + "km";
} else {
diffDistanceRoad = String.valueOf(diffDistanceIntRoad) + "m";
}
road.setDiffDistance(diffDistanceRoad);
}
info.put("performancesInfo", performancesInfo);
info.put("roadList", roadList);
......
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