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.text.ParseException;
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.User_battmaint_check;
import com.fgkj.dto.User_battmaint_check_process;
 
public class User_battmaint_check_processImpl implements BaseDAO,CallBack{
 
    public List getResults(ResultSet rs) {
        List list=new ArrayList();
 
            try {
                while(rs.next()){
                    User_battmaint_check_process uprocess=new User_battmaint_check_process();
                    uprocess.setNum(rs.getInt("num"));
                    uprocess.setUsr_id(rs.getInt("usr_id"));
                    uprocess.setTask_rec_id(rs.getInt("task_rec_id"));
                    uprocess.setWork_caption(rs.getString("work_caption"));
                    uprocess.setWork_caption_time(rs.getTimestamp("work_caption_time"));
                    list.add(uprocess);
                    }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
            return list;
    }
 
    public boolean add(Object obj) {
        User_battmaint_check_process uprocess=(User_battmaint_check_process) obj;
        String sql="insert into db_user.tb_user_battmaint_check_process(task_rec_id,work_caption,work_caption_time) values(?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{uprocess.getTask_rec_id(),
            uprocess.getWork_caption(),uprocess.getWork_caption_time()});
        return bl;
    } 
    //4.10user_battmaint_check表修改时User_battmaint_check_process表就新增一条记录
    public String addPro(Object obj) {
        User_battmaint_check_process uprocess=(User_battmaint_check_process) obj;
        String sql="insert into db_user.tb_user_battmaint_check_process(task_rec_id,work_caption,usr_id,work_caption_time) " +
                "values("+uprocess.getTask_rec_id()
                 +",'"+uprocess.getWork_caption()+"'"
                 +","+uprocess.getUsr_id()
                 +",'"+DAOHelper.sdf.format(uprocess.getWork_caption_time())
                 +"')";
        return sql;
    } 
    public boolean update(Object obj) {
        User_battmaint_check_process uprocess=(User_battmaint_check_process) obj;
        String sql="update db_user.tb_user_battmaint_check_process task_rec_id=?,work_caption=?,work_caption_time=? where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{uprocess.getTask_rec_id(),
            uprocess.getWork_caption(),uprocess.getWork_caption_time(),uprocess.getNum()});
        return bl;
    }
 
    public boolean del(Object obj) {
        User_battmaint_check_process uprocess=(User_battmaint_check_process) obj;
        String sql="delete from db_user.tb_user_battmaint_check_process where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{uprocess.getNum()});
        return bl;
    }
    //4.10user_battmaint_check表删除一条记录时User_battmaint_check_process表就删除相关的记录
    public String delPro(Object obj) {
        User_battmaint_check_process uprocess=(User_battmaint_check_process) obj;
        String sql="delete from db_user.tb_user_battmaint_check_process where task_rec_id="+uprocess.getTask_rec_id();
        return sql;
    }
    public List searchAll() {
        String sql="select * from db_user.tb_user_battmaint_check_process";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new User_battmaint_check_processImpl());
        return list;
    }    
    //4.10根据User_battmaint_check的num查询User_battmaint_check_process对应的数据
    public List serchByCondition(Object obj) {
        User_battmaint_check mcheck=(User_battmaint_check) obj;
        String sql="select num,usr_id,task_rec_id,work_caption,work_caption_time from db_user.tb_user_battmaint_check_process where task_rec_id=? ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{mcheck.getNum()}, new User_battmaint_check_processImpl());
        return list;
    }
 
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
    public static void main(String[] args) {
        
        User_battmaint_check_processImpl up=new User_battmaint_check_processImpl();
        User_battmaint_check mcheck=new User_battmaint_check();
        mcheck.setNum(4);
        List<User_battmaint_check_process> list=up.serchByCondition(mcheck);
        for (User_battmaint_check_process u : list) {
            System.out.println(u);
        }
        System.out.println(list.size());
    }
 
}