xuhy
2023-08-11 7a8c46e7acecf0a0275e36f27623ed44db7451fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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<List<BaseWarpper>> queryLineShiftDriver(Integer lineShiftId, String time, Integer lineShiftDriverId, Integer driverId){
        try {
            List<Map<String, Object>> 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<List<BaseWarpper>> queryNotInLineShiftDriver(Integer lineShiftId, String time){
        try {
            List<Map<String, Object>> 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<List<BaseWarpper>> queryReassignDriver(Integer reassignId, HttpServletRequest request){
        try {
            Integer uid = dispatchService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> 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<List<BaseWarpper>> queryAllDriver(HttpServletRequest request){
        try {
            Integer uid = dispatchService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> list = driverService.queryAllDriver(uid);
            return ResultUtil.success(BaseWarpper.getBaseWarppers(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}