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
package com.fgkj.dao.impl;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import com.fgkj.dao.AlarmDaoFactory;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.db.DBUtil;
import com.fgkj.db.IDatabaseName;
import com.fgkj.dto.Alarm_param;
 
public class Alarm_paramImpl implements BaseDAO,CallBack{
 
    public List getResults(ResultSet rs) {
        List list=new ArrayList();
        try {
            while(rs.next()){
                Alarm_param ap=new Alarm_param();
                ap.setNum(rs.getInt("num"));
                ap.setAlm_id(rs.getInt("alm_id"));
                ap.setAlm_name(rs.getString("alm_name"));
                ap.setAlm_high_coe(rs.getFloat("alm_high_coe"));
                ap.setAlm_low_coe(rs.getFloat("alm_low_coe"));
                ap.setAlm_high_level(rs.getInt("alm_high_level"));
                ap.setAlm_low_level(rs.getInt("alm_low_level"));
                ap.setAlm_high_en(rs.getInt("alm_high_en"));
                ap.setAlm_low_en(rs.getInt("alm_low_en"));
                list.add(ap);
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
 
    public boolean add(Object obj) {
        Alarm_param ap=(Alarm_param) obj;
        String sql="insert into db_param.tb_alarm_param(alm_id,alm_name,alm_high_coe,alm_low_coe,alm_high_level,alm_low_level,alm_high_en,alm_low_en) values(?,?,?,?,?,?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ap.getAlm_id(),ap.getAlm_name(),ap.getAlm_high_coe(),ap.getAlm_low_coe(),
            ap.getAlm_high_level(),ap.getAlm_low_level(),ap.getAlm_high_en(),ap.getAlm_low_en()});
        return bl;
    }
   //编辑参数
    public boolean update(Object obj) {
        Alarm_param ap=(Alarm_param) obj;
        String sql="update db_param.tb_alarm_param set alm_high_coe=?,alm_low_coe=?,alm_high_level=?,alm_low_level=?,alm_high_en=?,alm_low_en=? where alm_id=? ";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ap.getAlm_high_coe(),ap.getAlm_low_coe(),
            ap.getAlm_high_level(),ap.getAlm_low_level(),ap.getAlm_high_en(),ap.getAlm_low_en(),ap.getAlm_id()});
        return bl;
    }
 
    public boolean del(Object obj) {
        Alarm_param ap=(Alarm_param) obj;
        String sql="delete from db_param.tb_alarm_param where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ap.getNum()});
        return bl;
    }
 
    public List searchAll() {
        String sql="select num,alm_id,alm_name,alm_high_coe,alm_low_coe,alm_high_level,alm_low_level,alm_high_en,alm_low_en  from db_param.tb_alarm_param " ;
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new App_ParamImpl());
        return list;
    }
    //7.1根据告警类型查告警参数
    public List serchByCondition(Object obj) {
        Alarm_param ap=(Alarm_param) obj;
        String sql="";
        String baseSql=" select num,alm_id,alm_name,alm_high_coe,alm_low_coe,alm_high_level,alm_low_level,alm_high_en,alm_low_en  from db_param.tb_alarm_param  " +
                       " where  ";
        //alm_id=1电池告警参数
        String idSqlT=" alm_id in ("+AlarmDaoFactory.Alarm_vol_Online+","+AlarmDaoFactory.Alarm_vol_Group+","+AlarmDaoFactory.Alarm_curr_Charge+","+AlarmDaoFactory.Alarm_curr_Discharge
                                  +","+AlarmDaoFactory.Alarm_vol_Monomer+","+AlarmDaoFactory.Alarm_tmp_Monomer+","+AlarmDaoFactory.Alarm_res_Monomer+","+AlarmDaoFactory.Alarm_res_Conn
                                  +","+AlarmDaoFactory.ALM_TYPE_DisChargeMonVol_ID+") ";
        //alm_id=2容量/更换告警参数
        String idSqlF=" alm_id in ("+AlarmDaoFactory.Alarm_CapAlarm+","+AlarmDaoFactory.Alarm_CapChange+")  ";
        if(ap.getAlm_id()==1){
            baseSql+=idSqlT;
        }else{
            baseSql+=idSqlF;
        }
        String endSql=" order by alm_id ";
        sql=baseSql+endSql;
        //System.out.println(sql);;
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),null, new Alarm_paramImpl());
        return list;
    }
 
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
    public static void main(String[] args) {
        Alarm_paramImpl aimpl=new Alarm_paramImpl();
        Alarm_param ap=new Alarm_param();
        ap.setAlm_id(2);
        List<Alarm_param> list=aimpl.serchByCondition(ap);
        for (Alarm_param a : list) {
            System.out.println(a);
        }
    }
}