Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -12,12 +12,10 @@
import com.stylefeng.guns.modular.smallLogistics.server.impl.OrderLogisticsSpreadService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.model.Car;
import com.stylefeng.guns.modular.system.model.OrderPosition;
import com.stylefeng.guns.modular.system.model.Reassign;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IOrderPositionService;
import com.stylefeng.guns.modular.system.service.IOrderService;
import com.stylefeng.guns.modular.system.service.IReassignService;
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.Tingg.model.CallbackRequest;
@@ -83,6 +81,9 @@
    
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private ICarService carService;
@@ -477,7 +478,7 @@
            return orderService.confirmFees(language, orderId, orderType, type, travelFee, parkingFee, crossingFee, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
            return ResultUtil.runErr(null, e.getMessage());
        }
    }
@@ -548,7 +549,7 @@
     */
    @ResponseBody
    @PostMapping("/base/order/pushOrderState")
    public String pushOrderState(Integer language, Integer orderId, Integer orderType){
    public String pushOrderState(Integer language, Integer orderId, Integer orderType, String from){
        try {
            Map<String, Object> map = orderService.queryOrderInfo(language, orderId, orderType);
            //更新小号绑定关系
@@ -558,7 +559,7 @@
            pushUtil.pushOrderReassign(Integer.valueOf(String.valueOf(map.get("userId"))), 1,Integer.valueOf(String.valueOf(map.get("orderId"))), orderType, "");
            pushUtil.pushOrderState(1, Integer.valueOf(String.valueOf(map.get("userId"))), Integer.valueOf(String.valueOf(map.get("orderId"))), orderType,
                    Integer.valueOf(String.valueOf(map.get("orderState"))), 0, "");
                    Integer.valueOf(String.valueOf(map.get("orderState"))), 0, "", from);
            return JSON.toJSONString(ResultUtil.success());
        }catch (Exception e){
            e.printStackTrace();
@@ -710,7 +711,7 @@
            return ResultUtil.success(MoneyInfoWarpper.getMoneyInfoWarpper(map));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
            return ResultUtil.runErr(null, e.getMessage());
        }
    }
@@ -932,7 +933,7 @@
    @ResponseBody
    @PostMapping("/base/taxi/editTripStatus")
    public ResultUtil editTripStatus(String tripStatus, String tripId){
        boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null);
        boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null, null, null);
        if(b){
            return ResultUtil.success();
        }
@@ -979,38 +980,49 @@
            if(ToolUtil.isNotEmpty(trip)){
                JSONObject jsonObject = JSON.parseObject(trip);
                String tripStatus = jsonObject.getString("tripStatus");
                Car car = carService.selectById(privateCar.getCarId());
                if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null);
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null);
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1);
                            if(updateTrip){
                                continue;
                                privateCar.setIsover(1);
                                orderPrivateCarService.updateById(privateCar);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                                e.printStackTrace();
                            }
                        }
                    }else{
                        privateCar.setIsover(1);
                        orderPrivateCarService.updateById(privateCar);
                    }
                }
                if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null);
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null);
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1);
                            if(updateTrip){
                                continue;
                                privateCar.setIsover(1);
                                orderPrivateCarService.updateById(privateCar);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                                e.printStackTrace();
                            }
                        }
                    }else{
                        privateCar.setIsover(1);
                        orderPrivateCarService.updateById(privateCar);
                    }
                }
            }
@@ -1023,42 +1035,97 @@
            if(ToolUtil.isNotEmpty(trip)){
                JSONObject jsonObject = JSON.parseObject(trip);
                String tripStatus = jsonObject.getString("tripStatus");
                Car car = carService.selectById(orderLogistics.getCarId());
                if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null);
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null);
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4);
                            if(updateTrip){
                                continue;
                                orderLogistics.setIsover(1);
                                orderLogisticsService.updateById(orderLogistics);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                                e.printStackTrace();
                            }
                        }
                    }else{
                        orderLogistics.setIsover(1);
                        orderLogisticsService.updateById(orderLogistics);
                    }
                }
                if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null);
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null);
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4);
                            if(updateTrip){
                                continue;
                                orderLogistics.setIsover(1);
                                orderLogisticsService.updateById(orderLogistics);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                                e.printStackTrace();
                            }
                        }
                    }else{
                        orderLogistics.setIsover(1);
                        orderLogisticsService.updateById(orderLogistics);
                    }
                }
            }
        }
        return ResultUtil.success();
    }
    @ResponseBody
    @PostMapping("/base/taxi/getTrips")
    public String getTrips(String vehicleId, Integer pageSize, String pageToken){
        return fleetEngineUtil.getTrips(vehicleId, pageSize, pageToken);
    }
    @ResponseBody
    @GetMapping("/base/taxi/getTripsStatus")
    public ResultUtil<List<Map<String, String>>> getTripsStatus(){
        String pageToken = null;
        List<Map<String, String>> list = new ArrayList<>();
        while (true){
            String trips = fleetEngineUtil.getTrips(null, 50, pageToken);
            if(ToolUtil.isEmpty(trips)){
                break;
            }
            JSONObject jsonObject = JSON.parseObject(trips);
            JSONArray array = jsonObject.getJSONArray("trips");
            if(null == array){
                break;
            }
            for (int i = 0; i < array.size(); i++) {
                JSONObject trip = array.getJSONObject(i);
                String tripStatus = trip.getString("tripStatus");
                String name = trip.getString("name");
                Integer index = name.lastIndexOf("/") + 1;
                String tripId = name.substring(index);
                Map<String, String> map = new HashMap<>();
                map.put(tripId, tripStatus);
                list.add(map);
            }
            pageToken = jsonObject.getString("nextPageToken");
            if(null == pageToken){
                break;
            }
        }
        return ResultUtil.success(list);
    }
}