whyclxw
7 天以前 a6018ae593fc2d2fb3ccfa4e7c34f28387326f6b
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.PowerAlarmEnum;
import com.whyc.dto.AlarmParam;
import com.whyc.dto.Param.ParamAlmDto;
import com.whyc.dto.Real.AlmDto;
import com.whyc.dto.Response;
import com.whyc.mapper.PwrdevAlarmParamMapper;
import com.whyc.pojo.db_param.BattAlmparam;
import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmParam;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class PwrdevAlarmParamService {
    @Autowired(required = false)
    private PwrdevAlarmParamMapper mapper;
 
    @Autowired(required = false)
    private PowerInfService pinfService;
 
    //获取电源告警参数
    public Response getPwrAlmParam(ParamAlmDto dto) {
        //根据查询条件获取电源集合
        PowerInf pinf=pinfService.getPowerIdList(dto.getPowerId());
        /*Map<String, List<PwrdevAlarmParam>> map=new HashMap<>();
        List<PwrdevAlarmParam> almmap30=new ArrayList<>();
        List<PwrdevAlarmParam> almmap31=new ArrayList<>();
        List<PwrdevAlarmParam> almmap32=new ArrayList<>();
        List<PwrdevAlarmParam> almmap33=new ArrayList<>();
        List<PwrdevAlarmParam> almmap34=new ArrayList<>();
        List<PwrdevAlarmParam> almmap35=new ArrayList<>();
        List<PwrdevAlarmParam> almmap36=new ArrayList<>();*/
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("power_id",dto.getPowerId());
        if(dto.getAlmIdList()!=null){
            wrapper.in("alm_id",dto.getAlmIdList());
        }
        wrapper.orderByAsc("alm_id");
        //PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        List<PwrdevAlarmParam> list = mapper.selectList(wrapper);
        if(list!=null && list.size()>0){
            for (PwrdevAlarmParam alm:list) {
                alm.setAlarmName(PowerAlarmEnum.getValue(alm.getAlmId()));
               /* if(alm.getAlmId()/100000==30){
                    almmap30.add(alm);
                    map.put("故障告警",almmap30);
                }
                if(alm.getAlmId()/100000==31){
                    almmap31.add(alm);
                    map.put("交流输入告警",almmap31);
                }
                if(alm.getAlmId()/100000==32){
                    almmap32.add(alm);
                    map.put("交流ABC告警",almmap32);
                }
                if(alm.getAlmId()/100000==33){
                    almmap33.add(alm);
                    map.put("整流器告警",almmap33);
                }
                if(alm.getAlmId()/100000==34){
                    almmap34.add(alm);
                    map.put("蓄电池告警",almmap34);
                }
                if(alm.getAlmId()/100000==35){
                    almmap35.add(alm);
                    map.put("温湿度烟感告警",almmap35);
                }
                if(alm.getAlmId()/100000==36){
                    almmap36.add(alm);
                    map.put("直流告警",almmap36);
                }*/
            }
        }
       // PageInfo<PwrdevAlarmParam> pageInfo=new PageInfo(list);
        return new Response().setIII(1,list!=null,list,pinf,"获取电源告警参数");
    }
    //修改电源告警参数
    public Response setPwrAlmParam(List<PwrdevAlarmParam> almparamList) {
        for (PwrdevAlarmParam param:almparamList) {
            UpdateWrapper wrapper=new UpdateWrapper();
            wrapper.eq("power_id",param.getPowerId());
            wrapper.eq("alm_id",param.getAlmId());
            mapper.update(param,wrapper);
        }
        return new Response().set(1,true,"修改电源告警参数");
    }
}