Pu Zhibing
昨天 ddf438536267b9c9bb77369cdccce4e67206842a
DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -205,64 +205,64 @@
            car.setVehicleId(UUIDUtil.getRandomCode());
            carService.updateById(car);
        }
        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
        if(ToolUtil.isEmpty(vehicles)){
            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
            boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
            if(!createVehicles){
                for (int i = 0; i < 5; i++) {
                    createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                    if(createVehicles){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
        //修改google订单信息或者创建新的行程
        String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId());
        if(ToolUtil.isEmpty(trip)){
            JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
                    orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
            JSONObject error = createTrip.getJSONObject("error");
            if(null != error){
                for (int i = 0; i < 5; i++) {
                    createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
                            orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
                    error = createTrip.getJSONObject("error");
                    String tripStatus = createTrip.getString("tripStatus");
                    if(null == error && "NEW".equals(tripStatus)){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }else{
            //开始修改行程数据
            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
//        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
//        if(ToolUtil.isEmpty(vehicles)){
//            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
//            boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
//            if(!createVehicles){
//                for (int i = 0; i < 5; i++) {
//                    createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
//                    if(createVehicles){
//                        break;
//                    }
//                    try {
//                        Thread.sleep(3000L);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            }
//        }
//
//        //修改google订单信息或者创建新的行程
//        String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId());
//        if(ToolUtil.isEmpty(trip)){
//            JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
//                    orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
//            JSONObject error = createTrip.getJSONObject("error");
//            if(null != error){
//                for (int i = 0; i < 5; i++) {
//                    createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
//                            orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
//                    error = createTrip.getJSONObject("error");
//                    String tripStatus = createTrip.getString("tripStatus");
//                    if(null == error && "NEW".equals(tripStatus)){
//                        break;
//                    }
//                    try {
//                        Thread.sleep(3000L);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            }
//        }else{
//            //开始修改行程数据
//            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//            if(!updateTrip){
//                for (int i = 0; i < 5; i++) {
//                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//                    if(updateTrip){
//                        break;
//                    }
//                    try {
//                        Thread.sleep(3000L);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            }
//        }
        
    
        /**
@@ -451,23 +451,23 @@
        this.updateById(orderLogistics);
    
        //修改行程数据
        if(ToolUtil.isNotEmpty(tripStatus)){
            Car car = carService.selectById(orderLogistics.getCarId());
            boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
//        if(ToolUtil.isNotEmpty(tripStatus)){
//            Car car = carService.selectById(orderLogistics.getCarId());
//            boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//            if(!updateTrip){
//                for (int i = 0; i < 5; i++) {
//                    updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//                    if(updateTrip){
//                        break;
//                    }
//                    try {
//                        Thread.sleep(3000L);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            }
//        }
        
        // TODO: 2020/6/5 推送状态
        new Thread(new Runnable() {
@@ -778,23 +778,23 @@
            orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat()));
            orderLogistics.setEndAddress(orderLogistics.getDestination());
            //修改google地图行程终点
            Car car = carService.selectById(orderLogistics.getCarId());
            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
                    null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
                            null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
//            Car car = carService.selectById(orderLogistics.getCarId());
//            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
//                    null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
//            if(!updateTrip){
//                for (int i = 0; i < 5; i++) {
//                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
//                            null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
//                    if(updateTrip){
//                        break;
//                    }
//                    try {
//                        Thread.sleep(3000L);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            }
        }
        this.updateById(orderLogistics);
        pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status);
@@ -1148,41 +1148,41 @@
        driverService.updateById(driver);
        
        //修改行程数据
        Car car = carService.selectById(orderLogistics.getCarId());
        boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
        if(!updateTrip){
            for (int i = 0; i < 5; i++) {
                updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                if(updateTrip){
                    orderLogistics.setIsover(1);
                    this.updateById(orderLogistics);
                    break;
                }
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }else{
            orderLogistics.setIsover(1);
            this.updateById(orderLogistics);
        }
        //上报行程
        boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
        if(!reportBillableEvent){
            for (int i = 0; i < 5; i++) {
                reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
                if(reportBillableEvent){
                    break;
                }
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
//        Car car = carService.selectById(orderLogistics.getCarId());
//        boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//        if(!updateTrip){
//            for (int i = 0; i < 5; i++) {
//                updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
//                if(updateTrip){
//                    orderLogistics.setIsover(1);
//                    this.updateById(orderLogistics);
//                    break;
//                }
//                try {
//                    Thread.sleep(3000L);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
//        }else{
//            orderLogistics.setIsover(1);
//            this.updateById(orderLogistics);
//        }
//        //上报行程
//        boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
//        if(!reportBillableEvent){
//            for (int i = 0; i < 5; i++) {
//                reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
//                if(reportBillableEvent){
//                    break;
//                }
//                try {
//                    Thread.sleep(3000L);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
        
        
        pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据