DELL
2024-12-16 13b303d0d82e77f7cc7bf1daa7a56d1299ac04d2
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
package com.dev.lock.data;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
 
public class ElectLock_Array {
 
    private List<ElectLock_Inf> mInfs = new ArrayList<ElectLock_Inf>();
    
    public ElectLock_Inf getIteam(int idx) {
        return mInfs.get(idx);
    }
    
    public int getIteamCount() {
        return mInfs.size();
    }
 
    
    public boolean initEleLockData(MysqlConnPool pool) {
        String sql_str = " SELECT * FROM " + Sql_Mysql.Lock_Inf_Table;
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        boolean isChange = false;
        try {
            res = sql.sqlMysqlQuery(sql_str);
            while(res.next()) {
                int lock_id = res.getInt("id");
                int area_id = res.getInt("area_id");                    //区域ID
                String lock_name = res.getString("lock_name");            //锁名称
                String lock_type = res.getString("lock_type");            //锁类型(无源,蓝牙)
                int lock_state = res.getInt("lock_state");                //锁状态
                String lock_address = res.getString("lock_address");    //'锁地址',
                String lock_path = res.getString("lock_path");            //'图片路径',
                String lock_ip = res.getString("lock_ip").trim();        //'电子锁IP地址[内网可通过IP地址识别设备]',
                
                boolean isexist = false;
                for(int k = 0 ;k<mInfs.size();k++) {
                    ElectLock_Inf tmp_lock = getIteam(k);
                    if(lock_id == tmp_lock.getId()) {
                        if(!lock_ip.equals(tmp_lock.getLock_ip())) {
                            tmp_lock.setLock_ip(lock_ip);
                            isChange = true;
                        }
                        isexist = true;
                    }
                }
                
                if(isexist) {
                    continue;
                } else {
                    ElectLock_Inf tmp_lock = new ElectLock_Inf();
                    tmp_lock.setId(lock_id);
                    tmp_lock.setArea_id(area_id);                //'区域id',
                    tmp_lock.setLock_name(lock_name);            //'锁名称',
                    tmp_lock.setLock_type(lock_type);            //'锁类型(无源,蓝牙)',
                    tmp_lock.setLock_state(lock_state);            //'锁状态',
                    tmp_lock.setLock_address(lock_address);        //'锁地址',
                    tmp_lock.setLock_path(lock_path);            //'图片路径',
                    tmp_lock.setLock_ip(lock_ip);;                //'电子锁IP地址[内网可通过IP地址识别设备]',
                    mInfs.add(tmp_lock);
                }
                
            }
        } catch (Exception e) {
            sql.logger.error(e.toString(),e);
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    sql.logger.error(e.toString(),e);
                }
            }
            sql.close_con();
        }
        return isChange;
    }
}