From cb7e84fe6e40f3ce3ed1fe3fb3b4c0da8c847793 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 27 八月 2025 23:51:22 +0800 Subject: [PATCH] 修改bug --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java | 332 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 184 insertions(+), 148 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java index 6eef1c7..41a37b6 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java @@ -193,20 +193,23 @@ 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); //添加已收入明细 @@ -219,20 +222,23 @@ 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()); @@ -245,6 +251,7 @@ orderLogistics.setOldState(orderLogistics.getState()); orderLogistics.setState(11); orderLogistics.setReassignNotice(2); + orderLogistics.setIsReassign(2); orderLogisticsService.updateById(orderLogistics); //添加已收入明细 @@ -255,6 +262,7 @@ orderLogistics1.setOldState(orderLogistics1.getState()); orderLogistics1.setState(11); orderLogistics1.setReassignNotice(2); + orderLogistics1.setIsReassign(2); orderLogisticsService.updateById(orderLogistics1); //添加已收入明细 @@ -298,18 +306,20 @@ 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()); @@ -319,18 +329,20 @@ 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())); @@ -541,6 +553,7 @@ orderCrossCity.setOldState(orderCrossCity.getState()); orderCrossCity.setState(11); orderCrossCity.setReassignNotice(2); + orderCrossCity.setIsReassign(2); orderCrossCityService.updateById(orderCrossCity); //添加已收入明细 @@ -548,13 +561,13 @@ } 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) { @@ -619,14 +632,14 @@ 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); @@ -638,6 +651,7 @@ orderCrossCity1.setOldState(orderCrossCity1.getState()); orderCrossCity1.setState(11); orderCrossCity1.setReassignNotice(2); + orderCrossCity1.setIsReassign(2); orderCrossCityService.updateById(orderCrossCity1); System.out.println("==============跨城修改改派通知状态完毕===================" + orderCrossCity1); @@ -683,6 +697,7 @@ orderPrivateCar.setOldState(orderPrivateCar.getState()); orderPrivateCar.setState(11); orderPrivateCar.setReassignNotice(2); + orderPrivateCar.setIsReassign(2); orderPrivateCarService.updateById(orderPrivateCar); //添加已收入明细 @@ -694,6 +709,7 @@ orderTaxi.setOldState(orderTaxi.getState()); orderTaxi.setState(11); orderTaxi.setReassignNotice(2); + orderTaxi.setIsReassign(2); orderTaxiService.updateById(orderTaxi); //添加已收入明细 @@ -705,6 +721,7 @@ orderLogistics.setOldState(orderLogistics.getState()); orderLogistics.setState(11); orderLogistics.setReassignNotice(2); + orderLogistics.setIsReassign(2); orderLogisticsService.updateById(orderLogistics); //添加已收入明细 @@ -716,6 +733,7 @@ orderLogistics1.setOldState(orderLogistics1.getState()); orderLogistics1.setState(11); orderLogistics1.setReassignNotice(2); + orderLogistics1.setIsReassign(2); orderLogisticsService.updateById(orderLogistics1); //添加已收入明细 @@ -724,14 +742,14 @@ 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 + ")"); @@ -771,50 +789,58 @@ } OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()); List<PushOrder> querys = pushOrderService.querys(null, 2, openCity.getId());//获取需要推送的次数 - int size=18; - 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) { - orderIds.remove(orderTaxi.getId()); + if(push){ break; } - if (i == 18 && (state == 1 || state==11)) { - System.err.println("结束改派退单-------------修改订单为取消状态"); - pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); - pushUtil.pushOrderState(2, orderTaxi.getDriverId(), orderTaxi.getId(), 2, 10); - orderTaxi1.setState(10); - orderTaxiService.updateById(orderTaxi1); - orderIds.remove(orderTaxi.getId()); - } } + } catch (Exception e) { e.printStackTrace(); } @@ -843,57 +869,67 @@ } OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//获取需要推送的次数 - int size=18; - 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 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) { - break; - } - //获取空闲司机 - List<Driver> list = driverService.queryIdleDriver(orderType, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 - 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();//计算占比转成整数(下标截取) - 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 (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().equals(uid)).collect(Collectors.toList()); + 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(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), pushOrder.getPushTime()); } - if (bo) { - continue; - } - pushUtil.pushOrderState(2, driver.getId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), pushOrder.getPushTime()); + } + Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 + Integer state = orderPrivateCar.getState(); + if (state > 1 && state != 11) { + orderIds.remove(orderPrivateCar.getId()); + push = true; + return; + } + 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()); } } - Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 - Integer state = orderPrivateCar.getState(); - if (state > 1 && state != 11) { - orderIds.remove(orderPrivateCar.getId()); - return; + if(push){ + break; } - if (i == 18 && (state == 1 || state==11)) { - System.err.println("结束改派退单-------------修改订单为取消状态"); - pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1); - pushUtil.pushReassignEndCancel(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 10); - orderPrivateCar.setState(10); - orderPrivateCarService.updateById(orderPrivateCar); - orderIds.remove(orderPrivateCar.getId()); - } - } + } catch (Exception e) { e.printStackTrace(); } -- Gitblit v1.7.1