| | |
| | | if (xpOrder.getStatus() == 0) { |
| | | return R.fail("订单已取消"); |
| | | } |
| | | xpOrder.setStatus(status); |
| | | if(xpOrder.getStatus() >= 8){ |
| | | return R.fail("订单已结束"); |
| | | } |
| | | switch (status) { |
| | | case 4: |
| | | // 查询起点点位 |
| | |
| | | xpOrder.setTripBegin(LocalDateTime.now()); |
| | | break; |
| | | case 7: |
| | | // 查询自动结束行程时间 |
| | | if (xpOrder.getOpenTrunk() != 1) { |
| | | Integer arriveTime = xpSystemSettingClient.getOrderFinishTime().getData(); |
| | | // 添加自动结束行程定时任务job |
| | | Map<String, ? extends Object> endTripJobMaps = |
| | | new ImmutableMap.Builder<String, Long>(). |
| | | put("id", xpOrder.getId()) |
| | | .build(); |
| | | QuartzManager.addJob( |
| | | EndTripJob.class, |
| | | (EndTripJob.name + xpOrder.getId()).toUpperCase(), |
| | | TimeJobType.END_TRIP, |
| | | DateUtils.localDateTimeToDate(LocalDateTime.now().plusMinutes(arriveTime)), |
| | | endTripJobMaps |
| | | ); |
| | | // 推送倒计时消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", xpOrder.getId().toString()); |
| | | content.put("isOpen", 1); |
| | | params.put("type", PushMessageTypeEnum.OPEN_TRUNK.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | | params.put("timestamp", new Date().getTime() + ""); |
| | | String message = JSONObject.toJSONString(params); |
| | | SendMessageDTO sendMessageDTO = new SendMessageDTO(); |
| | | sendMessageDTO.setMessage(message); |
| | | sendMessageDTO.setAppUserId(String.valueOf(xpOrder.getAppUserId())); |
| | | xpPushMessageClient.sendStatus(sendMessageDTO); |
| | | } |
| | | Integer arriveTime = xpSystemSettingClient.getOrderFinishTime().getData(); |
| | | // 添加自动结束行程定时任务job |
| | | Map<String, ? extends Object> endTripJobMaps = |
| | | new ImmutableMap.Builder<String, String>() |
| | | .put("id", xpOrder.getId().toString()) |
| | | .put("appid", appid) |
| | | .build(); |
| | | QuartzManager.addJob( |
| | | EndTripJob.class, |
| | | (EndTripJob.name + xpOrder.getId()).toUpperCase(), |
| | | TimeJobType.END_TRIP, |
| | | DateUtils.localDateTimeToDate(LocalDateTime.now().plusMinutes(arriveTime)), |
| | | endTripJobMaps |
| | | ); |
| | | // 添加车辆到达终点后限停时间到后驶离的定时任务 |
| | | //时间到后添加巡游订单,解绑车辆关系,车辆驶离点位 |
| | | XpPoint point = xpPointClient.queryById(xpOrder.getEndPointId()).getData(); |
| | | Map<String, ? extends Object> jobMaps = |
| | | new ImmutableMap.Builder<String, String>() |
| | | .put("id", xpOrder.getId().toString()) |
| | | .put("appid", appid) |
| | | .build(); |
| | | QuartzManager.addJob( |
| | | AddCruiseMissionJob.class, |
| | | (AddCruiseMissionJob.name + xpOrder.getId()).toUpperCase(), |
| | | TimeJobType.ADD_CRUISE_MISSION, |
| | | DateUtils.localDateTimeToDate(LocalDateTime.now().plusMinutes(point.getParkingTimeLimit())), |
| | | jobMaps |
| | | ); |
| | | // 推送倒计时消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", xpOrder.getId().toString()); |
| | | content.put("isOpen", 1); |
| | | params.put("type", PushMessageTypeEnum.OPEN_TRUNK.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | | params.put("timestamp", new Date().getTime() + ""); |
| | | String message = JSONObject.toJSONString(params); |
| | | SendMessageDTO sendMessageDTO = new SendMessageDTO(); |
| | | sendMessageDTO.setMessage(message); |
| | | sendMessageDTO.setAppUserId(String.valueOf(xpOrder.getAppUserId())); |
| | | xpPushMessageClient.sendStatus(sendMessageDTO); |
| | | break; |
| | | } |
| | | xpOrder.setStatus(status); |
| | | xpOrder.setAppUserId(null); |
| | | this.updateById(xpOrder); |
| | | return R.ok(); |
| | |
| | | exactMinutes = new BigDecimal(exactMinutes).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
| | | order.setDuration(exactMinutes); |
| | | |
| | | // order.setMileageKilometers(80.0); |
| | | baseMapper.updateById(order); |
| | | // 解绑用户与车辆关系 |
| | | CancelTaxiPassengerVo cancelTaxiPassengerVo = new CancelTaxiPassengerVo(); |
| | | XpVehicle vehicle = xpVehicleClient.queryById(order.getVehicleId()).getData(); |
| | | if (vehicle != null) { |
| | | cancelTaxiPassengerVo.setVin(vehicle.getVehicleVin()); |
| | | cancelTaxiPassengerVo.setUid(uid); |
| | | cancelTaxiPassengerVo.setOrderNo(order.getOrderNumber()); |
| | | // TODO 加配置文件取 |
| | | cancelTaxiPassengerVo.setAppId(appid); |
| | | userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo); |
| | | |
| | | // 修改车辆接单状态 |
| | | vehicle.setState(0); |
| | | xpVehicleClient.updateVehicleById(vehicle); |
| | | } |
| | | |
| | | |
| | | // 根据订单所属开通城市id 查询定价 |
| | | R<XpPricing> pricingByCityId = xpPricingClient.getPricingByCid(order.getCityId()); |
| | |
| | | TaxiPricingDemoService.GpsPoint point = new TaxiPricingDemoService.GpsPoint(trajectory.getDistance(), trajectory.getLocatetime()); |
| | | gpsPoints.add(point); |
| | | } |
| | | // 补充临时轨迹数据 |
| | | // List<TaxiPricingDemoService.GpsPoint> gpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime())); |
| | | |
| | | |
| | | TaxiPricingDemoService.PricingConfig config = new TaxiPricingDemoService.PricingConfig(); |
| | | JSONArray startingFareJsonArray = JSONArray.parseArray(pricing.getStartingFareJson()); |
| | |
| | | Double duration1 = order.getDuration(); |
| | | |
| | | com.alibaba.fastjson.JSONObject basicPricingJson = com.alibaba.fastjson.JSONObject.parseObject(pricing.getBasicPricingJson()); |
| | | // String num1 = "00:00"; |
| | | // String num2 = "23:59"; |
| | | // String num3 = basicPricingJson.getString("num1"); |
| | | // String num4 = basicPricingJson.getString("num2"); |
| | | // String num5 = basicPricingJson.getString("num3"); |
| | | // String num6 = basicPricingJson.getString("num4"); |
| | | // String num7 = basicPricingJson.getString("num5"); |
| | | // config.normals.add(new TaxiPricingDemoService.PricingRule("普通时段", num1, num2, Double.parseDouble(num3), Double.parseDouble(num4), Double.parseDouble(num5), Double.parseDouble(num6), Double.parseDouble(num7))); |
| | | // paramNum4 = basicPricingJson.getDouble("num2"); |
| | | // paramNum5 = basicPricingJson.getDouble("num3"); |
| | | |
| | | XpPricingCardVo xpPricingCardVo = xpPricingUtil.calculationFixedPrice(orderAppUserId.toString(), basicPricingJson, null, mileageKilometers, duration1, 0, 0.0, pricing.getIsDynamicPrice(), order.getCityId(), pricing.getDynamicPricingJson()); |
| | | XpOrderDetail xpOrderDetail = new XpOrderDetail(); |
| | | xpOrderDetail.setDetailType(1); |
| | |
| | | order.setOrderMoney(totalPrice); |
| | | order.setAppUserId(null); |
| | | baseMapper.updateById(order); |
| | | |
| | | |
| | | } else { |
| | | |
| | | |
| | | //动态计费 |
| | | if (pricing.getPricingType() == 1) { |
| | | |
| | |
| | | BigDecimal add = order.getDurationMoney().add(fareBreakdownDetailVo.getMoney()); |
| | | order.setDurationMoney(add); |
| | | } |
| | | // for (XpOrderDetail xpOrderDetail : xpOrderDetails) { |
| | | // if (xpOrderDetail.getDetailType() == 1) { |
| | | // order.setDurationType(xpOrderDetail.getType()); |
| | | // order.setDurationMoney(xpOrderDetail.getMoney()); |
| | | //// order.setDuration(Double.parseDouble(xpOrderDetail.getDuration() + "")); |
| | | // } else { |
| | | // order.setLongDistanceType(order.getDurationType()); |
| | | // order.setLongDistance(xpOrderDetail.getMileage().doubleValue()); |
| | | // order.setLongDistancemoney(xpOrderDetail.getMoney()); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | |
| | | BigDecimal orderMoney = startMoney.add(mileageMoney).add(order.getDurationMoney() != null ? order.getDurationMoney() : BigDecimal.ZERO) |
| | | .add(order.getLongDistancemoney() != null ? order.getLongDistancemoney() : BigDecimal.ZERO) |
| | |
| | | } |
| | | order.setAppUserId(null); |
| | | baseMapper.updateById(order); |
| | | |
| | | |
| | | // 结束后的车辆操作 |
| | | if (vehicle != null) { |
| | | // 修改车辆状态 |
| | | vehicle.setState(0); |
| | | //发送巡游订单 |
| | | addCruiseMission(vehicle, order); |
| | | // // 获取配置 根据配置判断是否该收车 如果是则找到收车点位进行收车操作 |
| | | // R<XpTaskRule> xpTaskRuleR = xpTaskRuleClient.queryDetail(); |
| | | // XpTaskRule xpTaskRule = xpTaskRuleR.getData(); |
| | | // |
| | | // // 生成新的巡游单子 回到最新巡游的初始起点位置 |
| | | // XpCruiseOrder xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 2).orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | // int temp=0; |
| | | // if(xpCruiseOrders==null){ |
| | | // temp=1; |
| | | // //特殊情况 可能没有产生终止的订单 (到站点就被正常接单了)所以找正常订单 |
| | | // xpCruiseOrders=xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 3).orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | // } |
| | | // XpCruiseOrder xpCruiseOrder = new XpCruiseOrder(); |
| | | // xpCruiseOrder.setVehicleId(vehicle.getId()); |
| | | // xpCruiseOrder.setFleetId(vehicle.getFleetId()); |
| | | // xpCruiseOrder.setVehicleVin(vehicle.getVehicleVin()); |
| | | // xpCruiseOrder.setOrderType(2); |
| | | // // 返程起点是当前正常订单的终点 |
| | | // xpCruiseOrder.setStartPointId(order.getEndPointId()); |
| | | // xpCruiseOrder.setStartPointName(order.getEndPointName()); |
| | | // xpCruiseOrder.setStartLon(order.getEndLon()); |
| | | // xpCruiseOrder.setStartLat(order.getEndLat()); |
| | | // |
| | | // // 完成的直接走终点 终止的走起点 |
| | | // if(temp==0){ |
| | | // xpCruiseOrder.setEndPointId(xpCruiseOrders.getStartPointId()); |
| | | // xpCruiseOrder.setEndPointName(xpCruiseOrders.getStartPointName()); |
| | | // xpCruiseOrder.setEndLon(xpCruiseOrders.getStartLon()); |
| | | // xpCruiseOrder.setEndLat(xpCruiseOrders.getStartLat()); |
| | | // }else { |
| | | // xpCruiseOrder.setEndPointId(xpCruiseOrders.getEndPointId()); |
| | | // xpCruiseOrder.setEndPointName(xpCruiseOrders.getEndPointName()); |
| | | // xpCruiseOrder.setEndLon(xpCruiseOrders.getEndLon()); |
| | | // xpCruiseOrder.setEndLat(xpCruiseOrders.getEndLat()); |
| | | // } |
| | | // |
| | | // |
| | | // xpCruiseOrder.setStatus(0); |
| | | // xpCruiseOrder.setLastOrderId(xpCruiseOrders.getId()); |
| | | // xpCruiseOrder.setCreateTime(LocalDateTime.now()); |
| | | // xpCruiseOrder.setId("XU"+ IdUtil.fastUUID()); |
| | | // |
| | | // // 判断当前时分秒是否大于收车时间 |
| | | // LocalTime vehicleCollectionTime = xpTaskRule.getVehicleCollectionTime(); |
| | | // if (vehicleCollectionTime.isBefore(LocalTime.now())) { |
| | | // vehicle.setOperatingStatus(3); |
| | | // //找到车辆的收车点位 更新终点点位 |
| | | // R<XpCruiseOrder> returnCruisePoint = xpCruisePlanClient.findReturnCruisePoint(xpCruiseOrder); |
| | | // xpCruiseOrder = returnCruisePoint.getData(); |
| | | // } |
| | | // xpVehicleClient.updateVehicleById(vehicle); |
| | | // |
| | | // xpCruiseOrderMapper.insert(xpCruiseOrder); |
| | | // |
| | | // |
| | | // R<XpPoint> xpPointR = xpPointClient.queryById(order.getEndPointId()); |
| | | // XpPoint data = xpPointR.getData(); |
| | | // //下发命令 |
| | | // // 添加自动结束行程定时任务job |
| | | // Map<String, ? extends Object> jobMaps = |
| | | // new ImmutableMap.Builder<String, String>(). |
| | | // put("id", xpCruiseOrder.getId()) |
| | | // .build(); |
| | | // QuartzManager.addJob( |
| | | // AddCruiseMissionJob.class, |
| | | // (AddCruiseMissionJob.name + xpCruiseOrder.getId()).toUpperCase(), |
| | | // TimeJobType.ADD_CRUISE_MISSION, |
| | | // DateUtils.localDateTimeToDate(LocalDateTime.now().plusMinutes(data.getParkingTimeLimit())), |
| | | // jobMaps |
| | | // ); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | |
| | | public void addCruiseMission(XpVehicle vehicle, XpOrder order) { |
| | | log.info("添加巡游订单 {}", vehicle.getPlateNumber()); |
| | | if (vehicle.getState() != 0 || vehicle.getOperatingStatus() != 1) { |
| | | log.info("添加巡游单失败,车辆状态限制 {}", vehicle.getState()); |
| | | return; |
| | |
| | | } |
| | | xpVehicleClient.updateVehicleById(vehicle); |
| | | } |
| | | |
| | | xpCruiseOrderMapper.insert(xpCruiseOrder); |
| | | |
| | | |
| | | R<XpPoint> xpPointR = xpPointClient.queryById(order.getEndPointId()); |
| | | XpPoint data = xpPointR.getData(); |
| | | //下发命令 |
| | | // 添加自动结束行程定时任务job |
| | | Map<String, ? extends Object> jobMaps = |
| | | new ImmutableMap.Builder<String, String>(). |
| | | put("id", xpCruiseOrder.getId() + "") |
| | | .build(); |
| | | QuartzManager.addJob( |
| | | AddCruiseMissionJob.class, |
| | | (AddCruiseMissionJob.name + xpCruiseOrder.getId()).toUpperCase(), |
| | | TimeJobType.ADD_CRUISE_MISSION, |
| | | DateUtils.localDateTimeToDate(LocalDateTime.now().plusMinutes(data.getParkingTimeLimit())), |
| | | jobMaps |
| | | ); |
| | | log.info("添加巡游单成功 {}", xpCruiseOrder.getId()); |
| | | //下发XUP巡游订单报文 |
| | | PushOrderDto pushOrderDto = new PushOrderDto(); |
| | | pushOrderDto.setVin(xpCruiseOrder.getVehicleVin()); |
| | | pushOrderDto.setOrderId("XU" + xpCruiseOrder.getId()); |
| | | pushOrderDto.setStartLatitude(xpCruiseOrder.getStartLat()); |
| | | pushOrderDto.setStartLongitude(xpCruiseOrder.getStartLon()); |
| | | pushOrderDto.setEndLatitude(xpCruiseOrder.getEndLat()); |
| | | pushOrderDto.setEndLongitude(xpCruiseOrder.getEndLon()); |
| | | pushOrderDto.setOrderType(OrderType.CRUISE_ORDER); |
| | | pushOrderDto.setStage(2); |
| | | orderMissionClient.pushOrder(pushOrderDto); |
| | | log.info("下发XUP巡游订单报文成功"); |
| | | } |
| | | |
| | | |