| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverWorkMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.model.DriverWork; |
| | | import com.supersavedriving.driver.modular.system.model.OrderTransfer; |
| | | import com.supersavedriving.driver.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverWorkService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IOrderTransferService orderTransferService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | driverWork.setWorkTime(new Date()); |
| | | driverWork.setOnlineTime(0L); |
| | | driverWork.setStatus(1); |
| | | this.updateById(driverWork); |
| | | this.insert(driverWork); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil driverOffWork(Integer driverId, Long onlineTime) throws Exception { |
| | | DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", 1).eq("status", 2)); |
| | | if(null != driverWork){ |
| | | return ResultUtil.error("您已下班,不能重复操作"); |
| | | } |
| | | driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", 1).eq("status", 1)); |
| | | DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driverId).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("您还未上班"); |
| | | } |
| | | driverWork.setOffWorkTime(new Date()); |
| | | driverWork.setOnlineTime(onlineTime); |
| | | driverWork.setOnlineTime(0L); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | Integer online = Integer.valueOf(value.split("_")[0]); |
| | | driverWork.setOnlineTime(online.longValue()); |
| | | } |
| | | driverWork.setStatus(2); |
| | | this.updateById(driverWork); |
| | | return ResultUtil.success(); |