| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.stylefeng.guns.modular.crossCity.server.ILineShiftDriverService; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.DriverShiftListWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.LineShiftItemWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.ScanOrderDetailWarpper; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.SystemException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 【202601】城际专线排班控制器 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 【202604】获取司机城际专线排班列表 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/queryMyDriverShiftList") |
| | | @ApiOperation(value = "【202604】获取司机城际专线排班列表", tags = {"司机端-首页"}, notes = "获取司机在今天之后(包含今天)的城际专线排班信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "日期(yyyy-MM-dd),默认无", name = "date", required = false, dataType = "String"), |
| | | @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<LineShiftItemWarpper>> queryMyDriverShiftList(String date, int pageNum, int size, HttpServletRequest request) { |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<LineShiftItemWarpper> result = lineShiftDriverService.queryMyDriverShiftList(driverId, date, pageNum, size); |
| | | return ResultUtil.success(result); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 验证日期有效性 |
| | | * @param dateStr |
| | | * @return |
| | |
| | | * @return 班次列表 |
| | | */ |
| | | List<Map<String, Object>> queryDriverAvailableShifts(@Param("driverId") Integer driverId, @Param("date") String date); |
| | | |
| | | /** |
| | | * 【202604】查询司机本人已领取/被分配的排班列表(今天及之后) |
| | | * @param driverId 司机id |
| | | * @param startDate 开始日期(yyyy-MM-dd) |
| | | * @param offset 分页偏移量 |
| | | * @param size 每页条数 |
| | | * @return 排班列表 |
| | | */ |
| | | List<Map<String, Object>> queryMyDriverShiftList(@Param("driverId") Integer driverId, |
| | | @Param("startDate") String startDate, |
| | | @Param("offset") Integer offset, |
| | | @Param("size") Integer size); |
| | | } |
| | |
| | | <result column="laveSeatNumber" property="laveSeatNumber"/> |
| | | <result column="totalSeat" property="totalSeat"/> |
| | | <result column="inserTime" property="inserTime"/> |
| | | <result column="assignType" property="assignType"/> |
| | | </resultMap> |
| | | |
| | | |
| | |
| | | laveSeat as laveSeat, |
| | | laveSeatNumber as laveSeatNumber, |
| | | totalSeat as totalSeat, |
| | | inserTime as inserTime |
| | | inserTime as inserTime, |
| | | assignType as assignType |
| | | from t_line_shift_driver where 1 = 1 |
| | | <if test="null != driverId"> |
| | | and driverId = #{driverId} |
| | |
| | | WHERE dl.driverId = #{driverId} |
| | | ORDER BY lineCompletedCount DESC, l.id, ls.startTime |
| | | </select> |
| | | </mapper> |
| | | |
| | | <!-- 【202604】查询司机本人已领取/被分配的排班列表(今天及之后) --> |
| | | <select id="queryMyDriverShiftList" resultType="java.util.Map"> |
| | | SELECT |
| | | lsd.id as lineShiftDriverId, |
| | | lsd.lineShiftId as lineShiftId, |
| | | lsd.laveSeat as laveSeat, |
| | | lsd.totalSeat as totalSeat, |
| | | ls.startTime as startTime, |
| | | ls.endTime as endTime, |
| | | l.name as lineName, |
| | | IFNULL(lsd.assignType, 1) as assignType, |
| | | occ.orderId as orderId, |
| | | CASE WHEN occ.orderId IS NOT NULL THEN 3 ELSE NULL END as orderType, |
| | | DATE_FORMAT(lsd.day, '%Y-%m-%d') as day |
| | | FROM t_line_shift_driver lsd |
| | | LEFT JOIN t_line_shift ls ON lsd.lineShiftId = ls.id |
| | | LEFT JOIN t_line l ON ls.lineId = l.id |
| | | LEFT JOIN ( |
| | | SELECT lineShiftDriverId, MIN(id) AS orderId |
| | | FROM t_order_cross_city |
| | | GROUP BY lineShiftDriverId |
| | | ) occ ON occ.lineShiftDriverId = lsd.id |
| | | WHERE lsd.driverId = #{driverId} |
| | | <if test="startDate != null and startDate != ''"> |
| | | AND lsd.day = CAST(#{startDate} AS DATE) |
| | | </if> |
| | | <if test="startDate == null or startDate == ''"> |
| | | AND lsd.day >= CURDATE() |
| | | </if> |
| | | AND ls.state = 1 |
| | | AND l.state = 1 |
| | | ORDER BY lsd.day ASC, ls.startTime ASC, lsd.id ASC |
| | | LIMIT #{offset}, #{size} |
| | | </select> |
| | | </mapper> |
| | |
| | | */ |
| | | @TableField("inserTime") |
| | | private Date inserTime; |
| | | /** |
| | | * 排班来源(1=司机自领,2=手动排班) |
| | | */ |
| | | @TableField("assignType") |
| | | private Integer assignType; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | |
| | | this.inserTime = inserTime; |
| | | } |
| | | |
| | | public Integer getAssignType() { |
| | | return assignType; |
| | | } |
| | | |
| | | public void setAssignType(Integer assignType) { |
| | | this.assignType = assignType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "LineShiftDriver{" + |
| | |
| | | ", laveSeatNumber='" + laveSeatNumber + '\'' + |
| | | ", totalSeat=" + totalSeat + |
| | | ", inserTime=" + inserTime + |
| | | ", assignType=" + assignType + |
| | | '}'; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineShiftDriver; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.DriverShiftListWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.LineShiftItemWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.ScanOrderDetailWarpper; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ILineShiftDriverService extends IService<LineShiftDriver> { |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | DriverShiftListWarpper queryDriverShiftList(Integer driverId, String date) throws Exception; |
| | | |
| | | /** |
| | | * 【202604】查询司机本人已领取/被分配的排班列表(今天及之后) |
| | | * @param driverId 司机id |
| | | * @param date 日期(yyyy-MM-dd),为空查今天及之后,不为空查当天 |
| | | * @param pageNum 页码(首页1) |
| | | * @param size 每页条数 |
| | | * @return 排班列表 |
| | | * @throws Exception |
| | | */ |
| | | List<LineShiftItemWarpper> queryMyDriverShiftList(Integer driverId, String date, Integer pageNum, Integer size) throws Exception; |
| | | /** |
| | | * 【202601】查询班次详情 |
| | | * @param lineShiftDriverId 班次id |
| | |
| | | lineShiftDriver.setLaveSeatNumber(seatNumber.substring(0, seatNumber.length() - 1)); |
| | | lineShiftDriver.setTotalSeat(carModel.getSeat() - 1); |
| | | lineShiftDriver.setInserTime(new Date()); |
| | | lineShiftDriver.setAssignType(1); |
| | | lineShiftDriverMapper.insert(lineShiftDriver); |
| | | } |
| | | if(type == 2){//取消预约 |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 【202604】查询司机本人已领取/被分配的排班列表(今天及之后) |
| | | */ |
| | | @Override |
| | | public List<LineShiftItemWarpper> queryMyDriverShiftList(Integer driverId, String date, Integer pageNum, Integer size) throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); |
| | | |
| | | String today = sdf.format(new Date()); |
| | | String startDate = ToolUtil.isEmpty(date) ? null : date; |
| | | int safePageNum = (pageNum == null || pageNum < 1) ? 1 : pageNum; |
| | | int safeSize = (size == null || size < 1) ? 10 : size; |
| | | int offset = (safePageNum - 1) * safeSize; |
| | | |
| | | List<Map<String, Object>> rows = lineShiftDriverMapper.queryMyDriverShiftList(driverId, startDate, offset, safeSize); |
| | | List<LineShiftItemWarpper> result = new ArrayList<>(); |
| | | String currentTime = timeFormat.format(new Date()); |
| | | |
| | | for (Map<String, Object> row : rows) { |
| | | LineShiftItemWarpper item = new LineShiftItemWarpper(); |
| | | item.setLineShiftId(row.get("lineShiftId") == null ? null : Integer.valueOf(row.get("lineShiftId").toString())); |
| | | item.setLineShiftDriverId(row.get("lineShiftDriverId") == null ? null : Integer.valueOf(row.get("lineShiftDriverId").toString())); |
| | | item.setStartTime(row.get("startTime") == null ? "" : row.get("startTime").toString()); |
| | | item.setEndTime(row.get("endTime") == null ? "" : row.get("endTime").toString()); |
| | | item.setDay(row.get("day") == null ? "" : row.get("day").toString()); |
| | | item.setLaveSeat(row.get("laveSeat") == null ? 0 : Integer.valueOf(row.get("laveSeat").toString())); |
| | | item.setTotalSeat(row.get("totalSeat") == null ? 0 : Integer.valueOf(row.get("totalSeat").toString())); |
| | | item.setLineName(row.get("lineName") == null ? "" : row.get("lineName").toString()); |
| | | item.setAssignType(row.get("assignType") == null ? 1 : Integer.valueOf(row.get("assignType").toString())); |
| | | item.setOrderId(row.get("orderId") == null ? null : Integer.valueOf(row.get("orderId").toString())); |
| | | item.setOrderType(row.get("orderType") == null ? null : Integer.valueOf(row.get("orderType").toString())); |
| | | |
| | | String dayStr = row.get("day") == null ? today : row.get("day").toString(); |
| | | boolean isExpired = dayStr.equals(today) && currentTime.compareTo(item.getEndTime()) >= 0; |
| | | if (isExpired) { |
| | | item.setStatus(2); |
| | | item.setStatusText("已过期"); |
| | | item.setCanOperate(false); |
| | | } else { |
| | | item.setStatus(1); |
| | | item.setStatusText("已预约"); |
| | | item.setCanOperate(true); |
| | | } |
| | | result.add(item); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil<ScanOrderDetailWarpper> getDetail(Integer lineShiftDriverId) { |
| | | // 1. 查询基础数据 |
| | |
| | | private String startTime; |
| | | @ApiModelProperty("结束时间") |
| | | private String endTime; |
| | | @ApiModelProperty("排班日期(yyyy-MM-dd)") |
| | | private String day; |
| | | @ApiModelProperty("状态(1=已预约可操作, 2=已过期, 3=未预约)") |
| | | private Integer status; |
| | | @ApiModelProperty("状态文本") |
| | |
| | | private Integer laveSeat; |
| | | @ApiModelProperty("总座位") |
| | | private Integer totalSeat; |
| | | @ApiModelProperty("线路名称") |
| | | private String lineName; |
| | | @ApiModelProperty("排班来源(1=司机自领,2=手动排班)") |
| | | private Integer assignType; |
| | | @ApiModelProperty("关联订单id(任意一笔)") |
| | | private Integer orderId; |
| | | @ApiModelProperty("关联订单类型(固定3=城际)") |
| | | private Integer orderType; |
| | | |
| | | public Integer getLineShiftId() { |
| | | return lineShiftId; |
| | |
| | | |
| | | public void setEndTime(String endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public String getDay() { |
| | | return day; |
| | | } |
| | | |
| | | public void setDay(String day) { |
| | | this.day = day; |
| | | } |
| | | |
| | | public Integer getStatus() { |
| | |
| | | this.totalSeat = totalSeat; |
| | | } |
| | | |
| | | public String getLineName() { |
| | | return lineName; |
| | | } |
| | | |
| | | public void setLineName(String lineName) { |
| | | this.lineName = lineName; |
| | | } |
| | | |
| | | public Integer getAssignType() { |
| | | return assignType; |
| | | } |
| | | |
| | | public void setAssignType(Integer assignType) { |
| | | this.assignType = assignType; |
| | | } |
| | | |
| | | public Integer getOrderId() { |
| | | return orderId; |
| | | } |
| | | |
| | | public void setOrderId(Integer orderId) { |
| | | this.orderId = orderId; |
| | | } |
| | | |
| | | public Integer getOrderType() { |
| | | return orderType; |
| | | } |
| | | |
| | | public void setOrderType(Integer orderType) { |
| | | this.orderType = orderType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "LineShiftItemWarpper{" + |
| | |
| | | ", lineShiftDriverId=" + lineShiftDriverId + |
| | | ", startTime='" + startTime + '\'' + |
| | | ", endTime='" + endTime + '\'' + |
| | | ", day='" + day + '\'' + |
| | | ", status=" + status + |
| | | ", statusText='" + statusText + '\'' + |
| | | ", canOperate=" + canOperate + |
| | | ", laveSeat=" + laveSeat + |
| | | ", totalSeat=" + totalSeat + |
| | | ", lineName='" + lineName + '\'' + |
| | | ", assignType=" + assignType + |
| | | ", orderId=" + orderId + |
| | | ", orderType=" + orderType + |
| | | '}'; |
| | | } |
| | | |
| | |
| | | warpper.setLineShiftDriverId(null != map.get("lineShiftDriverId") ? Integer.valueOf(map.get("lineShiftDriverId").toString()) : null); |
| | | warpper.setStartTime(null != map.get("startTime") ? map.get("startTime").toString() : ""); |
| | | warpper.setEndTime(null != map.get("endTime") ? map.get("endTime").toString() : ""); |
| | | warpper.setDay(null != map.get("day") ? map.get("day").toString() : ""); |
| | | warpper.setStatus(null != map.get("status") ? Integer.valueOf(map.get("status").toString()) : 3); |
| | | warpper.setStatusText(null != map.get("statusText") ? map.get("statusText").toString() : ""); |
| | | warpper.setCanOperate(null != map.get("canOperate") ? Boolean.valueOf(map.get("canOperate").toString()) : false); |
| | | warpper.setLaveSeat(null != map.get("laveSeat") ? Integer.valueOf(map.get("laveSeat").toString()) : 0); |
| | | warpper.setTotalSeat(null != map.get("totalSeat") ? Integer.valueOf(map.get("totalSeat").toString()) : 0); |
| | | warpper.setLineName(null != map.get("lineName") ? map.get("lineName").toString() : ""); |
| | | warpper.setAssignType(null != map.get("assignType") ? Integer.valueOf(map.get("assignType").toString()) : 1); |
| | | warpper.setOrderId(null != map.get("orderId") ? Integer.valueOf(map.get("orderId").toString()) : null); |
| | | warpper.setOrderType(null != map.get("orderType") ? Integer.valueOf(map.get("orderType").toString()) : null); |
| | | } |
| | | return warpper; |
| | | } |