package com.sql.util;
|
|
import java.sql.SQLException;
|
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class Db_Batt {
|
public static void init(MysqlConnPool pool) {
|
createDb_Batt(pool);
|
|
createMon_Inf_Table(pool);
|
|
createMon_Plan_Table(pool);
|
|
createPower_Inf_Table(pool);
|
|
createSinf_Pinf_Table(pool);
|
|
createStation_Inf_Table(pool);
|
|
}
|
|
public static void createStation_Inf_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Station_Inf_Table + " "
|
+ "(sinf_id integer NOT NULL," +
|
" sinf_name character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '»ú×é1'::character varying," +
|
" stype integer NOT NULL DEFAULT 1," +
|
" PRIMARY KEY (sinf_id)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Station_Inf_Table + " OWNER TO sysdba;");
|
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Station_Inf_Table + ".sinf_id IS '»ú·¿id';");
|
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Station_Inf_Table + ".sinf_name IS '»ú·¿Ãû³Æ';");
|
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Station_Inf_Table + ".stype IS '»ú·¿ÀàÐÍ';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
|
public static void createSinf_Pinf_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Sinf_Pinf_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Sinf_Pinf_Table + " "
|
+ "(num integer NOT NULL DEFAULT nextval('" + Sql_Mysql.Sinf_Pinf_Table + "_auto'::regclass)," +
|
" sinf_id integer NOT NULL," +
|
" pinf_id integer NOT NULL," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Sinf_Pinf_Table + " OWNER TO sysdba;");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createPower_Inf_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Power_Inf_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Power_Inf_Table + " "
|
+ "(power_id integer NOT NULL DEFAULT 1," +
|
" power_name character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'µçÔ´×é1'::character varying," +
|
" mon_num integer NOT NULL DEFAULT 1," +
|
" acvol_high_limit double precision NOT NULL DEFAULT '200'::double precision," +
|
" acvol_low_limit double precision NOT NULL DEFAULT '200'::double precision," +
|
" dcoutvol_low_limit double precision NOT NULL DEFAULT '43.2'::double precision," +
|
" power_ip character(32) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '127.0.0.1'::character varying," +
|
" dev_type integer NOT NULL DEFAULT 1," +
|
" binf_id integer NOT NULL DEFAULT 0," +
|
" binf_name character varying(32) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'µçÔ´×é1'::character varying," +
|
" mon_vol integer NOT NULL DEFAULT 2," +
|
" mon_cap integer NOT NULL DEFAULT 150," +
|
" mon_res double precision NOT NULL DEFAULT '0.4'::double precision," +
|
" load_curr double precision NOT NULL DEFAULT '0'::double precision," +
|
|
" sip_num character(32) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '127.0.0.1'::character varying," +
|
" channel_count integer NOT NULL DEFAULT 1," +
|
" create_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," +
|
" update_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," +
|
|
" PRIMARY KEY (power_id)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Power_Inf_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".power_id IS 'µçÔ´ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".power_name IS 'µçÔ´Ãû³Æ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".mon_num IS 'µç³Ø×éµ¥Ìå¸öÊý';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".acvol_high_limit IS '½»Á÷ÉÏÏÞãÐÖµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".acvol_low_limit IS '½»Á÷ÏÂÏÞãÐÖµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".dcoutvol_low_limit IS 'Ö±Á÷Êä³öµçѹÏÂÏÞãÐÖµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".power_ip IS 'µçÔ´IPµØÖ·';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".dev_type IS 'µçÔ´ÀàÐÍ[1-Ò»¶ÎÖ±Á÷µçÔ´ 2-¶þ¶ÎÖ±Á÷µçÔ´ 3-Èý¶ÎÖ±Á÷µçÔ´(3¶ÎÖ±Á÷µçÔ´ÎÞÐîµç³ØÊý¾Ý)]';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".binf_id IS '°ó¶¨µç³Ø×éID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".binf_name IS 'µç³Ø×éÃû³Æ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".mon_vol IS '±ê³Æµ¥Ìåµçѹ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".mon_cap IS '±ê³ÆÈÝÁ¿';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".mon_res IS '±ê³ÆÄÚ×è';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".load_curr IS '¸ºÔصçÁ÷';");
|
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".sip_num IS 'sip񅧏';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".channel_count IS 'ÊÓÆµÁ÷ƵµÀÊý';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".create_time IS '´´½¨Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Inf_Table + ".update_time IS '¸üÐÂʱ¼ä';");
|
|
|
|
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createMon_Plan_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Mon_Plan_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Mon_Plan_Table + " "
|
+ "(num integer NOT NULL DEFAULT nextval('" + Sql_Mysql.Mon_Plan_Table + "_auto'::regclass)," +
|
" mon_id character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '2011'::character varying," +
|
" plan_type integer NOT NULL DEFAULT 0," +
|
" plan_rate double precision NOT NULL DEFAULT 0," +
|
" start_time timestamp without time zone NOT NULL DEFAULT '2024-01-01 00:00:00'::timestamp without time zone," +
|
" stop_time timestamp without time zone NOT NULL DEFAULT '2024-01-01 00:00:00'::timestamp without time zone," +
|
" create_time timestamp without time zone NOT NULL DEFAULT '2024-01-01 00:00:00'::timestamp without time zone," +
|
" create_user_id integer NOT NULL DEFAULT 1001," +
|
" create_user_name character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'hw'::character varying," +
|
" old_row character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" old_col character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" old_addres_num character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" new_row character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" new_col character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" new_addres_num character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" plan_state integer NOT NULL DEFAULT 0," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Mon_Plan_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".mon_id IS 'µ¥Ìå±àºÅ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".plan_type IS '¼Æ»®ÀàÐÍ:0±¨·Ï£¬1תÔË£¬2Èë¿â£¬3³ö¿â';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".plan_rate IS '¼Æ»®½ø¶È°Ù·Ö±È';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".start_time IS '¼Æ»®¿ªÊ¼Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".stop_time IS '¼Æ»®½áÊøÊ±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".create_time IS '´´½¨Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".create_user_id IS '´´½¨ÈËid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".create_user_name IS '´´½¨ÈËÃû';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".old_row IS 'Ô²ã';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".old_col IS 'ÔÁÐ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".old_addres_num IS 'Ô¿âλ±àºÅ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".new_row IS 'вã';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".new_col IS 'ÐÂÁÐ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".new_addres_num IS 'пâλ±àºÅ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Plan_Table + ".plan_state IS '¼Æ»®×´Ì¬£º0δ¿ªÊ¼£¬1½øÐÐÖУ¬2Íê³É£¬3ʧ°Ü';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createMon_Inf_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Mon_Inf_Table + " "
|
+ "( mon_id character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '2011'::character varying," +
|
" batt_type character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'ǦËá·§¿ØÐîµç³Ø'::character varying," +
|
" mon_vol integer NOT NULL DEFAULT 2," +
|
" mon_model character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'ÀíÊ¿'::character varying," +
|
" mon_inuse_year integer NOT NULL DEFAULT 2," +
|
" mon_cap double precision NOT NULL DEFAULT '300'::double precision," +
|
" product_time date NOT NULL DEFAULT '2024-01-01'::date," +
|
" mon_type character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT 'A'::character varying," +
|
" local_row character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" local_col character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" addres_num character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT '1'::character varying," +
|
" laid_up_time date NOT NULL DEFAULT '2024-01-01'::date" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Mon_Inf_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_id IS 'µ¥Ìå±àºÅ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".batt_type IS 'µ¥ÌåÀàÐÍ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_vol IS '±ê³Æµçѹ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_model IS 'µ¥Ì寷ů';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_inuse_year IS 'ʹÓÃÄêÏÞ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_cap IS '±ê³ÆÈÝÁ¿';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".product_time IS '³ö³¡ÈÕÆÚ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".mon_type IS '¿âλÀàÐÍ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".local_row IS '²ã';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".local_col IS 'ÁÐ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".addres_num IS '¿âλ±àºÅ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Mon_Inf_Table + ".laid_up_time IS 'Èë¿âʱ¼ä';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createDb_Batt(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE SCHEMA IF NOT EXISTS " + Sql_Mysql.DB_BATT + " AUTHORIZATION sysdba");
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|