Pu Zhibing
2025-04-03 33ac3b8bf6683024784d9e3152732bc0d50472c3
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
package com.stylefeng.guns.modular.api;
 
import com.google.api.Http;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.*;
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.annotation.Resource;
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;
    
    @Resource
    private IUserInfoService userInfoService;
    
    @Autowired
    private ICompanyCityService companyCityService;
 
 
 
 
 
 
    /**
     * 获取5公里范围内空闲司机数量
     * @param type 业务类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     * @return
     */
    @ResponseBody
    @PostMapping("/base/driver/queryIdleDriver")
    @ApiOperation(value = "获取5公里范围内空闲司机数量【1.0】", 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, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null != uid){
                UserInfo userInfo = userInfoService.selectById(uid);
                Company company = companyCityService.query1(uid, lon.toString(), lat.toString());
                if(null != userInfo && null != company){
                    System.err.println("-----更新用户所属公司-----lon:" + lon + "---lat:" + lat);
                    userInfo.setCompanyId(company.getId());
                    userInfoService.updateById(userInfo);
                }
            }
            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, Integer language){
        try {
            Map<String, Object> map = driverService.queryDriverInfo(id);
//            String name = String.valueOf(map.get("name"));
//            map.put("name", name.substring(0, 1) + (language == 1 ? "师傅" : language == 2 ? "driver" : "Le conducteur"));
            List<BaseWarpper> list = driverService.queryBusiness(id, language);
            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 language, Integer id, Integer pageNum, Integer size){
        try {
            List<Map<String, Object>> list = orderEvaluateService.queryOrderEvaluate(language, id, pageNum, size);
            return ResultUtil.success(OrderEvaluateWarpper.getOrderEvaluateWarpper(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
}