81041
2019-06-24 797038b15180e4f757e4ef84ae4e5cb323fd99ee
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
package com.fgkj.test;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.db.DBUtil;
 
public class Batt_DevdischargeTest {
    
    public static void main(String[] args) {
        String table_cm="web_site.tb_batt_devdischarge_CM";
        String table_cu="web_site.tb_batt_devdischarge_CU";
        String table_ct="web_site.tb_batt_devdischarge_CT";
        String table=table_ct;
        String dev_idSql="select distinct(dev_id) from "+table;
        List list=DAOHelper.executeQuery(dev_idSql, DBUtil.getConn(), null, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        int dev_id=rs.getInt("dev_id");
                        list.add(dev_id);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        
        for(int i=0;i<list.size();i++){
            String allSql="select num from "+table+" where dev_id=? order by dev_recordtime asc,num asc ";
            List listA=DAOHelper.executeQuery(allSql, DBUtil.getConn(), new Object[]{list.get(i)}, new CallBack() {
                
                public List getResults(ResultSet rs) {
                    List listA=new ArrayList();
                    try {
                        while(rs.next()){
                            int num=rs.getInt("num");
                            listA.add(num);
                        }
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return listA;
                }
            });
            for(int j=0;j<listA.size();j++){
                String updateSql="update "+table+" set record_num=? where num=? ";
                System.out.println(j+1);
                boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), updateSql, new Object[]{(j+1),listA.get(j)});
            }
        }
    }
 
}