| | |
| | | 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; |
| | |
| | | |
| | | @Resource |
| | | private IBalanceUsageRecordService balanceUsageRecordService; |
| | | |
| | | @Resource |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public Integer queryOrderNum(Integer driverId, Date start, Date end) throws Exception { |
| | | //出租车 |
| | | int i = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", driverId) |
| | | .between("insertTime", start, end).in("state", Arrays.asList(6, 7, 8, 9))); |
| | | return i; |
| | | int i1 = orderLogisticsService.selectCount(new EntityWrapper<OrderLogistics>().eq("driverId", driverId) |
| | | .between("insertTime", start, end).in("state", Arrays.asList(6, 7, 8, 9))); |
| | | return i + i1; |
| | | } |
| | | |
| | | |
| | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalUserId, orderId, orderType, finalState, 0, ""); |
| | | pushUtil.pushOrderState(2, finalDriverId, orderId, orderType, finalState, 0, ""); |
| | | pushUtil.pushOrderState(1, finalUserId, orderId, orderType, finalState, 0, "", "driver"); |
| | | pushUtil.pushOrderState(2, finalDriverId, orderId, orderType, finalState, 0, "", "driver"); |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 结束google订单状态 |
| | | */ |
| | | @Override |
| | | public void overGoogleOrder() { |
| | | List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId") |
| | | .eq("isover", 0).in("state", Arrays.asList(6, 7, 8, 9, 10, 12)).eq("isDelete", 1)); |
| | | for (OrderPrivateCar privateCar : privateCars) { |
| | | Integer state = privateCar.getState(); |
| | | String tripId = privateCar.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(null != trip && "" == trip){ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | continue; |
| | | } |
| | | 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 != 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 != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException 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 != 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 != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId") |
| | | .eq("isover", 0).in("state", Arrays.asList(6, 7, 8, 9, 10, 12)).eq("isDelete", 1)); |
| | | for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | Integer state = orderLogistics.getState(); |
| | | String tripId = orderLogistics.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(null != trip && "" == trip){ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | continue; |
| | | } |
| | | 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 != 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 != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(updateTrip){ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException 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 != 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 != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(updateTrip){ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |