package com.electrical.TwoKW;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.List;
|
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class Electrical_2KWTask_SQL {
|
|
/**
|
* ³õʼ»¯Êý¾Ý¿â±í
|
* @param pool
|
*/
|
public static void init(MysqlConnPool pool) {
|
createDB_Electric2MWSystem(pool);
|
|
createTb_electric2MW_inf(pool);
|
|
//initTb_electric2MW_inf(pool);
|
|
createTb_electric2MW_rt(pool);
|
|
createTb_electric2MW_control(pool);
|
}
|
|
/**
|
* ³õʼ»¯¸ºÔØÐÅÏ¢±í
|
* @param pool
|
*/
|
public static void initTb_electric2MW_inf(MysqlConnPool pool) {
|
String sql_str= " replace INTO " + Sql_Mysql.Tb_electric2MW_inf + "(electric2KW_id,electric2KW_ip,electric2KW_name,electric2KW_type) VALUES(6001,'127.0.0.1','2MW','1'),(6002,'127.0.0.1','2MW','1')";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/**
|
* ´´½¨2MWµçԴϵͳÊý¾Ý¿â
|
* @param pool
|
*/
|
public static void createDB_Electric2MWSystem(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_Electric2MWSystem);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/**
|
* ´´½¨2MWÐÅÏ¢±í
|
* @param pool
|
*/
|
public static void createTb_electric2MW_inf(MysqlConnPool pool) {
|
String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_electric2MW_inf + " (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü'," +
|
" electric2KW_id int(11) NOT NULL DEFAULT '5001' COMMENT 'µçÔ´id'," +
|
" electric2KW_ip varchar(255) NOT NULL DEFAULT '127.0.0.1' COMMENT 'µçÔ´ip'," +
|
" electric2KW_name varchar(255) NOT NULL DEFAULT 'A×é' COMMENT 'µçÔ´Ãû³Æ'," +
|
" electric2KW_type int(11) NOT NULL DEFAULT '2' COMMENT 'µçÔ´ÀàÐÍ'," +
|
" note varchar(255) NOT NULL DEFAULT ''," +
|
" PRIMARY KEY (num)," +
|
" UNIQUE KEY electric2KW_id_key (electric2KW_id) USING BTREE " +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/**
|
* ´´½¨2MWʵʱÐÅÏ¢±í
|
* @param pool
|
*/
|
public static void createTb_electric2MW_rt(MysqlConnPool pool) {
|
String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_electric2MW_rt + " (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü'," +
|
" electric2KW_id int(11) NOT NULL DEFAULT '5001' COMMENT 'µçÔ´id'," +
|
" upper_pulse_block int(11) NOT NULL DEFAULT '0' COMMENT 'ÉÏλ»úÂö³å·âËø'," +
|
" consvolcurrstatus int(11) NOT NULL DEFAULT '0' COMMENT 'ºãѹºãÁ÷ģʽ״̬'," +
|
" constantvolflag int(11) NOT NULL DEFAULT '0' COMMENT '4²¢»ò2´®2²¢ºãѹ±ê־λ'," +
|
" main_circuit_connmode int(11) NOT NULL DEFAULT '0' COMMENT 'Ö÷µç·Á¬½Óģʽ'," +
|
" remote_start int(11) NOT NULL DEFAULT '0' COMMENT 'Ô¶³ÌÆô¶¯'," +
|
" fault_reset int(11) NOT NULL DEFAULT '0' COMMENT '¹ÊÕϸ´Î»'," +
|
" conscurrswitch int(11) NOT NULL DEFAULT '0' COMMENT 'ºãÁ÷Çл»'," +
|
" constantvol float NOT NULL DEFAULT '0' COMMENT 'A»ú×é4²¢»ò2´®2²¢ºãѹ'," +
|
" volset_confirm int(11) NOT NULL DEFAULT '0' COMMENT 'µçѹ¸ø¶¨È·ÈÏ'," +
|
" currset_confirm int(11) NOT NULL DEFAULT '0' COMMENT 'µçÁ÷¸ø¶¨È·ÈÏ'," +
|
" remote_stop int(11) NOT NULL DEFAULT '0' COMMENT 'Ô¶³ÌÍ£Ö¹'," +
|
" start_screen_set int(11) NOT NULL DEFAULT '0' COMMENT 'Æô¶¯´¥ÃþÆÁ¸ø¶¨'," +
|
" start_upper_set int(11) NOT NULL DEFAULT '0' COMMENT 'Æô¶¯ÉÏλ»ú¸ø¶¨'," +
|
" consvolswitch int(11) NOT NULL DEFAULT '0' COMMENT 'ºãѹÇл»'," +
|
" othermode int(11) NOT NULL DEFAULT '0' COMMENT '4²¢»ò2´®2²¢ÒÔÍâģʽ'," +
|
" consvol_distribution int(11) NOT NULL DEFAULT '0' COMMENT 'ËÄ´®ºãѹµçѹ·ÖÅäλ'," +
|
" local_remote_control int(11) NOT NULL DEFAULT '0' COMMENT '¾ÍµØÔ¶³Ì¿ØÖÆ×´Ì¬'," +
|
|
" pulse_blocking int(11) NOT NULL DEFAULT '0' COMMENT 'Âö³å·âËø'," +
|
|
" curve_charge_mode int(11) NOT NULL DEFAULT '0' COMMENT 'ÇúÏß³äµçģʽ״̬'," +
|
" start_curve_charge_mode int(11) NOT NULL DEFAULT '0' COMMENT 'Æô¶¯ÇúÏß³äµçģʽ'," +
|
" stop_curve_charge_mode int(11) NOT NULL DEFAULT '0' COMMENT 'Í£Ö¹ÇúÏß³äµçģʽ'," +
|
" note varchar(255) NOT NULL DEFAULT ''," +
|
" PRIMARY KEY (num)," +
|
" UNIQUE KEY electric2KW_id_key (electric2KW_id) USING BTREE " +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/**
|
* ´´½¨2MW¿ØÖÆÐÅÏ¢±í
|
* @param pool
|
*/
|
public static void createTb_electric2MW_control(MysqlConnPool pool) {
|
String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_electric2MW_control + " (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü'," +
|
" electric2KW_id int(11) NOT NULL DEFAULT '5001' COMMENT 'µçÔ´id'," +
|
" consvolmode_chargecurr float NOT NULL DEFAULT '0' COMMENT 'תΪºãѹģʽ³äµçµçѹֵ'," +
|
" chargecurr_five float NOT NULL DEFAULT '0' COMMENT 'µÚ5½×¶Î³äµçµçÁ÷Öµ'," +
|
" chargecurr_four float NOT NULL DEFAULT '0' COMMENT 'µÚ4½×¶Î³äµçµçÁ÷Öµ'," +
|
" chargecurr_three float NOT NULL DEFAULT '0' COMMENT 'µÚ3½×¶Î³äµçµçÁ÷Öµ'," +
|
" chargecurr_two float NOT NULL DEFAULT '0' COMMENT 'µÚ2½×¶Î³äµçµçÁ÷Öµ'," +
|
" chargecurr_one float NOT NULL DEFAULT '0' COMMENT 'µÚ1½×¶Î³äµçµçÁ÷Öµ'," +
|
" currset float NOT NULL DEFAULT '0' COMMENT 'µçÁ÷É趨ֵ'," +
|
" localgivecurr float NOT NULL DEFAULT '0' COMMENT 'µ±Ç°¸ø¶¨µçÁ÷'," +
|
" volset float NOT NULL DEFAULT '0' COMMENT 'µçѹÉ趨ֵ'," +
|
" localgivevol float NOT NULL DEFAULT '0' COMMENT 'µ±Ç°¸ø¶¨µçѹ'," +
|
" controlangle float NOT NULL DEFAULT '0' COMMENT '¿ØÖƽÇ'," +
|
" stopchargevol_five float NOT NULL DEFAULT '0' COMMENT 'µÚ5½×¶Î³äµçÖÕÖ¹µçѹ'," +
|
" stopchargevol_four float NOT NULL DEFAULT '0' COMMENT 'µÚ4½×¶Î³äµçÖÕÖ¹µçѹ'," +
|
" stopchargevol_three float NOT NULL DEFAULT '0' COMMENT 'µÚ3½×¶Î³äµçÖÕÖ¹µçѹ'," +
|
" stopchargevol_two float NOT NULL DEFAULT '0' COMMENT 'µÚ2½×¶Î³äµçÖÕÖ¹µçѹ'," +
|
" stopchargevol_one float NOT NULL DEFAULT '0' COMMENT 'µÚ1½×¶Î³äµçÖÕÖ¹µçѹ'," +
|
" " +
|
" alldccurr float NOT NULL DEFAULT '0' COMMENT '×ÜÖ±Á÷µçÁ÷'," +
|
" alldcvol float NOT NULL DEFAULT '0' COMMENT '×ÜÖ±Á÷µçѹ'," +
|
" brachdccurr float NOT NULL DEFAULT '0' COMMENT '·ÖÖ±Á÷µçÁ÷'," +
|
" brachdcvol float NOT NULL DEFAULT '0' COMMENT '·ÖÖ±Á÷µçѹ'," +
|
" " +
|
" PRIMARY KEY (num)," +
|
" UNIQUE KEY electric2KW_id_key (electric2KW_id) USING BTREE " +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ²éѯËùÓеÄ2mwµçԴϵͳ
|
* @param pool
|
* @param electric
|
*/
|
public static void queryAllElectrical2MW(MysqlConnPool pool,List<Electric_inf_2kw> einfs) {
|
String sql_str = " select * from " + Sql_Mysql.Tb_electric2MW_inf+ " order by electric2KW_id asc ";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
ResultSet res = null;
|
try {
|
res = sql.sqlMysqlQuery(sql_str);
|
while(res.next()) {
|
Electric_inf_2kw einf=new Electric_inf_2kw();
|
einf.setElectric2KW_id(res.getInt("electric2kw_id"));
|
einf.setElectric2KW_ip(res.getString("electric2kw_ip"));
|
einf.setElectric2KW_name(res.getString("electric2kw_name"));
|
einf.setElectric2KW_type(res.getInt("electric2kw_type"));
|
einfs.add(einf);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
if(res != null) {
|
try {
|
res.close();
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
sql.close_con();
|
}
|
}
|
|
//²åÈë»ò¸üÐÂ2mwµçԴϵͳʵʱÐÅÏ¢±í
|
public static void replace_electric2MW_rt(MysqlConnPool pool,Electric_Rt_2kw ert) {
|
String sql_str = " replace into "+ Sql_Mysql.Tb_electric2MW_rt+"(electric2KW_id) "
|
+ " values("+ert.electric2KW_id+")";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
//²åÈë»ò¸üÐÂ2mwµçԴϵͳÐÅÏ¢±í
|
public static void replace_electric2MW_inf(MysqlConnPool pool,Electric_inf_2kw einf) {
|
String sql_str = " replace into "+ Sql_Mysql.Tb_electric2MW_inf+"(electric2KW_id) "
|
+ " values("+einf.electric2KW_id+")";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
//²åÈë»ò¸üÐÂ2mwµçÔ´¿ØÖÆÐÅÏ¢±í
|
public static void replace_electric2MW_Control(MysqlConnPool pool,Electric_Control_Single_2kw econtrol) {
|
String sql_str = " replace into "+ Sql_Mysql.Tb_electric2MW_control+"(electric2KW_id) "
|
+ " values("+econtrol.electric2KW_id+")";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
//¸üÐÂ2mwµçԴʵʱÐÅÏ¢±í
|
public static void update_Electric_Rt_2KW(MysqlConnPool pool,Electric_Rt_2kw ert) {
|
String sql_str = " UPDATE "+ Sql_Mysql.Tb_electric2MW_rt +""
|
+ " SET upper_pulse_block = "+ert.upper_pulse_block+","
|
+ " consvolcurrstatus = "+ert.consvolcurrstatus+","
|
+ " constantvolflag = "+ert.constantvolflag+","
|
+ " main_circuit_connmode = "+ert.main_circuit_connmode+","
|
+ " remote_start = "+ert.remote_start+","
|
+ " fault_reset = "+ert.fault_reset+","
|
+ " conscurrswitch = "+ert.conscurrswitch+","
|
+ " constantvol = "+ert.constantvol+","
|
+ " volset_confirm = "+ert.volset_confirm+","
|
+ " currset_confirm = "+ert.currset_confirm+","
|
+ " remote_stop = "+ert.remote_stop+","
|
+ " start_screen_set = "+ert.start_screen_set+","
|
+ " start_upper_set = "+ert.start_upper_set+","
|
+ " consvolswitch = "+ert.consvolswitch+","
|
+ " othermode = "+ert.othermode+","
|
+ " consvol_distribution = "+ert.consvol_distribution+","
|
+ " local_remote_control = "+ert.local_remote_control+","
|
+ " curve_charge_mode = "+ert.curve_charge_mode+","
|
+ " start_curve_charge_mode = "+ert.start_curve_charge_mode+","
|
+ " stop_curve_charge_mode = "+ert.stop_curve_charge_mode+" "
|
+ " WHERE electric2KW_id = " + ert.electric2KW_id;
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
//¸üÐÂ2mwµçÔ´¿ØÖÆÐÅÏ¢±í
|
public static void update_Electric_Control_2KW(MysqlConnPool pool,Electric_Control_Single_2kw econ) {
|
String sql_str = " UPDATE "+ Sql_Mysql.Tb_electric2MW_control +""
|
+ " SET consvolmode_chargecurr = "+econ.consvolmode_chargecurr+","
|
+ " chargecurr_five = "+econ.chargecurr_five+","
|
+ " chargecurr_four = "+econ.chargecurr_four+","
|
+ " chargecurr_three = "+econ.chargecurr_three+","
|
+ " chargecurr_two = "+econ.chargecurr_two+","
|
+ " chargecurr_one = "+econ.chargecurr_one+","
|
+ " currset = "+econ.currset+","
|
+ " volset = "+econ.volset+","
|
+ " stopchargevol_five = "+econ.stopchargevol_five+","
|
+ " stopchargevol_four = "+econ.stopchargevol_four+","
|
+ " stopchargevol_three = "+econ.stopchargevol_three+","
|
+ " stopchargevol_two = "+econ.stopchargevol_two+","
|
+ " stopchargevol_one = "+econ.stopchargevol_one+" "
|
+ " WHERE electric2KW_id = " + econ.electric2KW_id;
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|