zhibing.pu
2024-05-28 9317fed1cea5372d9997a8273c07f041db94f99c
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -11,13 +11,11 @@
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.system.dao.CarMapper;
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.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.FleetEngineUtil;
import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob;
@@ -115,6 +113,15 @@
    
    @Resource
    private SystemPriceMapper systemPriceMapper;
    @Autowired
    private FleetEngineUtil fleetEngineUtil;
    @Resource
    private CarModelMapper carModelMapper;
    @Autowired
    private ICarService carService;
@@ -168,7 +175,6 @@
        driver.setState(3);
        driverService.updateById(driver);
    
        //todo 待翻译
        //添加定时任务(普通任务)
        ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId()));
        if(null != reminderRules){
@@ -179,13 +185,26 @@
            jobDataMap.put("driverId", uid);
            jobDataMap.put("orderId", orderLogistics.getId());
            jobDataMap.put("orderType", 4);
            jobDataMap.put("describe", "您的包裹订单已超时" + m + "分钟,请抓紧!");
            jobDataMap.put("describe", language == 1 ? "您的包裹订单已超时" + m + "分钟,请抓紧!" : language == 2 ? "Your delivery order is overdue for " + m + " minute(s), please go faster." : "Votre commande de livraison est en retard depuis " + m + " minute(s), veuillez aller plus vite.");
            QuartzUtil.addSimpleQuartzTask(
                    new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap)
                    , new Date(packageTimeoutReminderInterval), packageTimeoutReminderInterval, -1);
        }
        String trip = fleetEngineUtil.getTrip(1, orderLogistics.getId());
        if(ToolUtil.isEmpty(trip)){
            String vehicles = fleetEngineUtil.getVehicles(orderLogistics.getCarId());
            if(ToolUtil.isEmpty(vehicles)){
                Car car = carService.selectById(orderLogistics.getCarId());
                CarModel carModel = carModelMapper.selectById(car.getCarModelId());
                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getId());
            }
            fleetEngineUtil.createTrip(orderLogistics.getCarId(), 1, 4, orderLogistics.getId(),
                    orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(),  orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
        }else{
            //开始修改行程数据
            fleetEngineUtil.updateTrip(null, driver.getCarId(), null, 4, orderLogistics.getId(), null, null, null, null);
        }
        
        //推送相关代码------------------start----------------
        new Thread(new Runnable() {
@@ -257,19 +276,22 @@
        }
        List<OrderLogisticsSpread> orderLogisticsId = spreadService.selectList(new EntityWrapper<OrderLogisticsSpread>().eq("orderLogisticsId", orderLogistics.getId()).eq("payType",4));
        String tripStatus = "UNKNOWN_TRIP_STATUS";
        switch (state){
            case 3://出发前往预约点
                orderLogistics.setState(3);
                orderLogistics.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.", orderLogistics.getUserId());
                pushUtil.pushDriverPosition(orderId, 4);
                tripStatus = "ENROUTE_TO_PICKUP";
                break;
            case 4://到达预约点,等待客户上车
                orderLogistics.setState(4);
                orderLogistics.setArriveTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已到达您设置的预约地点。" : language == 2 ? "The driver has arrived at the reserved location." : "Le chauffeur est arrivé à l'endroit prévu.", orderLogistics.getUserId());
                tripStatus = "ARRIVED_AT_PICKUP";
                break;
            case 5://开始服务
                orderLogistics.setBoardingLon(lon);
@@ -278,6 +300,7 @@
                orderLogistics.setBoardingTime(new Date());
                orderLogistics.setState(5);
                orderLogistics.setStartServiceTime(new Date());
                tripStatus = "ENROUTE_TO_DROPOFF";
                break;
            case 6://结束服务
                orderLogistics.setGetoffLon(lon);
@@ -286,9 +309,14 @@
                orderLogistics.setGetoffTime(new Date());
                orderLogistics.setEndServiceTime(new Date());
                orderLogistics.setState(6);
                tripStatus = "COMPLETE";
                break;
        }
        this.updateById(orderLogistics);
        Driver driver = driverService.selectById(orderLogistics.getDriverId());
        //修改行程数据
        fleetEngineUtil.updateTrip(tripStatus, null, null, 4, orderLogistics.getId(), null, null, null, null);
        
        // TODO: 2020/6/5 推送状态
        new Thread(new Runnable() {