|
@@ -119,18 +119,18 @@ public class DriverApiController {
|
|
|
public MessageResult<DriverInfo> findByPhone(String phone){
|
|
|
|
|
|
MessageResult<DriverInfo> messageResult = new MessageResult<>();
|
|
|
- try{
|
|
|
|
|
|
+ try{
|
|
|
DriverInfo driverInfo = driverInfoService.findByPhone(phone);
|
|
|
|
|
|
-
|
|
|
if (driverInfo == null){
|
|
|
throw new Exception("司机不存在");
|
|
|
}
|
|
|
- List<ShiftInfo> shiftInfo = shiftInfoService.findByDriverIdAndStatus(driverInfo.getId(),"1");
|
|
|
- if (shiftInfo.size()>0){
|
|
|
- throw new Exception("此司机有正在运行的班次,请核对后输入");
|
|
|
- }
|
|
|
+
|
|
|
+// List<ShiftInfo> shiftInfo = shiftInfoService.findByDriverIdAndStatus(driverInfo.getId(),"1");
|
|
|
+// if (shiftInfo.size()>0){
|
|
|
+// throw new Exception("此司机有正在运行的班次,请核对后输入");
|
|
|
+// }
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
messageResult.setData(driverInfo);
|
|
@@ -185,6 +185,8 @@ public class DriverApiController {
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
|
}
|
|
@@ -229,30 +231,34 @@ public class DriverApiController {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
+
|
|
|
if (vehicleInfo == null){
|
|
|
throw new Exception("当前车辆不存在");
|
|
|
}
|
|
|
+
|
|
|
if (StringUtils.isBlank(vehicleInfo.getRouteId())){
|
|
|
throw new Exception("当前车辆还未分配线路");
|
|
|
}
|
|
|
+
|
|
|
RouteInfo routeInfo = routeInfoService.get(vehicleInfo.getRouteId());
|
|
|
+
|
|
|
if (routeInfo == null){
|
|
|
throw new Exception("线路错误");
|
|
|
}
|
|
|
+
|
|
|
//始发站
|
|
|
List<StationInfo> startStationInfoList = stationInfoService.findByRouteIdAndClassify(routeInfo.getId(),1);
|
|
|
if (startStationInfoList.size() != 1){
|
|
|
throw new Exception("线路的始发站配置错误");
|
|
|
}
|
|
|
+
|
|
|
//终点站
|
|
|
List<StationInfo> endStationInfoList = stationInfoService.findByRouteIdAndClassify(routeInfo.getId(),3);
|
|
|
if (endStationInfoList.size() != 1){
|
|
|
throw new Exception("线路的终点站配置错误");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("startStationId",startStationInfoList.get(0).getId());
|
|
|
map.put("startStationName",startStationInfoList.get(0).getName());
|
|
@@ -263,6 +269,7 @@ public class DriverApiController {
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
|
}
|
|
@@ -284,31 +291,43 @@ public class DriverApiController {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
+
|
|
|
if (vehicleInfo == null){
|
|
|
throw new Exception("当前车辆不存在");
|
|
|
}
|
|
|
+
|
|
|
DriverInfo driverInfo = driverInfoService.get(driverId);
|
|
|
+
|
|
|
if (driverInfo == null){
|
|
|
throw new Exception("司机不存在");
|
|
|
}
|
|
|
+
|
|
|
+ List<ShiftInfo> shiftInfo = shiftInfoService.findByDriverIdAndStatus(driverInfo.getId(),"1");
|
|
|
+
|
|
|
+ if (shiftInfo.size()>0){
|
|
|
+ throw new Exception("已有正在运行的班次!");
|
|
|
+ }
|
|
|
+
|
|
|
//始发站
|
|
|
StationInfo start = stationInfoService.get(startStationId);
|
|
|
+
|
|
|
//终点站
|
|
|
StationInfo end = stationInfoService.get(endStationId);
|
|
|
+
|
|
|
if (start == null || end == null){
|
|
|
throw new Exception("站点错误");
|
|
|
}
|
|
|
if (!start.getRouteId().equals(vehicleInfo.getRouteId()) || !end.getRouteId().equals(vehicleInfo.getRouteId())){
|
|
|
throw new Exception("站点错误");
|
|
|
}
|
|
|
- shiftInfoService.createShift(vehicleInfo,driverId,startStationId,endStationId);
|
|
|
|
|
|
+ shiftInfoService.createShift(vehicleInfo,driverId,startStationId,endStationId);
|
|
|
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
|
}
|
|
@@ -326,7 +345,6 @@ public class DriverApiController {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
if (vehicleInfo == null){
|
|
|
throw new Exception("当前车辆不存在");
|
|
@@ -352,8 +370,12 @@ public class DriverApiController {
|
|
|
map.put("startStationName",startStation.getName());
|
|
|
map.put("endStationId",endStation.getId());
|
|
|
map.put("endStationName",endStation.getName());
|
|
|
- map.put("currentStationId",currentStation.getId());
|
|
|
- map.put("currentStationName",currentStation.getName());
|
|
|
+
|
|
|
+ if(currentStation!=null) {
|
|
|
+ map.put("currentStationId", currentStation.getId());
|
|
|
+ map.put("currentStationName", currentStation.getName());
|
|
|
+ }
|
|
|
+
|
|
|
map.put("nextStationId",stationStatusDTO.getNextStationId());
|
|
|
map.put("nextStationName",stationStatusDTO.getNextStationName());
|
|
|
|
|
@@ -361,6 +383,7 @@ public class DriverApiController {
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
|
}
|