package com.skyline.electricity.controller;
|
|
import org.springframework.beans.factory.annotation.*;
|
import com.skyline.electricity.service.*;
|
import org.springframework.web.bind.annotation.*;
|
import com.skyline.electricity.pojo.*;
|
import java.util.*;
|
import io.swagger.annotations.*;
|
|
@RequestMapping({ "/alarm" })
|
@RestController
|
@Api("基于Swagger的电力区域报警系统")
|
@CrossOrigin
|
public class AlarmController
|
{
|
@Autowired
|
private AlarmService alarmService;
|
@Autowired
|
private InfoSynchService infoSynchService;
|
|
@RequestMapping(value = { "/getAlarmInfo" }, method = { RequestMethod.POST })
|
@ApiOperation("获取所有预警信息")
|
public Object getAlarmInfo() {
|
final List<Information> list = (List<Information>)this.alarmService.getAlarmInfo();
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", list);
|
return map;
|
}
|
|
@RequestMapping(value = { "/getLatestAlarmInfo" }, method = { RequestMethod.POST })
|
@ApiOperation("获取最新的预警信息")
|
public Object getLatestAlarmInfo() {
|
final List<AllowPerson> allowList = (List<AllowPerson>)this.infoSynchService.selectAllowPerson();
|
final List<Information> list = (List<Information>)this.alarmService.getLatestAlarmInfo();
|
final List<Information> alarmInfo_list = new ArrayList<Information>();
|
final AllowPerson allowPerson = new AllowPerson();
|
for (final Information information : list) {
|
allowPerson.setUserId(information.getUserId());
|
allowPerson.setWorkId(information.getWtId());
|
if (!allowList.contains(allowPerson)) {
|
alarmInfo_list.add(information);
|
}
|
}
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", alarmInfo_list);
|
return map;
|
}
|
|
@RequestMapping(value = { "/getAlarmInfoById" }, method = { RequestMethod.POST })
|
@ApiOperation("根据用户票务ID获取预警信息")
|
public Object getAlarmInfoById(final String... userId) {
|
final List<Information> list = new ArrayList<Information>();
|
for (int i = 0; i < userId.length; ++i) {
|
final List<Information> list2 = (List<Information>)this.alarmService.getAlarmInfoById(userId[i]);
|
for (final Information information : list2) {
|
list.add(information);
|
}
|
}
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", list);
|
return map;
|
}
|
|
@RequestMapping(value = { "/getAlarmInfoByStatus" }, method = { RequestMethod.POST })
|
@ApiOperation("根据出入状态获取预警信息")
|
@ApiImplicitParam(paramType = "query", name = "status", value = "出入状态", required = true, dataType = "String")
|
public Object getAlarmInfoByStatus(final String status) {
|
final List<Information> list = (List<Information>)this.alarmService.getAlarmInfoByStatus(status);
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", list);
|
return map;
|
}
|
|
@RequestMapping(value = { "/getAlarmInfoByTime" }, method = { RequestMethod.POST })
|
@ApiOperation("根据时间段获取预警信息")
|
@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "starttime", value = "起始时间", required = true, dataType = "String"), @ApiImplicitParam(paramType = "query", name = "endtime", value = "结束时间", required = true, dataType = "String") })
|
public Object getAlarmInfoByTime(final String starttime, final String endtime) {
|
final List<Information> list = (List<Information>)this.alarmService.getAlarmInfoByTime(starttime, endtime);
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", list);
|
return map;
|
}
|
|
@RequestMapping(value = { "/getAlarmInfoByCondition" }, method = { RequestMethod.POST })
|
@ApiOperation("根据时间段获取预警信息")
|
@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "starttime", value = "起始时间", required = true, dataType = "String"), @ApiImplicitParam(paramType = "query", name = "endtime", value = "结束时间", required = true, dataType = "String"), @ApiImplicitParam(paramType = "query", name = "status", value = "出入状态", required = true, dataType = "String"), @ApiImplicitParam(paramType = "query", name = "userId", value = "人员ID", required = true, dataType = "String") })
|
public Object getAlarmInfoByCondition(final String starttime, final String endtime, final String userId, final String status) {
|
final List<Information> list = (List<Information>)this.alarmService.getAlarmInfoByCondition(starttime, endtime, userId, status);
|
final Map<String, Object> map = new HashMap<String, Object>();
|
map.put("alarminfo", list);
|
return map;
|
}
|
}
|