| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<DriverActivityHistory> driverActivityHistories = driverActivityHistoryMapper.selectList(new EntityWrapper<DriverActivityHistory>().eq("driverId", driverId) |
| | | .eq("type", 3).eq("carryOut", 1).last(" and day = '" + sdf.format(new Date()) + "' and driverActivityId in (select id from t_driver_activity where status = 3 and now() between startTime and endTime)")); |
| | | if(!driverActivityHistories.isEmpty()){ |
| | | //如果一直属于上班中,则需要从任务开始时间计算时间 |
| | | Date insertTime = driverActivityHistories.get(0).getInsertTime(); |
| | | if(driverWork.getStartTime().getTime() < insertTime.getTime()){ |
| | | driverWork.setStartTime(insertTime); |
| | | } |
| | | } |
| | | //生成每个活动从开始上班到当前时间的时长记录 |
| | | for (DriverActivityHistory driverActivityHistory : driverActivityHistories) { |
| | | String value = redisUtil.getValue("driverActivity_" + driverId + "_" + driverActivityHistory.getId()); |
| | |
| | | continue; |
| | | } |
| | | Integer driverId = driverOnline.getDriverId(); |
| | | Driver driver1 = driverService.selectById(driverId); |
| | | long m = Double.valueOf(driverActivityOnline.getOfflineTime() * 3600000L).longValue(); |
| | | |
| | | //找出最后一次接单的时间 |
| | |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Process process = null; |
| | | try { |
| | | process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (process != null) { |
| | | process.destroy(); |
| | | // 使用Runtime执行命令 |
| | | Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName); |
| | | // 读取命令的输出 |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | } |
| | | // 等待命令执行完成 |
| | | process.waitFor(); |
| | | // 关闭流 |
| | | reader.close(); |
| | | } catch (IOException | InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }, 30000); |
| | |
| | | //在线时长累计 |
| | | Long time = jsonObject.getLong("time") / 60000; |
| | | int count1 = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", driverActivityHistory.getDriverId()) |
| | | .eq("isDelete", 1).ne("state", 10).last(" and UNIX_TIMESTAMP(snatchOrderTime) > " + (startTime) / 1000)); |
| | | .eq("isDelete", 1).ne("state", 10).last(" and UNIX_TIMESTAMP(snatchOrderTime) > " + (startTime / 1000))); |
| | | int count2 = orderLogisticsService.selectCount(new EntityWrapper<OrderLogistics>().eq("driverId", driverActivityHistory.getDriverId()) |
| | | .eq("isDelete", 1).ne("state", 10).last(" and UNIX_TIMESTAMP(snatchOrderTime) > " + (startTime) / 1000)); |
| | | .eq("isDelete", 1).ne("state", 10).last(" and UNIX_TIMESTAMP(snatchOrderTime) > " + (startTime / 1000))); |
| | | |
| | | Driver driver = driverService.selectById(driverWork.getDriverId()); |
| | | //阶段时间累计时长超过设定时长且没有接单,不计入累计总时长(司机服务中不下班) |
| | | if(m <= time && count1 + count2 == 0 && driver.getState() != 3){ |
| | | if(m <= time && (count1 + count2) == 0){ |
| | | //司机下班,清空当前阶段的累计时长 |
| | | driverWork.setState(2); |
| | | driverWork.setEndTime(new Date()); |
| | |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Process process = null; |
| | | try { |
| | | process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (process != null) { |
| | | process.destroy(); |
| | | // 使用Runtime执行命令 |
| | | Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName); |
| | | // 读取命令的输出 |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | } |
| | | // 等待命令执行完成 |
| | | process.waitFor(); |
| | | // 关闭流 |
| | | reader.close(); |
| | | } catch (IOException | InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }, 30000); |
| | | } |
| | | //阶段时间累计有新的订单,计入累计总时长,重置新的开始统计时间戳 |
| | | if(m <= time && count1 + count2 > 0){ |
| | | } else if(m <= time && (count1 + count2) > 0){ |
| | | //阶段时间累计有新的订单,计入累计总时长,重置新的开始统计时间戳 |
| | | DriverOnline driverOnline = this.selectOne(new EntityWrapper<DriverOnline>().eq("DATE_FORMAT(date, '%Y-%m-%d')", sdf.format(new Date())) |
| | | .eq("driverId", driverActivityHistory.getDriverId())); |
| | | if(null == driverOnline){ |