Commit 4ab7e743 by 吕明尚

保洁完成增加查询当前房间当前时间加5分钟有没有预约订单

parent c46efc2b
package share.system.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import share.common.constant.Constants;
import share.common.enums.CleaningStatusEnum;
import share.common.enums.OpTypeEnum;
import share.common.enums.RoleTypeEnum;
import share.common.enums.*;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.mapper.SCleanRecordsMapper;
import share.system.domain.SCleanRecords;
import share.system.mapper.SConsumerMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreMapper;
import share.system.service.DeviceOpService;
import share.system.service.ISCleanRecordsService;
import share.system.service.ISOrderService;
import share.system.service.SmsService;
/**
......@@ -46,12 +46,16 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
private SmsService smsService;
@Autowired
private DeviceOpService deviceOpService;
@Autowired
private ISOrderService orderService;
//管理员手机号
private static final String phone = "13888888888";
//5秒延迟
private static final Long FIVE = 5L;
private static final int CLEANING = 5;
/**
* 查询保洁记录
*
......@@ -201,12 +205,30 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
if (list.size() == 0) {
return Boolean.FALSE;
}
//获取List的房间集合
List<Long> roomIds = list.stream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.in(SOrder::getRoomId, roomIds);
sOrderLambdaQueryWrapper.eq(SOrder::getOrderType, OrderTypeEnum.RESERVER.getCode());
sOrderLambdaQueryWrapper.between(SOrder::getPreStartDate, now, DateUtil.offsetMinute(now, CLEANING));
List<SOrder> orderList = orderService.list(sOrderLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(orderList)) {
List<Long> orderRoomIds = orderList.stream().map(SOrder::getRoomId).collect(Collectors.toList());
list = list.stream().filter(item -> orderRoomIds.contains(item.getRoomId())).collect(Collectors.toList());
}
//查询当前房间当前时间加5分钟有没有预约订单
for (SCleanRecords sCleanRecords : list) {
sCleanRecords.setStatus(2);
sCleanRecords.setStartDate(now);
sCleanRecords.setEndDate(now);
sCleanRecords.setUpdateTime(now);
deviceOpService.openOrCloseDevice(sCleanRecords.getRoomId(), phone, OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE);
List<Long> unusedOrderRoomIds = Optional.ofNullable(orderList).
orElse(new ArrayList<>()).stream().filter(order -> order.getStatus().equals(OrderStatusEnum.UNUSED.getCode()))
.map(SOrder::getRoomId).collect(Collectors.toList());
if (unusedOrderRoomIds.contains(sCleanRecords.getRoomId())) {
deviceOpService.openOrCloseDevice(sCleanRecords.getRoomId(), phone, OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE);
}
}
return 0 < baseMapper.updateBatch(list);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment