Commit 18424b91 by wuwenlong

clean records bugfix & opt;

parent c3070782
...@@ -85,7 +85,7 @@ public class SStore extends BaseEntity ...@@ -85,7 +85,7 @@ public class SStore extends BaseEntity
private String openShopUuid; private String openShopUuid;
@TableField(exist = false) @TableField(exist = false)
private List<SRoom> roolList; private List<SRoomVo> roolList;
public String getOpenShopUuid() { public String getOpenShopUuid() {
return openShopUuid; return openShopUuid;
...@@ -95,11 +95,11 @@ public class SStore extends BaseEntity ...@@ -95,11 +95,11 @@ public class SStore extends BaseEntity
this.openShopUuid = openShopUuid; this.openShopUuid = openShopUuid;
} }
public List<SRoom> getRoolList() { public List<SRoomVo> getRoolList() {
return roolList; return roolList;
} }
public void setRoolList(List<SRoom> roolList) { public void setRoolList(List<SRoomVo> roolList) {
this.roolList = roolList; this.roolList = roolList;
} }
......
package share.system.domain.vo; package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -87,22 +86,31 @@ public class SRoomVo extends BaseEntity ...@@ -87,22 +86,31 @@ public class SRoomVo extends BaseEntity
/** /**
* 套餐ID * 套餐ID
*/ */
@TableField(exist = false)
private String packIds; private String packIds;
/** /**
* 套餐列表 * 套餐列表
*/ */
@TableField(exist = false)
private List<SPack> packList; private List<SPack> packList;
/** /**
* 美团点评店铺id * 美团点评店铺id
*/ */
@TableField(exist = false)
private String openShopUuid; private String openShopUuid;
/**
* 保洁状态
*/
private Integer recordsStatus;
/**
* 保洁订单ID
*/
private Long recordsId;
/** 门店名称 */
@Override @Override
public String toString() { public String toString() {
......
...@@ -32,5 +32,5 @@ public interface SStoreConsumerMapper { ...@@ -32,5 +32,5 @@ public interface SStoreConsumerMapper {
public int deleteInfos(@Param("storeId") Long storeId, @Param("consumerIds") Long[] consumerIds); public int deleteInfos(@Param("storeId") Long storeId, @Param("consumerIds") Long[] consumerIds);
List<String> selectByConsumerId(Long id); List<Long> selectByConsumerId(Long id);
} }
...@@ -67,4 +67,7 @@ public interface IRoomPackService extends IService<SRoomPack> { ...@@ -67,4 +67,7 @@ public interface IRoomPackService extends IService<SRoomPack> {
List<SRoomPack> selectRoomPackByPackId(Long id); List<SRoomPack> selectRoomPackByPackId(Long id);
List<SRoomPack> listByRoomIds(List<Long> roomIds); List<SRoomPack> listByRoomIds(List<Long> roomIds);
List<SRoomPack> packIdsByRoomIds(List<Long> roomId);
} }
package share.system.service; package share.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SCleanRecords; import share.system.domain.SCleanRecords;
/** /**
...@@ -9,7 +11,7 @@ import share.system.domain.SCleanRecords; ...@@ -9,7 +11,7 @@ import share.system.domain.SCleanRecords;
* @author ruoyi * @author ruoyi
* @date 2023-09-28 * @date 2023-09-28
*/ */
public interface ISCleanRecordsService public interface ISCleanRecordsService extends IService<SCleanRecords>
{ {
/** /**
* 查询保洁记录 * 查询保洁记录
...@@ -82,4 +84,7 @@ public interface ISCleanRecordsService ...@@ -82,4 +84,7 @@ public interface ISCleanRecordsService
boolean finishCleanRecords(); boolean finishCleanRecords();
int startCleanRecords(SCleanRecords sCleanRecords); int startCleanRecords(SCleanRecords sCleanRecords);
List<SCleanRecords> unCleanedListByRoomIds(List<Long> roomIds);
} }
...@@ -34,6 +34,14 @@ public interface ISRoomService extends IService<SRoom> ...@@ -34,6 +34,14 @@ public interface ISRoomService extends IService<SRoom>
public List<SRoom> selectSRoomList(SRoom sRoom); public List<SRoom> selectSRoomList(SRoom sRoom);
/** /**
* 查询房间列表
*
* @param sRoom 房间
* @return 房间集合
*/
public List<SRoomVo> selectSRoomVoList(SRoom sRoom);
/**
* 新增房间 * 新增房间
* *
* @param sRoom 房间 * @param sRoom 房间
......
...@@ -2,6 +2,8 @@ package share.system.service.impl; ...@@ -2,6 +2,8 @@ package share.system.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -22,8 +24,6 @@ import share.system.service.IRoomPackService; ...@@ -22,8 +24,6 @@ import share.system.service.IRoomPackService;
@Service @Service
public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> implements IRoomPackService { public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> implements IRoomPackService {
@Autowired @Autowired
private RoomPackMapper roomPackMapper;
@Autowired
private SRoomMapper sRoomMapper; private SRoomMapper sRoomMapper;
/** /**
...@@ -34,7 +34,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -34,7 +34,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
*/ */
@Override @Override
public SRoomPack selectRoomPackById(Long id) { public SRoomPack selectRoomPackById(Long id) {
return roomPackMapper.selectRoomPackById(id); return baseMapper.selectRoomPackById(id);
} }
/** /**
...@@ -45,7 +45,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -45,7 +45,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
*/ */
@Override @Override
public List<SRoomPack> selectRoomPackList(SRoomPack SRoomPack) { public List<SRoomPack> selectRoomPackList(SRoomPack SRoomPack) {
return roomPackMapper.selectRoomPackList(SRoomPack); return baseMapper.selectRoomPackList(SRoomPack);
} }
/** /**
...@@ -57,7 +57,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -57,7 +57,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
@Override @Override
public int insertRoomPack(SRoomPack SRoomPack) { public int insertRoomPack(SRoomPack SRoomPack) {
SRoomPack.setCreateTime(DateUtils.getNowDate()); SRoomPack.setCreateTime(DateUtils.getNowDate());
return roomPackMapper.insertRoomPack(SRoomPack); return baseMapper.insertRoomPack(SRoomPack);
} }
/** /**
...@@ -69,7 +69,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -69,7 +69,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
@Override @Override
public int updateRoomPack(SRoomPack SRoomPack) { public int updateRoomPack(SRoomPack SRoomPack) {
SRoomPack.setUpdateTime(DateUtils.getNowDate()); SRoomPack.setUpdateTime(DateUtils.getNowDate());
return roomPackMapper.updateRoomPack(SRoomPack); return baseMapper.updateRoomPack(SRoomPack);
} }
/** /**
...@@ -80,7 +80,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -80,7 +80,7 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
*/ */
@Override @Override
public int deleteRoomPackByIds(Long[] ids) { public int deleteRoomPackByIds(Long[] ids) {
return roomPackMapper.deleteRoomPackByIds(ids); return baseMapper.deleteRoomPackByIds(ids);
} }
/** /**
...@@ -91,26 +91,26 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -91,26 +91,26 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
*/ */
@Override @Override
public int deleteRoomPackById(Long id) { public int deleteRoomPackById(Long id) {
return roomPackMapper.deleteRoomPackById(id); return baseMapper.deleteRoomPackById(id);
} }
@Override @Override
public List<Long> selectPackListByRoomId(Long id) { public List<Long> selectPackListByRoomId(Long id) {
return roomPackMapper.selectPackListByRoomId(id); return baseMapper.selectPackListByRoomId(id);
} }
@Override @Override
public int deleteRoomPackByRoomId(Long id) { public int deleteRoomPackByRoomId(Long id) {
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SRoomPack::getRoomId, id); queryWrapper.eq(SRoomPack::getRoomId, id);
return roomPackMapper.delete(queryWrapper); return baseMapper.delete(queryWrapper);
} }
@Override @Override
public List<SRoomPack> selectRoomPackByPackId(Long id) { public List<SRoomPack> selectRoomPackByPackId(Long id) {
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SRoomPack::getPackId, id); queryWrapper.eq(SRoomPack::getPackId, id);
List<SRoomPack> sRoomPackList = roomPackMapper.selectList(queryWrapper); List<SRoomPack> sRoomPackList = baseMapper.selectList(queryWrapper);
sRoomPackList.forEach(item -> { sRoomPackList.forEach(item -> {
item.setRoomName(sRoomMapper.selectById(item.getRoomId()).getName()); item.setRoomName(sRoomMapper.selectById(item.getRoomId()).getName());
}); });
...@@ -122,11 +122,18 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -122,11 +122,18 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
LambdaQueryWrapper<SRoomPack> roomPackQueryWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<SRoomPack> roomPackQueryWrapper = new LambdaQueryWrapper();
if (roomIds.size() > 0) { if (roomIds.size() > 0) {
roomPackQueryWrapper.in(SRoomPack::getRoomId, roomIds); roomPackQueryWrapper.in(SRoomPack::getRoomId, roomIds);
List<SRoomPack> roomPacks = roomPackMapper.selectList(roomPackQueryWrapper); List<SRoomPack> roomPacks = baseMapper.selectList(roomPackQueryWrapper);
return roomPacks; return roomPacks;
} else { } else {
return new ArrayList<SRoomPack>(); return new ArrayList<SRoomPack>();
} }
} }
@Override
public List<SRoomPack> packIdsByRoomIds(List<Long> roomId) {
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoomPack::getRoomId);
return list(queryWrapper);
}
} }
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import share.common.enums.CleaningStatusEnum; import share.common.enums.CleaningStatusEnum;
import share.common.enums.RoleTypeEnum; import share.common.enums.RoleTypeEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
...@@ -29,11 +30,9 @@ import share.system.service.SmsService; ...@@ -29,11 +30,9 @@ import share.system.service.SmsService;
* @date 2023-09-28 * @date 2023-09-28
*/ */
@Service @Service
public class SCleanRecordsServiceImpl implements ISCleanRecordsService public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SCleanRecords> implements ISCleanRecordsService
{ {
@Autowired @Autowired
private SCleanRecordsMapper sCleanRecordsMapper;
@Autowired
private SConsumerMapper sConsumerMapper; private SConsumerMapper sConsumerMapper;
@Autowired @Autowired
private SRoomMapper sRoomMapper; private SRoomMapper sRoomMapper;
...@@ -51,7 +50,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -51,7 +50,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override @Override
public SCleanRecords selectSCleanRecordsById(Long id) public SCleanRecords selectSCleanRecordsById(Long id)
{ {
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectSCleanRecordsById(id); SCleanRecords sCleanRecords = baseMapper.selectSCleanRecordsById(id);
if (sCleanRecords != null) { if (sCleanRecords != null) {
SStore store = sStoreMapper.selectSStoreById(sCleanRecords.getStoreId()); SStore store = sStoreMapper.selectSStoreById(sCleanRecords.getStoreId());
SRoom room = sRoomMapper.selectSRoomById(sCleanRecords.getRoomId()); SRoom room = sRoomMapper.selectSRoomById(sCleanRecords.getRoomId());
...@@ -70,7 +69,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -70,7 +69,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override @Override
public List<SCleanRecords> selectSCleanRecordsList(SCleanRecords sCleanRecords) public List<SCleanRecords> selectSCleanRecordsList(SCleanRecords sCleanRecords)
{ {
return sCleanRecordsMapper.selectSCleanRecordsList(sCleanRecords); return baseMapper.selectSCleanRecordsList(sCleanRecords);
} }
/** /**
...@@ -83,7 +82,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -83,7 +82,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
public int insertSCleanRecords(SCleanRecords sCleanRecords) public int insertSCleanRecords(SCleanRecords sCleanRecords)
{ {
sCleanRecords.setCreateTime(DateUtils.getNowDate()); sCleanRecords.setCreateTime(DateUtils.getNowDate());
return sCleanRecordsMapper.insertSCleanRecords(sCleanRecords); return baseMapper.insertSCleanRecords(sCleanRecords);
} }
/** /**
...@@ -96,7 +95,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -96,7 +95,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
public int updateSCleanRecords(SCleanRecords sCleanRecords) public int updateSCleanRecords(SCleanRecords sCleanRecords)
{ {
sCleanRecords.setUpdateTime(DateUtils.getNowDate()); sCleanRecords.setUpdateTime(DateUtils.getNowDate());
return sCleanRecordsMapper.updateSCleanRecords(sCleanRecords); return baseMapper.updateSCleanRecords(sCleanRecords);
} }
/** /**
...@@ -108,7 +107,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -108,7 +107,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override @Override
public int deleteSCleanRecordsByIds(Long[] ids) public int deleteSCleanRecordsByIds(Long[] ids)
{ {
return sCleanRecordsMapper.deleteSCleanRecordsByIds(ids); return baseMapper.deleteSCleanRecordsByIds(ids);
} }
/** /**
...@@ -120,7 +119,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -120,7 +119,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override @Override
public int deleteSCleanRecordsById(Long id) public int deleteSCleanRecordsById(Long id)
{ {
return sCleanRecordsMapper.deleteSCleanRecordsById(id); return baseMapper.deleteSCleanRecordsById(id);
} }
/** /**
...@@ -136,7 +135,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -136,7 +135,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
sCleanRecords.setRoomId(roomId); sCleanRecords.setRoomId(roomId);
sCleanRecords.setStatus(0); sCleanRecords.setStatus(0);
sCleanRecords.setCreateTime(DateUtils.getNowDate()); sCleanRecords.setCreateTime(DateUtils.getNowDate());
boolean b = 0 < sCleanRecordsMapper.insertSCleanRecords(sCleanRecords); boolean b = 0 < baseMapper.insertSCleanRecords(sCleanRecords);
if (b) { if (b) {
SStore store = sStoreMapper.selectSStoreById(storeId); SStore store = sStoreMapper.selectSStoreById(storeId);
SRoom room = sRoomMapper.selectSRoomById(roomId); SRoom room = sRoomMapper.selectSRoomById(roomId);
...@@ -147,12 +146,12 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -147,12 +146,12 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override @Override
public List<SCleanRecords> unCleanList(SCleanRecords sCleanRecords) { public List<SCleanRecords> unCleanList(SCleanRecords sCleanRecords) {
return sCleanRecordsMapper.unCleanList(sCleanRecords); return baseMapper.unCleanList(sCleanRecords);
} }
@Override @Override
public List<SCleanRecords> myCleanList(SCleanRecords sCleanRecords) { public List<SCleanRecords> myCleanList(SCleanRecords sCleanRecords) {
return sCleanRecordsMapper.myCleanList(sCleanRecords); return baseMapper.myCleanList(sCleanRecords);
} }
@Override @Override
...@@ -160,7 +159,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -160,7 +159,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SCleanRecords::getRoomId,roomId); queryWrapper.in(SCleanRecords::getRoomId,roomId);
queryWrapper.in(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode()); queryWrapper.in(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode());
return sCleanRecordsMapper.selectOne(queryWrapper); return baseMapper.selectOne(queryWrapper);
} }
@Override @Override
...@@ -172,7 +171,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -172,7 +171,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SCleanRecords::getConsumerId,user.getId()); queryWrapper.in(SCleanRecords::getConsumerId,user.getId());
queryWrapper.in(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode()); queryWrapper.in(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode());
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectOne(queryWrapper); SCleanRecords sCleanRecords = baseMapper.selectOne(queryWrapper);
if(sCleanRecords == null){ if(sCleanRecords == null){
throw new RuntimeException("当前用户没有保洁任务"); throw new RuntimeException("当前用户没有保洁任务");
} }
...@@ -187,7 +186,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -187,7 +186,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SCleanRecords::getStatus,0); queryWrapper.eq(SCleanRecords::getStatus,0);
queryWrapper.le(SCleanRecords::getCreateTime, DateUtil.offsetMinute(now, -30)); queryWrapper.le(SCleanRecords::getCreateTime, DateUtil.offsetMinute(now, -30));
List<SCleanRecords> list = sCleanRecordsMapper.selectList(queryWrapper); List<SCleanRecords> list = baseMapper.selectList(queryWrapper);
if (list.size() == 0) { if (list.size() == 0) {
return Boolean.FALSE; return Boolean.FALSE;
} }
...@@ -197,7 +196,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -197,7 +196,7 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
sCleanRecords.setEndDate(now); sCleanRecords.setEndDate(now);
sCleanRecords.setUpdateTime(now); sCleanRecords.setUpdateTime(now);
} }
return 0 < sCleanRecordsMapper.updateBatch(list); return 0 < baseMapper.updateBatch(list);
} }
@Override @Override
...@@ -206,11 +205,11 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -206,11 +205,11 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
queryWrapper.eq(SCleanRecords::getStatus,CleaningStatusEnum.CLEANING.getCode()); queryWrapper.eq(SCleanRecords::getStatus,CleaningStatusEnum.CLEANING.getCode());
queryWrapper.eq(SCleanRecords::getConsumerId,sCleanRecords.getConsumerId()); queryWrapper.eq(SCleanRecords::getConsumerId,sCleanRecords.getConsumerId());
queryWrapper.ne(SCleanRecords::getId,sCleanRecords.getId()); queryWrapper.ne(SCleanRecords::getId,sCleanRecords.getId());
List<SCleanRecords> list = sCleanRecordsMapper.selectList(queryWrapper); List<SCleanRecords> list = baseMapper.selectList(queryWrapper);
if (list.size() > 0) { if (list.size() > 0) {
throw new RuntimeException("当前用户有未结束的保洁任务"); throw new RuntimeException("当前用户有未结束的保洁任务");
} }
SCleanRecords records = sCleanRecordsMapper.selectSCleanRecordsById(sCleanRecords.getId()); SCleanRecords records = baseMapper.selectSCleanRecordsById(sCleanRecords.getId());
if (records == null) { if (records == null) {
throw new RuntimeException("当前保洁任务不存在!"); throw new RuntimeException("当前保洁任务不存在!");
} }
...@@ -220,6 +219,15 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -220,6 +219,15 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
return updateSCleanRecords(sCleanRecords); return updateSCleanRecords(sCleanRecords);
} }
@Override
public List<SCleanRecords> unCleanedListByRoomIds(List<Long> roomIds) {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SCleanRecords::getRoomId, roomIds);
queryWrapper.ne(SCleanRecords::getStatus, CleaningStatusEnum.CLEANED.getCode());
queryWrapper.orderByDesc(SCleanRecords::getStartDate);
return list(queryWrapper);
}
private void sendSms(Long storeId,SStore store, SRoom room) { private void sendSms(Long storeId,SStore store, SRoom room) {
List<SConsumer> list = sConsumerMapper.selectListByStoreId(storeId); List<SConsumer> list = sConsumerMapper.selectListByStoreId(storeId);
for (SConsumer consumer : list) { for (SConsumer consumer : list) {
......
...@@ -61,16 +61,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -61,16 +61,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override @Override
public SRoomVo selectSRoomById(Long id) { public SRoomVo selectSRoomById(Long id) {
SRoom sRoom = sRoomMapper.selectSRoomById(id); SRoom sRoom = sRoomMapper.selectSRoomById(id);
sRoom.setPackIds(roomPackService.selectPackListByRoomId(id).stream().map(String::valueOf).collect(Collectors.joining(","))); return convertVo(sRoom);
if (Objects.nonNull(sRoom) && sRoom.getId() != null) {
SRoom room = convertVoList(new ArrayList<SRoom>() {{
add(sRoom);
}}).get(0);
SRoomVo sRoomVo = new SRoomVo();
BeanUtils.copyProperties(room, sRoomVo);
return sRoomVo;
}
return new SRoomVo();
} }
/** /**
...@@ -82,27 +73,81 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -82,27 +73,81 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override @Override
public List<SRoom> selectSRoomList(SRoom sRoom) { public List<SRoom> selectSRoomList(SRoom sRoom) {
List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom); List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom);
List<Long> storeIds = roomList.stream().map(SRoom::getStoreId).collect(Collectors.toList());
List<Map> storeList = sStoreService.optionList(storeIds);
roomList.forEach(o -> { roomList.forEach(o -> {
List<Long> roomId = roomPackService.selectPackListByRoomId(o.getId()); List<Long> roomId = roomPackService.selectPackListByRoomId(o.getId());
o.setPackIds(roomId.stream().map(String::valueOf).collect(Collectors.joining(","))); o.setPackIds(roomId.stream().map(String::valueOf).collect(Collectors.joining(",")));
o.setPackList(packService.selectPackListByIds(roomId)); o.setPackList(packService.selectPackListByIds(roomId));
storeList.stream().forEach(store -> {
if (o.getStoreId().compareTo(Long.parseLong(store.get("id").toString())) == 0) {
o.setStoreName(store.getOrDefault("name", "").toString());
}
});
}); });
return convertVoList(roomList);
return roomList;
} }
private List<SRoom> convertVoList(List<SRoom> roomList) { private SRoomVo convertVo(SRoom room) {
SRoomVo vo = new SRoomVo();
if(Objects.nonNull(room)&&Objects.nonNull(room.getId())){
BeanUtils.copyProperties(room, vo);
SStore store = sStoreService.getById(room.getStoreId());
vo.setStoreName(store.getName());
List<Long> packIds = roomPackService.selectPackListByRoomId(room.getId());
vo.setPackIds(Optional.ofNullable(packIds).orElse(new ArrayList<>()).stream().map(String::valueOf).collect(Collectors.joining(",")));
}
return vo;
}
private List<SRoomVo> convertVoList(List<SRoom> roomList) {
List<SRoomVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(roomList)) { 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); List<Map> storeList = sStoreService.optionList(storeIds);
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);
roomList.stream().forEach(sRoom -> { roomList.stream().forEach(sRoom -> {
SRoomVo vo = new SRoomVo();
BeanUtils.copyProperties(sRoom, vo);
storeList.stream().forEach(store -> { storeList.stream().forEach(store -> {
if (sRoom.getStoreId().compareTo(Long.parseLong(store.get("id").toString())) == 0) { if (vo.getStoreId().compareTo(Long.parseLong(store.get("id").toString())) == 0) {
sRoom.setStoreName(store.getOrDefault("name", "").toString()); vo.setStoreName(store.getOrDefault("name", "").toString());
} }
}); });
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(",")));
List<SPack> packs = new ArrayList<>();
packList.stream().forEach( pack -> {
if(packIds.contains(pack.getId())){
packs.add(pack);
}
});
sRoom.setPackList(packList);
}
voList.add(vo);
}); });
} }
return roomList; return voList;
}
/**
* 查询房间列表
*
* @param sRoom 房间
* @return 房间
*/
@Override
public List<SRoomVo> selectSRoomVoList(SRoom sRoom) {
List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom);
return convertVoList(roomList);
} }
/** /**
......
...@@ -19,6 +19,7 @@ import org.locationtech.spatial4j.context.SpatialContext; ...@@ -19,6 +19,7 @@ import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.distance.DistanceUtils; import org.locationtech.spatial4j.distance.DistanceUtils;
import org.locationtech.spatial4j.shape.Point; import org.locationtech.spatial4j.shape.Point;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import share.common.enums.CleaningStatusEnum;
import share.common.enums.RoleTypeEnum; import share.common.enums.RoleTypeEnum;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
...@@ -50,7 +51,7 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -50,7 +51,7 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
@Autowired @Autowired
private QPService qpService; private QPService qpService;
@Autowired @Autowired
private SCleanRecordsMapper sCleanRecordsMapper; private ISCleanRecordsService cleanRecordsService;
@Autowired @Autowired
private IRoomPackService roomPackService; private IRoomPackService roomPackService;
...@@ -296,31 +297,27 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -296,31 +297,27 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
throw new BaseException("当前用户不是保洁人员!"); throw new BaseException("当前用户不是保洁人员!");
} }
//查询保洁人员所属门店 //查询保洁人员所属门店
List<String> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId()); List<Long> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId());
//List<String> 转 List<Long>
List<Long> idList = storeIdList.stream().map(Long::parseLong).collect(Collectors.toList());
// 查询门店信息
List<SStore> storeList = new ArrayList<>(); List<SStore> storeList = new ArrayList<>();
idList.forEach(item -> { if(CollectionUtils.isNotEmpty(storeIdList)) {
storeList.add(baseMapper.selectById(item)); // 查询门店信息
}); storeList = listByIds(storeIdList);
storeList.forEach(item -> { List<SRoomVo> sRoomVoList = sRoomService.listByStoreIds(storeIdList);
List<SRoom> sRooms = sRoomService.selectSroomListByStroeId(item.getId()); Map<Long,List<SRoomVo>> roomMap = Optional.ofNullable(sRoomVoList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(SRoomVo::getStoreId));
if (CollectionUtils.isNotEmpty(sRooms)) { List<Long> roomIdList = Optional.ofNullable(sRoomVoList).orElse(new ArrayList<>()).stream().map(SRoomVo::getId).collect(Collectors.toList());
item.setRoolList(sRoomService.selectSroomListByStroeId(item.getId())); List<SCleanRecords> sCleanRecordsList = cleanRecordsService.unCleanedListByRoomIds(roomIdList);
Map<Long,List<SCleanRecords>> recordsMap = Optional.ofNullable(sCleanRecordsList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(SCleanRecords::getRoomId));
Optional.ofNullable(storeList).orElse(new ArrayList<>()).forEach(item -> {
item.setRoolList(roomMap.get(item.getId()));
item.getRoolList().forEach(room -> { item.getRoolList().forEach(room -> {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>(); if (CollectionUtils.isNotEmpty(sCleanRecordsList)) {
queryWrapper.eq(SCleanRecords::getRoomId, room.getId()); SCleanRecords records = recordsMap.get(room.getId()).get(0);
queryWrapper.eq(SCleanRecords::getStoreId, item.getId()); room.setRecordsStatus(records.getStatus());
queryWrapper.ne(SCleanRecords::getStatus, 2); room.setRecordsId(records.getId());
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectOne(queryWrapper);
if (ObjectUtils.isNotEmpty(sCleanRecords)) {
room.setRecordsStatus(sCleanRecords.getStatus());
room.setRecordsId(sCleanRecords.getId());
} }
}); });
} });
}); }
return storeList; return storeList;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<select id="countByStoreId" resultType="Integer"> <select id="countByStoreId" resultType="Integer">
select count(1) from s_store_consumer where store_id=#{storeId} select count(1) from s_store_consumer where store_id=#{storeId}
</select> </select>
<select id="selectByConsumerId" resultType="java.lang.String"> <select id="selectByConsumerId" resultType="Long">
select store_id from s_store_consumer where consumer_id=#{consumerId} select store_id from s_store_consumer where consumer_id=#{consumerId}
</select> </select>
......
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