diff --git a/src/main/java/com/hisense/monitormanage/controller/QidiController.java b/src/main/java/com/hisense/monitormanage/controller/QidiController.java index d94117a..501eb30 100644 --- a/src/main/java/com/hisense/monitormanage/controller/QidiController.java +++ b/src/main/java/com/hisense/monitormanage/controller/QidiController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,6 +51,9 @@ public class QidiController { @Autowired private QidiService qidiService; + @Autowired + private RoadDataMapper roadDataMapper; + //道路统计数据与排名 @GetMapping("roadData") @ApiOperation("道路统计数据与排名,根据后台dt调用接口") @@ -293,9 +297,14 @@ public class QidiController { */ @GetMapping("selectRoadData") @ApiOperation("查询全部道路污染累计事件数量") - public Result selectRoadData(){ - List roadData = roadDataService.selectRoadData(); - Result success = Result.success(roadData); + public Result selectRoadData(Integer page,Integer pageSize){ + List roadData = roadDataMapper.selectRoadData(page,pageSize); + Integer integer = roadDataMapper.selectCountRoadData(); + page = integer/pageSize + 1; + Map map = new HashMap<>(); + map.put("page",page); + map.put("roadData",roadData); + Result success = Result.success(map); return success; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java index 3351764..fe6e3f2 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java @@ -3,6 +3,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.entity.RoadData; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import java.util.List; import java.util.Map; @@ -16,4 +17,9 @@ import java.util.Map; */ public interface RoadDataMapper extends BaseMapper { public void batchSave(List list); + + List selectRoadData(@Param("page") Integer page,@Param("pageSize") Integer pageSize); + + @Select("select count(*) from t_road_data where pm10 > 150") + Integer selectCountRoadData(); } diff --git a/src/main/java/com/hisense/monitormanage/service/RoadDataService.java b/src/main/java/com/hisense/monitormanage/service/RoadDataService.java index cee7160..c747572 100644 --- a/src/main/java/com/hisense/monitormanage/service/RoadDataService.java +++ b/src/main/java/com/hisense/monitormanage/service/RoadDataService.java @@ -119,13 +119,6 @@ public class RoadDataService { return list; } - public List selectRoadData(){ - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.gt("pm10",150); - List list = roadDataMapper.selectList(queryWrapper); - return list; - } - //获取当前日期的时间串,2022-05-08 00:00:00 private String dateTimeStr(){ LocalDate localDate = LocalDate.now(); diff --git a/src/main/resources/mapper/RoadDataMapper.xml b/src/main/resources/mapper/RoadDataMapper.xml index 23d6ca5..c95ab67 100644 --- a/src/main/resources/mapper/RoadDataMapper.xml +++ b/src/main/resources/mapper/RoadDataMapper.xml @@ -16,5 +16,10 @@ + \ No newline at end of file