Ver Fonte

增加获取班次信息接口。

zhengqiang há 4 anos atrás
pai
commit
cf084bc327

+ 84 - 4
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -525,28 +525,107 @@ public class DriverApiController {
         return messageResult;
     }
 
+    @PostMapping("shiftDetail")
+    @ApiOperation(value = "车辆班次信息")
+    public MessageResult<Map> shiftDetail(String shiftId, @RequestAttribute String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            ShiftInfo shiftInfo = shiftInfoService.get(shiftId);
+
+            if (shiftInfo == null){
+                throw new Exception("车辆没有相关班次信息");
+            }
+
+            VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
+
+            //始发站
+            StationInfo startStation = stationInfoService.get(shiftInfo.getStartStationId());
+
+            //终点站
+            StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
+
+            //当前站点
+            StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
+
+            //根据车辆当前坐标
+            StationStatusDTO stationStatusDTO = gpsService.queryStation(vehicleInfo.getId());
+
+            Map<String,Object> map = new HashMap<>();
+
+            DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
+
+            map.put("licensePlateNumber", vehicleInfo.getLicensePlateNumber());
+
+            if(driverInfo!=null) {
+                map.put("driverName", driverInfo.getName());
+            }
+
+            SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyy-MM-dd");
+            SimpleDateFormat hmFormat = new SimpleDateFormat("HH:mm");
+
+            map.put("date", ymdFormat.format(shiftInfo.getCreateTime()));
+            map.put("startTime", hmFormat.format(shiftInfo.getCreateTime()));
+
+            if (shiftInfo.getFinishTime()!=null){
+                map.put("finishTime", hmFormat.format(shiftInfo.getFinishTime()));
+            }
+
+            map.put("startStationId",startStation.getId());
+            map.put("startStationName",startStation.getName());
+            map.put("endStationId",endStation.getId());
+            map.put("endStationName",endStation.getName());
+
+            if(currentStation != null) {
+                map.put("currentStationId", currentStation.getId());
+                map.put("currentStationName", currentStation.getName());
+            }
+
+            map.put("nextStationId",stationStatusDTO.getNextStationId());
+            map.put("nextStationName",stationStatusDTO.getNextStationName());
+
+            RouteInfo routeInfo = routeInfoService.get(vehicleInfo.getRouteId());
+
+            if(routeInfo!=null){
+                map.put("routeName", routeInfo.getName());
+            }
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(),ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
     @PostMapping("busShiftInfo")
     @ApiOperation(value = "车辆班次信息")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "token", value = "令牌", paramType = "form"),
-            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+        @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
     })
-    public MessageResult<Map> busShiftInfo(String token, @RequestAttribute String subject) {
+    public MessageResult<Map> busShiftInfo(@RequestAttribute String subject) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
-
             VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
+
             if (vehicleInfo == null){
                 throw new Exception("当前车辆不存在");
             }
 
             List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
+
             if (shiftInfoList.size() == 0){
                 throw new Exception("车辆没有相关班次信息");
             }
 
             ShiftInfo shiftInfo = shiftInfoList.get(0);
+
             //始发站
             StationInfo startStation = stationInfoService.get(shiftInfo.getStartStationId());
             //终点站
@@ -559,6 +638,7 @@ public class DriverApiController {
             StationStatusDTO stationStatusDTO = gpsService.queryStation(vehicleInfo.getId());
 
             Map<String,Object> map = new HashMap<>();
+
             map.put("startStationId",startStation.getId());
             map.put("startStationName",startStation.getName());
             map.put("endStationId",endStation.getId());