|
@@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.gavaghan.geodesy.Ellipsoid;
|
|
|
import org.gavaghan.geodesy.GlobalCoordinates;
|
|
|
import org.joda.time.DateTime;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -771,9 +772,123 @@ public class PassengerApiController {
|
|
|
|
|
|
for (StationInfo stationInfo : stationInfos0) {
|
|
|
|
|
|
- RouteInfo routeInfo0 = routeInfoService.get(stationInfo.getRouteId());
|
|
|
+ NearbyStationDTO nearbyStationDTO = new NearbyStationDTO();
|
|
|
+ List<NearbyShiftDTO> nearbyShiftDTOList = new ArrayList<>();
|
|
|
|
|
|
- List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatus(stationInfo.getRouteId(), "1");
|
|
|
+ RouteInfo routeInfo = routeInfoService.get(stationInfo.getRouteId());
|
|
|
+
|
|
|
+ List<StationInfo> stationInfoList1 = stationInfoService.findByRouteIdAndClassify(routeInfo.getId(),1);
|
|
|
+ List<StationInfo> stationInfoList2 = stationInfoService.findByRouteIdAndClassify(routeInfo.getId(),3);
|
|
|
+ // List<StationInfo> stationInfoList1 = stationInfoService.findByRouteId(routeInfo.getId());
|
|
|
+
|
|
|
+ nearbyStationDTO.setStationName(stationInfo.getName());
|
|
|
+
|
|
|
+ for (int n = 0;n<2;n++){
|
|
|
+ String startStationId = stationInfoList1.get(0).getId();
|
|
|
+ String startStationName = stationInfoList1.get(0).getName();
|
|
|
+ String endStationId = stationInfoList2.get(0).getId();
|
|
|
+ String endStationName = stationInfoList2.get(0).getName();
|
|
|
+ if (n == 1){
|
|
|
+ startStationId = stationInfoList2.get(0).getId();
|
|
|
+ startStationName = stationInfoList2.get(0).getName();
|
|
|
+ endStationId = stationInfoList1.get(0).getId();
|
|
|
+ endStationName = stationInfoList1.get(0).getName();
|
|
|
+ }
|
|
|
+ NearbyShiftDTO nearbyShiftDTO = new NearbyShiftDTO();
|
|
|
+ String des = null;
|
|
|
+ nearbyShiftDTO.setRouteId(routeInfo.getId());
|
|
|
+ nearbyShiftDTO.setRouteName(routeInfo.getName());
|
|
|
+ nearbyShiftDTO.setStartStationName(startStationName);
|
|
|
+ nearbyShiftDTO.setStartStationId(startStationId);
|
|
|
+ nearbyShiftDTO.setEndStationName(endStationName);
|
|
|
+ nearbyShiftDTO.setEndStationId(endStationId);
|
|
|
+
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatusAndStartStationId(routeInfo.getId(),"1",nearbyShiftDTO.getStartStationId());
|
|
|
+ if (shiftInfoList.size() == 0){
|
|
|
+ des = "等待发车";
|
|
|
+ }else {
|
|
|
+
|
|
|
+ List<StationInfo> stationInfos = stationInfoService.findByRouteId(routeInfo.getId());
|
|
|
+
|
|
|
+
|
|
|
+ int dis = 0;
|
|
|
+ ShiftInfo shiftInfo0 = null;
|
|
|
+ for (ShiftInfo shiftInfo : shiftInfoList){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
|
|
|
+
|
|
|
+
|
|
|
+ //距离
|
|
|
+ GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
|
|
|
+ GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(latitude), Double.valueOf(longitude));
|
|
|
+
|
|
|
+ double meter1 = CommonUtil.getDistanceMeter(source, target, Ellipsoid.Sphere);
|
|
|
+
|
|
|
+ int intMeter = (new Double(meter1)).intValue();
|
|
|
+
|
|
|
+ if (dis == 0){
|
|
|
+ dis = intMeter;
|
|
|
+ shiftInfo0 = shiftInfo;
|
|
|
+ }else {
|
|
|
+ if (dis>intMeter){
|
|
|
+ dis = intMeter;
|
|
|
+ shiftInfo0 = shiftInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //当前站
|
|
|
+ StationInfo currentStation = stationInfoService.get(shiftInfo0.getCurrentStationId());
|
|
|
+
|
|
|
+ //班次当前站下标
|
|
|
+ int stationIndex = stationInfos.indexOf(currentStation);
|
|
|
+ //行人当前站
|
|
|
+ int personStationIndex = stationInfos.indexOf(stationInfo);
|
|
|
+
|
|
|
+ //判断顺行还是逆行
|
|
|
+ Boolean tmp = false;
|
|
|
+ if (shiftInfo0.getStartStationId().equals(stationInfos.get(0).getId())){
|
|
|
+ //顺行
|
|
|
+ tmp = true;
|
|
|
+ }
|
|
|
+ if (tmp){
|
|
|
+ if (personStationIndex > stationIndex){
|
|
|
+
|
|
|
+ int diff = personStationIndex - stationIndex;
|
|
|
+ des = diff + "站 "+ dis + "米";
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!tmp){
|
|
|
+ if (personStationIndex < stationIndex){
|
|
|
+ int diff = stationIndex - personStationIndex;
|
|
|
+ des = diff + "站 "+ dis + "米";
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (personStationIndex == stationIndex){
|
|
|
+ des = "已到站";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ nearbyShiftDTO.setDes(des);
|
|
|
+ nearbyShiftDTOList.add(nearbyShiftDTO);
|
|
|
+ }
|
|
|
+ nearbyStationDTO.setNearbyShiftDTOList(nearbyShiftDTOList);
|
|
|
+
|
|
|
+ nearbyStationDTOList.add(nearbyStationDTO);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatus(stationInfo.getRouteId(), "1");
|
|
|
if (shiftInfoList.size() > 0) {
|
|
|
NearbyStationDTO nearbyStationDTO = new NearbyStationDTO();
|
|
|
List<NearbyShiftDTO> nearbyShiftDTOList = new ArrayList<>();
|
|
@@ -888,7 +1003,7 @@ public class PassengerApiController {
|
|
|
nearbyStationDTOList.add(nearbyStationDTO);
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -907,6 +1022,54 @@ public class PassengerApiController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @PostMapping("routeShiftList")
|
|
|
+ @ApiOperation(value = "线路上的所有车列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "routeId", value = "线路id", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "startStationId", value = "开始站点id", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<List<RouteShiftDTO>> routeShiftList(String routeId,String startStationId) {
|
|
|
+ MessageResult<List<RouteShiftDTO>> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(routeId) || StringUtils.isBlank(startStationId)){
|
|
|
+ throw new Exception("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RouteShiftDTO> list = new ArrayList<>();
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatusAndStartStationId(routeId,"1",startStationId);
|
|
|
+
|
|
|
+ if (shiftInfoList.size()>0){
|
|
|
+ for (ShiftInfo shiftInfo : shiftInfoList){
|
|
|
+ RouteShiftDTO routeShiftDTO = new RouteShiftDTO();
|
|
|
+ BeanUtils.copyProperties(shiftInfo,routeShiftDTO);
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
|
|
|
+ routeShiftDTO.setLongitude(vehicleInfo.getLongitude());
|
|
|
+ routeShiftDTO.setLatitude(vehicleInfo.getLatitude());
|
|
|
+ list.add(routeShiftDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(list);
|
|
|
+ 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")
|
|
|
@ApiOperation(value = "乘客查询线路列表")
|
|
|
@ApiImplicitParams({
|