package com.stylefeng.guns.modular.api; import com.stylefeng.guns.modular.system.service.IDispatchService; import com.stylefeng.guns.modular.system.service.IDriverService; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.LineShiftWarpper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @Api @RestController @RequestMapping("/api/driver") public class DriverController { @Autowired private IDriverService driverService; @Autowired private IDispatchService dispatchService; /** * 获取排班管理中可更换的司机列表 * 1.司机必须预约了该班次, * 2.司机的剩余座位数必须班次订单总人数 * * @param lineShiftId * @param time * @param lineShiftDriverId * @param driverId * @return */ @ResponseBody @RequestMapping(value = "/queryLineShiftDriver", method = RequestMethod.POST) @ApiOperation(value = "获取可更换的司机列表", tags = {"调度端-排班管理"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "排班数据id", name = "lineShiftId", required = true, dataType = "int"), @ApiImplicitParam(value = "查询日期(2020-10-13)", name = "time", required = true, dataType = "string"), @ApiImplicitParam(value = "排班详情数据id", name = "lineShiftDriverId", required = true, dataType = "int"), @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryLineShiftDriver(Integer lineShiftId, String time, Integer lineShiftDriverId, Integer driverId){ try { List> list = driverService.queryLineShiftDriver(lineShiftId, time, lineShiftDriverId, driverId); return ResultUtil.success(BaseWarpper.getBaseWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取没有排班给定日期班次的司机 * @param lineShiftId * @param time * @return */ @ResponseBody @RequestMapping(value = "/queryNotInLineShiftDriver", method = RequestMethod.POST) @ApiOperation(value = "获取没有排班给定日期班次的司机", tags = {"调度端-排班管理"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "排班数据id", name = "lineShiftId", required = true, dataType = "int"), @ApiImplicitParam(value = "查询日期(2020-10-13)", name = "time", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryNotInLineShiftDriver(Integer lineShiftId, String time){ try { List> list = driverService.queryNotInLineShiftDriver(lineShiftId, time); return ResultUtil.success(BaseWarpper.getBaseWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 调度班次中添加司机操作 * @param lineShiftId * @param time * @param driverId * @return */ @ResponseBody @RequestMapping(value = "/addDriverForLineShift", method = RequestMethod.POST) @ApiOperation(value = "调度班次中添加司机操作", tags = {"调度端-排班管理"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "排班数据id", name = "lineShiftId", required = true, dataType = "int"), @ApiImplicitParam(value = "查询日期(2020-10-13)", name = "time", required = true, dataType = "string"), @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil addDriverForLineShift(Integer lineShiftId, String time, Integer driverId){ try { return driverService.addDriverForLineShift(lineShiftId, time, driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取改派可接单的司机列表 * @param reassignId * @param request * @return */ @ResponseBody @RequestMapping(value = "/queryReassignDriver", method = RequestMethod.POST) @ApiOperation(value = "获取改派可接单的司机列表", tags = {"调度端-新改派订单"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "改派订单id", name = "reassignId", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryReassignDriver(Integer reassignId, HttpServletRequest request){ try { Integer uid = dispatchService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryReassignDriver(reassignId, uid); return ResultUtil.success(BaseWarpper.getBaseWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取所以没有服务的司机列表 * @param request * @return */ @ResponseBody @RequestMapping(value = "/queryAllDriver", method = RequestMethod.POST) @ApiOperation(value = "获取所以没有服务的司机列表", tags = {"调度端-车辆管理"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryAllDriver(HttpServletRequest request){ try { Integer uid = dispatchService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = driverService.queryAllDriver(uid); return ResultUtil.success(BaseWarpper.getBaseWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }