zhibing.pu
2024-05-28 9317fed1cea5372d9997a8273c07f041db94f99c
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -8,12 +8,14 @@
import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.CarModelMapper;
import com.stylefeng.guns.modular.system.dao.RegionMapper;
import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
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.FleetEngineUtil;
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;
@@ -95,6 +97,15 @@
    
    @Autowired
    private IReminderRulesService reminderRulesService;
    @Autowired
    private FleetEngineUtil fleetEngineUtil;
    @Resource
    private CarModelMapper carModelMapper;
    @Autowired
    private ICarService carService;
@@ -191,7 +202,7 @@
            }
        }
        if(orderPrivateCar.getState() == 9){
        if(orderPrivateCar.getState() == 10){
            return ResultUtil.error(language == 1 ? "订单已取消" : language == 2 ? "Order cancelled" : "Commande annulée");
        }
        if(orderPrivateCar.getState() != 1){
@@ -214,7 +225,6 @@
        }
        
        
        //todo 待翻译
        //添加定时任务(普通任务)
        ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId()));
        if(null != reminderRules){
@@ -227,7 +237,7 @@
                jobDataMap.put("driverId", uid);
                jobDataMap.put("orderId", orderPrivateCar.getId());
                jobDataMap.put("orderType", 1);
                jobDataMap.put("describe", "您的打车订单已超时" + m + "分钟,请抓紧!");
                jobDataMap.put("describe", language == 1 ? "您的打车订单已超时" + m + "分钟,请抓紧!" : language == 2 ? "Your ride order is overdue for " + m + " minute(s), please go faster." : "Votre commande de course est en retard depuis " + m + " minute(s), veuillez aller plus vite.");
                QuartzUtil.addSimpleQuartzTask(
                        new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap)
                        , new Date(specialCarTimeoutReminderInterval), specialCarTimeoutReminderInterval, -1);
@@ -257,6 +267,20 @@
                        , new Date(appointmentReminder + appointmentTimeoutReminderInterval), appointmentTimeoutReminderInterval, -1);
            }
        }
        String trip = fleetEngineUtil.getTrip(1, orderPrivateCar.getId());
        if(ToolUtil.isEmpty(trip)){
            String vehicles = fleetEngineUtil.getVehicles(orderPrivateCar.getCarId());
            if(ToolUtil.isEmpty(vehicles)){
                Car car = carService.selectById(orderPrivateCar.getCarId());
                CarModel carModel = carModelMapper.selectById(car.getCarModelId());
                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getId());
            }
            fleetEngineUtil.createTrip(orderPrivateCar.getCarId(), 1, 1, orderPrivateCar.getId(),
                    orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(),  orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString());
        }
        //开始修改行程数据
        fleetEngineUtil.updateTrip(null, driver.getCarId(), null, 1, orderPrivateCar.getId(), null, null, null, null);
        
        //推送相关代码------------------start----------------
        new Thread(new Runnable() {
@@ -320,12 +344,14 @@
        if(state==4 && orderPrivateCar.getState()!=3){
            return ResultUtil.error(language == 1 ? "当前订单不能到达预约地点" : language == 2 ? "The current order cannot arrive at the reservation" : "La commande en cours ne peut pas atteindre le rendez-vous");
        }
        String tripStatus = "UNKNOWN_TRIP_STATUS";
        switch (state){
            case 3://出发前往预约点
                orderPrivateCar.setState(3);
                orderPrivateCar.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderPrivateCar.getUserId());
                pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
                tripStatus = "ENROUTE_TO_PICKUP";
                break;
            case 4://到达预约点,等待客户上车
                orderPrivateCar.setState(4);
@@ -333,6 +359,7 @@
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已到达您设置的预约地点,请及时上车" : language == 2 ?
                        "The driver has arrived at the reserved location, please get in timely." :
                        "Le chauffeur est arrivé à l'endroit prévu, veuillez monter dans la voiture à temps.", orderPrivateCar.getUserId());
                tripStatus = "ARRIVED_AT_PICKUP";
                break;
            case 5://开始服务
                orderPrivateCar.setBoardingLon(lon);
@@ -365,6 +392,7 @@
                out.write(JSON.toJSONString(orderPositions));
                out.flush();
                out.close();
                tripStatus = "ENROUTE_TO_DROPOFF";
                break;
            case 6://结束服务(专车可以返回继续服务)不修改状态
                orderPrivateCar.setState(6);
@@ -373,9 +401,14 @@
                orderPrivateCar.setGetoffAddress(address);
                orderPrivateCar.setGetoffTime(new Date());
                orderPrivateCar.setEndServiceTime(new Date());
                tripStatus = "COMPLETE";
                break;
        }
        this.updateById(orderPrivateCar);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        //修改行程数据
        fleetEngineUtil.updateTrip(tripStatus, null, 1, 1, orderPrivateCar.getId(), null, null, null, null);
        // TODO: 2020/6/5 推送状态
        OrderPrivateCar finalOrderPrivateCar = orderPrivateCar;