Commit 7c70d58e by wuwenlong

Merge branch 'dev' into test

parents ba58daa6 ea0be758
......@@ -44,10 +44,11 @@ public class SRoomController extends BaseController {
/**
* 查询房间列表
*/
@ApiOperation(value = "房间列表")
@GetMapping("/list")
public TableDataInfo list(SRoom sRoom) {
startPage();
List<SRoom> list = sRoomService.selectSRoomList(sRoom);
List<SRoomVo> list = sRoomService.selectSRoomVoList(sRoom);
return getDataTable(list);
}
......
......@@ -123,7 +123,10 @@ public class SRoomVo extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date recordsTime;
/** 门店名称 */
/**
* 房间状态列表
*/
private List<RoomStatusVo> roomStatusList;
@Override
......
package share.system.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SCleanRecords;
......@@ -89,6 +90,8 @@ public interface ISCleanRecordsService extends IService<SCleanRecords>
SCleanRecords lastCleanByRoomId(Long roomId);
Map<Long, SCleanRecords> lastCleanRoomByRoomIds(List<Long> roomIds);
/**
* 结束保洁
* @param sCleanRecords
......
......@@ -89,11 +89,12 @@ public interface ISOrderService extends IService<SOrder>
/**
* 查询房间指定日T+1的订单
* @param storeId
* @param roomId
* @param roomIds
* @param day
* @return
*/
List<SOrder> listByRoomInfo(Long storeId, Long roomId, Date day);
List<SOrder> listByRoomInfo(Long storeId, List<Long> roomIds, Date day);
/**
* 订单预下单
......
......@@ -20,4 +20,13 @@ public interface RoomStatusService {
*/
List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day, Integer orderType);
/**
* 通过门店ID,房间ID,日期查询房间T+1天时段状态
* @param storeId
* @param roomIds
* @return List<RoomStatusVo>
*/
List<RoomStatusVo> listRoomStatus(Long storeId, List<Long> roomIds);
}
......@@ -51,13 +51,36 @@ public class RoomStatusServiceImpl implements RoomStatusService {
//查询门店营业时间
SStore store = storeService.getById(storeId);
// 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,roomId,day);
List<SOrder> orderList = orderService.listByRoomInfo(storeId,new ArrayList<Long>(){{add(roomId);}},day);
SCleanRecords cleanRecords = cleanRecordsService.lastCleanByRoomId(roomId);
List<RoomStatusVo> voList = generatorRoomStatusList(store,roomId,orderList,cleanRecords,day,orderType);
voList.addAll(generatorRoomStatusList(store,roomId,orderList,cleanRecords,DateUtils.addDays(day,1),orderType));
return voList;
}
@Override
public List<RoomStatusVo> listRoomStatus(Long storeId,List<Long> roomIds) {
SConsumer user = consumerService.getInfo();
if(user!=null){
FrontTokenComponent.loginSConsumerEntryThreadLocal.set(user);
}
Date day = new Date();
//查询门店营业时间
SStore store = storeService.getById(storeId);
// 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,roomIds,day);
Map<Long,SCleanRecords> cleanRecordMap = cleanRecordsService.lastCleanRoomByRoomIds(roomIds);
List<RoomStatusVo> voList = new ArrayList<>();
roomIds.stream().forEach(roomId -> {
voList.addAll(generatorRoomStatusList(store,roomId,orderList,cleanRecordMap.get(roomId),day,OrderTypeEnum.RESERVER.getCode()));
voList.addAll(generatorRoomStatusList(store,roomId,orderList,cleanRecordMap.get(roomId),DateUtils.addDays(day,1),OrderTypeEnum.RESERVER.getCode()));
});
return voList;
}
private List<RoomStatusVo> generatorRoomStatusList(SStore store,Long roomId,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType){
String nowTime = "00:00";
String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day);
......
......@@ -274,6 +274,22 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
}
@Override
public Map<Long, SCleanRecords> lastCleanRoomByRoomIds(List<Long> roomIds) {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SCleanRecords::getRoomId, roomIds);
queryWrapper.gt(SCleanRecords::getCreateTime,DateUtils.addDays(new Date(),-1));
List<SCleanRecords> records = list(queryWrapper);
if(CollectionUtils.isNotEmpty(records)){
Map<Long, SCleanRecords> cleanMap = records.parallelStream().collect(
Collectors.groupingBy(SCleanRecords::getRoomId,
Collectors.collectingAndThen(
Collectors.reducing(( c1, c2) -> c1.getCreateTime().compareTo(c2.getCreateTime())>0 ? c1 : c2), Optional::get)));
return cleanMap;
}
return null;
}
@Override
public int endCleanRecords(SCleanRecords sCleanRecords) {
SCleanRecords records = baseMapper.selectSCleanRecordsById(sCleanRecords.getId());
if (records == null) {
......
......@@ -277,10 +277,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
@Override
public List<SOrder> listByRoomInfo(Long storeId, Long roomId, Date day) {
public List<SOrder> listByRoomInfo(Long storeId, List<Long> roomIds, Date day) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStoreId, storeId);
queryWrapper.eq(SOrder::getRoomId, roomId);
if(CollectionUtils.isNotEmpty(roomIds)) {
queryWrapper.in(SOrder::getRoomId, roomIds);
}
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
queryWrapper.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus());
queryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
......
......@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper;
......@@ -32,8 +33,6 @@ import share.system.service.*;
*/
@Service
public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ISRoomService {
@Autowired
private SRoomMapper sRoomMapper;
@Autowired
private ISStoreService sStoreService;
......@@ -51,6 +50,8 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private MqttxService mqttxService;
@Autowired
private DeviceOpService deviceOpService;
@Autowired
private RoomStatusService roomStatusService;
/**
......@@ -61,7 +62,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
*/
@Override
public SRoomVo selectSRoomById(Long id) {
SRoom sRoom = sRoomMapper.selectSRoomById(id);
SRoom sRoom = baseMapper.selectSRoomById(id);
return convertVo(sRoom);
}
......@@ -73,7 +74,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
*/
@Override
public List<SRoom> selectSRoomList(SRoom sRoom) {
List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom);
List<SRoom> roomList = baseMapper.selectSRoomList(sRoom);
if (CollectionUtils.isEmpty(roomList)) {
return new ArrayList<>();
}
......@@ -105,25 +106,29 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
return vo;
}
/**
* TODO 注意:只能转换一个门店下的房间列表
* 门店列表VO转换
* @param roomList
* @return
*/
private List<SRoomVo> convertVoList(List<SRoom> roomList) {
List<SRoomVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(roomList)) {
List<Long> storeIds = roomList.stream().map(SRoom::getStoreId).collect(Collectors.toList());
// List<Long> storeIds = roomList.stream().map(SRoom::getStoreId).collect(Collectors.toList());
List<Long> roomIds = roomList.stream().map(SRoom::getId).collect(Collectors.toList());
List<SRoomPack> roomPacks = roomPackService.packIdsByRoomIds(roomIds);
List<Map> storeList = sStoreService.optionList(storeIds);
SStore store = sStoreService.getById(roomList.get(0).getStoreId());
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<SPack> packList = packService.selectPackListByIds(packIdList);
List<RoomStatusVo> roomStatusVoList = roomStatusService.listRoomStatus(store.getId(),roomIds);
Map<Long,List<RoomStatusVo>> roomStatusMap = Optional.ofNullable(roomStatusVoList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(RoomStatusVo::getRoomId));
roomList.stream().forEach(sRoom -> {
SRoomVo vo = new SRoomVo();
BeanUtils.copyProperties(sRoom, vo);
storeList.stream().forEach(store -> {
if (vo.getStoreId().compareTo(Long.parseLong(store.get("id").toString())) == 0) {
vo.setStoreName(store.getOrDefault("name", "").toString());
}
});
vo.setStoreName(store.getName());
vo.setRoomStatusList(roomStatusMap.get(sRoom.getId()));
if(!roomPackMap.isEmpty()) {
List<Long> packIds = Optional.ofNullable(roomPackMap.get(sRoom.getId())).orElse(new ArrayList<>()).stream().map(SRoomPack::getPackId).collect(Collectors.toList());
sRoom.setPackIds(packIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
......@@ -150,7 +155,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
*/
@Override
public List<SRoomVo> selectSRoomVoList(SRoom sRoom) {
List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom);
List<SRoom> roomList = baseMapper.selectSRoomList(sRoom);
return convertVoList(roomList);
}
......@@ -165,7 +170,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
int i = 0;
try {
sRoom.setCreateTime(DateUtils.getNowDate());
i = sRoomMapper.insertSRoom(sRoom);
i = baseMapper.insertSRoom(sRoom);
//判断套餐ID
if (!sRoom.getPackIds().isEmpty()) {
//String 转Long
......@@ -222,7 +227,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
roomPackService.deleteRoomPackByRoomId(sRoom.getId());
}
sRoom.setUpdateTime(DateUtils.getNowDate());
return sRoomMapper.updateSRoom(sRoom);
return baseMapper.updateSRoom(sRoom);
}
/**
......@@ -234,7 +239,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override
public int deleteSRoomByIds(Long[] ids) {
roomPackService.deleteRoomPackByIds(ids);
return sRoomMapper.deleteSRoomByIds(ids);
return baseMapper.deleteSRoomByIds(ids);
}
/**
......@@ -245,14 +250,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
*/
@Override
public int deleteSRoomById(Long id) {
return sRoomMapper.deleteSRoomById(id);
return baseMapper.deleteSRoomById(id);
}
@Override
public List<SRoomVo> listByStoreIds(List<Long> storeIds) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoom::getStoreId, storeIds);
List<SRoom> roomList = sRoomMapper.selectList(queryWrapper);
List<SRoom> roomList = baseMapper.selectList(queryWrapper);
return convertDoListToVoList(roomList);
}
......@@ -260,7 +265,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
public List<SRoom> selectSroomListByIds(List<Long> storeIds) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoom::getStoreId, storeIds);
List<SRoom> roomList = sRoomMapper.selectList(queryWrapper);
List<SRoom> roomList = baseMapper.selectList(queryWrapper);
return roomList;
}
......@@ -268,7 +273,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
public List<SRoom> selectSroomListByStroeId(Long storeId) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoom::getStoreId, storeId);
List<SRoom> roomList = sRoomMapper.selectList(queryWrapper);
List<SRoom> roomList = baseMapper.selectList(queryWrapper);
return roomList;
}
......@@ -278,7 +283,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是保洁人员");
}
SRoom room = sRoomMapper.selectById(id);
SRoom room = baseMapper.selectById(id);
if (Objects.isNull(room)) {
throw new RuntimeException("房间不存在");
}
......@@ -301,7 +306,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override
public SRoomVo queryById(Long id) {
SRoom room = sRoomMapper.selectById(id);
SRoom room = baseMapper.selectById(id);
SStore sStore = sStoreService.selectSStoreById(room.getStoreId());
room.setOpenShopUuid(sStore.getOpenShopUuid());
List<Long> packIds = roomPackService.selectPackListByRoomId(id);
......@@ -339,7 +344,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override
public List<Map> queryRoomList() {
List<SRoom> roomList = sRoomMapper.selectSRoomList(new SRoom());
List<SRoom> roomList = baseMapper.selectSRoomList(new SRoom());
List<Map> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(roomList)) {
result = roomList.stream().map(store -> {
......@@ -358,7 +363,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
public List<SRoom> selectByStoreIds(List<Long> storeIds) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoom::getStoreId, storeIds);
return sRoomMapper.selectList(queryWrapper);
return baseMapper.selectList(queryWrapper);
}
......
......@@ -191,7 +191,7 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
} else {
voList = convertDosToVos(storeList);
}
handleSStoreVoList(voList);
// handleSStoreVoList(voList);
return voList;
}
......
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