lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.fgkj.services;
 
import java.util.ArrayList;
import java.util.List;
 
import com.fgkj.dao.AlarmDaoFactory;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.ProcessServerDao;
import com.fgkj.dao.impl.Alarm_paramImpl;
import com.fgkj.dao.impl.BattInfImpl;
import com.fgkj.dao.impl.Dev_paramImpl;
import com.fgkj.dao.impl.Process_surveyImpl;
import com.fgkj.dto.Alarm_param;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Dev_param;
import com.fgkj.dto.Process_survey;
import com.fgkj.dto.ServiceModel;
import com.mysql.fabric.xmlrpc.base.Array;
 
public class Dev_paramService {
    private ServiceModel model;
    private BaseDAO dao;
    public Dev_paramService() {
        super();
        this.model = new ServiceModel();
        this.dao = BaseDAOFactory.getBaseDAO(BaseDAO.DEV_PARAM);
    }
     //给设备添加参数
    public ServiceModel add(Object obj){
        boolean bl=dao.add(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("插入成功!");
        }else{
            model.setCode(0);
            model.setMsg("插入失败!");
        }        
        return model;
    }
    //查询所有设备的所有的告警参数
    public ServiceModel update(Object obj){
        Boolean bl=dao.update(obj);
        if(bl){
            //告警参数修改成功后重启服务
            int alarm_id=((Dev_param) obj).getAlm_id();
            Process_survey process=new Process_survey();
            //将电池告警的服务设为重启
            process.setProcessName(ProcessServerDao.BMS_FBSDEV_ALARM_BATT);
            Boolean b=(new Process_surveyImpl()).update(process);
            model.setCode(1);
            model.setMsg("修改成功!");
        }else{
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        return model;
    }
     //查询所有设备的所有的告警参数
    public ServiceModel searchAll(){
        List list=dao.searchAll();
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    //根据设备id和告警类型查设备告警参数
    public ServiceModel serchByCondition(Object obj){
        List list=dao.serchByCondition(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    //查询所有存在设备告警参数的机房
    public ServiceModel serchAllDevId(){
        List list=((Dev_paramImpl)dao).serchAllDevId();
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    //根据设备id查询设备对应的告警参数种类
    public ServiceModel serchByInfo(Object obj){
        List list=dao.serchByInfo(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    
     //根据设备id查询设备所有的参数
    public ServiceModel serchParamById(Object obj){
        List list=((Dev_paramImpl)dao).serchParamById(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    public static void main(String[] args) {
        Dev_paramService dservice=new Dev_paramService();
        BattInf binf=new BattInf();
        binf.setBattGroupId(1000021);
        int dev_id=(new BattInfImpl()).serchDev_id(binf);
        Alarm_param aparam=new Alarm_param();
        aparam.setAlm_id(1);
        List listP=(new Alarm_paramImpl()).serchByCondition(aparam);
        List list=new ArrayList();
        for (int i = 0; i < listP.size(); i++) {
            Alarm_param param=(Alarm_param) listP.get(i);
            Dev_param dparam=new Dev_param();
            dparam.setDev_id(dev_id);
            dparam.setAlm_id(param.getAlm_id());
            dparam.setAlm_name(param.getAlm_name());
            dparam.setAlm_high_coe(param.getAlm_high_coe());
            dparam.setAlm_low_coe(param.getAlm_low_coe());
            dparam.setAlm_high_level(param.getAlm_high_level());
            dparam.setAlm_low_level(param.getAlm_low_level());
            dparam.setAlm_high_en(param.getAlm_high_en());
            dparam.setAlm_low_en(param.getAlm_low_en());
            list.add(dparam);
        }
        ServiceModel model=dservice.add(list);
    }
}