| | |
| | | |
| | | 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; |
| | | import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService; |
| | |
| | | // if(null != query){ |
| | | // return ResultUtil.error("有未完成支付的改派申请"); |
| | | // } |
| | | int types=1; |
| | | Reassign query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 1); |
| | | if (null != query) { |
| | | types=2; |
| | | // return ResultUtil.error("不能重复提交申请"); |
| | | reassignMapper.deleteById(query.getId()); |
| | | } |
| | | query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 2); |
| | | int types=1; |
| | | |
| | | if (null != query) { |
| | | types=2; |
| | | // return ResultUtil.error("您提交的申请正在处理中"); |
| | | } |
| | | |
| | | //获取支付金额 |
| | | // Double aDouble = orderService.queryReassignMoney(reassign.getOrderId(), reassign.getOrderType()); |
| | | // reassign.setMoney(aDouble); |
| | | // reassign.setOriginalDriverId(uid); |
| | | // reassign.setOriginalCarId(driver.getCarId()); |
| | | // reassign.setInsertTime(new Date()); |
| | | // this.insert(reassign); |
| | | Double aDouble = orderService.queryReassignMoney(reassign.getOrderId(), reassign.getOrderType()); |
| | | reassign.setMoney(aDouble); |
| | | reassign.setOriginalDriverId(uid); |
| | | reassign.setOriginalCarId(driver.getCarId()); |
| | | reassign.setInsertTime(new Date()); |
| | | if(types==1){ |
| | | this.insert(reassign); |
| | | } |
| | | // systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | |
| | | //开始支付 |
| | |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | | orderPrivateCar.setState(11); |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCar.setIsReassign(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){ |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | |
| | | |
| | | //添加已收入明细 |
| | |
| | | orderTaxi.setOldState(orderTaxi.getState()); |
| | | orderTaxi.setState(11); |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxi.setIsReassign(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | |
| | | //添加已收入明细 |
| | | // incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney()); |
| | |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | | orderLogistics.setState(11); |
| | | orderLogistics.setReassignNotice(2); |
| | | orderLogistics.setIsReassign(2); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | |
| | | //添加已收入明细 |
| | |
| | | orderLogistics1.setOldState(orderLogistics1.getState()); |
| | | orderLogistics1.setState(11); |
| | | orderLogistics1.setReassignNotice(2); |
| | | orderLogistics1.setIsReassign(2); |
| | | orderLogisticsService.updateById(orderLogistics1); |
| | | |
| | | //添加已收入明细 |
| | |
| | | Driver driver = driverService.selectById(uid); |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()) { |
| | | |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | if(orderPrivateCar.getState() == 10){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | orderPrivateCar.setState(orderPrivateCar.getOldState()); |
| | | orderPrivateCar.setReassignNotice(0); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){ |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | | if(orderTaxi.getState() == 10){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | orderTaxi.setState(orderTaxi.getOldState()); |
| | | orderTaxi.setReassignNotice(0); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | break; |
| | | } |
| | | reassignMapper.delete(new EntityWrapper<Reassign>().eq("orderId",reassign.getOrderId()).eq("orderType",reassign.getOrderType())); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | orderCrossCity.setOldState(orderCrossCity.getState()); |
| | | orderCrossCity.setState(11); |
| | | orderCrossCity.setReassignNotice(2); |
| | | orderCrossCity.setIsReassign(2); |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | |
| | | //添加已收入明细 |
| | |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid, 1); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | | map.put("orderType", reassign.getOrderType().toString()); |
| | | List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderId", reassign.getOrderId().toString()); |
| | | // map.put("orderType", reassign.getOrderType().toString()); |
| | | // List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | // for (Dispatch dispatch : dispatches) { |
| | | // jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | // } |
| | | } |
| | | if (reassign.getPayType() == 4) { |
| | | |
| | |
| | | reassign.setPayOrder(order_id); |
| | | reassign.setPayTime(new Date()); |
| | | this.updateById(reassign); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | | map.put("orderType", reassign.getOrderType().toString()); |
| | | List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | // //开始推送调度单 |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderId", reassign.getOrderId().toString()); |
| | | // map.put("orderType", reassign.getOrderType().toString()); |
| | | // List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | // for (Dispatch dispatch : dispatches) { |
| | | // jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | // } |
| | | } |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | |
| | | orderCrossCity1.setOldState(orderCrossCity1.getState()); |
| | | orderCrossCity1.setState(11); |
| | | orderCrossCity1.setReassignNotice(2); |
| | | orderCrossCity1.setIsReassign(2); |
| | | orderCrossCityService.updateById(orderCrossCity1); |
| | | System.out.println("==============跨城修改改派通知状态完毕===================" + orderCrossCity1); |
| | | |
| | |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | | orderPrivateCar.setState(11); |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCar.setIsReassign(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | //添加已收入明细 |
| | |
| | | orderTaxi.setOldState(orderTaxi.getState()); |
| | | orderTaxi.setState(11); |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxi.setIsReassign(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | |
| | | //添加已收入明细 |
| | |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | | orderLogistics.setState(11); |
| | | orderLogistics.setReassignNotice(2); |
| | | orderLogistics.setIsReassign(2); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | |
| | | //添加已收入明细 |
| | |
| | | orderLogistics1.setOldState(orderLogistics1.getState()); |
| | | orderLogistics1.setState(11); |
| | | orderLogistics1.setReassignNotice(2); |
| | | orderLogistics1.setIsReassign(2); |
| | | orderLogisticsService.updateById(orderLogistics1); |
| | | |
| | | //添加已收入明细 |
| | |
| | | break; |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2 ? "支付宝" : "云闪付")) + "成功支付改派申请费用!", reassign.getOriginalDriverId(), 1); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | | map.put("orderType", reassign.getOrderType().toString()); |
| | | List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | // //开始推送调度单 |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderId", reassign.getOrderId().toString()); |
| | | // map.put("orderType", reassign.getOrderType().toString()); |
| | | // List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | // for (Dispatch dispatch : dispatches) { |
| | | // jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | // } |
| | | System.out.println("==============其他订单完毕==================="); |
| | | } else { |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | |
| | | } |
| | | OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 2, openCity.getId());//获取需要推送的次数 |
| | | int size=1; |
| | | if(type==2){ |
| | | size = 6; |
| | | } |
| | | |
| | | for (int i = 1; i <= size; i++) { |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | list = list.stream().filter(e -> e.getId() != uid).collect(Collectors.toList()); |
| | | OrderTaxi orderTaxi1 = orderTaxiService.selectById(orderTaxi.getId()); |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | lastIndex = lastIndex == 0 ? list.size() : lastIndex; |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | for (Driver driver : list) {//开始进行推送 |
| | | //查询是否在限制推单范围内 |
| | | boolean bo = false; |
| | | for (Integer integer : integers) { |
| | | if (integer.compareTo(driver.getId()) == 0) { |
| | | bo = true; |
| | | break; |
| | | int num = 0; |
| | | for (int j = 0; j < 6; j++) { |
| | | Boolean push = false; |
| | | for (int i = 1; i <= querys.size(); i++) { |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | list = list.stream().filter(e -> e.getId() != uid).collect(Collectors.toList()); |
| | | OrderTaxi orderTaxi1 = orderTaxiService.selectById(orderTaxi.getId()); |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | lastIndex = lastIndex == 0 ? list.size() : lastIndex; |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | for (Driver driver : list) {//开始进行推送 |
| | | //查询是否在限制推单范围内 |
| | | boolean bo = false; |
| | | for (Integer integer : integers) { |
| | | if (integer.compareTo(driver.getId()) == 0) { |
| | | bo = true; |
| | | break; |
| | | } |
| | | } |
| | | if (bo) { |
| | | continue; |
| | | } |
| | | pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime()); |
| | | } |
| | | if (bo) { |
| | | continue; |
| | | } |
| | | pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime()); |
| | | } |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |
| | | Integer state = orderTaxi1.getState(); |
| | | if (state != 1 || state!= 11) { |
| | | orderIds.remove(orderTaxi.getId()); |
| | | push = true; |
| | | break; |
| | | } |
| | | if (num == 18 && (state == 1 || state==11)) { |
| | | System.err.println("结束改派退单-------------修改订单为取消状态"); |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2, 11); |
| | | pushUtil.pushOrderState(2, orderTaxi.getDriverId(), orderTaxi.getId(), 2, 10); |
| | | orderTaxi1.setState(10); |
| | | orderTaxiService.updateById(orderTaxi1); |
| | | orderIds.remove(orderTaxi.getId()); |
| | | } |
| | | } |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |
| | | Integer state = orderTaxi1.getState(); |
| | | if (state != 1 || state!= 11) { |
| | | if(push){ |
| | | break; |
| | | } |
| | | if (i == 6 && (state == 1 || state==11)) { |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); |
| | | orderTaxi1.setState(10); |
| | | orderTaxiService.updateById(orderTaxi1); |
| | | orderIds.remove(orderTaxi.getId()); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//获取需要推送的次数 |
| | | int size=1; |
| | | if(type==2){ |
| | | size=6; |
| | | } |
| | | for (int i = 1; i <= size; i++) { |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(id); |
| | | if (null == orderPrivateCar || (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11)) { |
| | | break; |
| | | } |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | int i2 = pushOrder.getPushTime() / 10; |
| | | if (i2 == 0) { |
| | | i2 = 1; |
| | | } |
| | | for (int i1 = 0; i1 < i2; i1++) { |
| | | int num = 0; |
| | | for (int j = 0; j < 6; j++) { |
| | | Boolean push = false; |
| | | for (int i = 1; i <= querys.size(); i++) { |
| | | num++; |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(id); |
| | | if (null == orderPrivateCar || (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11)) { |
| | | push = true; |
| | | break; |
| | | } |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | |
| | | if (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11) { |
| | | push = true; |
| | | break; |
| | | } |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(orderType, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | list = list.stream().filter(e -> e.getId() != uid).collect(Collectors.toList()); |
| | | list = list.stream().filter(e -> !e.getId().equals(uid)).collect(Collectors.toList()); |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | |
| | | pushUtil.pushOrderState(2, driver.getId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), pushOrder.getPushTime()); |
| | | } |
| | | } |
| | | Thread.sleep(10000);//设置等待时间 |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |
| | | Integer state = orderPrivateCar.getState(); |
| | | if (state > 1 && state != 11) { |
| | | orderIds.remove(orderPrivateCar.getId()); |
| | | push = true; |
| | | return; |
| | | } |
| | | if (i == 6 && (state == 1 || state==11)) { |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1); |
| | | if (num == 18 && (state == 1 || state==11)) { |
| | | System.err.println("结束改派退单-------------修改订单为取消状态"); |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 11); |
| | | pushUtil.pushReassignEndCancel(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 10); |
| | | orderPrivateCar.setState(10); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | orderIds.remove(orderPrivateCar.getId()); |
| | | } |
| | | } |
| | | if(push){ |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |