|
|
@@ -844,6 +844,90 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
* 定时任务
|
|
|
*/
|
|
|
public void setBookStatus(){
|
|
|
- int i = bookService.updateBookStatus();
|
|
|
+
|
|
|
+ HotelDict respTime = hotelDictService.getById(1000011001);//响应时间
|
|
|
+ HotelDict operate = hotelDictService.getById(1000011002);//响应时间 1自动接单 2自动拒单
|
|
|
+ String sqlx = " and create_time <= DATE_SUB(NOW(), INTERVAL " + respTime.getName() + " MINUTE) and order_status = 2 and hotel_is_order = 1";
|
|
|
+ List<Booking> bookings = bookService.queryList(sqlx);
|
|
|
+
|
|
|
+ System.out.println("自动接单,订单编号"+bookings.stream().map(Booking::getOrderNum)+";拼接条件:"+sqlx);
|
|
|
+
|
|
|
+ AtomicInteger n = new AtomicInteger();
|
|
|
+ if ("1".equals(operate.getName())){
|
|
|
+ bookings.forEach(booking -> {
|
|
|
+ List<HouseNumberStatus> list = new ArrayList<>();
|
|
|
+ //不可入住的房间
|
|
|
+ List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(booking);
|
|
|
+ //所有房间
|
|
|
+ List<HouseNumber> houseNumberList = houseNumberService.queryByHouseId(booking.getHouseId());
|
|
|
+ AtomicInteger i = new AtomicInteger();
|
|
|
+ List<String> Ids = new ArrayList<>();
|
|
|
+ if (houseNumbers != null){
|
|
|
+ houseNumberList.forEach(houseNumber -> {
|
|
|
+ //添加的房间不在不可添加的房间当中并且数量小于订房总数
|
|
|
+ if (!houseNumbers.contains(houseNumber) && i.get() < booking.getHouseOrderNumber()){
|
|
|
+ Ids.add(houseNumber.getId());
|
|
|
+ i.getAndIncrement();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ //所有房间都可以预定
|
|
|
+ houseNumberList.forEach(houseNumber -> {
|
|
|
+ //添加的房间不在不可添加的房间当中并且数量小于订房总数
|
|
|
+ if (i.get() < booking.getHouseOrderNumber()){
|
|
|
+ Ids.add(houseNumber.getId());
|
|
|
+ i.getAndIncrement();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime str = LocalDateTime.parse(booking.getOrderStartTime(), inputFormatter);
|
|
|
+ LocalDateTime end = LocalDateTime.parse(booking.getOrderEndTime(), inputFormatter);
|
|
|
+ String a = str.format(formatter);
|
|
|
+ String B = end.format(formatter);
|
|
|
+ LocalDate strDate = LocalDate.parse(a, formatter);
|
|
|
+ LocalDate endDate = LocalDate.parse(B, formatter);
|
|
|
+ Date now = null;
|
|
|
+ try {
|
|
|
+ now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ for (String number : Ids){
|
|
|
+ for (LocalDate date = strDate; !date.isAfter(endDate.minusDays(1)); date = date.plusDays(1)){
|
|
|
+ HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
|
|
|
+ houseNumberStatus.setNumberId(number);
|
|
|
+ houseNumberStatus.setId(String.valueOf(UUID.randomUUID()));
|
|
|
+ houseNumberStatus.setCreateDate(now);
|
|
|
+ houseNumberStatus.setModifyDate(now);
|
|
|
+ houseNumberStatus.setRemark("");
|
|
|
+ houseNumberStatus.setBookingId(String.valueOf(booking.getId()));
|
|
|
+ houseNumberStatus.setSetDate(date.format(formatter));
|
|
|
+ houseNumberStatus.setStatus(5);//状态(0删除 1.正常 2.关房 3.脏房 4.净房 5.预定 6.入住)
|
|
|
+ list.add(houseNumberStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int m = houseNumberStatusService.saveBatch(list);
|
|
|
+ if (m > 0){
|
|
|
+ n.getAndIncrement();
|
|
|
+ booking.setOrderStatus("3");
|
|
|
+ booking.setUpdateTime(UUIDUtil.getNewDate());
|
|
|
+ bookService.updateBooking(booking);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ HotelDict dict = hotelDictService.getById(1000011999);
|
|
|
+ bookings.forEach(booking -> {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("bookingId", String.valueOf(booking.getId()));
|
|
|
+ try {
|
|
|
+ String msg = HttpUtils.post(dict.getFileUrl(), params);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|