道路污染事件接口添加分页并按时间倒序
This commit is contained in:
parent
7ddc950e89
commit
2ca138ffb1
|
@ -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> roadData = roadDataService.selectRoadData();
|
||||
Result success = Result.success(roadData);
|
||||
public Result selectRoadData(Integer page,Integer pageSize){
|
||||
List<RoadData> roadData = roadDataMapper.selectRoadData(page,pageSize);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<RoadData> {
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -119,13 +119,6 @@ public class RoadDataService {
|
|||
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
|
||||
private String dateTimeStr(){
|
||||
LocalDate localDate = LocalDate.now();
|
||||
|
|
|
@ -16,5 +16,10 @@
|
|||
</foreach>
|
||||
</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>
|
Loading…
Reference in New Issue