蓄电池监控管理平台数据库初始化程序
DELL
2024-11-05 578a33144c0435f7479535e540a7e60622e4b232
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
package com.database_util;
 
import java.sql.SQLException;
 
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
 
public class DB_Batt_TestData {
    
    
    public static void init(MysqlConnPool pool, boolean recreate) {
        //´´½¨Êý¾Ý¿â
        createDB_Batt_TestData(pool);
        
        createBatttestdata_Inf_Table(pool, recreate);
 
    }
    
    /**
     *    ´´½¨ tb_batttestdata_inf
     * @param pool
     * @param recreate
     */
    public static void createBatttestdata_Inf_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Batttestdata_Inf_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Batttestdata_Inf_Table + " (" + 
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '×ÔÔöÖ÷¼ü'," + 
                "  `dev_id` int(11) NOT NULL DEFAULT '0' COMMENT 'É豸ID'," + 
                "  `batt_idx` int(11) NOT NULL DEFAULT '0' COMMENT 'µç³Ø×é±àºÅ[0-×é1 1-×é2 ... 4-×é4]'," + 
                "  `test_type` int(11) NOT NULL DEFAULT '0' COMMENT '²âÊÔÀàÐÍ'," + 
                "  `test_record_count` int(11) NOT NULL DEFAULT '0' COMMENT '²âÊԼǼ´ÎÊý'," + 
                "  `record_num` int(11) NOT NULL DEFAULT '0' COMMENT '¼Ç¼±ÊÊý'," + 
                "  `test_starttime` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '²âÊÔ¿ªÊ¼Ê±¼ä'," + 
                "  `test_timelong` bigint(20) NOT NULL DEFAULT '0' COMMENT '²âÊÔʱ³¤'," + 
                "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¼Ç¼ʱ¼ä'," + 
                "  `test_stoptype` int(11) NOT NULL DEFAULT '0' COMMENT 'Í£Ö¹Ô­Òò'," + 
                "  `group_vol` float NOT NULL DEFAULT '0' COMMENT '×é¶Ëµçѹ'," + 
                "  `test_curr` float NOT NULL DEFAULT '0' COMMENT '²âÊÔµçÁ÷'," + 
                "  `test_cap` float NOT NULL DEFAULT '0' COMMENT '²âÊÔÈÝÁ¿'," + 
                "  `max_monvol` float NOT NULL DEFAULT '0' COMMENT '×î´óµ¥Ìåµçѹ'," + 
                "  `max_monvolnum` int(11) NOT NULL DEFAULT '0' COMMENT '×î´óµ¥Ìåµçѹ±àºÅ'," + 
                "  `min_monvol` float NOT NULL DEFAULT '0' COMMENT '×îСµ¥Ìåµçѹ'," + 
                "  `min_monvolnum` int(11) NOT NULL DEFAULT '0' COMMENT '×îСµ¥Ìåµçѹ±àºÅ'," + 
                "  PRIMARY KEY (`num`)," + 
                "  KEY `idx_dev_id` (`dev_id`) USING BTREE," + 
                "  KEY `idx_test_record_count` (`test_record_count`) USING BTREE," + 
                "  KEY `idx_batt_idx` (`batt_idx`) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='µç³Ø×éÀúÊ·Êý¾Ý×ܱí';";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {            
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    
    
    
    public static void createDB_Batt_TestData(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_BATT_TESTDATA);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}