puzhibing
2023-03-15 79962435853baf5a28e08461f46a831fffa1a4b0
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
173
174
175
176
177
178
179
180
181
182
package com.stylefeng.guns.modular.crossCity.controller;
 
 
import com.stylefeng.guns.modular.crossCity.server.ILineService;
import com.stylefeng.guns.modular.crossCity.server.ILineShiftDriverService;
import com.stylefeng.guns.modular.crossCity.server.ILineSiteService;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
import com.stylefeng.guns.modular.crossCity.warpper.LineShiftWarpper;
import com.stylefeng.guns.modular.crossCity.warpper.LineWarpper;
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 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/line")
public class LineController {
 
    @Autowired
    private ILineService lineService;
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private ILineSiteService lineSiteService;
 
    @Autowired
    private ILineShiftDriverService lineShiftDriverService;
 
    @Autowired
    private IOrderCrossCityService orderCrossCityService;
 
 
 
 
    /**
     * 获取司机对应的线路
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/scanCodeQueryLines", 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>> scanCodeQueryLines(HttpServletRequest request){
        try {
            Integer driverId = driverService.getUserIdFormRedis(request);
            if(null == driverId){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> list = lineService.scanCodeQueryLines(driverId);
            return ResultUtil.success(BaseWarpper.getBaseWarppers(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 根据选择的起点和终点获取线路
     * @param startId
     * @param endId
     * @param driverId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/queryLines", method = RequestMethod.POST)
    @ApiOperation(value = "根据选择的起点和终点获取线路", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "起始站点id", name = "startId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "终点站点id", name = "endId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "司机id", name = "driverId", required = false, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<LineWarpper>> queryLines(Integer startId, Integer endId, Integer driverId){
        try {
            List<Map<String, Object>> list = lineService.queryLines(startId, endId, driverId);
            return ResultUtil.success(LineWarpper.getLineWarppers(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 获取线路的班次数据
     * @param lineId
     * @param time
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/queryLineShiftInfo", method = RequestMethod.POST)
    @ApiOperation(value = "获取线路的班次数据", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "线路id", name = "lineId", 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<LineShiftWarpper>> queryLineShiftInfo(Integer lineId, String time, HttpServletRequest request){
        try {
            Integer driverId = driverService.getUserIdFormRedis(request);
            if(null == driverId){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> list = lineSiteService.queryLineShiftInfo(lineId, time, driverId);
            return ResultUtil.success(LineShiftWarpper.getLineShiftWarppers(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @RequestMapping(value = "/reservation", method = RequestMethod.POST)
    @ApiOperation(value = "预约/取消预约", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "操作类型(1=预约,2=取消预约)", name = "type", required = true, dataType = "int"),
            @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 reservation(Integer type, Integer lineShiftId, String time, HttpServletRequest request){
        try {
            Integer driverId = driverService.getUserIdFormRedis(request);
            if(null == driverId){
                return ResultUtil.tokenErr();
            }
            return lineShiftDriverService.reservation(type, lineShiftId, time, driverId);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    @ResponseBody
    @RequestMapping(value = "/queryOrderMoney", method = RequestMethod.POST)
    @ApiOperation(value = "获取跨城的支付金额", tags = {"司机端-首页"}, notes = "distance:距离数(米),price:支付金额")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "起点坐标(103.32123,30.6232)", name = "startLonLat", required = true, dataType = "int"),
            @ApiImplicitParam(value = "终点坐标(103.32123,30.6232)", name = "endLonLat", required = true, dataType = "int"),
            @ApiImplicitParam(value = "乘车人数", name = "peopleNumber", required = true, dataType = "int"),
            @ApiImplicitParam(value = "出行方式(1=拼车,2=包车)", name = "travelMode", required = true, dataType = "int"),
            @ApiImplicitParam(value = "线路id", name = "lineId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "车辆总座位数", name = "totalSeat", required = true, dataType = "int"),
            @ApiImplicitParam(value = "座位编号(1,3,4)", name = "seatNumber", required = true, dataType = "int")
    })
    public ResultUtil queryOrderMoney(String startLonLat, String endLonLat, Integer peopleNumber, Integer travelMode,
                                      Integer lineId, Integer serverCarModelId, Integer totalSeat, String seatNumber){
        try {
            return orderCrossCityService.queryOrderMoney(startLonLat, endLonLat, peopleNumber, travelMode, lineId, serverCarModelId, totalSeat, seatNumber);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}