Commit 98b38478 by 吕明尚

修改设备网关信息分页

parent d74f34ef
package share.system.service.impl; package share.system.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
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;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.common.core.page.PageDomain; import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport; import share.common.core.page.TableSupport;
import share.common.enums.DeviceStatusEnum; import share.common.enums.DeviceStatusEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import share.system.domain.DeviceGateway;
import org.springframework.stereotype.Service; import share.system.domain.DeviceGatewayDto;
import share.system.domain.*; import share.system.domain.SStore;
import share.system.domain.vo.DeviceGatewayVo; import share.system.domain.vo.DeviceGatewayVo;
import share.system.domain.vo.DeviceVo;
import share.system.mapper.DeviceGatewayMapper; import share.system.mapper.DeviceGatewayMapper;
import share.system.mapper.SStoreMapper; import share.system.mapper.SStoreMapper;
import share.system.service.DeviceGatewayService; import share.system.service.DeviceGatewayService;
import share.system.service.ISysConfigService; import share.system.service.ISysConfigService;
import share.system.service.SmsService; import share.system.service.SmsService;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
/** /**
* 设备网关信息Service业务层处理 * 设备网关信息Service业务层处理
* *
...@@ -159,7 +158,13 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -159,7 +158,13 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
@Override @Override
public TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto) { public TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto) {
List<DeviceGateway> deviceGateways = deviceGatewayMapper.selectDeviceGatewayList(deviceGatewayDto); List<DeviceGateway> deviceGateways = deviceGatewayMapper.selectDeviceGatewayList(deviceGatewayDto);
List<DeviceGatewayVo> deviceGatewayVoList = convertDosToVos(deviceGateways); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setTotal(deviceGateways.size());
PageDomain pageDomain = TableSupport.buildPageRequest();
int start = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
int end = Math.min(start + pageDomain.getPageSize(), deviceGateways.size());
List<DeviceGateway> deviceGatewayVos = deviceGateways.subList(start, end);
List<DeviceGatewayVo> deviceGatewayVoList = convertDosToVos(deviceGatewayVos);
if (CollectionUtils.isNotEmpty(deviceGatewayVoList)) { if (CollectionUtils.isNotEmpty(deviceGatewayVoList)) {
List<SStore> sStoreList = storeMapper.selectList(new LambdaQueryWrapper<>()); List<SStore> sStoreList = storeMapper.selectList(new LambdaQueryWrapper<>());
deviceGatewayVoList.stream().forEach(item -> { deviceGatewayVoList.stream().forEach(item -> {
...@@ -172,13 +177,7 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -172,13 +177,7 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
}); });
} }
deviceGatewayVoList.sort(Comparator.comparing(DeviceGatewayVo::getCreateTime).reversed()); deviceGatewayVoList.sort(Comparator.comparing(DeviceGatewayVo::getCreateTime).reversed());
PageDomain pageDomain = TableSupport.buildPageRequest(); tableDataInfo.setRows(deviceGatewayVoList);
int start = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
int end = Math.min(start + pageDomain.getPageSize(), deviceGatewayVoList.size());
List<DeviceGatewayVo> deviceGatewayVos = deviceGatewayVoList.subList(start, end);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(deviceGatewayVos);
tableDataInfo.setTotal(deviceGatewayVoList.size());
tableDataInfo.setCode(200); tableDataInfo.setCode(200);
tableDataInfo.setMsg("查询成功"); tableDataInfo.setMsg("查询成功");
return tableDataInfo; return tableDataInfo;
......
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