package com.sql.util;
|
|
import java.sql.SQLException;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
/**
|
* µçÔ´¸æ¾¯Êý¾Ý¿â³õʼ»¯
|
* @author DELL
|
*
|
*/
|
public class Db_Power_Alarm {
|
public static void init(MysqlConnPool pool) {
|
System.out.println("Db_Power_Alarm init Start " + Com.getDateTimeFormat(new Date(),Com.DTF_YMDhms));
|
|
createDb_Power_Alarm(pool);
|
|
createPower_Alarm_Table(pool);
|
|
createPower_Alarm_Cfg_Table(pool);
|
|
|
System.out.println("Db_Power_Alarm init End " + Com.getDateTimeFormat(new Date(),Com.DTF_YMDhms));
|
}
|
|
|
|
public static void createPower_Alarm_Cfg_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Power_Alarm_Cfg_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_Alarm_Cfg_Table + " "
|
+ "(num bigint NOT NULL DEFAULT nextval('" + Sql_Mysql.Power_Alarm_Cfg_Table + "_auto'::regclass)," +
|
" alm_id integer NOT NULL DEFAULT 0," +
|
" alm_name character varying NOT NULL COLLATE pg_catalog.\"default\" DEFAULT ''::character varying," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Power_Alarm_Cfg_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Cfg_Table + ".num IS '×ÔÔöÖ÷¼ü';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Cfg_Table + ".alm_id IS 'µçÔ´¸æ¾¯ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Cfg_Table + ".alm_name IS 'µçÔ´¸æ¾¯Ãû³Æ';");
|
sql.sqlMysqlExecute("COMMENT ON TABLE " + Sql_Mysql.Power_Alarm_Cfg_Table + " IS 'µçÔ´¸æ¾¯Ãû³ÆÅäÖñí';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createPower_Alarm_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Power_Alarm_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_Alarm_Table + " "
|
+ "(num bigint NOT NULL DEFAULT nextval('" + Sql_Mysql.Power_Alarm_Table + "_auto'::regclass)," +
|
" power_id integer NOT NULL DEFAULT 0," +
|
" alm_id integer NOT NULL DEFAULT 0," +
|
" alm_value double precision NOT NULL DEFAULT 0," +
|
" alm_start_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," +
|
" alm_end_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," +
|
" alm_confirm_en integer NOT NULL DEFAULT 0," +
|
" alm_confirm_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," +
|
" alm_level integer NOT NULL DEFAULT 1," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Power_Alarm_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("CREATE INDEX IF NOT EXISTS idx_power_id ON " + Sql_Mysql.Power_Alarm_Table + " USING btree (" +
|
" power_id" +
|
") TABLESPACE pg_default ;");
|
|
sql.sqlMysqlExecute("CREATE INDEX IF NOT EXISTS idx_alm_id ON " + Sql_Mysql.Power_Alarm_Table + " USING btree (" +
|
" alm_id " +
|
") TABLESPACE pg_default ;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".num IS '×ÔÔöÖ÷¼ü';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".power_id IS 'µçÔ´ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_id IS 'µçÔ´¸æ¾¯ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_value IS '¸æ¾¯Öµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_start_time IS '¸æ¾¯¿ªÊ¼Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_end_time IS '¸æ¾¯½áÊøÊ±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_confirm_en IS '¸æ¾¯ÊÇ·ñÈ·ÈÏ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_confirm_time IS '¸æ¾¯È·ÈÏʱ¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Power_Alarm_Table + ".alm_level IS '¸æ¾¯µÈ¼¶';");
|
sql.sqlMysqlExecute("COMMENT ON TABLE " + Sql_Mysql.Power_Alarm_Table + " IS 'µçԴʵʱ¸æ¾¯±í';");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createDb_Power_Alarm(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE SCHEMA IF NOT EXISTS " + Sql_Mysql.DB_POWER_ALARM + " AUTHORIZATION sysdba");
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|