whycxzp
9 天以前 167236d51d359745c6abe0b6ed827b2ff7d37a4b
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.whyc.controller;
 
import com.whyc.constant.*;
import com.whyc.dto.AlarmParam;
import com.whyc.dto.Param.AlmAnalyseDto;
import com.whyc.dto.Param.ParamAlmDto;
import com.whyc.dto.Real.AlmDto;
import com.whyc.dto.Response;
import com.whyc.dto.Station.Power;
import com.whyc.pojo.db_param.BattAlmparam;
import com.whyc.pojo.db_param.DevAlmparam;
import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmParam;
import com.whyc.service.*;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@RestController
@Api(tags = "告警参数管理")
@RequestMapping("almParam")
public class AlmParamController {
    @Autowired
    private BattAlmparamService battAlmparamService;
 
    @Autowired
    private DevAlmparamService devAlmparamService;
 
    @Autowired
    private PwrdevAlarmParamService pwrAlmparamService;
 
    @Autowired
    private BattalarmDataService battalarmDataService;
 
    @Autowired
    private BattRealdataIdService battRealdataIdService;
 
 
    /*@PostMapping("getBattAlmParam")
    @ApiOperation("获取电池告警参数")
    public Response getBattAlmParam(@RequestBody AlmDto almDto){
        almDto.setUid(ActionUtil.getUser().getId());
        return battAlmparamService.getBattAlmParam(almDto);
    }*/
 
    @PostMapping("getBattAlmParam")
    @ApiOperation("获取电池告警参数")
    public Response getBattAlmParam(@RequestBody ParamAlmDto dto){
        Integer uid=ActionUtil.getUser().getId();
        dto.setUid(uid);
        return battAlmparamService.getBattAlmParam(dto);
    }
 
    @PostMapping("setBattAlmParam")
    @ApiOperation("修改电池告警参数")
    public Response setBattAlmParam(@RequestBody List<BattAlmparam> almparamList){
        return battAlmparamService.setBattAlmParam(almparamList);
    }
 
    @GetMapping("getDevAlmParam")
    @ApiOperation("获取设备告警参数")
    public Response getDevAlmParam(@RequestParam(required = false) Integer almId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        return devAlmparamService.getDevAlmParam(almId,pageNum,pageSize);
    }
 
    @PostMapping("setDevAlmParam")
    @ApiOperation("修改设备告警参数")
    public Response setDevAlmParam(@RequestBody List<DevAlmparam> almparamList){
        return devAlmparamService.setDevAlmParam(almparamList);
    }
 
    /*@PostMapping("getPwrAlmParam")
    @ApiOperation("获取电源告警参数")
    public Response getPwrAlmParam(@RequestBody AlmDto almDto){
        almDto.setUid(ActionUtil.getUser().getId());
        return pwrAlmparamService.getPwrAlmParam(almDto);
    }*/
 
    @PostMapping("getPwrAlmParam")
    @ApiOperation("获取电源告警参数")
    public Response getPwrAlmParam(@RequestBody ParamAlmDto dto){
        Integer uid=ActionUtil.getUser().getId();
        dto.setUid(uid);
        return pwrAlmparamService.getPwrAlmParam(dto);
    }
 
 
    @PostMapping("setPwrAlmParam")
    @ApiOperation("修改电源告警参数")
    public Response setPwrAlmParam(@RequestBody List<PwrdevAlarmParam> almparamList){
        return pwrAlmparamService.setPwrAlmParam(almparamList);
    }
 
    @GetMapping("getAlarmList")
    @ApiOperation(value = "获取所有告警,1-电源,2-设备,3-电池",tags = "告警诊断")
    public Response<List<AlarmParam>> getAlarmList(@RequestParam Integer type){
        List<AlarmParam> list = new ArrayList<>();
        if(type==1){ //电源告警
            //遍历枚举类型PowerAlarmEnum
            for(PowerAlarmEnum powerAlarmEnum:PowerAlarmEnum.values()){
                list.add(new AlarmParam(powerAlarmEnum.getStateId(),powerAlarmEnum.getStateName()));
            }
        }else if (type==2){ //设备告警
            for (DevAlarmEnum devAlarmEnum:DevAlarmEnum.values()){
                list.add(new AlarmParam(devAlarmEnum.getStateId(),devAlarmEnum.getStateName()));
            }
        }else{ //电池告警
            for (BattSingalIdEnum battSignalIdEnum:BattSingalIdEnum.values()){
                list.add(new AlarmParam(battSignalIdEnum.getStateId(),battSignalIdEnum.getStateName()));
            }
        }
        return new Response<List<AlarmParam>>().set(1,list);
    }
 
    @PostMapping("getBattAlmAnalyse")
    @ApiOperation("预警分析管理-电池告警")
    public Response getBattAlmAnalyse(@RequestBody AlmAnalyseDto dto){
        Integer uid=ActionUtil.getUser().getId();
        dto.setUid(uid);
        return battalarmDataService.getBattAlmAnalyse(dto);
    }
 
    @GetMapping("getBattHisRealInAlm")
    @ApiOperation("电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据")
    public Response getBattHisRealInAlm(@RequestParam Integer battgroupId,@RequestParam String startTime,@RequestParam(required = false) Integer monNum) throws ParseException, InterruptedException {
        return battRealdataIdService.getBattHisRealInAlm(battgroupId,startTime,monNum);
    }
 
}