吉安感知网项目-后端
rain
2026-01-21 b48cc8bd8382037650197cb30b1895b1321f6897
反无分页优化
3 files modified
54 ■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/controller/FwDeviceController.java 17 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/IFwDeviceService.java 11 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/impl/FwDeviceServiceImpl.java 26 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/controller/FwDeviceController.java
@@ -32,7 +32,6 @@
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import org.sxkj.fw.cockpit.vo.DeviceStatisticsVO;
import org.sxkj.fw.common.GenericConverter;
@@ -104,21 +103,7 @@
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入fwDevice")
    public R<IPage<FwDeviceVO>> page(FwDevicePageParam fwDevice, Query query) {
        IPage<FwDeviceEntity> pages = fwDeviceService.selectFwDevicePage(Condition.getPage(query), GenericConverter.convert(fwDevice, FwDeviceDTO.class));
        IPage<FwDeviceVO> result = FwDeviceWrapper.build().pageVO(pages);
        List<FwDeviceVO> records = result.getRecords();
        if (records != null && !records.isEmpty()) {
            List<Long> deviceIds = records.stream()
                .map(FwDeviceVO::getId)
                .filter(id -> id != null)
                .collect(Collectors.toList());
            Map<Long, String> sceneNameMap = fwDeviceService.selectSceneNameByDeviceIds(deviceIds);
            for (FwDeviceVO record : records) {
                String sceneName = sceneNameMap.get(record.getId());
                record.setSceneName(StringUtil.isBlank(sceneName) ? "/" : sceneName);
            }
        }
        return R.data(result);
        return R.data(fwDeviceService.selectFwDevicePageVo(fwDevice, query));
    }
    /**
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/IFwDeviceService.java
@@ -21,12 +21,14 @@
import org.sxkj.fw.cockpit.vo.DeviceStatisticsVO;
import org.sxkj.fw.device.dto.FwDeviceDTO;
import org.sxkj.fw.device.entity.FwDeviceEntity;
import org.sxkj.fw.device.param.FwDevicePageParam;
import org.sxkj.fw.device.vo.CockpitFwDeviceVO;
import org.sxkj.fw.device.vo.DeviceTypeStatisticsVO;
import org.sxkj.fw.device.vo.FwDeviceVO;
import org.sxkj.fw.device.excel.FwDeviceExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import java.util.List;
import java.util.Map;
@@ -47,6 +49,15 @@
    IPage<FwDeviceEntity> selectFwDevicePage(IPage<FwDeviceEntity> page, FwDeviceDTO fwDevice);
    /**
     * 自定义分页返回
     *
     * @param fwDevice
     * @param query
     * @return
     */
    IPage<FwDeviceVO> selectFwDevicePageVo(FwDevicePageParam fwDevice, Query query);
    /**
     * 列表查询
     *
     * @param isAreaSelect 是否过滤区域
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/impl/FwDeviceServiceImpl.java
@@ -18,8 +18,10 @@
import org.sxkj.fw.cockpit.vo.AlarmStatisticsVO;
import org.sxkj.fw.cockpit.vo.DeviceStatisticsVO;
import org.sxkj.fw.common.GenericConverter;
import org.sxkj.fw.device.dto.FwDeviceDTO;
import org.sxkj.fw.device.entity.FwDeviceEntity;
import org.sxkj.fw.device.param.FwDevicePageParam;
import org.sxkj.fw.device.vo.CockpitFwDeviceVO;
import org.sxkj.fw.device.vo.DeviceTypeStatisticsVO;
import org.sxkj.fw.device.vo.FwDeviceVO;
@@ -27,12 +29,17 @@
import org.sxkj.fw.device.mapper.FwDeviceMapper;
import org.sxkj.fw.device.service.IFwDeviceService;
import org.sxkj.fw.area.service.IFwAreaDivideService;
import org.sxkj.fw.device.wrapper.FwDeviceWrapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.StringUtil;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
/**
@@ -53,6 +60,25 @@
    }
    @Override
    public IPage<FwDeviceVO> selectFwDevicePageVo(FwDevicePageParam fwDevice, Query query) {
        IPage<FwDeviceEntity> pages = selectFwDevicePage(Condition.getPage(query), GenericConverter.convert(fwDevice, FwDeviceDTO.class));
        IPage<FwDeviceVO> result = FwDeviceWrapper.build().pageVO(pages);
        List<FwDeviceVO> records = result.getRecords();
        if (records != null && !records.isEmpty()) {
            List<Long> deviceIds = records.stream()
                .map(FwDeviceVO::getId)
                .filter(id -> id != null)
                .collect(Collectors.toList());
            Map<Long, String> sceneNameMap = selectSceneNameByDeviceIds(deviceIds);
            for (FwDeviceVO record : records) {
                String sceneName = sceneNameMap.get(record.getId());
                record.setSceneName(StringUtil.isBlank(sceneName) ? "/" : sceneName);
            }
        }
        return result;
    }
    @Override
    public List<FwDeviceEntity> selectFwDeviceList(Integer isAreaSelect, Long areaId, Integer status) {
        return baseMapper.selectFwDeviceList(isAreaSelect, areaId, status);
    }