| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.DispatchMapper; |
| | | import com.stylefeng.guns.modular.system.dao.ReassignMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.server.impl.OrderPrivateCarServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.apache.shiro.util.StringUtils; |
| | | import org.quartz.JobDataMap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | @Autowired |
| | | private IPushOrderService pushOrderService; |
| | | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | |
| | | @Autowired |
| | | private IOrderCrossCityService orderCrossCityService; |
| | |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private ICarService carService; |
| | | |
| | | @Resource |
| | | private ISysOvertimeService sysOvertimeService; |
| | | |
| | | @Resource |
| | | private ICancleOrderService cancleOrderService; |
| | | |
| | | @Resource |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | @Resource |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Resource |
| | | private CarModelMapper carModelMapper; |
| | | |
| | | |
| | | |
| | |
| | | "Your request for reassignment was submitted, we shall handle it for you as soon as possible." : |
| | | "Votre demande de réaffectation a été soumise. Nous la traiterons pour vous dans les plus brefs délais.", uid); |
| | | |
| | | //开始自动完成改派 |
| | | switch (reassign.getOrderType()){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | Company company = companyCityService.query1(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司 |
| | | PushOrder pushOrder = pushOrderService.querys(1, 1, company.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | System.err.println("【" + orderPrivateCar.getId() + "】空闲司机:" + JSON.toJSONString(list)); |
| | | if(list.size() > 0){ |
| | | String text = ""; |
| | | Driver driver1 = list.get(0); |
| | | reassign.setState(3); |
| | | reassign.setNowDriverId(driver1.getId()); |
| | | reassign.setNowCarId(driver1.getCarId()); |
| | | reassign.setCompleteTime(new Date()); |
| | | this.updateById(reassign); |
| | | |
| | | |
| | | Integer language1 = driver1.getLanguage(); |
| | | switch (language1){ |
| | | case 1: |
| | | text = "收到新的打车订单,从" + orderPrivateCar.getStartAddress() + "出发,全程约" + orderPrivateCar.getEstimatedMileage() + "公里"; |
| | | break; |
| | | case 2: |
| | | text = "Received a new ride order, starting from " + orderPrivateCar.getStartAddress() + ", the whole journey is about " + orderPrivateCar.getEstimatedMileage() + "kilometre"; |
| | | break; |
| | | case 3: |
| | | text = "J'ai reçu une nouvelle commande de course, à partir de " + orderPrivateCar.getStartAddress() + ", le trajet complet est d’environ " + orderPrivateCar.getEstimatedMileage() + "kilométrage"; |
| | | break; |
| | | |
| | | } |
| | | String audioUrl = ""; |
| | | String fileName = "pushOrder" + orderPrivateCar.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; |
| | | try { |
| | | audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //定时任务删除语音文件 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Process process = null; |
| | | try { |
| | | process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (process != null) { |
| | | process.destroy(); |
| | | } |
| | | } |
| | | }, 30000); |
| | | |
| | | orderPrivateCar.setDriverId(driver1.getId()); |
| | | orderPrivateCar.setCarId(driver1.getCarId()); |
| | | orderPrivateCar.setCompanyId(driver1.getFranchiseeId() != null && driver1.getFranchiseeId() != 0 ? driver1.getFranchiseeId() : ( |
| | | driver1.getCompanyId() != null && driver1.getCompanyId() != 0 ? driver1.getCompanyId() : 1)); |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | orderPrivateCar.setState(orderPrivateCar.getOldState()); |
| | | orderPrivateCar.setOldState(null); |
| | | if(!StringUtils.hasLength(orderPrivateCar.getTripId())){ |
| | | orderPrivateCar.setTripId(UUIDUtil.getRandomCode()); |
| | | } |
| | | |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | | orderPrivateCar.setEstimateArriveMileage(distancematrix.getDistance()); |
| | | } |
| | | } |
| | | orderPrivateCarService.updateAllColumnById(orderPrivateCar); |
| | | driver1.setState(3); |
| | | driverService.updateById(driver1); |
| | | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_1_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_2_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("3_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | | * 预约单:行程时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | | * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | | * |
| | | * 超时用户取消订单后需要弹给司机提醒弹框,超时时间 = 当前时间 - 行程时间 - 配置不收费的时间 |
| | | * |
| | | * 定时提醒弹框 |
| | | * 司机只要开始超时且还未到达预约点,则需要定时提醒 |
| | | * |
| | | * 预约单需要提前xx分钟提醒司机需要接乘客,过后每隔xx分钟提醒一次。超时后停止提醒 |
| | | */ |
| | | |
| | | //添加定时任务(普通任务) |
| | | SysOvertime reminderRules = sysOvertimeService.selectOne(new EntityWrapper<SysOvertime>().eq("companyId", driver1.getCompanyId())); |
| | | if(null != reminderRules){ |
| | | CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", driver1.getCompanyId())); |
| | | Integer driverTimeout = JSON.parseObject(cancleOrder.getContent()).getInteger("driverTimeout"); |
| | | |
| | | //即时单 |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | //超时时间 |
| | | long timeOut = orderPrivateCar.getEstimateArriveTime().getTime() + (driverTimeout * 60 * 1000); |
| | | //乘客取消不收费提醒 |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 1); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", language1 == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language1 == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(timeOut), timeOut, 0); |
| | | |
| | | //超时循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 3); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getEstimateArriveTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", ""); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("3_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , orderPrivateCar.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | }else{ |
| | | //超时时间 |
| | | long timeOut = orderPrivateCar.getTravelTime().getTime() + (driverTimeout * 60000); |
| | | //乘客取消不收费提醒 |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 1); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", language1 == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language1 == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(timeOut), timeOut, 0); |
| | | |
| | | |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | |
| | | //预约单出发首次提醒 |
| | | long travelTime = orderPrivateCar.getTravelTime().getTime() - reminderRules.getReserveTime() * 60000; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 2); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", language1 == 1 ? "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + ",请准时!" : |
| | | language1 == 2 ? "You are going to pick up " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " at " + sdf.format(orderPrivateCar.getTravelTime()) + ", please be on time. " : |
| | | "Vous allez chercher " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " à " + sdf.format(orderPrivateCar.getTravelTime()) + ", s’il vous plaît soyez à l’heure."); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("2_1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(travelTime), travelTime, 0); |
| | | |
| | | //预约单出发循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 2); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getTravelTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", language1 == 1 ? "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + ",请准时!" : |
| | | language1 == 2 ? "You are going to pick up " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " at " + sdf.format(orderPrivateCar.getTravelTime()) + ", please be on time. " : |
| | | "Vous allez chercher " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " à " + sdf.format(orderPrivateCar.getTravelTime()) + ", s’il vous plaît soyez à l’heure."); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("2_2_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(travelTime + reminderRules.getReserveNext() * 60000), reminderRules.getReserveNext() * 60000, -1); |
| | | |
| | | //超时循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 3); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getTravelTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", ""); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("3_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , orderPrivateCar.getTravelTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | } |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderReassign(orderPrivateCar.getUserId(), 1, orderPrivateCar.getId(), 1, ""); |
| | | pushUtil.pushOrderReassign(orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, finalAudioUrl); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | systemNoticeService.addSystemNotice(2, language1 == 1 ? "您已成功抢得打车订单,请及时联系客户!" : |
| | | language1 == 2 ? "You have grabbed the ride order, please contact the client timely." |
| | | : "Vous avez saisi la commande de course, veuillez contacter le client en temps opportun.", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" : |
| | | language1 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on." |
| | | : "Votre commande a été attribuée au chauffeur- " + driver1.getFirstName() + ", S'il vous plaît, restez en ligne.", orderPrivateCar.getUserId()); |
| | | |
| | | } |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | Company company1 = companyCityService.query1(String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司 |
| | | PushOrder pushOrder1 = pushOrderService.querys(1, 1, company1.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<Driver> list1 = driverService.queryIdleDriver(orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder1.getPushDistance(), null);//所有附近空闲司机 |
| | | System.err.println("【" + orderLogistics.getId() + "】空闲司机:" + JSON.toJSONString(list1)); |
| | | if(list1.size() > 0){ |
| | | Driver driver1 = list1.get(0); |
| | | reassign.setState(3); |
| | | reassign.setNowDriverId(driver1.getId()); |
| | | reassign.setNowCarId(driver1.getCarId()); |
| | | reassign.setCompleteTime(new Date()); |
| | | this.updateById(reassign); |
| | | |
| | | String text = ""; |
| | | Integer language1 = driver1.getLanguage(); |
| | | switch (language1){ |
| | | case 1: |
| | | text = "收到新的包裹订单,从" + orderLogistics.getStartAddress() + "出发,全程约" + orderLogistics.getEstimatedMileage() + "公里"; |
| | | break; |
| | | case 2: |
| | | text = "Received a new delivery order, starting from " + orderLogistics.getStartAddress() + ", the whole journey is about " + orderLogistics.getEstimatedMileage() + "kilometre"; |
| | | break; |
| | | case 3: |
| | | text = "J'ai reçu une nouvelle commande de livraison, à partir de " + orderLogistics.getStartAddress() + ", le trajet complet est d’environ " + orderLogistics.getEstimatedMileage() + "kilométrage"; |
| | | break; |
| | | |
| | | } |
| | | String audioUrl = ""; |
| | | String fileName = "pushOrder" + driver1.getId() + UUIDUtil.getRandomCode(5) + ".mp3"; |
| | | try { |
| | | audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //定时任务删除语音文件 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Process process = null; |
| | | try { |
| | | process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (process != null) { |
| | | process.destroy(); |
| | | } |
| | | } |
| | | }, 30000); |
| | | |
| | | |
| | | orderLogistics.setDriverId(driver1.getId()); |
| | | orderLogistics.setCarId(driver1.getCarId()); |
| | | orderLogistics.setCompanyId(driver1.getFranchiseeId() != null && driver1.getFranchiseeId() != 0 ? driver1.getFranchiseeId() : ( |
| | | driver1.getCompanyId() != null && driver1.getCompanyId() != 0 ? driver1.getCompanyId() : 1)); |
| | | orderLogistics.setState(orderLogistics.getOldState()); |
| | | orderLogistics.setOldState(null); |
| | | orderLogistics.setSnatchOrderTime(new Date()); |
| | | if(!StringUtils.hasLength(orderLogistics.getTripId())){ |
| | | orderLogistics.setTripId(UUIDUtil.getRandomCode()); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderLogistics.setEstimateArriveTime(new Date(timeOut)); |
| | | orderLogistics.setEstimateArriveMileage(distancematrix.getDistance()); |
| | | } |
| | | orderLogisticsService.updateAllColumnById(orderLogistics); |
| | | //修改司机为服务中 |
| | | driver1.setState(3); |
| | | driverService.updateById(driver1); |
| | | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_1_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_2_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("3_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | | * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | | * |
| | | * 超时用户取消订单后需要弹给司机提醒弹框,超时时间 = 当前时间 - 行程时间 - 配置不收费的时间 |
| | | * |
| | | * 定时提醒弹框 |
| | | * 司机只要开始超时且还未到达预约点,则需要定时提醒 |
| | | */ |
| | | |
| | | //添加定时任务(普通任务) |
| | | SysOvertime reminderRules = sysOvertimeService.selectOne(new EntityWrapper<SysOvertime>().eq("companyId", driver1.getCompanyId())); |
| | | if(null != reminderRules){ |
| | | CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", driver1.getCompanyId())); |
| | | Integer driverTimeout = JSON.parseObject(cancleOrder.getContent()).getInteger("driverTimeout"); |
| | | //超时时间 |
| | | long timeOut = orderLogistics.getEstimateArriveTime().getTime() + (driverTimeout * 60 * 1000); |
| | | //乘客取消不收费提醒 |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 1); |
| | | jobDataMap.put("orderId", orderLogistics.getId()); |
| | | jobDataMap.put("orderType", 4); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", language1 == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language1 == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("1_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(timeOut), timeOut, 0); |
| | | |
| | | //超时循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", driver1.getId()); |
| | | jobDataMap.put("timeOutType", 3); |
| | | jobDataMap.put("orderId", orderLogistics.getId()); |
| | | jobDataMap.put("orderType", 4); |
| | | jobDataMap.put("language", language1); |
| | | jobDataMap.put("timeOut", orderLogistics.getEstimateArriveTime().getTime()); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", ""); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob("3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap) |
| | | , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | }else{ |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderReassign(orderLogistics.getUserId(), 1, orderLogistics.getId(), 4, ""); |
| | | pushUtil.pushOrderReassign(orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, finalAudioUrl); |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, language1 == 1 ? "您已成功抢得包裹订单,请及时联系客户!" : |
| | | language1 == 2 ? "You have grabbed the delivery order, please contact the client timely." |
| | | : "Vous avez saisi la commande du livraison. Veuillez contacter le client en temps opportun.", orderLogistics.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" : |
| | | language1 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on." |
| | | : "Votre commande a été attribuée au chauffeur- " + driver1.getFirstName() + ", S'il vous plaît, restez en ligne.", orderLogistics.getUserId()); |
| | | |
| | | } |
| | | break; |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |