| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.constant.*; |
| | | import com.whyc.dto.AlarmParam; |
| | | 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.BattAlmparamService; |
| | | import com.whyc.service.DevAlmparamService; |
| | | import com.whyc.service.PwrdevAlarmParamService; |
| | | 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.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private DevAlmparamService devAlmparamService; |
| | | |
| | | @Autowired |
| | | private PwrdevAlarmParamService pwrAlmparamService; |
| | | |
| | | |
| | | @PostMapping("getBattAlmParam") |
| | |
| | | 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("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); |
| | | } |
| | | |
| | | } |