蓄电池监控管理平台数据库初始化程序
2018-09-29 b471d645e91846f3c54f4f1b3bcbf0a6729ed847
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.dev.fbs9100;
 
import java.sql.SQLException;
 
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
 
public class FBS9100_Task_Thread_SQL {
    
    /**
     * ´´½¨ tb_fbs9100_state ±í²¢ÇÒ½«É豸idºÍÉ豸hip²åÈëµ½±íÖÐ
     * @param con_pool
     * @param al_param
     */
    public static void createFBS9100StateTableOnRam(MysqlConnPool con_pool)
    {
        String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100State_Table;
        String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100State_Table
                    + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                    + "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
                    + "`dev_version` varchar(20) NOT NULL DEFAULT '0', "
                    + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                    + "`op_cmd` INT NOT NULL DEFAULT 0, "
                    + "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
                    + "`dev_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
                    + "`dev_testtype` INT NOT NULL DEFAULT 0, "
                    + "`dev_testgroupnum` INT NOT NULL DEFAULT 0, "
                    + "`dev_workstate` INT NOT NULL DEFAULT 0, "
                    + "`dev_alarmstate` INT NOT NULL DEFAULT 0, "
                    + "`dev_temp` float NOT NULL DEFAULT 0, "
                    + "`dev_res_test_state` INT NOT NULL DEFAULT 0, "        //ÄÚ×è²âÊÔ״̬
                    + "`dev_onlinevollow` BOOLEAN NOT NULL DEFAULT false, "
                    + "`dev_eachgroup_battsum` INT NOT NULL DEFAULT 0, "
                    + "`dev_captest_onlinevol` float NOT NULL DEFAULT 0, "
                    + "`dev_captest_groupvol` float NOT NULL DEFAULT 0, "
                    + "`dev_captest_curr` float NOT NULL DEFAULT 0, "
                    + "`dev_captest_cap` float NOT NULL DEFAULT 0, "
                    + "`dev_captest_timelong` INT NOT NULL DEFAULT 0, "
                    + "`dev_restest_count` INT NOT NULL DEFAULT 0, "
                    + "`dev_restest_moncount` INT NOT NULL DEFAULT 0, "
                    + "`dev_restest_monindex` INT NOT NULL DEFAULT 0, "
                    + "`dev_commcount` INT NOT NULL DEFAULT 0, "
                    + "`dev_errcommcount` INT NOT NULL DEFAULT 0, "
                    + "`dev_rxnullerrcount` INT NOT NULL DEFAULT 0, "
                    
                    + "`dev_last_captest_stop_type` INT NOT NULL DEFAULT 0, "
                    + "`dev_concurr`  float NOT NULL DEFAULT 0, "
                    + "`dev_condvoldp`  float NOT NULL DEFAULT 0, "
                    + "`dev_conresist`  float NOT NULL DEFAULT 0, "
                    + "`dev_condcurr`  float NOT NULL DEFAULT 0, "
                    + "`dev_61850alarms`  varchar(64) NOT NULL DEFAULT '', "
                    
                    + "`dev_batt_xuhang_tlong` INT NOT NULL DEFAULT 0, "                //Ðøº½Ê±³¤
                    + "`dev_station_poff_tlong` INT NOT NULL DEFAULT 0, "                //Í£µçʱ³¤
                    + "`dev_station_poff_cnt` INT NOT NULL DEFAULT 0, "                    //Í£µç´ÎÊý
                    + "`dev_data_flowsum` BIGINT NOT NULL DEFAULT 0, "                    //»ú·¿Á÷Á¿
                    
                    + " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
                    + " PRIMARY KEY (`num`) ) "
                    + " ENGINE=InnoDB DEFAULT CHARSET=utf8";
        /*
        String str3 = "INSERT INTO " + Sql_Mysql.FBS9100State_Table + " (dev_ip, dev_id) ";
        str3 += " SELECT dev_ip, dev_id FROM " + Sql_Mysql.BattInf_Table;
        */
        Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
        try {
            sql.sqlMysqlExecute(str1);
            sql.sqlMysqlExecute(str2);
            //sql.sqlMysqlExecute(str3);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     * ´´½¨ tb_fbs9100s_dcdc_data ±í²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
     * @param con_pool
     * @param al_param
     */
    public static void createFBS9100S_DCDC_DataTableOnRam(MysqlConnPool con_pool)
    {
        String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table;
        String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table
                    + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                    + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                    + "`dcdc_num` BIGINT NOT NULL DEFAULT 0, "
                    + "`dcdc_Vsys` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Vout` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Vbat` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Iout` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Ibuck` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Tmp_Dis` float NOT NULL DEFAULT 0, "
                    + "`dcdc_Tmp_Chr` float NOT NULL DEFAULT 0, "
                    + "`dcdc_SMR_Alarm1` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_SMR_Alarm2` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_version` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_ModeSetComm` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_RunSetComm` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_BuckISet` float NOT NULL DEFAULT 0, "
                    + "`dcdc_DisVolSet` float NOT NULL DEFAULT 0, "
                    + "`dcdc_DisCurrSet` float NOT NULL DEFAULT 0, "
                    + "`dcdc_CommTxCnt` INT NOT NULL DEFAULT 0, "
                    + "`dcdc_CommRxCnt` INT NOT NULL DEFAULT 0, "
                    + " UNIQUE INDEX index_dcdc_num_uniq (`dcdc_num`), "
                    + " PRIMARY KEY (`num`) ) "
                    + " ENGINE=MEMORY DEFAULT CHARSET=utf8";
        
        Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
        try {
            sql.sqlMysqlExecute(str1);
            sql.sqlMysqlExecute(str2);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     * ´´½¨ tb_fbs9100_setparam ±í£¬²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
     * @param con_pool
     * @param al_param
     */
    public static void createFBS9100SetTestParamTableOnRam(MysqlConnPool con_pool)
    {
        String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SetParam_Table;
        String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SetParam_Table
                    + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                    + "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
                    + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                    + "`op_cmd` INT NOT NULL DEFAULT 0, "
                    + "`TestCmd` INT NOT NULL DEFAULT 0, "
                    + "`HourRate` INT NOT NULL DEFAULT 0, "
                    + "`DisCurr` FLOAT NOT NULL DEFAULT 0, "
                    + "`DisCap` FLOAT NOT NULL DEFAULT 0, "
                    + "`DisTime` INT NOT NULL DEFAULT 0, "
                    + "`GroupVol_LOW` FLOAT NOT NULL DEFAULT 0, "
                    + "`MonomerVol_LOW` FLOAT NOT NULL DEFAULT 0, "
                    + "`MonomerLowCount` INT NOT NULL DEFAULT 0, "
                    + "`BattGroupNum` INT NOT NULL DEFAULT 0, "
                    + "`OnlineVolLowAction` INT NOT NULL DEFAULT 0, "
                    + "`DCVolHighLimit` FLOAT NOT NULL DEFAULT 0, "
                    + "`ChargeCurrSet` FLOAT NOT NULL DEFAULT 0, "
                    + "`MonomerTmp_High` FLOAT NOT NULL DEFAULT 0, "
                    + "`AutoTestStartVol`  float NOT NULL DEFAULT 0, "            //Æðʼµçѹ
                    + " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
                    + " PRIMARY KEY (`num`) ) "
                    + " ENGINE=MEMORY DEFAULT CHARSET=utf8";
        
        Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
        try {
            sql.sqlMysqlExecute(str1);
            sql.sqlMysqlExecute(str2);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    /**
     * ´´½¨ Sql_Mysql.RamDB_CMCC_POWER_Data ±í²¢ÇÒ½«É豸id²åÈëµ½±íÖÐ
     * @param con_pool
     * @param al_param
     */
    public static void createFBS9100CmccPowerDataOnRam(MysqlConnPool con_pool)
    {
        String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data;
        String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data
                    + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                    + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                    + "`vol1` float NOT NULL DEFAULT 0, "
                    + "`vol2` float NOT NULL DEFAULT 0, "
                    + "`vol3` float NOT NULL DEFAULT 0, "
                    + "`vol4` float NOT NULL DEFAULT 0, "
                    + "`vol5` float NOT NULL DEFAULT 0, "
                    + "`curr1` float NOT NULL DEFAULT 0, "
                    + "`curr2` float NOT NULL DEFAULT 0, "
                    + "`curr3` float NOT NULL DEFAULT 0, "
                    + "`curr4` float NOT NULL DEFAULT 0, "
                    + "`curr5` float NOT NULL DEFAULT 0, "
                    + " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
                    + " PRIMARY KEY (`num`) ) "
                    + " ENGINE=InnoDB DEFAULT CHARSET=utf8";
        
        Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
        try {
            sql.sqlMysqlExecute(str1);
            sql.sqlMysqlExecute(str2);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /***********************************************************************************/
}