Commit 595d122e by wuwenlong

新增房间状态(上架,下架,维护),下架时用户端房间列表不展示,下架与维护中下单限制,房间预约时段锁定

parent 5dd55333
package share.common.enums; package share.common.enums;
import share.common.utils.StringUtils;
/** /**
* @className: share.common.enums.RoomStatEnum * @className: share.common.enums.RoomStatEnum
* @description: 门店房间上下架 * @description: 门店房间上下架
...@@ -7,8 +9,8 @@ package share.common.enums; ...@@ -7,8 +9,8 @@ package share.common.enums;
* @create: 2024-02-28 13:46 * @create: 2024-02-28 13:46
*/ */
public enum RoomStatEnum { public enum RoomStatEnum {
GROUNDING(1,"上架"), ITEM_UP_SHELF(1,"上架"),
UNDERCARRIAGE(2,"下架"), ITEM_DOWN_SHELF(2,"下架"),
MAINTENANCE(3,"维护"); MAINTENANCE(3,"维护");
private Integer value; private Integer value;
...@@ -19,6 +21,16 @@ public enum RoomStatEnum { ...@@ -19,6 +21,16 @@ public enum RoomStatEnum {
this.name = name; this.name = name;
} }
public static RoomStatEnum getEnumByValue(Integer value){
if(value!=null) {
for (RoomStatEnum stat : RoomStatEnum.values()) {
if (stat.value.compareTo(value) == 0) {
return stat;
}
}
}
return null;
}
public Integer getValue() { public Integer getValue() {
return value; return value;
......
...@@ -48,8 +48,6 @@ public class SCleanRecordsController extends BaseController ...@@ -48,8 +48,6 @@ public class SCleanRecordsController extends BaseController
{ {
@Autowired @Autowired
private ISCleanRecordsService sCleanRecordsService; private ISCleanRecordsService sCleanRecordsService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/** /**
* 查询保洁记录列表 * 查询保洁记录列表
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController; import share.common.core.controller.BaseController;
import share.common.core.domain.R; import share.common.core.domain.R;
import share.common.enums.RoomStatEnum;
import share.system.domain.SPack; import share.system.domain.SPack;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.domain.vo.RoomStatusVo; import share.system.domain.vo.RoomStatusVo;
...@@ -36,17 +37,13 @@ public class SRoomController extends BaseController { ...@@ -36,17 +37,13 @@ public class SRoomController extends BaseController {
@Autowired @Autowired
private RoomStatusService roomStatusService; private RoomStatusService roomStatusService;
@Autowired
private IPackService packService;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 查询房间列表 * 查询房间列表
*/ */
@ApiOperation(value = "房间列表") @ApiOperation(value = "房间列表")
@GetMapping("/list") @GetMapping("/list")
public R<List<SRoomVo>> list(SRoom sRoom) { public R<List<SRoomVo>> list(SRoom sRoom) {
sRoom.setQueryNotRoomStat(RoomStatEnum.ITEM_DOWN_SHELF.getValue());
List<SRoomVo> list = sRoomService.selectSRoomVoList(sRoom); List<SRoomVo> list = sRoomService.selectSRoomVoList(sRoom);
return R.ok(list); return R.ok(list);
} }
......
...@@ -132,4 +132,9 @@ public class SRoom extends BaseEntity ...@@ -132,4 +132,9 @@ public class SRoom extends BaseEntity
@TableField(exist = false) @TableField(exist = false)
private String storeName; private String storeName;
/** 查询条件:非此房间状态 */
@TableField(exist = false)
private Integer queryNotRoomStat;
} }
...@@ -98,7 +98,7 @@ public class SRoomVo extends BaseEntity ...@@ -98,7 +98,7 @@ public class SRoomVo extends BaseEntity
/** /**
* 房间上下架(1-上架,2-下架,3-维护) * 房间上下架(1-上架,2-下架,3-维护)
*/ */
@Excel(name = "房间上下架") @ApiModelProperty(value = "房间上下架(1-上架,2-下架,3-维护)")
private Integer roomStat; private Integer roomStat;
/** /**
......
package share.system.service; package share.system.service;
import share.system.domain.SRoom;
import share.system.domain.vo.RoomStatusVo; import share.system.domain.vo.RoomStatusVo;
import java.util.Date; import java.util.Date;
...@@ -27,6 +28,6 @@ public interface RoomStatusService { ...@@ -27,6 +28,6 @@ public interface RoomStatusService {
* @param roomIds * @param roomIds
* @return List<RoomStatusVo> * @return List<RoomStatusVo>
*/ */
List<RoomStatusVo> listRoomStatus(Long storeId, List<Long> roomIds); List<RoomStatusVo> listRoomStatus(Long storeId, List<SRoom> roomList);
} }
...@@ -4,16 +4,10 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -4,16 +4,10 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.constant.Constants; import share.common.constant.Constants;
import share.common.enums.CleaningStatusEnum; import share.common.enums.*;
import share.common.enums.OrderStatusEnum;
import share.common.enums.OrderTypeEnum;
import share.common.enums.RoomStatusEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import share.common.utils.StringUtils; import share.common.utils.StringUtils;
import share.system.domain.SCleanRecords; import share.system.domain.*;
import share.system.domain.SConsumer;
import share.system.domain.SOrder;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.RoomStatusVo; import share.system.domain.vo.RoomStatusVo;
import share.system.service.*; import share.system.service.*;
...@@ -43,6 +37,9 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -43,6 +37,9 @@ public class RoomStatusServiceImpl implements RoomStatusService {
@Autowired @Autowired
private ISCleanRecordsService cleanRecordsService; private ISCleanRecordsService cleanRecordsService;
@Autowired
private ISRoomService roomService;
@Override @Override
public List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day, Integer orderType) { public List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day, Integer orderType) {
SConsumer user = consumerService.getInfo(); SConsumer user = consumerService.getInfo();
...@@ -54,13 +51,14 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -54,13 +51,14 @@ public class RoomStatusServiceImpl implements RoomStatusService {
// 通过门店及房间查询指定日期T+1的订单 // 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,new ArrayList<Long>(){{add(roomId);}},day); List<SOrder> orderList = orderService.listByRoomInfo(storeId,new ArrayList<Long>(){{add(roomId);}},day);
SCleanRecords cleanRecords = cleanRecordsService.lastCleanByRoomId(roomId); SCleanRecords cleanRecords = cleanRecordsService.lastCleanByRoomId(roomId);
List<RoomStatusVo> voList = generatorRoomStatusList(store,roomId,orderList,cleanRecords,day,orderType, user); SRoom room = roomService.getById(roomId);
voList.addAll(generatorRoomStatusList(store,roomId,orderList,cleanRecords,DateUtils.addDays(day,1),orderType, user)); List<RoomStatusVo> voList = generatorRoomStatusList(store,room,orderList,cleanRecords,day,orderType, user);
voList.addAll(generatorRoomStatusList(store,room,orderList,cleanRecords,DateUtils.addDays(day,1),orderType, user));
return voList; return voList;
} }
@Override @Override
public List<RoomStatusVo> listRoomStatus(Long storeId,List<Long> roomIds) { public List<RoomStatusVo> listRoomStatus(Long storeId,List<SRoom> roomList) {
SConsumer user = consumerService.getInfo(); SConsumer user = consumerService.getInfo();
if(user!=null){ if(user!=null){
FrontTokenComponent.loginSConsumerEntryThreadLocal.set(user); FrontTokenComponent.loginSConsumerEntryThreadLocal.set(user);
...@@ -68,6 +66,7 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -68,6 +66,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
Date day = new Date(); Date day = new Date();
//查询门店营业时间 //查询门店营业时间
SStore store = storeService.getById(storeId); SStore store = storeService.getById(storeId);
List<Long> roomIds = roomList.stream().map(SRoom::getId).collect(Collectors.toList());
// 通过门店及房间查询指定日期T+1的订单 // 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,roomIds,day); List<SOrder> orderList = orderService.listByRoomInfo(storeId,roomIds,day);
Map<Long,List<SOrder>> orderMap = Optional.ofNullable(orderList).orElse(new ArrayList<>()).parallelStream().collect(Collectors.groupingBy(SOrder::getRoomId)); Map<Long,List<SOrder>> orderMap = Optional.ofNullable(orderList).orElse(new ArrayList<>()).parallelStream().collect(Collectors.groupingBy(SOrder::getRoomId));
...@@ -77,9 +76,9 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -77,9 +76,9 @@ public class RoomStatusServiceImpl implements RoomStatusService {
} }
List<RoomStatusVo> voList = new ArrayList<>(); List<RoomStatusVo> voList = new ArrayList<>();
Map<Long, SCleanRecords> finalCleanRecordMap = cleanRecordMap; Map<Long, SCleanRecords> finalCleanRecordMap = cleanRecordMap;
roomIds.stream().forEach(roomId -> { roomList.stream().forEach(room -> {
voList.addAll(generatorRoomStatusList(store, roomId, orderMap.get(roomId), finalCleanRecordMap.get(roomId), day, OrderTypeEnum.RESERVER.getCode(), user)); voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), day, OrderTypeEnum.RESERVER.getCode(), user));
voList.addAll(generatorRoomStatusList(store, roomId, orderMap.get(roomId), finalCleanRecordMap.get(roomId), DateUtils.addDays(day, 1), OrderTypeEnum.RESERVER.getCode(), user)); voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), DateUtils.addDays(day, 1), OrderTypeEnum.RESERVER.getCode(), user));
}); });
return voList; return voList;
} }
...@@ -87,7 +86,7 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -87,7 +86,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
private List<RoomStatusVo> generatorRoomStatusList(SStore store,Long roomId,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType, SConsumer user){ private List<RoomStatusVo> generatorRoomStatusList(SStore store,SRoom room,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType, SConsumer user){
String nowTime = "00:00"; String nowTime = "00:00";
String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day); String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day);
Boolean isToday = StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day) Boolean isToday = StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day)
...@@ -108,22 +107,35 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -108,22 +107,35 @@ public class RoomStatusServiceImpl implements RoomStatusService {
timeHour = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day) + " " + lock; timeHour = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day) + " " + lock;
} }
vo.setStoreId(store.getId()); vo.setStoreId(store.getId());
vo.setRoomId(roomId); vo.setRoomId(room.getId());
vo.setTimeHour(timeHour); vo.setTimeHour(timeHour);
Date timeHourDate = DateUtils.parseDate(timeHour); Date timeHourDate = DateUtils.parseDate(timeHour);
setTimeHourStatus(vo,timeHourDate,store,orderList,cleanRecords,dayStr,finalNowTime,isToday,orderType, user); setTimeHourStatus(vo,timeHourDate,store,room,orderList,cleanRecords,dayStr,finalNowTime,isToday,orderType, user);
voList.add(vo); voList.add(vo);
}); });
return voList; return voList;
} }
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单) //设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
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, SRoom room, 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); if(checkRoomUpShelf(vo,timeHourDate,room)) {
checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday); checkIsDirtyRoom(vo, timeHourDate, store, cleanRecords, day);
checkTimeHourToBusiness(vo,timeHourDate,store,day); checkTimeHourToSysDate(vo, timeHourDate, day, finalNowTime, isToday);
checkTimeHourToOrder(vo,timeHourDate,orderList,cleanRecords,orderType, user); checkTimeHourToBusiness(vo, timeHourDate, store, day);
checkTimeHourToOrder(vo, timeHourDate, orderList, cleanRecords, orderType, user);
}
}
//校验房间是否维修中,维修中不可预定
private Boolean checkRoomUpShelf(RoomStatusVo vo,Date timeHourDate,SRoom room){
if(room.getRoomStat()!=null&&RoomStatEnum.ITEM_UP_SHELF.getValue().compareTo(room.getRoomStat())!=0){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
changeStartHoldTime(vo,timeHourDate);
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
return false;
}
return true;
} }
private void checkIsDirtyRoom(RoomStatusVo vo,Date timeHourDate, SStore store, SCleanRecords cleanRecords, String day){ private void checkIsDirtyRoom(RoomStatusVo vo,Date timeHourDate, SStore store, SCleanRecords cleanRecords, String day){
......
...@@ -510,9 +510,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -510,9 +510,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
List<SStore> stores = storeService.list(); List<SStore> stores = storeService.list();
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
if (ObjectUtil.isNotEmpty(room) && room.getIsDirtyRoom().equals(YesNoEnum.yes.getIndex())) { checkOrderRoomStat(room);
throw new BaseException("未保洁,不能预定!");
}
//生成订单 //生成订单
SOrder sOrder = generatSOrder(request, user); SOrder sOrder = generatSOrder(request, user);
//校验订单金额 //校验订单金额
...@@ -603,11 +601,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -603,11 +601,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_SUCCESS.getCode(), deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_SUCCESS.getCode(),
cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN), cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1"); cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
SRoom sRoom = roomService.getById(sOrder.getRoomId()); // SRoom sRoom = roomService.getById(sOrder.getRoomId());
//通知保洁人员 //通知保洁人员
sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> { sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> {
// 循环发送短信提示门店保洁打扫卫生 // 循环发送短信提示门店保洁打扫卫生
smsService.sendSmsCleanRecordsStopRemind(item.getPhone(), stores.stream().filter(store -> store.getId().equals(request.getStoreId())).findFirst().get(), sRoom); smsService.sendSmsCleanRecordsStopRemind(item.getPhone(), stores.stream().filter(store -> store.getId().equals(request.getStoreId())).findFirst().get(), room);
}); });
} }
} }
...@@ -742,6 +740,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -742,6 +740,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
} }
private void checkOrderRoomStat(SRoom room) {
if (ObjectUtil.isNotEmpty(room)){
throw new BaseException("房间不存在!");
}
if(room.getRoomStat()!=null&&RoomStatEnum.ITEM_UP_SHELF.getValue().compareTo(room.getRoomStat())!=0){
throw new BaseException("房间维护中,不可预定!");
}
}
private void checkOrderPrice(SOrder order, SConsumer user) { private void checkOrderPrice(SOrder order, SConsumer user) {
OrderComputedPriceRequest request = new OrderComputedPriceRequest(); OrderComputedPriceRequest request = new OrderComputedPriceRequest();
BeanUtils.copyProperties(order, request); BeanUtils.copyProperties(order, request);
......
...@@ -125,7 +125,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -125,7 +125,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
Map<Long,List<SRoomPack>> roomPackMap = Optional.ofNullable(roomPacks).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(SRoomPack::getRoomId)); Map<Long,List<SRoomPack>> roomPackMap = Optional.ofNullable(roomPacks).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(SRoomPack::getRoomId));
List<Long> packIdList = Optional.ofNullable(roomPacks).orElse(new ArrayList<>()).stream().map(SRoomPack::getPackId).collect(Collectors.toList()); List<Long> packIdList = Optional.ofNullable(roomPacks).orElse(new ArrayList<>()).stream().map(SRoomPack::getPackId).collect(Collectors.toList());
List<SPack> packList = packService.selectPackListByIds(packIdList); List<SPack> packList = packService.selectPackListByIds(packIdList);
List<RoomStatusVo> roomStatusVoList = roomStatusService.listRoomStatus(store.getId(),roomIds); List<RoomStatusVo> roomStatusVoList = roomStatusService.listRoomStatus(store.getId(),roomList);
Map<Long,List<RoomStatusVo>> roomStatusMap = Optional.ofNullable(roomStatusVoList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(RoomStatusVo::getRoomId)); Map<Long,List<RoomStatusVo>> roomStatusMap = Optional.ofNullable(roomStatusVoList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(RoomStatusVo::getRoomId));
roomList.stream().forEach(sRoom -> { roomList.stream().forEach(sRoom -> {
SRoomVo vo = new SRoomVo(); SRoomVo vo = new SRoomVo();
...@@ -209,7 +209,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -209,7 +209,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override @Override
public int updateSRoom(SRoom sRoom) { public int updateSRoom(SRoom sRoom) {
SRoom room = baseMapper.selectSRoomById(sRoom.getId()); SRoom room = baseMapper.selectSRoomById(sRoom.getId());
if (RoomStatEnum.UNDERCARRIAGE.getValue().equals(sRoom.getRoomStat()) && if (RoomStatEnum.ITEM_DOWN_SHELF.getValue().equals(sRoom.getRoomStat()) &&
!sRoom.getRoomStat().equals(room.getRoomStat())) { !sRoom.getRoomStat().equals(room.getRoomStat())) {
// 房间下架验证是否存在使用中、待使用的订单 // 房间下架验证是否存在使用中、待使用的订单
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper();
......
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
<if test="params1 != null and params1 != ''"> and params1 = #{params1}</if> <if test="params1 != null and params1 != ''"> and params1 = #{params1}</if>
<if test="params2 != null and params2 != ''"> and params2 = #{params2}</if> <if test="params2 != null and params2 != ''"> and params2 = #{params2}</if>
<if test="roomStat != null">and room_stat = #{roomStat}</if> <if test="roomStat != null">and room_stat = #{roomStat}</if>
<if test="queryNotRoomStat != null ">and room_stat != #{queryNotRoomStat}</if>
</where> </where>
order by sort desc order by sort desc
......
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