浏览代码

1.站点经纬度编辑界面中可以修改入口经纬度。
2.站点入口只与站点及方向绑定。
3.开班时,增加方法判断当前车辆是在起始站还是终点站附近,自动设置换向。

zhengqiang 4 年之前
父节点
当前提交
0902a397ff

+ 2 - 2
web/src/main/java/com/jpsoft/bus/modules/bus/controller/RouteInfoController.java

@@ -194,8 +194,8 @@ public class RouteInfoController {
                         stationInfoDTO.setLocation(stationInfo.getLongitude()+","+stationInfo.getLatitude());
                     }
 
-                    stationInfoDTO.setClassify(stationInfo.getClassify().toString());
-                    String classifyName = dataDictionaryService.findNameByCatalogNameAndValue("站点类型",stationInfo.getClassify().toString());
+                    stationInfoDTO.setClassify(String.valueOf(stationInfo.getClassify()));
+                    String classifyName = dataDictionaryService.findNameByCatalogNameAndValue("站点类型",String.valueOf(stationInfo.getClassify()));
                     stationInfoDTO.setClassifyName(classifyName);
                     stationInfoDTO.setRouteId(stationInfo.getRouteId());
                     stationInfoDTO.setRadius(stationInfo.getRadius());

+ 48 - 57
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -26,6 +26,8 @@ import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.bouncycastle.crypto.signers.ECDSASigner;
+import org.gavaghan.geodesy.Ellipsoid;
+import org.gavaghan.geodesy.GlobalCoordinates;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -375,6 +377,52 @@ public class DriverApiController {
 
         return messageResult;
     }
+    
+    @GetMapping("queryDirection")
+    @ApiOperation(value="查询方向")
+    public MessageResult<String> queryDirection(@RequestAttribute String subject){
+        MessageResult<String> messageResult = new MessageResult<>();
+    
+        try {
+            String direction = null;
+
+            VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
+
+            RouteInfo routeInfo = routeInfoService.get(vehicleInfo.getRouteId());
+
+            List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeInfo.getId());
+
+            if (stationInfoList.size()>1) {
+                StationInfo firstStation = stationInfoList.get(0);
+                StationInfo lastStation = stationInfoList.get(stationInfoList.size() - 1);
+
+                //查询当前车辆与起点和终点的距离那个更近
+                GlobalCoordinates vehiclePos = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
+                GlobalCoordinates firstPos = new GlobalCoordinates(Double.valueOf(firstStation.getLatitude()), Double.valueOf(firstStation.getLongitude()));
+                GlobalCoordinates lastPos = new GlobalCoordinates(Double.valueOf(lastStation.getLatitude()), Double.valueOf(lastStation.getLongitude()));
+
+                double meter1 = CommonUtil.getDistanceMeter(vehiclePos, firstPos, Ellipsoid.Sphere);
+                double meter2 = CommonUtil.getDistanceMeter(vehiclePos, lastPos, Ellipsoid.Sphere);
+
+                direction = meter1 <= meter2 ? "1" : "2";
+            }
+            else{
+                direction = "1";
+            }
+
+            //todo 填写具体代码
+            messageResult.setData(direction);
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+    
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+    
+        return messageResult;
+    }
 
     @PostMapping("createShift")
     @ApiOperation(value = "开班")
@@ -1295,15 +1343,6 @@ public class DriverApiController {
             //收班
             shiftInfoService.finishShift(shiftInfo);
 
-
-
-            /*shiftInfo.setStatus("2");
-            shiftInfo.setFinishTime(new Date());
-            shiftInfo.setUpdateTime(new Date());
-            shiftInfo.setUpdateBy(subject);
-
-            shiftInfoService.update(shiftInfo);*/
-
             //todo 填写具体代码
             messageResult.setData(shiftInfo.getFinishTime());
             messageResult.setResult(true);
@@ -1343,54 +1382,6 @@ public class DriverApiController {
 
             Map<String,Object> dataMap = PojoUtils.pageWrapper(page);
 
-//            List<Map> mapList = new ArrayList<>();
-//
-//            VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
-//
-//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-//
-//            for (ShiftInfo shiftInfo : page.getResult()) {
-//                Map<String,Object> map = new HashMap<>();
-//
-//                //查询司机、线路、车牌、起始站、终点站、开班时间、收班时间
-//                DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
-//                RouteInfo routeInfo = routeInfoService.get(shiftInfo.getRouteId());
-//                //起始站
-//                StationInfo startStation = stationInfoService.get(shiftInfo.getStartStationId());
-//                //终点站
-//                StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
-//
-//                if (driverInfo!=null){
-//                    map.put("driverName", driverInfo.getName());
-//                }
-//
-//                if (routeInfo!=null) {
-//                    map.put("routeName", routeInfo.getName());
-//                }
-//
-//                map.put("licensePlateNumber", vehicleInfo.getLicensePlateNumber());
-//
-//                if (startStation!=null){
-//                    map.put("startStationName", startStation.getName());
-//                }
-//
-//                if(endStation!=null) {
-//                    map.put("endStationName", endStation.getName());
-//                }
-//
-//                if (shiftInfo.getCreateTime()!=null){
-//                    map.put("createTime", sdf.format(shiftInfo.getCreateTime()));
-//                }
-//
-//                if (shiftInfo.getFinishTime()!=null){
-//                    map.put("finishTime", sdf.format(shiftInfo.getFinishTime()));
-//                }
-//
-//                mapList.add(map);
-//            }
-
-//            dataMap.put("data", mapList);
-
             messageResult.setData(dataMap);
 
             messageResult.setResult(true);