1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
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.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.Batt_param_low;
 
public class Batt_param_lowImpl implements BaseDAO,CallBack{
 
    public List getResults(ResultSet rs) {
        List list=new ArrayList();
        try {
            while(rs.next()){
                Batt_param_low blow=new Batt_param_low();
                blow.setNum(rs.getInt("num"));
                blow.setLow_type(rs.getInt("low_type"));
                blow.setLow_nametype(rs.getInt("low_nametype"));
                blow.setLow_value(rs.getFloat("low_value"));
                blow.setLow_method(rs.getInt("low_method"));
                list.add(blow);
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
 
    public boolean add(Object obj) {
        Batt_param_low blow=(Batt_param_low) obj;
        String sql="insert into web_site.tb_batt_param_low(low_type,low_nametype,low_value,low_method) values(?,?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{blow.getLow_type(),blow.getLow_nametype(),
            blow.getLow_value(),blow.getLow_method()});
        return bl;
    }
 
    public boolean update(Object obj) {
        Batt_param_low blow=(Batt_param_low) obj;
        String sql="update web_site.tb_batt_param_low set low_value=?,low_method=? where low_type=? and low_nametype=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{blow.getLow_value(),blow.getLow_method()
          ,blow.getLow_type(),blow.getLow_nametype()});
        return bl;
    }
    //修改
    public boolean del(Object obj) {
        Batt_param_low blow=(Batt_param_low) obj;
        String sql="delete from web_site.tb_batt_param_low where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{blow.getNum()});
        return bl;
    }
 
    public List searchAll() {
        String sql="select num,low_type,low_nametype,low_value,low_method  from web_site.tb_batt_param_low";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new Batt_param_lowImpl());
        return list;
    }
 
    public List serchByCondition(Object obj) {
        Batt_param_low blow=(Batt_param_low) obj;
        String sql="select num,low_type,low_nametype,low_value,low_method from web_site.tb_batt_param_low where num=?";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{blow.getNum()}, new Batt_param_lowImpl());
        return list;
    }
    //根据low_type,low_nametype查阈值
    public List serchByLow(Object obj){
        Batt_param_low blow=(Batt_param_low) obj;
        String sql="select num,low_type,low_nametype,low_value,low_method from web_site.tb_batt_param_low where low_type=? and low_nametype=?";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{blow.getLow_type(),blow.getLow_nametype()}, new Batt_param_lowImpl());
        return list;
    }
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
public static void main(String[] args) {
    
    Batt_param_lowImpl bpl=new Batt_param_lowImpl();
    Batt_param_low b=new Batt_param_low();
    b.setLow_nametype(1);
    b.setLow_type(1);
    /*b.setNum(4);
    b.setLow_type(3);
    b.setLow_name("low4");
    b.setLow_value(0.75f);*/
    /*List<Batt_param_low> list=bpl.serchByCondition(b);
    for(Batt_param_low bb:list){
        System.out.println(bb);
    }*/
    
    //System.out.println(bpl.add(b));
    //System.out.println(bpl.del(b));
    //System.out.println(bpl.update(b));
    List<Batt_param_low> list=bpl.serchByLow(b);
    for(Batt_param_low bb:list){
        System.out.println(bb);
    }
}
}