创城事件接口优化

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){ public Result selectByName(String eventNewName,Integer page,Integer pageSize){
if (eventNewName.equals("环境卫生")){ if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize); List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize);
for (EventDto list: lists) { lists.forEach(list ->{
list.setEventNewName("环境卫生"); list.setEventNewName("环境卫生");
} });
Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'"); Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
@ -225,9 +225,9 @@ public class EventController {
return success; return success;
}else if (eventNewName.equals("占道经营")){ }else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize); List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize);
for (EventDto list: lists) { lists.forEach(list ->{
list.setEventNewName("占道经营"); list.setEventNewName("占道经营");
} });
Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'"); Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
@ -236,9 +236,9 @@ public class EventController {
return success; return success;
}else if (eventNewName.equals("沿街晾晒")){ }else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'",page,pageSize); List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'",page,pageSize);
for (EventDto list: lists) { lists.forEach(list ->{
list.setEventNewName("沿街晾晒"); list.setEventNewName("沿街晾晒");
} });
Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'"); Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
@ -247,72 +247,29 @@ public class EventController {
return success; return success;
}else if (eventNewName.equals("违章停车")){ }else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByName("'机动车违停'",page,pageSize); List<EventDto> lists = eventMapper.selectByName("'机动车违停'",page,pageSize);
for (EventDto list: lists) { lists.forEach(list ->{
list.setEventNewName("违章停车"); list.setEventNewName("违章停车");
} });
Integer integer = eventMapper.selectCountByName("'机动车违停'"); Integer integer = eventMapper.selectCountByName("'机动车违停'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
map.put("events",lists); map.put("events",lists);
Result success = Result.success(map); Result success = Result.success(map);
return success; return success;
}else if (eventNewName.equals("渣土车发现")) { }else {
List<EventDto> lists = eventMapper.selectByName("'渣土车发现'",page,pageSize); StringBuilder str = new StringBuilder(eventNewName);
for (EventDto list : lists) { String s = str.insert(0, "'").append("'").toString();
list.setEventNewName("渣土车发现"); List<EventDto> lists = eventMapper.selectByName(s, page, pageSize);
} lists.forEach(list ->{
Integer integer = eventMapper.selectCountByName("'渣土车发现'"); list.setEventNewName(list.getEventCnName());
Map<String,Object> map = new HashMap<>(); });
map.put("sum",integer); Integer integer = eventMapper.selectCountByName(s);
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<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
map.put("events",lists); map.put("events",lists);
Result success = Result.success(map); Result success = Result.success(map);
return success; return success;
} }
return Result.error("请输入正确的事件类型");
} }
/** /**
@ -352,43 +309,15 @@ public class EventController {
} }
Result success = Result.success(lists); Result success = Result.success(lists);
return success; return success;
}else if (eventNewName.equals("渣土车发现")) { } else {
List<EventDto> lists = eventMapper.selectByTimeAndName("'渣土车发现'"); StringBuilder str = new StringBuilder(eventNewName);
for (EventDto list : lists) { String s = str.insert(0, "'").append("'").toString();
list.setEventNewName("渣土车发现"); List<EventDto> lists = eventMapper.selectByTimeAndName(s);
} lists.forEach(list -> {
Result success = Result.success(lists); list.setEventNewName(list.getEventCnName());
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); Result success = Result.success(lists);
return success; return success;
} }
return Result.error("请输入正确的事件类型");
} }
} }

View File

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