| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.mchange.util.FailSuppressedMessageLogger; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | |
| | | |
| | | @Autowired |
| | | private IOrderCancelService orderCancelService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&type=%s", uid, type); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return driverService.work(uid, type, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread; |
| | |
| | | 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.util.*; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 订单相关控制器 |
| | |
| | | |
| | | @Resource |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&orderId=%s&orderType=%s&state=%s", uid, orderId, orderType, state); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return orderService.process(orderId, orderType, state, uid, lon, lat, phone, pickUpCode, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/getTripInfo") |
| | | public ResultUtil getTripInfo(String tripId){ |
| | | return ResultUtil.success(fleetEngineUtil.getTrip(tripId)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 更新google订单状态 |
| | | * @param tripStatus |
| | | * @param tripId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editTripStatus") |
| | | public ResultUtil editTripStatus(String tripStatus, String tripId){ |
| | | boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null); |
| | | if(b){ |
| | | return ResultUtil.success(); |
| | | } |
| | | return ResultUtil.error("更新失败"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上传订单经纬度 |
| | | * @param orderPosition |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/saveOrderPosition") |
| | | public ResultUtil saveOrderPosition(OrderPosition orderPosition, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | if(null != orderPosition.getOrderId()){ |
| | | orderPosition.setDriverId(uid); |
| | | orderPosition.setInsertTime(new Date()); |
| | | orderPositionService.saveData(orderPosition); |
| | | } |
| | | redisUtil.setStrValue("DRIVER" + uid, orderPosition.getLon() + "," + orderPosition.getLat(), 300);//实时位置存入redis中 |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editGoogleTripStatus") |
| | | public ResultUtil editGoogleTripStatus(){ |
| | | List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId")); |
| | | for (OrderPrivateCar privateCar : privateCars) { |
| | | Integer state = privateCar.getState(); |
| | | String tripId = privateCar.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId")); |
| | | for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | Integer state = orderLogistics.getState(); |
| | | String tripId = orderLogistics.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.SettlementRecord; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.ISettlementRecordService; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackResponse; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2023/8/17 9:39 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class SettlementRecordController { |
| | |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&payType=%s&language=%s", uid, payType, language); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return settlementRecordService.paymentSettlementAmount(uid, payType, bankCardId, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/settlementRecord/paymentSettlementAmountCallback") |
| | | public CallbackResponse paymentSettlementAmountCallback(@RequestBody CallbackRequest callbackRequest){ |
| | | log.info("结算支付回调结果:{}", JSON.toJSONString(callbackRequest)); |
| | | CallbackResponse callbackResponse = new CallbackResponse(); |
| | | try { |
| | | /** |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | log.info("结算支付回调结果处理结束:{}", JSON.toJSONString(callbackResponse)); |
| | | return callbackResponse; |
| | | } |
| | | } |
| | |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return withdrawalService.withdrawal(money, uid, type, remark, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | 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); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | | * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | |
| | | , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | 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(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | 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()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | |
| | | orderLogistics.setGetoffTime(new Date()); |
| | | orderLogistics.setEndServiceTime(new Date()); |
| | | orderLogistics.setState(6); |
| | | tripStatus = "COMPLETE"; |
| | | tripStatus = ""; |
| | | break; |
| | | } |
| | | this.updateById(orderLogistics); |
| | | |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | | new Thread(new Runnable() { |
| | |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, Integer status) { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(ToolUtil.isEmpty(orderLogistics.getDestinationLon())){ |
| | | return; |
| | | } |
| | | if(2 == status){ |
| | | orderLogistics.setEndLon(Double.valueOf(orderLogistics.getDestinationLon())); |
| | | orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat())); |
| | |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderLogistics.setDestinationLon(""); |
| | | orderLogistics.setDestination(""); |
| | | orderLogistics.setDestinationLat(""); |
| | | this.updateById(orderLogistics); |
| | | pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status); |
| | | } |
| | |
| | | orderLogistics.setBindId(""); |
| | | } |
| | | this.updateById(orderLogistics); |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | //上报行程 |
| | | 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) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据 |
| | |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); |
| | | } |
| | | }).start(); |
| | | |
| | | //上报google |
| | | OrderLogistics finalOrderLogistics = orderLogistics; |
| | | new Thread(()->{ |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 |
| | | if(distance1 > 30 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 |
| | | orderLogistics.setToStartPointMileage(new BigDecimal(orderLogistics.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderLogistics); |
| | | return true; |
| | | } |
| | | if(distance1 > 50 && orderLogistics.getState()==5){//大于50米表示在移动 |
| | | if(distance1 > 30 && orderLogistics.getState()==5){//大于50米表示在移动 |
| | | orderLogistics.setMileage(new BigDecimal(orderLogistics.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderLogistics); |
| | | return true; |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | 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(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.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, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | 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(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | |
| | | orderPrivateCar.setGetoffAddress(address); |
| | | orderPrivateCar.setGetoffTime(new Date()); |
| | | orderPrivateCar.setEndServiceTime(new Date()); |
| | | tripStatus = "COMPLETE"; |
| | | tripStatus = ""; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-CN.mp3"; |
| | |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | }).start(); |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | |
| | | //获取google trip_info获取轨迹线路,重新存储轨迹和计算行驶距离和时间 |
| | | |
| | | |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | orderPrivateCar.setPayManner(type); |
| | |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //上报行程 |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | |
| | | } |
| | | }).start(); |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | //上报google |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | if(distance1 > 30 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | orderPrivateCar.setToStartPointMileage(new BigDecimal(orderPrivateCar.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | | } |
| | | if(distance1 > 50 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | if(distance1 > 30 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | orderPrivateCar.setMileage(new BigDecimal(orderPrivateCar.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, Integer status) { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(ToolUtil.isEmpty(orderPrivateCar.getDestinationLon())){ |
| | | return; |
| | | } |
| | | if(2 == status){ |
| | | orderPrivateCar.setEndLon(Double.valueOf(orderPrivateCar.getDestinationLon())); |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |
| | | orderPrivateCar.setDestination(""); |
| | | orderPrivateCar.setDestinationLat(""); |
| | | this.updateById(orderPrivateCar); |
| | | pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status); |
| | | } |
| | |
| | | Company query1(@Param("cityIds") List<Integer> cityIds); |
| | | |
| | | |
| | | List<Company> queryList(@Param("city") String[] city, @Param("type") Integer type); |
| | | List<Company> queryList(@Param("ids") List<Integer> ids, @Param("type") Integer type); |
| | | |
| | | |
| | | |
| | |
| | | upload as upload, |
| | | insertTime as insertTime |
| | | from t_company where flag != 3 and state = 0 and id in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != city"> |
| | | and cityId in (select id from t_city where englishName in |
| | | <foreach collection="city" item="item" index="index" open="(" separator="," close=")"> |
| | | <foreach collection="ids" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | ) |
| | | <if test="null != type"> |
| | | and type = #{type} |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | * 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车) |
| | | */ |
| | | @TableField("orderType") |
| | | @ApiModelProperty(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)", required = true) |
| | | private Integer orderType; |
| | | /** |
| | | * 订单id |
| | | */ |
| | | @TableField("orderId") |
| | | @ApiModelProperty(value = "订单id", required = true) |
| | | private Integer orderId; |
| | | /** |
| | | * 司机id |
| | |
| | | * 经度 |
| | | */ |
| | | @TableField("lon") |
| | | @ApiModelProperty(value = "经度", required = true) |
| | | private String lon; |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | @TableField("lat") |
| | | @ApiModelProperty(value = "纬度", required = true) |
| | | private String lat; |
| | | /** |
| | | * 方向角 |
| | | */ |
| | | @TableField("directionAngle") |
| | | @ApiModelProperty(value = "方向角", required = false) |
| | | private String directionAngle; |
| | | /** |
| | | * 海拔 |
| | | */ |
| | | @TableField("altitude") |
| | | @ApiModelProperty(value = "海拔", required = false) |
| | | private String altitude; |
| | | /** |
| | | * 添加时间 |
| | |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil payOrder(Integer uid, Integer orderId, Integer orderType, Integer payType, Integer bankCardId, Integer language) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 使用google获取司机的最新位置信息 |
| | | */ |
| | | void getDriverNowPosition(); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Override |
| | | public Company query(String[] city) throws Exception { |
| | | List<Company> query = companyMapper.queryList(city, 3); |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<Company> query = companyMapper.queryList(collect, 3); |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 2); |
| | | query = companyMapper.queryList(collect, 2); |
| | | } |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 1); |
| | | query = companyMapper.queryList(collect, 1); |
| | | } |
| | | if(query.size() > 0){ |
| | | return query.get(0); |
| | |
| | | |
| | | |
| | | public Company query1(String[] city) throws Exception { |
| | | List<City> cities = cityService.selectList(new EntityWrapper<City>().in("chineseName", Arrays.asList(city)).or() |
| | | .in("englishName", Arrays.asList(city)).or().in("frenchName", Arrays.asList(city))); |
| | | List<Integer> collect = cities.stream().map(City::getId).collect(Collectors.toList()); |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(collect.size() == 0){ |
| | | return null; |
| | | } |
| | |
| | | if(!file.exists()){ |
| | | file.getParentFile().mkdirs(); |
| | | file.createNewFile(); |
| | | file.setReadable(true, false);//设置读取权限 |
| | | file.setWritable(true, false);//设置写入权限 |
| | | } |
| | | //写入相应的文件 |
| | | orderPositions.add(orderPosition); |
| | | System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | // System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | FileUtil.writeUtf8String(JSON.toJSONString(orderPositions), file); |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyService; |
| | | import com.stylefeng.guns.modular.system.service.IPhoneService; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | |
| | | @Resource |
| | | private PhoneMapper phoneMapper; |
| | | |
| | | @Resource |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | /** |
| | | * 获取所有系统电话 |
| | |
| | | Phone query = phoneMapper.query(2, 1, null, null, null); |
| | | map.put("platform", null != query ? query.getPhone() : ""); |
| | | |
| | | List<Company> companies = companyMapper.queryList(city, null); |
| | | if(companies.size() > 0){ |
| | | Integer id = companies.get(0).getId(); |
| | | Company companies = companyCityService.query(city); |
| | | if(null != companies){ |
| | | Integer id = companies.getId(); |
| | | Phone phone = this.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", id)); |
| | | map.put("company", phone.getPhone()); |
| | | phone = this.selectOne(new EntityWrapper<Phone>().eq("type", 3).eq("companyId", id)); |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | 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(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.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, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_1_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | 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(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | | new Thread(new Runnable() { |
| | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | 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); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | | QuartzUtil.deleteQuartzTask("2_1_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | |
| | | , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | 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(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | 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()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | |
| | | |
| | | public static void main(String[] ages){ |
| | | GeodesyUtil geodesyUtil = new GeodesyUtil(); |
| | | geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); |
| | | geodesyUtil.getDistance("-0.2621451,5.6025811", "-0.2592737227678299,5.6036623712816533"); |
| | | } |
| | | } |
| | |
| | | * @param end_lng 终点经度 |
| | | * @return |
| | | */ |
| | | public boolean createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | public JSONObject createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips?tripId=" + tripId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | end_point.put("longitude", end_lng); |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | logger.info("创建行程请求:{}", body.toJSONString()); |
| | | logger.info("创建行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = post.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("创建行程结果:{}", response.body()); |
| | |
| | | } |
| | | } |
| | | logger.error("创建行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "currentRouteSegmentTrafficVersion": "2024-05-27T02:05:37.941167Z" |
| | | * } |
| | | */ |
| | | return true; |
| | | return jsonObject; |
| | | } |
| | | |
| | | |
| | |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | } |
| | | logger.info("修改行程请求:{}", body.toJSONString()); |
| | | logger.info("修改行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = put.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("修改行程结果:{}", response.body()); |
| | |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) { |
| | | log.info("行程上报:{}", tripId); |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | |
| | | if((state == 2 || state == 3 || state == 4) || (oldState != null && (oldState == 2 || oldState == 3 || oldState == 4))){//前往预约地 |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(startLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = startLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |
| | | d = distancematrix.getDistance().toString();//距离m |
| | | t = distancematrix.getDuration().toString();//时间s |
| | | } |
| | | } |
| | | d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | // if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(startLonLat)){ |
| | | // String[] split = value.split(","); |
| | | // String[] split1 = startLonLat.split(","); |
| | | // DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | // if(null == distancematrix){ |
| | | // System.err.println("地图获取距离出错"); |
| | | // }else{ |
| | | // d = distancematrix.getDistance().toString();//距离m |
| | | // t = distancematrix.getDuration().toString();//时间s |
| | | // } |
| | | // } |
| | | // d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | // t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | map.put("reservationMileage", d);//当前位置距离预约点的剩余里程 |
| | | map.put("reservationTime", t);//当前位置距离预约点的剩余分钟 |
| | | map.put("servedMileage", "0");//距离起点已经服务的里程 |
| | |
| | | |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(endLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = endLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |
| | | d = distancematrix.getDistance().toString();//距离m |
| | | t = distancematrix.getDuration().toString();//时间s |
| | | } |
| | | } |
| | | |
| | | d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | // if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(endLonLat)){ |
| | | // String[] split = value.split(","); |
| | | // String[] split1 = endLonLat.split(","); |
| | | // DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | // if(null == distancematrix){ |
| | | // System.err.println("地图获取距离出错"); |
| | | // }else{ |
| | | // d = distancematrix.getDistance().toString();//距离m |
| | | // t = distancematrix.getDuration().toString();//时间s |
| | | // } |
| | | // } |
| | | // |
| | | // d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | // t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | map.put("laveMileage", d);//距离终点剩余未服务的里程数 |
| | | map.put("laveTime", t);//距离终端剩余未服务的预计时间 |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 5秒钟处理的任务 |
| | | */ |
| | | @Scheduled(fixedRate = 5000) |
| | | public void task5Second(){ |
| | | try { |
| | | // orderService.getDriverNowPosition(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |