Commit b8ae7060 by wuwenlong

脏房到次日门店保洁时段锁定房间状态不可预定,如果没有设置门店保洁时段则只锁定当日

parent 2f52bd75
...@@ -15,6 +15,15 @@ public enum CleaningStatusEnum { ...@@ -15,6 +15,15 @@ public enum CleaningStatusEnum {
CleaningStatusEnum() { CleaningStatusEnum() {
} }
public static CleaningStatusEnum getEnumByCode(Integer code) {
for (CleaningStatusEnum status : CleaningStatusEnum.values()) {
if (status.getCode().compareTo(code)==0) {
return status;
}
}
return null;
}
public Integer getCode() { public Integer getCode() {
return code; return code;
} }
......
...@@ -120,12 +120,40 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -120,12 +120,40 @@ public class RoomStatusServiceImpl implements RoomStatusService {
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单) //设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user){ private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user){
vo.setStatus(RoomStatusEnum.FREE.getValue()); vo.setStatus(RoomStatusEnum.FREE.getValue());
checkIsDirtyRoom(vo,timeHourDate,store,cleanRecords,day);
checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday); checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday);
checkTimeHourToBusiness(vo,timeHourDate,store,day); checkTimeHourToBusiness(vo,timeHourDate,store,day);
checkTimeHourToOrder(vo,timeHourDate,orderList,cleanRecords,orderType, user); checkTimeHourToOrder(vo,timeHourDate,orderList,cleanRecords,orderType, user);
} }
private void checkIsDirtyRoom(RoomStatusVo vo,Date timeHourDate, SStore store, SCleanRecords cleanRecords, String day){
CleaningStatusEnum cleaningStatusEnum = CleaningStatusEnum.getEnumByCode(cleanRecords.getStatus());
switch (cleaningStatusEnum){
case UNCLEAN:
case CLEANING:
//当天
if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate()))){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
changeStartHoldTime(vo,timeHourDate);
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
//次日
if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.addDays(DateUtils.getNowDate(),1)))){
if(StringUtils.isNotBlank(store.getCleaningPeriod())
&&timeHourDate.getTime()<DateUtils.parseDate(day+" "+store.getCleaningPeriod()).getTime()){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
changeStartHoldTime(vo,timeHourDate);
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
break;
case CLEANED:
break;
default:
break;
}
}
private void changeEndHoldTime(RoomStatusVo vo, Date date){ private void changeEndHoldTime(RoomStatusVo vo, Date date){
if(Objects.isNull(vo.getEndHoldTime())||vo.getEndHoldTime().compareTo(date)<0){ if(Objects.isNull(vo.getEndHoldTime())||vo.getEndHoldTime().compareTo(date)<0){
vo.setEndHoldTime(date); vo.setEndHoldTime(date);
......
...@@ -428,7 +428,7 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -428,7 +428,7 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
public SCleanRecords lastCleanByRoomId(Long roomId) { public SCleanRecords lastCleanByRoomId(Long roomId) {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SCleanRecords::getRoomId, roomId); queryWrapper.eq(SCleanRecords::getRoomId, roomId);
queryWrapper.gt(SCleanRecords::getCreateTime,DateUtils.addDays(new Date(),-1)); queryWrapper.gt(SCleanRecords::getCreateTime,DateUtils.addDays(new Date(),-7));
List<SCleanRecords> records = list(queryWrapper); List<SCleanRecords> records = list(queryWrapper);
if(CollectionUtils.isNotEmpty(records)){ if(CollectionUtils.isNotEmpty(records)){
Optional<SCleanRecords> cleanRecords = records.stream().max(Comparator.comparing(SCleanRecords::getCreateTime)); Optional<SCleanRecords> cleanRecords = records.stream().max(Comparator.comparing(SCleanRecords::getCreateTime));
......
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