无关风月
2024-11-14 3af9c82375df6bd77ae78a5d900c409a895ecd18
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java
@@ -20,6 +20,7 @@
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.GoogleMap.ReverseGeocodeVo;
import com.stylefeng.guns.modular.system.util.Tingg.TinggPayUtil;
@@ -105,6 +106,12 @@
    
    @Resource
    private IBalanceUsageRecordService balanceUsageRecordService;
    @Resource
    private FleetEngineUtil fleetEngineUtil;
    @Autowired
    private IOrderPositionService orderPositionService;
@@ -1234,6 +1241,57 @@
        }
        return ResultUtil.success();
    }
    @Override
    public void getDriverNowPosition() {
        for (OrderPrivateCar orderPrivateCar : orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("state", 5))) {
            String trackId = orderPrivateCar.getTrackId();
            if(ToolUtil.isNotEmpty(trackId)){
                String trip = fleetEngineUtil.getTrip(trackId);
                JSONObject lastLocation = JSON.parseObject(trip).getJSONObject("lastLocation");
                JSONObject location = lastLocation.getJSONObject("location");
                Double latitude = location.getDouble("latitude");
                Double longitude = location.getDouble("longitude");
                OrderPosition orderPosition = new OrderPosition();
                orderPosition.setOrderId(orderPrivateCar.getId());
                orderPosition.setOrderType(1);
                orderPosition.setDriverId(orderPrivateCar.getDriverId());
                orderPosition.setLat(latitude.toString());
                orderPosition.setLon(longitude.toString());
                orderPosition.setInsertTime(new Date());
                try {
                    orderPositionService.saveData(orderPosition);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
        List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().eq("state", 5));
        for (OrderLogistics orderLogistics : orderLogisticsList) {
            String trackId = orderLogistics.getTrackId();
            if(ToolUtil.isNotEmpty(trackId)){
                String trip = fleetEngineUtil.getTrip(trackId);
                JSONObject lastLocation = JSON.parseObject(trip).getJSONObject("lastLocation");
                JSONObject location = lastLocation.getJSONObject("location");
                Double latitude = location.getDouble("latitude");
                Double longitude = location.getDouble("longitude");
                OrderPosition orderPosition = new OrderPosition();
                orderPosition.setOrderId(orderLogistics.getId());
                orderPosition.setOrderType(1);
                orderPosition.setDriverId(orderLogistics.getDriverId());
                orderPosition.setLat(latitude.toString());
                orderPosition.setLon(longitude.toString());
                orderPosition.setInsertTime(new Date());
                try {
                    orderPositionService.saveData(orderPosition);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}