| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.DriverWorkMapper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.DriverWork; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverWorkService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | |
| | |
| | | private JGPushUtil jgPushUtil; |
| | | |
| | | public Set<Integer> driverIds = new HashSet<>();//存储需要提醒司机预约单的司机id |
| | | @Autowired |
| | | private DriverWorkMapper driverWorkMapper; |
| | | |
| | | @Autowired |
| | | private IDriverWorkService driverWorkService; |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | |
| | | /** |
| | |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void taskMinute(){ |
| | | try { |
| | | |
| | | //修改满足活动条件的数据(在线时长,订单量) |
| | | driverService.taskMinute(); |
| | | // driverService.taskMinute(); |
| | | // 处理车载端断电后的自动下班 |
| | | // driverService.taskOffWork(); |
| | | // 处理结束订单后30分钟解绑小号功能 |
| | |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void taskMinute2(){ |
| | | try { |
| | | updateDriverState(); |
| | | //处于预约单 |
| | | orderService.reservationOrder(); |
| | | } catch (Exception e) { |
| | |
| | | try { |
| | | //处理未支付订单发送短信通知 |
| | | orderService.taskSmsSend(); |
| | | for (Integer id: driverIds){ |
| | | // for (Integer id: driverIds){ |
| | | // jgPushUtil.push(1, "您的预约订单出行时间就要到了,请尽快前往预约地点接乘客", "DRIVER" + id); |
| | | } |
| | | // } |
| | | this.driverIds.clear(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | private void updateDriverState(){ |
| | | List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("authState", 2).ne("flag", 3)); |
| | | for (Driver driver : drivers) { |
| | | Integer state = driver.getState(); |
| | | int driverWork = driverWorkService.selectCount(new EntityWrapper<DriverWork>().eq("driverId", driver.getId()).eq("state", 1)); |
| | | int count = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", driver.getId()) |
| | | .in("state", Arrays.asList(2, 3, 4, 5, 11)).eq("isDelete", 1).last(" and (orderType = 1 or (orderType = 2 and UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(NOW()) < 1800))")); |
| | | if(1 == state){ |
| | | if(count > 0){ |
| | | driver.setState(3); |
| | | } else if (count == 0 && driverWork > 0) { |
| | | driver.setState(2); |
| | | } |
| | | } |
| | | if(2 == state){ |
| | | if(count > 0){ |
| | | driver.setState(3); |
| | | } else if (0 == driverWork) { |
| | | driver.setState(1); |
| | | } |
| | | } |
| | | if(3 == state){ |
| | | if(count == 0 && driverWork > 0){ |
| | | driver.setState(2); |
| | | } |
| | | if (count == 0 && 0 == driverWork) { |
| | | driver.setState(1); |
| | | } |
| | | } |
| | | } |
| | | if(!drivers.isEmpty()){ |
| | | driverService.updateBatchById(drivers); |
| | | } |
| | | } |
| | | } |