Merge remote-tracking branch 'origin/master'
| | |
| | | |
| | | |
| | | List<OrderPrivateCar> queryByDriver(@Param("driverId") Integer driverId, @Param("state") Integer...state); |
| | | |
| | | /** |
| | | * 批量查询司机的预约单 |
| | | * @param driverIds |
| | | * @param orderType |
| | | * @param state |
| | | * @return |
| | | */ |
| | | List<OrderPrivateCar> queryOrderByState(@Param("driverIds")List<Integer> driverIds, Integer orderType, @Param("state") Integer...state); |
| | | } |
| | |
| | | #{item} |
| | | </foreach> |
| | | </select> |
| | | <select id="queryOrderByState" resultType="com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar"> |
| | | select |
| | | id as id, |
| | | `type` as `type`, |
| | | userId as userId, |
| | | serverCarModelId as serverCarModelId, |
| | | driverId as driverId, |
| | | carId as carId, |
| | | orderNum as orderNum, |
| | | placementLon as placementLon, |
| | | placementLat as placementLat, |
| | | placementAddress as placementAddress, |
| | | startLon as startLon, |
| | | startLat as startLat, |
| | | startAddress as startAddress, |
| | | endLon as endLon, |
| | | endLat as endLat, |
| | | endAddress as endAddress, |
| | | boardingLon as boardingLon, |
| | | boardingLat as boardingLat, |
| | | boardingAddress as boardingAddress, |
| | | boardingTime as boardingTime, |
| | | getoffLon as getoffLon, |
| | | getoffLat as getoffLat, |
| | | getoffAddress as getoffAddress, |
| | | getoffTime as getoffTime, |
| | | mileage as mileage, |
| | | payManner as payManner, |
| | | payType as payType, |
| | | orderMoney as orderMoney, |
| | | startMileage as startMileage, |
| | | startMoney as startMoney, |
| | | mileageKilometers as mileageKilometers, |
| | | mileageMoney as mileageMoney, |
| | | duration as duration, |
| | | durationMoney as durationMoney, |
| | | wait as wait, |
| | | waitMoney as waitMoney, |
| | | longDistance as longDistance, |
| | | longDistanceMoney as longDistanceMoney, |
| | | parkMoney as parkMoney, |
| | | roadTollMoney as roadTollMoney, |
| | | redPacketMoney as redPacketMoney, |
| | | couponMoney as couponMoney, |
| | | redPacketId as redPacketId, |
| | | couponId as couponId, |
| | | discount as discount, |
| | | discountMoney as discountMoney, |
| | | activityId as activityId, |
| | | companyId as companyId, |
| | | payMoney as payMoney, |
| | | substitute as substitute, |
| | | passengers as passengers, |
| | | passengersPhone as passengersPhone, |
| | | state as state, |
| | | insertTime as insertTime, |
| | | travelTime as travelTime, |
| | | snatchOrderTime as snatchOrderTime, |
| | | setOutTime as setOutTime, |
| | | arriveTime as arriveTime, |
| | | startServiceTime as startServiceTime, |
| | | endServiceTime as endServiceTime, |
| | | orderType as orderType, |
| | | orderSource as orderSource, |
| | | invoiceId as invoiceId, |
| | | isReassign as isReassign, |
| | | reassignNotice as reassignNotice, |
| | | trackId as trackId, |
| | | isDelete as isDelete, |
| | | oldState as oldState, |
| | | telX as telX, |
| | | bindId as bindId |
| | | from t_order_private_car where isDelete = 1 |
| | | <if test="null != driverIds and driverIds.size()>0"> |
| | | and driverId in |
| | | <foreach collection="driverIds" item="driverId" index="index" open="(" separator="," close=")"> |
| | | #{driverId} |
| | | </foreach> |
| | | </if> |
| | | <if test="null != orderType"> |
| | | and orderType = #{orderType} |
| | | </if> |
| | | <if test="null != state"> |
| | | and state in |
| | | <foreach collection="state" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | if(list.size() > 0){ |
| | | // 查询预约单 |
| | | List<Integer> driverIds = list.stream().map(Driver::getId).collect(Collectors.toList()); |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryOrderByState(driverIds, 2, 1, 1, 2, 3, 4, 5, 6, 11); |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | for(Driver driver : list){//开始进行推送 |
| | | // 判断该司机是否有30分钟内预约单 |
| | | long count = orderPrivateCars.stream().filter(orderPrivateCar1 -> driver.getId().equals(orderPrivateCar1.getDriverId()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).minusMinutes(30).isBefore(LocalDateTime.now()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).isAfter(LocalDateTime.now())).count(); |
| | | if(count > 0){ |
| | | continue; |
| | | } |
| | | boolean bo = false; |
| | | for(Integer integer : integers){ |
| | | if(integer.compareTo(driver.getId()) == 0){ |
| | |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | map.put("endTime", end); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * Date转为LocalDateTime |
| | | * |
| | | * @param date 日期 |
| | | * @return LocalDateTime |
| | | */ |
| | | public static LocalDateTime dateToLocalDateTime(Date date) { |
| | | Instant instant = date.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | return instant.atZone(zoneId).toLocalDateTime(); |
| | | } |
| | | |
| | | /** |
| | | * LocalDateTime转Date |
| | | * |
| | | * @param dateTime 日期 |
| | | * @return Date |
| | | */ |
| | | public static Date localDateTimeToDate(LocalDateTime dateTime) { |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | ZonedDateTime zdt = dateTime.atZone(zoneId); |
| | | return Date.from(zdt.toInstant()); |
| | | } |
| | | |
| | | } |