|
@@ -952,6 +952,8 @@ public class PassengerApiController {
|
|
|
|
|
|
nearbyStationDTO.setStationId(stationInfo.getId());
|
|
nearbyStationDTO.setStationId(stationInfo.getId());
|
|
nearbyStationDTO.setStationName(stationInfo.getName());
|
|
nearbyStationDTO.setStationName(stationInfo.getName());
|
|
|
|
+ nearbyStationDTO.setLatitude(stationInfo.getLatitude());
|
|
|
|
+ nearbyStationDTO.setLongitude(stationInfo.getLongitude());
|
|
|
|
|
|
for (int n = 0; n < 2; n++) {
|
|
for (int n = 0; n < 2; n++) {
|
|
String startStationId = stationInfoList1.get(0).getId();
|
|
String startStationId = stationInfoList1.get(0).getId();
|
|
@@ -1128,6 +1130,103 @@ public class PassengerApiController {
|
|
return messageResult;
|
|
return messageResult;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @PostMapping("vehicleStationDis")
|
|
|
|
+ @ApiOperation(value = "站点车辆距离")
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "routeId", value = "线路id", required = true, paramType = "form"),
|
|
|
|
+ @ApiImplicitParam(name = "startStationId", value = "开始站点id", required = true, paramType = "form"),
|
|
|
|
+ @ApiImplicitParam(name = "currentStationId", value = "当前站点id", required = true, paramType = "form")
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<String> vehicleStationDis(String routeId, String startStationId,String currentStationId) {
|
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(routeId) || StringUtils.isBlank(startStationId)) {
|
|
|
|
+ throw new Exception("参数错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeId);
|
|
|
|
+ //是否顺路
|
|
|
|
+ Boolean tmp = true;
|
|
|
|
+ if (!startStationId.equals(stationInfoList.get(0).getId())){
|
|
|
|
+ tmp = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatusAndStartStationId(routeId,"1",startStationId);
|
|
|
|
+ //查询的当前站
|
|
|
|
+ StationInfo currentStation = stationInfoService.get(currentStationId);
|
|
|
|
+
|
|
|
|
+ String des = null;
|
|
|
|
+ if (shiftInfoList.size()>0){
|
|
|
|
+ String vehicleId = "";
|
|
|
|
+ int n = 1000;
|
|
|
|
+ for (ShiftInfo shiftInfo : shiftInfoList){
|
|
|
|
+ //班次当前站
|
|
|
|
+ StationInfo stationInfo = stationInfoService.get(shiftInfo.getCurrentStationId());
|
|
|
|
+ int stationInfoIndex = stationInfoList.indexOf(stationInfo);
|
|
|
|
+
|
|
|
|
+ int currentStationIndex = stationInfoList.indexOf(currentStation);
|
|
|
|
+ if (tmp){
|
|
|
|
+ if (stationInfoIndex<=currentStationIndex){
|
|
|
|
+ int m = currentStationIndex - stationInfoIndex;
|
|
|
|
+ if (m<n){
|
|
|
|
+ n = m;
|
|
|
|
+ vehicleId = shiftInfo.getVehicleId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (!tmp){
|
|
|
|
+ if (stationInfoIndex >= currentStationIndex){
|
|
|
|
+ int m = stationInfoIndex - currentStationIndex;
|
|
|
|
+ if (m<n){
|
|
|
|
+ n = m;
|
|
|
|
+ vehicleId = shiftInfo.getVehicleId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotBlank(vehicleId)){
|
|
|
|
+ //车辆
|
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
|
+ //距离
|
|
|
|
+ GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
|
|
|
|
+ GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(currentStation.getLatitude()), Double.valueOf(currentStation.getLongitude()));
|
|
|
|
+
|
|
|
|
+ double meter1 = CommonUtil.getDistanceMeter(source, target, Ellipsoid.Sphere);
|
|
|
|
+
|
|
|
|
+ int intMeter = (new Double(meter1)).intValue();
|
|
|
|
+ //距离详情
|
|
|
|
+ String distanceStr = null;
|
|
|
|
+ if (intMeter >= 1000) {
|
|
|
|
+ distanceStr = intMeter / 1000 + "公里";
|
|
|
|
+ } else {
|
|
|
|
+ distanceStr = intMeter + "米";
|
|
|
|
+ }
|
|
|
|
+ des = n + "站 "+ distanceStr;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ messageResult.setData(des);
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return messageResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
@PostMapping("routeList")
|
|
@PostMapping("routeList")
|
|
@ApiOperation(value = "乘客查询线路列表")
|
|
@ApiOperation(value = "乘客查询线路列表")
|