Commit d085da08 by YG8999

首页查询过慢,bug修复

parent 161f230d
......@@ -44,7 +44,7 @@ public class SRoomController extends BaseController
public TableDataInfo list(SRoom sRoom)
{
startPage();
List<SRoomVo> list = sRoomService.selectSRoomList(sRoom);
List<SRoom> list = sRoomService.selectSRoomList(sRoom);
return getDataTable(list);
}
......@@ -56,8 +56,8 @@ public class SRoomController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, SRoom sRoom)
{
List<SRoomVo> list = sRoomService.selectSRoomList(sRoom);
ExcelUtil<SRoomVo> util = new ExcelUtil<SRoomVo>(SRoomVo.class);
List<SRoom> list = sRoomService.selectSRoomList(sRoom);
ExcelUtil<SRoom> util = new ExcelUtil<SRoom>(SRoom.class);
util.exportExcel(response, list, "房间数据");
}
......
......@@ -46,7 +46,7 @@ public class SRoomController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(SRoom sRoom) {
startPage();
List<SRoomVo> list = sRoomService.selectSRoomList(sRoom);
List<SRoom> list = sRoomService.selectSRoomList(sRoom);
return getDataTable(list);
}
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -19,6 +21,7 @@ public class Device extends BaseEntity
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId(type = IdType.AUTO)
private Long id;
/** 设备名称 */
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -19,6 +21,7 @@ public class DeviceGateway extends BaseEntity
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId(type = IdType.AUTO)
private Long id;
/** 设备名称 */
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -19,6 +21,7 @@ public class DeviceLog extends BaseEntity
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.AUTO)
private Long id;
/** 设备mac */
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -19,6 +21,7 @@ public class Protocol extends BaseEntity
private static final long serialVersionUID = 1L;
/** 协议ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 协议标题 */
......
......@@ -2,7 +2,9 @@ package share.system.domain;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -20,6 +22,7 @@ public class SCleanRecords extends BaseEntity
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 门店ID */
......
......@@ -4,7 +4,9 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
......@@ -19,12 +21,13 @@ import share.common.core.domain.BaseEntity;
* @date 2023-09-27
*/
@Data
public class SConsumer
public class SConsumer implements Serializable
{
private static final long serialVersionUID = 1L;
/** 会员用户ID */
@JsonSerialize(using = ToStringSerializer.class)
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "用户账号")
......
......@@ -2,6 +2,9 @@ package share.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -22,6 +25,7 @@ public class SConsumerCoupon extends BaseEntity
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 用户ID */
......
package share.system.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -17,6 +20,7 @@ public class SConsumptionRecords extends BaseEntity
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 会员用户ID */
......
......@@ -2,6 +2,9 @@ package share.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
......@@ -21,6 +24,7 @@ public class SCoupon extends BaseEntity
private static final long serialVersionUID = 1L;
/** 优惠券ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 优惠券名称 */
......
......@@ -3,7 +3,9 @@ package share.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
......@@ -27,6 +29,7 @@ public class SOrder extends BaseEntity
private static final long serialVersionUID = 1L;
/** 订单ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 订单流水号 */
......
......@@ -2,6 +2,8 @@ package share.system.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -21,6 +23,7 @@ public class SPack extends BaseEntity {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -22,6 +25,7 @@ public class SRoom extends BaseEntity
private static final long serialVersionUID = 1L;
/** 房间ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 门店ID */
......@@ -107,6 +111,8 @@ public class SRoom extends BaseEntity
@TableField(exist = false)
private Long recordsId;
/** 门店名称 */
@TableField(exist = false)
private String storeName;
}
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -20,6 +22,7 @@ public class SRoomPack extends BaseEntity {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -21,6 +23,7 @@ public class SStore extends BaseEntity
private static final long serialVersionUID = 1L;
/** 门店ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 门店名称 */
......
package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -27,6 +29,7 @@ public class SOrderVo
private static final long serialVersionUID = 1L;
/** 订单ID */
@TableId(type = IdType.AUTO)
private Long id;
/** 订单流水号 */
......
......@@ -61,4 +61,5 @@ public interface RoomPackMapper extends BaseMapper<SRoomPack> {
public int deleteRoomPackByIds(Long[] ids);
List<Long> selectPackListByRoomId(Long id);
}
......@@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SRoom;
import share.system.domain.vo.SRoomVo;
/**
* 房间Mapper接口
......
......@@ -31,7 +31,7 @@ public interface ISRoomService extends IService<SRoom>
* @param sRoom 房间
* @return 房间集合
*/
public List<SRoomVo> selectSRoomList(SRoom sRoom);
public List<SRoom> selectSRoomList(SRoom sRoom);
/**
* 新增房间
......
......@@ -3,6 +3,7 @@ package share.system.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
......@@ -60,9 +61,12 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
SRoom sRoom = sRoomMapper.selectSRoomById(id);
sRoom.setPackIds(roomPackService.selectPackListByRoomId(id).stream().map(String::valueOf).collect(Collectors.joining(",")));
if (Objects.nonNull(sRoom) && sRoom.getId() != null) {
return convertVoList(new ArrayList<SRoom>() {{
SRoom room = convertVoList(new ArrayList<SRoom>() {{
add(sRoom);
}}).get(0);
SRoomVo sRoomVo = new SRoomVo();
BeanUtils.copyProperties(room, sRoomVo);
return sRoomVo;
}
return new SRoomVo();
}
......@@ -74,7 +78,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
* @return 房间
*/
@Override
public List<SRoomVo> selectSRoomList(SRoom sRoom) {
public List<SRoom> selectSRoomList(SRoom sRoom) {
List<SRoom> roomList = sRoomMapper.selectSRoomList(sRoom);
roomList.forEach(o -> {
List<Long> roomId = roomPackService.selectPackListByRoomId(o.getId());
......@@ -84,23 +88,19 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
return convertVoList(roomList);
}
private List<SRoomVo> convertVoList(List<SRoom> roomList) {
List<SRoomVo> voList = new ArrayList<>();
private List<SRoom> convertVoList(List<SRoom> roomList) {
if (CollectionUtils.isNotEmpty(roomList)) {
List<Long> storeIds = roomList.stream().map(SRoom::getStoreId).collect(Collectors.toList());
List<Map> storeList = sStoreService.optionList(storeIds);
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());
if (sRoom.getStoreId().compareTo(Long.parseLong(store.get("id").toString())) == 0) {
sRoom.setStoreName(store.getOrDefault("name", "").toString());
}
});
voList.add(vo);
});
}
return voList;
return roomList;
}
/**
......@@ -148,7 +148,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Override
public int updateSRoom(SRoom sRoom) {
//判断套餐ID
if (!sRoom.getPackIds().isEmpty()) {
if (!StrUtil.isEmpty(sRoom.getPackIds())) {
//判断套餐ID
List<SPack> SPackList = packService.selectPackListByIds(Arrays.asList(sRoom.getPackIds().split(",")).stream().map(Long::valueOf).collect(Collectors.toList()));
if (CollectionUtils.isEmpty(SPackList)) {
......
......@@ -231,10 +231,33 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
if (CollectionUtils.isNotEmpty(voList)) {
List<Long> storeIds = voList.stream().map(SStoreVo::getId).collect(Collectors.toList());
List<SRoomVo> roomVoList = sRoomService.listByStoreIds(storeIds);
List<Long> roomIds = new ArrayList<>();
roomVoList.stream().forEach(sRoomVo -> {
roomIds.add(sRoomVo.getId());
});
List<SRoomPack> roomPacks = roomPackMapper.selectBatchIds(roomIds);
List<Long> packIds = new ArrayList<>();
roomPacks.stream().forEach(sRoomPack -> {
packIds.add(sRoomPack.getPackId());
});
List<SPack> packs = packService.selectPackListByIds(packIds);
Map<Long,SPack> map = new HashMap<>();
packs.stream().forEach(sPack -> {
map.put(sPack.getId(), sPack);
});
roomVoList.stream().forEach(sRoomVo -> {
List<SPack> sPacks = new ArrayList<>();
roomPacks.stream().forEach(sRoomPack -> {
if (Long.compare(sRoomVo.getId(), sRoomPack.getRoomId()) == 0) {
sPacks.add(map.get(sRoomPack.getPackId()));
}
});
sRoomVo.setPackList(sPacks);
});
voList.stream().forEach(storeVo -> {
storeVo.setRoomVoList(roomVoList.stream().filter(roomVo -> {
List<Long> roomId = roomPackMapper.selectPackListByRoomId(roomVo.getId());
roomVo.setPackList(packService.selectPackListByIds(roomId));
// List<Long> roomId = roomPackMapper.selectPackListByRoomId(roomVo.getId());
// roomVo.setPackList(packService.selectPackListByIds(roomId));
if (Long.compare(roomVo.getStoreId(), storeVo.getId()) == 0) {
return true;
}
......
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