leutu
2024-05-08 543e4eb01ca210b20876e8139cb3d0403d7d065c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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;
    }
}