查询全部事件接口添加分页

This commit is contained in:
wuweida 2022-06-09 18:03:43 +08:00
parent e72a234e11
commit 9996dbc912
4 changed files with 70 additions and 12 deletions

View File

@ -1,6 +1,7 @@
package com.hisense.monitormanage.controller;
import com.alibaba.fastjson.JSONObject;
import com.hisense.monitormanage.dto.EventDto;
import com.hisense.monitormanage.entity.Event;
import com.hisense.monitormanage.entity.Result;
import com.hisense.monitormanage.mapper.EventMapper;
@ -141,10 +142,23 @@ public class EventController {
*/
@GetMapping("selectEvent")
@ApiOperation("查询所有事件")
public Result selectEvent(){
List<Event> events = eventMapper.selectEvent();
public Result selectEvent(Integer page,Integer pageSize){
List<EventDto> events = eventMapper.selectEvent(page,pageSize);
for (EventDto event: events) {
if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊")
|| event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){
event.setEventNewName("占道经营");
}else if (event.getEventCnName().equals("纸箱")|| event.getEventCnName().equals("街头散落垃圾")
||event.getEventCnName().equals("塑料篮子")){
event.setEventNewName("环境卫生");
}else if (event.getEventCnName().equals("沿街晾晒衣物被单")){
event.setEventNewName("沿街晾晒");
}else if (event.getEventCnName().equals("机动车违停")){
event.setEventNewName("违章停车");
}else {
event.setEventNewName(event.getEventCnName());
}
}
Result success = Result.success(events);
return success;
@ -157,9 +171,24 @@ public class EventController {
@GetMapping("selectByTime")
@ApiOperation("查询当天事件")
public Result selectByTime(){
List<Event> byTime = eventMapper.selectByTime();
List<EventDto> events = eventMapper.selectByTime();
for (EventDto event: events) {
if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊")
|| event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){
event.setEventNewName("占道经营");
}else if (event.getEventCnName().equals("纸箱")|| event.getEventCnName().equals("街头散落垃圾")
||event.getEventCnName().equals("塑料篮子")){
event.setEventNewName("环境卫生");
}else if (event.getEventCnName().equals("沿街晾晒衣物被单")){
event.setEventNewName("沿街晾晒");
}else if (event.getEventCnName().equals("机动车违停")){
event.setEventNewName("违章停车");
}else {
event.setEventNewName(event.getEventCnName());
}
}
Result success = Result.success(byTime);
Result success = Result.success(events);
return success;
@ -174,7 +203,8 @@ public class EventController {
@ApiOperation("根据事件名称查询事件")
@ApiImplicitParam(name = "eventCnName",value = "事件名称",required = true,dataType = "String")
public Result selectByName(String eventCnName){
List<Event> byName = eventMapper.selectByName(eventCnName);
List<EventDto> byName = eventMapper.selectByName(eventCnName);
Result success = Result.success(byName);

View File

@ -0,0 +1,23 @@
package com.hisense.monitormanage.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class EventDto {
private String eventCnName;
private String eventNewName;
private String eventSerial;
private String color;
private String vehicle;
private String classes;
private String cameraName;
private String district;
private BigDecimal latitude;
private BigDecimal longitude;
private String imageUrl;
private String taskId;
private String captureTime;
private String trackEvent;
}

View File

@ -1,6 +1,7 @@
package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.dto.EventDto;
import com.hisense.monitormanage.entity.Event;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -8,14 +9,14 @@ import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface EventMapper extends BaseMapper<Event> {
@Select("SELECT * FROM t_event where track_event = 'START'")
List<Event> selectEvent();
List<EventDto> selectEvent(@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND track_event = 'START'")
List<Event> selectByTime();
List<EventDto> selectByTime();
@Select("select * from t_event where event_cn_name = #{eventCnName} and track_event = 'START'")
List<Event> selectByName(@Param("eventCnName") String eventCnName);
List<EventDto> selectByName(@Param("eventCnName") String eventCnName);
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND event_cn_name = #{eventCnName} AND track_event = 'START'")
List<Event> selectByTimeAndName(@Param("eventCnName") String eventCnName);

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hisense.monitormanage.mapper.EventMapper">
<select id="selectEvent" resultType="com.hisense.monitormanage.dto.EventDto">
SELECT * FROM t_event where track_event = 'START'
<bind name="page" value="(page-1)*pageSize"/>
limit #{page},#{pageSize}
</select>
</mapper>