道路污染事件接口添加分页并按时间倒序

This commit is contained in:
wuweida 2022-06-30 11:32:33 +08:00
parent 7ddc950e89
commit 2ca138ffb1
4 changed files with 23 additions and 10 deletions

View File

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -50,6 +51,9 @@ public class QidiController {
@Autowired @Autowired
private QidiService qidiService; private QidiService qidiService;
@Autowired
private RoadDataMapper roadDataMapper;
//道路统计数据与排名 //道路统计数据与排名
@GetMapping("roadData") @GetMapping("roadData")
@ApiOperation("道路统计数据与排名根据后台dt调用接口") @ApiOperation("道路统计数据与排名根据后台dt调用接口")
@ -293,9 +297,14 @@ public class QidiController {
*/ */
@GetMapping("selectRoadData") @GetMapping("selectRoadData")
@ApiOperation("查询全部道路污染累计事件数量") @ApiOperation("查询全部道路污染累计事件数量")
public Result selectRoadData(){ public Result selectRoadData(Integer page,Integer pageSize){
List<RoadData> roadData = roadDataService.selectRoadData(); List<RoadData> roadData = roadDataMapper.selectRoadData(page,pageSize);
Result success = Result.success(roadData); Integer integer = roadDataMapper.selectCountRoadData();
page = integer/pageSize + 1;
Map<String,Object> map = new HashMap<>();
map.put("page",page);
map.put("roadData",roadData);
Result success = Result.success(map);
return success; return success;
} }

View File

@ -3,6 +3,7 @@ package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.entity.RoadData; import com.hisense.monitormanage.entity.RoadData;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -16,4 +17,9 @@ import java.util.Map;
*/ */
public interface RoadDataMapper extends BaseMapper<RoadData> { public interface RoadDataMapper extends BaseMapper<RoadData> {
public void batchSave(List<Map> list); public void batchSave(List<Map> list);
List<RoadData> selectRoadData(@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Select("select count(*) from t_road_data where pm10 > 150")
Integer selectCountRoadData();
} }

View File

@ -119,13 +119,6 @@ public class RoadDataService {
return list; return list;
} }
public List<RoadData> selectRoadData(){
QueryWrapper<RoadData> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("pm10",150);
List<RoadData> list = roadDataMapper.selectList(queryWrapper);
return list;
}
//获取当前日期的时间串2022-05-08 00:00:00 //获取当前日期的时间串2022-05-08 00:00:00
private String dateTimeStr(){ private String dateTimeStr(){
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();

View File

@ -16,5 +16,10 @@
</foreach> </foreach>
</insert> </insert>
<select id="selectRoadData" resultType="com.hisense.monitormanage.entity.RoadData">
select * from t_road_data where pm10 > 150 order by dt desc
<bind name="page" value="(page-1)*pageSize"/>
limit #{page},#{pageSize}
</select>
</mapper> </mapper>