创城事件接口优化

This commit is contained in:
wuweida 2022-08-09 14:08:47 +08:00
parent 793fdaec52
commit 43d36fff08
2 changed files with 52 additions and 166 deletions

View File

@ -214,9 +214,9 @@ public class EventController {
public Result selectByName(String eventNewName,Integer page,Integer pageSize){
if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("环境卫生");
}
});
Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -225,9 +225,9 @@ public class EventController {
return success;
}else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("占道经营");
}
});
Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -236,9 +236,9 @@ public class EventController {
return success;
}else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("沿街晾晒");
}
});
Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -247,72 +247,29 @@ public class EventController {
return success;
}else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByName("'机动车违停'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("违章停车");
}
});
Integer integer = eventMapper.selectCountByName("'机动车违停'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("渣土车发现")) {
List<EventDto> lists = eventMapper.selectByName("'渣土车发现'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("渣土车发现");
}
Integer integer = eventMapper.selectCountByName("'渣土车发现'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("安保区域人员滞留")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员滞留'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("安保区域人员滞留");
}
Integer integer = eventMapper.selectCountByName("'安保区域人员滞留'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("安保区域人员徘徊")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员徘徊'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("安保区域人员徘徊");
}
Integer integer = eventMapper.selectCountByName("'安保区域人员徘徊'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("渣土车未密闭")) {
List<EventDto> lists = eventMapper.selectByName("'渣土车未密闭'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("渣土车未密闭");
}
Integer integer = eventMapper.selectCountByName("'渣土车未密闭'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("道路积水事件")) {
List<EventDto> lists = eventMapper.selectByName("'道路积水事件'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("道路积水事件");
}
Integer integer = eventMapper.selectCountByName("'道路积水事件'");
}else {
StringBuilder str = new StringBuilder(eventNewName);
String s = str.insert(0, "'").append("'").toString();
List<EventDto> lists = eventMapper.selectByName(s, page, pageSize);
lists.forEach(list ->{
list.setEventNewName(list.getEventCnName());
});
Integer integer = eventMapper.selectCountByName(s);
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}
return Result.error("请输入正确的事件类型");
}
/**
@ -323,72 +280,44 @@ public class EventController {
@GetMapping("selectByTimeAndName")
@ApiOperation("查询当天根据事件名称查询事件")
@ApiImplicitParam(name = "eventNewName",value = "事件名称",required = true,dataType = "String")
public Result selectByTimeAndName(String eventNewName){
if (eventNewName.equals("环境卫生")){
public Result selectByTimeAndName(String eventNewName) {
if (eventNewName.equals("环境卫生")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'塑料篮子','纸箱','街头散落垃圾'");
for (EventDto list: lists) {
for (EventDto list : lists) {
list.setEventNewName("环境卫生");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("占道经营")){
} else if (eventNewName.equals("占道经营")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
for (EventDto list: lists) {
for (EventDto list : lists) {
list.setEventNewName("占道经营");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("沿街晾晒")){
} else if (eventNewName.equals("沿街晾晒")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'沿街晾晒衣物被单'");
for (EventDto list: lists) {
for (EventDto list : lists) {
list.setEventNewName("沿街晾晒");
}
Result success = Result.success(lists);
return success;
}else if (eventNewName.equals("违章停车")){
} else if (eventNewName.equals("违章停车")) {
List<EventDto> lists = eventMapper.selectByTimeAndName("'机动车违停'");
for (EventDto list: lists) {
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("道路积水事件");
}
} else {
StringBuilder str = new StringBuilder(eventNewName);
String s = str.insert(0, "'").append("'").toString();
List<EventDto> lists = eventMapper.selectByTimeAndName(s);
lists.forEach(list -> {
list.setEventNewName(list.getEventCnName());
});
Result success = Result.success(lists);
return success;
}
return Result.error("请输入正确的事件类型");
}
}

View File

@ -92,7 +92,7 @@ public class KeyAreaController {
})
public Result selectAreaEvent(Integer page,Integer pageSize){
List<EventDto> events = eventMapper.selectEvent(page,pageSize);
for (EventDto event: events) {
events.forEach(event -> {
if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊")
|| event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){
event.setEventNewName("占道经营");
@ -106,7 +106,7 @@ public class KeyAreaController {
}else {
event.setEventNewName(event.getEventCnName());
}
}
});
Integer integer = eventMapper.selectCountEvent();
page = integer/pageSize + 1;
Map<String,Object> map = new HashMap<>();
@ -125,7 +125,7 @@ public class KeyAreaController {
@ApiOperation("重点区域场景查询当天事件")
public Result selectAreaByTime(){
List<EventDto> events = eventMapper.selectByTime();
for (EventDto event: events) {
events.forEach(event -> {
if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊")
|| event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){
event.setEventNewName("占道经营");
@ -139,7 +139,7 @@ public class KeyAreaController {
}else {
event.setEventNewName(event.getEventCnName());
}
}
});
Result success = Result.success(events);
@ -162,9 +162,9 @@ public class KeyAreaController {
public Result selectAreaByName(String eventNewName,Integer page,Integer pageSize){
if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("环境卫生");
}
});
Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -173,9 +173,9 @@ public class KeyAreaController {
return success;
}else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("占道经营");
}
});
Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -184,9 +184,9 @@ public class KeyAreaController {
return success;
}else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("沿街晾晒");
}
});
Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
@ -195,72 +195,29 @@ public class KeyAreaController {
return success;
}else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByName("'机动车违停'",page,pageSize);
for (EventDto list: lists) {
lists.forEach(list ->{
list.setEventNewName("违章停车");
}
});
Integer integer = eventMapper.selectCountByName("'机动车违停'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("渣土车发现")) {
List<EventDto> lists = eventMapper.selectByName("'渣土车发现'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("渣土车发现");
}
Integer integer = eventMapper.selectCountByName("'渣土车发现'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("安保区域人员滞留")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员滞留'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("安保区域人员滞留");
}
Integer integer = eventMapper.selectCountByName("'安保区域人员滞留'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("安保区域人员徘徊")) {
List<EventDto> lists = eventMapper.selectByName("'安保区域人员徘徊'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("安保区域人员徘徊");
}
Integer integer = eventMapper.selectCountByName("'安保区域人员徘徊'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("渣土车未密闭")) {
List<EventDto> lists = eventMapper.selectByName("'渣土车未密闭'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("渣土车未密闭");
}
Integer integer = eventMapper.selectCountByName("'渣土车未密闭'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("道路积水事件")) {
List<EventDto> lists = eventMapper.selectByName("'道路积水事件'",page,pageSize);
for (EventDto list : lists) {
list.setEventNewName("道路积水事件");
}
Integer integer = eventMapper.selectCountByName("'道路积水事件'");
}else {
StringBuilder str = new StringBuilder(eventNewName);
String s = str.insert(0, "'").append("'").toString();
List<EventDto> lists = eventMapper.selectByName(s, page, pageSize);
lists.forEach(list ->{
list.setEventNewName(list.getEventCnName());
});
Integer integer = eventMapper.selectCountByName(s);
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}
return Result.error("请输入正确的事件类型");
}