根据事件类型查询事件优化

This commit is contained in:
wuweida 2022-06-10 11:30:30 +08:00
parent 9996dbc912
commit b5a9ade539
2 changed files with 113 additions and 23 deletions

View File

@ -21,8 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.*;
@RestController
@RequestMapping("STapi/project")
@ -196,35 +195,126 @@ public class EventController {
/**
* 根据事件名称查询事件
* @param eventCnName
* @param eventNewName
* @return
*/
@GetMapping("selectByName")
@ApiOperation("根据事件名称查询事件")
@ApiImplicitParam(name = "eventCnName",value = "事件名称",required = true,dataType = "String")
public Result selectByName(String eventCnName){
List<EventDto> byName = eventMapper.selectByName(eventCnName);
Result success = Result.success(byName);
return success;
@ApiImplicitParam(name = "eventNewName",value = "事件名称",required = true,dataType = "String")
public Result selectByName(String eventNewName){
if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'");
for (EventDto list: lists) {
list.setEventNewName("环境卫生");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
for (EventDto list: lists) {
list.setEventNewName("占道经营");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'");
for (EventDto list: lists) {
list.setEventNewName("沿街晾晒");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByName("'机动车违停'");
for (EventDto list: lists) {
list.setEventNewName("违章停车");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("渣土车发现")) {
List<EventDto> lists = eventMapper.selectByName("'渣土车发现'");
for (EventDto list : lists) {
list.setEventNewName("渣土车发现");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("安保区域人员滞留")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员滞留'");
for (EventDto list : lists) {
list.setEventNewName("安保区域人员滞留");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("安保区域人员徘徊")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员徘徊'");
for (EventDto list : lists) {
list.setEventNewName("安保区域人员徘徊");
}
Result success = Result.success(lists);
return success;
}
return Result.error("请输入正确的事件类型");
}
/**
* 查询当天根据事件名称查询事件
* @param eventCnName
* @param eventNewName
* @return
*/
@GetMapping("selectByTimeAndName")
@ApiOperation("查询当天根据事件名称查询事件")
@ApiImplicitParam(name = "eventCnName",value = "事件名称",required = true,dataType = "String")
public Result selectByTimeAndName(String eventCnName){
List<Event> byName = eventMapper.selectByTimeAndName(eventCnName);
Result success = Result.success(byName);
return success;
@ApiImplicitParam(name = "eventNewName",value = "事件名称",required = true,dataType = "String")
public Result selectByTimeAndName(String eventNewName){
if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByTimeAndName("'塑料篮子','纸箱','街头散落垃圾'");
for (EventDto list: lists) {
list.setEventNewName("环境卫生");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByTimeAndName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
for (EventDto list: lists) {
list.setEventNewName("占道经营");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByTimeAndName("'沿街晾晒衣物被单'");
for (EventDto list: lists) {
list.setEventNewName("沿街晾晒");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByTimeAndName("'机动车违停'");
for (EventDto list: lists) {
list.setEventNewName("违章停车");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("渣土车发现")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'渣土车发现'");
for (EventDto list : lists) {
list.setEventNewName("渣土车发现");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("安保区域人员滞留")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'安保区域人员滞留'");
for (EventDto list : lists) {
list.setEventNewName("安保区域人员滞留");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("安保区域人员徘徊")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'安保区域人员徘徊'");
for (EventDto list : lists) {
list.setEventNewName("安保区域人员徘徊");
}
Result success = Result.success(lists);
return success;
}
return Result.error("请输入正确的事件类型");
}
}

View File

@ -15,9 +15,9 @@ public interface EventMapper extends BaseMapper<Event> {
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND track_event = 'START'")
List<EventDto> selectByTime();
@Select("select * from t_event where event_cn_name = #{eventCnName} and track_event = 'START'")
List<EventDto> selectByName(@Param("eventCnName") String eventCnName);
@Select("select * from t_event where track_event = 'START' and event_cn_name in (${eventNewName})")
List<EventDto> selectByName(@Param("eventNewName") String eventNewName);
@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);
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND event_cn_name in (${eventNewName}) AND track_event = 'START'")
List<EventDto> selectByTimeAndName(@Param("eventNewName") String eventNewName);
}