puzhibing
2023-08-01 98bc380ae322eaac2ee7e21d0c565e30eacce2b5
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
package com.stylefeng.guns.modular.api;
 
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IOrderEvaluateService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper;
import com.stylefeng.guns.modular.system.warpper.OrderEvaluateWarpper;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
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("")
public class DriverController {
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private IOrderEvaluateService orderEvaluateService;
 
 
 
 
 
 
    /**
     * 获取5公里范围内空闲司机数量
     * @param type 业务类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     * @return
     */
    @ResponseBody
    @PostMapping("/base/driver/queryIdleDriver")
    @ApiOperation(value = "获取5公里范围内空闲司机数量", tags = {"用户端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "业务类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "乘客当前定位经度", name = "lon", required = true, dataType = "double"),
            @ApiImplicitParam(value = "乘客当前定位纬度", name = "lat", required = true, dataType = "double")
    })
    public ResultUtil<BaseWarpper> queryIdleDriver(Integer type, Double lon, Double lat){
        try {
            List<Driver> list = driverService.queryIdleDriver(type, lon, lat, 5D, null);
            BaseWarpper baseWarpper = new BaseWarpper();
            baseWarpper.setNumber(list.size());
            return ResultUtil.success(baseWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 获取司机详情
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/api/driver/queryDriverInfo")
    @ApiOperation(value = "获取司机详情", tags = {"用户端-订单相关"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "司机id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<DriverInfoWarpper> queryDriverInfo(Integer id){
        try {
            Map<String, Object> map = driverService.queryDriverInfo(id);
            String name = String.valueOf(map.get("name"));
            map.put("name", name.substring(0, 1) + "师傅");
            List<BaseWarpper> list = driverService.queryBusiness(id);
            map.put("list", list);
            return ResultUtil.success(DriverInfoWarpper.getDriverInfoWarpper(map));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 获取司机的历史评价
     * @param id
     * @param pageNum
     * @param size
     * @return
     */
    @ResponseBody
    @PostMapping("/api/driver/queryOrderEvaluate")
    @ApiOperation(value = "获取司机的历史评价", tags = {"用户端-订单相关"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "司机id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<OrderEvaluateWarpper>> queryOrderEvaluate(Integer id, Integer pageNum, Integer size){
        try {
            List<Map<String, Object>> list = orderEvaluateService.queryOrderEvaluate(id, pageNum, size);
            return ResultUtil.success(OrderEvaluateWarpper.getOrderEvaluateWarpper(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
}