| | |
| | | package com.stylefeng.guns.modular.crossCity.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.SpringContextHolder; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineShiftMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineShift; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | 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.OrderCrossCityInfoWrapper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderWarpper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.Reassign; |
| | | import com.stylefeng.guns.modular.system.model.TDriverLine; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.service.TDriverLineService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.SystemException; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Api |
| | |
| | | |
| | | @Autowired |
| | | private IReassignService reassignService; |
| | | |
| | | @Autowired |
| | | private LineShiftMapper lineShiftMapper; |
| | | |
| | | @Autowired |
| | | private TDriverLineService driverLineService; |
| | | // |
| | | // @Autowired |
| | | // private ICBCPayUtil icbcPayUtil; |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | // @ResponseBody |
| | | // @PostMapping("/api/orderCrossCity/reassignOrderCrossCityReassign") |
| | | // @ApiOperation(value = "提交改派申请(跨城)", tags = {"司机端-服务中"}, notes = "") |
| | | // @ApiImplicitParams({ |
| | | // @ApiImplicitParam(value = "订单id(多个以逗号分隔)", name = "orderIds", required = true, dataType = "string"), |
| | | // @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"), |
| | | // @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"), |
| | | // @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), |
| | | // @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | // }) |
| | | // public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds, HttpServletRequest request){ |
| | | // try { |
| | | // Integer uid = driverService.getUserIdFormRedis(request); |
| | | // if(null == uid){ |
| | | // return ResultUtil.tokenErr(); |
| | | // } |
| | | // return reassignService.saveData_(reassign, orderIds, uid, null); |
| | | // }catch (SystemException s){ |
| | | // return ResultUtil.error(s.getMsg()); |
| | | // } catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | @ResponseBody |
| | | @PostMapping("/api/orderCrossCity/reassignOrderCrossCityReassign") |
| | | @ApiOperation(value = "提交改派申请(跨城)", tags = {"司机端-服务中"}, notes = "") |
| | |
| | | @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), |
| | | @ApiImplicitParam(value = "改派司机id", name = "newDriverId", required = false, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds, HttpServletRequest request){ |
| | | public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds,Integer newDriverId, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return reassignService.saveData_(reassign, orderIds, uid, null); |
| | | return reassignService.saveData_(reassign, orderIds, uid, null,newDriverId); |
| | | }catch (SystemException s){ |
| | | return ResultUtil.error(s.getMsg()); |
| | | } catch (Exception e){ |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | //获取同线路下的司机 |
| | | @ResponseBody |
| | | @PostMapping("/api/orderCrossCity/querySameLineDriver") |
| | | @ApiOperation(value = "获取同线路下的司机", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id(多个以逗号分隔)", name = "orderIds", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil< List<DriverInfoWarpper>> querySameLineDriver(String orderIds, HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | //获取线路id |
| | | String[] split = orderIds.split(","); |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(split[0]); |
| | | Integer lineId = orderCrossCity.getLineId(); |
| | | //查出该线路的司机 |
| | | EntityWrapper<TDriverLine> driverLineWrapper = new EntityWrapper<>(); |
| | | driverLineWrapper.eq("lineId", lineId); |
| | | List<TDriverLine> tDriverLines = driverLineService.selectList(driverLineWrapper); |
| | | List<Integer> driverIds = tDriverLines.stream() |
| | | .map(TDriverLine::getDriverid) |
| | | .filter(id -> !id.equals(driverId)) // 去掉当前司机 |
| | | .distinct() // 去重 |
| | | .collect(Collectors.toList()); |
| | | //获取司机及车辆信息 |
| | | List<Map<String, Object>> maps = driverService.queryDriversByIds(driverIds); |
| | | List<DriverInfoWarpper> driverInfoWarppers = new ArrayList<>(); |
| | | for (Map<String, Object> map : maps) { |
| | | DriverInfoWarpper driverInfoWarpper = DriverInfoWarpper.getDriverInfoWarpper(map); |
| | | driverInfoWarppers.add(driverInfoWarpper); |
| | | } |
| | | |
| | | return ResultUtil.success(driverInfoWarppers); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取已完成订单明细 |