| | |
| | | import com.base.Com;
|
| | | import com.motor.data.Load_motor_state;
|
| | | import com.motor.data.Motor_inf;
|
| | | import com.motor.data.Subject_motor_state;
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | |
| | | * @param date_str
|
| | | */
|
| | | public static void createTb_Motor_ReaddataTable(MysqlConnPool pool,int motor_id,Date date) {
|
| | | String sql_str = " CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Motor_Readdata + motor_id + "_" + Com.getDateTimeFormat(date, Com.DTF_Y_M_D) + "(" + |
| | | String tb_name = "tb_motor_readdata_"+motor_id+"_"+Com.getDateTimeFormat(date, Com.DTF_Y_M_D);
|
| | | //完整表名称
|
| | | String tname = Sql_Mysql.Tb_Motor_Readdata + motor_id + "_" + Com.getDateTimeFormat(date, Com.DTF_Y_M_D);
|
| | | String sql_str = " CREATE TABLE IF NOT EXISTS "+ tname + "(" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," +
|
| | | " motor_id int(11) NOT NULL DEFAULT '2001' COMMENT '电机id'," +
|
| | | " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
| | |
| | | " PRIMARY KEY (num)" +
|
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | //System.out.println(sql_str);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | |
| | | //添加加载功率给定
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_power'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname |
| | | + " ADD COLUMN `load_power` float NOT NULL DEFAULT '0' COMMENT '加载功率给定';");
|
| | | }
|
| | | //添加加载转矩给定
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_torque'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_torque` float NOT NULL DEFAULT '0' COMMENT '加载转矩给定';");
|
| | | }
|
| | | //添加电机转速限制
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_speed_limit'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_speed_limit` float NOT NULL DEFAULT '0' COMMENT '加载电机转速限制';");
|
| | | }
|
| | | //添加加载电机转矩限制
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_torque_limit'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_torque_limit` float NOT NULL DEFAULT '0' COMMENT '加载电机转矩限制';");
|
| | | } |
| | | //添加加载步长
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_step_length'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_step_length` float NOT NULL DEFAULT '0' COMMENT '加载步长';");
|
| | | }
|
| | | //添加加载电机水冷进水风温
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_inwater_tmp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_inwater_tmp` float NOT NULL DEFAULT '0' COMMENT '加载电机水冷进水风温';");
|
| | | }
|
| | | //添加加载电机水冷出水风温
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_outwater_tmp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_outwater_tmp` float NOT NULL DEFAULT '0' COMMENT '加载电机水冷出水风温';");
|
| | | }
|
| | | //添加加载电机绕组温度1
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp1'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp1` float NOT NULL DEFAULT '0' COMMENT '加载电机绕组温度1';");
|
| | | }
|
| | | //添加加载电机绕组温度2
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp2'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp2` float NOT NULL DEFAULT '0' COMMENT '加载电机绕组温度2';");
|
| | | }
|
| | | //添加加载电机绕组温度3
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp3'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp3` float NOT NULL DEFAULT '0' COMMENT '加载电机绕组温度3';");
|
| | | }
|
| | | //添加加载电机轴承温度1
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_bear_tmp1'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_bear_tmp1` float NOT NULL DEFAULT '0' COMMENT '加载电机轴承温度1';");
|
| | | }
|
| | | //添加加载电机轴承温度2
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_bear_tmp2'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_bear_tmp2` float NOT NULL DEFAULT '0' COMMENT '加载电机轴承温度2';");
|
| | | }
|
| | | //添加加载电机出口温度
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_out_tmp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_out_tmp` float NOT NULL DEFAULT '0' COMMENT '加载电机出口温度';");
|
| | | }
|
| | | //添加加载电机进口温度
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_into_tmp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_into_tmp` float NOT NULL DEFAULT '0' COMMENT '加载电机进口温度';");
|
| | | }
|
| | | //添加加载电机启动
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_start'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_start` float NOT NULL DEFAULT '0' COMMENT '加载电机启动';");
|
| | | }
|
| | | //添加加载电机停机
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_downtime'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_downtime` float NOT NULL DEFAULT '0' COMMENT '加载电机停机';");
|
| | | }
|
| | | //添加加载
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_add'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_add` float NOT NULL DEFAULT '0' COMMENT '加载';");
|
| | | }
|
| | | //添加减载
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_reduct'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_reduct` float NOT NULL DEFAULT '0' COMMENT '减载';");
|
| | | }
|
| | | //添加手动加载
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_manual'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_manual` float NOT NULL DEFAULT '0' COMMENT '手动加载';");
|
| | | }
|
| | | //添加加载电机紧停
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_stop'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_stop` int(11) NOT NULL DEFAULT '0' COMMENT '加载电机紧停';");
|
| | | }
|
| | | //添加加载电机风机状态
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_fan_state'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_fan_state` int(11) NOT NULL DEFAULT '0' COMMENT '加载电机风机状态';");
|
| | | }
|
| | | //添加备用加载电机绕组温度1
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp1_bp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp1_bp` float NOT NULL DEFAULT '0' COMMENT '备用加载电机绕组温度1';");
|
| | | }
|
| | | //添加备用加载电机绕组温度2
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp2_bp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp2_bp` float NOT NULL DEFAULT '0' COMMENT '备用加载电机绕组温度2';");
|
| | | }
|
| | | //添加备用加载电机绕组温度3
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='load_motor_wind_tmp3_bp'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `load_motor_wind_tmp3_bp` float NOT NULL DEFAULT '0' COMMENT '备用加载电机绕组温度3';");
|
| | | }
|
| | | |
| | | //添加传感器转矩
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='sensor_torque'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `sensor_torque` float NOT NULL DEFAULT '0' COMMENT '传感器转矩';");
|
| | | }
|
| | | //添加传感器功率
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='sensor_power'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `sensor_power` float NOT NULL DEFAULT '0' COMMENT '传感器功率';");
|
| | | }
|
| | | //添加故障确认
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='fault_confirm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `fault_confirm` int(11) NOT NULL DEFAULT '0' COMMENT '故障确认';");
|
| | | }
|
| | | //添加齿轮箱轴功率
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_power'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_power` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴功率';");
|
| | | }
|
| | | //添加推进轴功率
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='advance_power'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `advance_power` float NOT NULL DEFAULT '0' COMMENT '推进轴功率';");
|
| | | }
|
| | | //添加齿轮箱轴承温度1
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp1'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp1` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度1';");
|
| | | }
|
| | | //添加齿轮箱轴承温度2
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp2'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp2` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度2';");
|
| | | }
|
| | | //添加齿轮箱轴承温度3
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp3'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp3` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度3';");
|
| | | }
|
| | | //添加齿轮箱轴承温度4
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp4'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp4` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度4';");
|
| | | }
|
| | | //添加齿轮箱轴承温度5
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp5'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp5` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度5';");
|
| | | }
|
| | | //添加齿轮箱轴承温度6
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gear_box_tmp6'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gear_box_tmp6` float NOT NULL DEFAULT '0' COMMENT '齿轮箱轴承温度6';");
|
| | | }
|
| | | //添加油站启动
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gas_station_start'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gas_station_start` int(11) NOT NULL DEFAULT '0' COMMENT '油站启动';");
|
| | | }
|
| | | //添加油站停机
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='gas_station_stop'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `gas_station_stop` int(11) NOT NULL DEFAULT '0' COMMENT '油站停机';");
|
| | | }
|
| | | //添加功率控制
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='pow_control'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `pow_control` int(11) NOT NULL DEFAULT '0' COMMENT '功率控制';");
|
| | | }
|
| | | //添加转矩控制
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='torque_control'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `torque_control` int(11) NOT NULL DEFAULT '0' COMMENT '转矩控制';");
|
| | | }
|
| | | //添加变压器高温报警
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='transformer_hightmp_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `transformer_hightmp_alarm` int(11) NOT NULL DEFAULT '0' COMMENT '变压器高温报警';");
|
| | | }
|
| | | //添加变压器高温故障
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='transformer_hightmp_fault'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `transformer_hightmp_fault` int(11) NOT NULL DEFAULT '0' COMMENT '变压器高温故障';");
|
| | | }
|
| | | //添加变压器缺相报警
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='transformer_lackphase_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `transformer_lackphase_alarm` int(11) NOT NULL DEFAULT '0' COMMENT '变压器缺相报警';");
|
| | | }
|
| | | //添加润滑泵1运行
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_pump1_start'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_pump1_start` int(11) NOT NULL DEFAULT '0' COMMENT '润滑泵1运行';");
|
| | | }
|
| | | //添加润滑泵2运行
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_pump2_start'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_pump2_start` int(11) NOT NULL DEFAULT '0' COMMENT '润滑泵2运行';");
|
| | | }
|
| | | //添加润滑允许远程访问
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_remote_start_allow'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_remote_start_allow` int(11) NOT NULL DEFAULT '0' COMMENT '润滑允许远程访问';");
|
| | | }
|
| | | //添加遥控/就地
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='remote_control'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `remote_control` int(11) NOT NULL DEFAULT '0' COMMENT '遥控/就地';");
|
| | | }
|
| | | //添加变频器就绪
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='inverter_ready'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `inverter_ready` int(11) NOT NULL DEFAULT '0' COMMENT '变频器就绪';");
|
| | | }
|
| | | //添加变频器运行
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='inverter_running'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `inverter_running` int(11) NOT NULL DEFAULT '0' COMMENT '变频器运行';");
|
| | | }
|
| | | //添加变频器报警
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='inverter_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `inverter_alarm` int(11) NOT NULL DEFAULT '0' COMMENT '变频器报警';");
|
| | | }
|
| | | //添加变频器故障
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='inverter_fault'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `inverter_fault` int(11) NOT NULL DEFAULT '0' COMMENT '变频器故障';");
|
| | | }
|
| | | //添加润滑允许主机运行
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_host_running_allow'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_host_running_allow` int(11) NOT NULL DEFAULT '0' COMMENT '润滑允许主机运行';");
|
| | | }
|
| | | //添加主开关状态
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='main_switch_state'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `main_switch_state` int(11) NOT NULL DEFAULT '0' COMMENT '主开关状态';");
|
| | | }
|
| | | //添加受试电机运行
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='subject_motor_running'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `subject_motor_running` int(11) NOT NULL DEFAULT '0' COMMENT '受试电机运行';");
|
| | | }
|
| | | //添加受试电机报警
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='subject_motor_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `subject_motor_alarm` int(11) NOT NULL DEFAULT '0' COMMENT '受试电机报警';");
|
| | | }
|
| | | //添加受试电机故障
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='subject_motor_fault'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `subject_motor_fault` int(11) NOT NULL DEFAULT '0' COMMENT '受试电机故障';");
|
| | | }
|
| | | //添加受试电机紧停
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='subject_motor_stop'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `subject_motor_stop` int(11) NOT NULL DEFAULT '0' COMMENT '受试电机紧停';");
|
| | | }
|
| | | //添加润滑故障
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_falut'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_falut` int(11) NOT NULL DEFAULT '0' COMMENT '润滑故障';");
|
| | | }
|
| | | //添加润滑报警
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_motor_realhistory'"
|
| | | + " AND table_name='"+tb_name+"'"
|
| | | + " AND column_name='lubrication_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + tname
|
| | | + " ADD COLUMN `lubrication_alarm` int(11) NOT NULL DEFAULT '0' COMMENT '润滑报警';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | |
| | | * @param pool
|
| | | * @param motor_inf
|
| | | */
|
| | | public static void insertTb_Motor_ReaddataTable(MysqlConnPool pool, Motor_inf motor,String date_str) {
|
| | | public static void insertTb_Motor_ReaddataTable(MysqlConnPool pool, Motor_inf motor,Date time) {
|
| | | Load_motor_state state = motor.load_state;
|
| | | String sql_str = " INSERT INTO " + Sql_Mysql.Tb_Motor_Readdata + motor.motor_id + "_" + date_str +
|
| | | " (motor_id,record_time,load_motor_power,load_motor_speed,load_motor_torque,load_motor_curr,load_motor_vol) " + |
| | | " VALUES("+state.motor_id+",'"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"+state.load_motor_power+","+state.load_motor_speed+","+state.load_motor_torque+","+state.load_motor_curr+","+state.load_motor_vol+"); ";
|
| | | Subject_motor_state sstate = motor.subject_state;
|
| | | String sql_str = " INSERT INTO " + Sql_Mysql.Tb_Motor_Readdata + motor.motor_id + "_" + Com.getDateTimeFormat(time, Com.DTF_Y_M_D) +
|
| | | " (motor_id,record_time,load_motor_power,load_motor_speed,load_motor_torque,load_motor_curr,load_motor_vol,load_power,load_torque,load_motor_speed_limit,load_motor_torque_limit,load_step_length,load_motor_inwater_tmp,load_motor_outwater_tmp,load_motor_wind_tmp1,load_motor_wind_tmp2,load_motor_wind_tmp3,load_motor_bear_tmp1,load_motor_bear_tmp2,load_motor_out_tmp,load_motor_into_tmp,load_motor_start,load_motor_downtime,load_add,load_reduct,load_manual,load_motor_stop,load_motor_fan_state,load_motor_wind_tmp1_bp,load_motor_wind_tmp2_bp,load_motor_wind_tmp3_bp,sensor_torque,sensor_power,fault_confirm,gear_box_power,advance_power,gear_box_tmp1,gear_box_tmp2,gear_box_tmp3,gear_box_tmp4,gear_box_tmp5,gear_box_tmp6,gas_station_start,gas_station_stop,pow_control,torque_control,transformer_hightmp_alarm,transformer_hightmp_fault,transformer_lackphase_alarm,lubrication_pump1_start,lubrication_pump2_start,lubrication_remote_start_allow,remote_control,inverter_ready,inverter_running,inverter_alarm,inverter_fault,lubrication_host_running_allow,main_switch_state,subject_motor_running,subject_motor_alarm,subject_motor_fault,subject_motor_stop,lubrication_falut,lubrication_alarm) " + |
| | | " VALUES("+state.motor_id+",'"+Com.getDateTimeFormat(time, Com.DTF_YMDhms)+"',"+state.load_motor_power+","+state.load_motor_speed+","+state.load_motor_torque+","+state.load_motor_curr+","+state.load_motor_vol+","+state.load_power+","+state.load_torque+","+state.load_motor_speed_limit+","+state.load_motor_torque_limit+","+state.load_step_length+","+state.load_motor_inwater_tmp+","+state.load_motor_outwater_tmp+","+state.load_motor_wind_tmp1+","+state.load_motor_wind_tmp2+","+state.load_motor_wind_tmp3+","+state.load_motor_bear_tmp1+","+state.load_motor_bear_tmp2+","+state.load_motor_out_tmp+","+state.load_motor_into_tmp+","+state.load_motor_start+","+state.load_motor_downtime+","+state.load_add+","+state.load_reduct+","+state.load_manual+","+state.load_motor_stop+","+state.load_motor_fan_state+","+state.load_motor_wind_tmp1_bp+","+state.load_motor_wind_tmp2_bp+","+state.load_motor_wind_tmp3_bp+","+sstate.sensor_torque+","+sstate.sensor_power+","+sstate.fault_confirm+","+sstate.gear_box_power+","+sstate.advance_power+","+sstate.gear_box_tmp1+","+sstate.gear_box_tmp2+","+sstate.gear_box_tmp3+","+sstate.gear_box_tmp4+","+sstate.gear_box_tmp5+","+sstate.gear_box_tmp6+","+sstate.gas_station_start+","+sstate.gas_station_stop+","+sstate.pow_control+","+sstate.torque_control+","+sstate.transformer_hightmp_alarm+","+sstate.transformer_hightmp_fault+","+sstate.transformer_lackphase_alarm+","+sstate.lubrication_pump1_start+","+sstate.lubrication_pump2_start+","+sstate.lubrication_remote_start_allow+","+sstate.remote_control+","+sstate.inverter_ready+","+sstate.inverter_running+","+sstate.inverter_alarm+","+sstate.inverter_fault+","+sstate.lubrication_host_running_allow+","+sstate.main_switch_state+","+sstate.subject_motor_running+","+sstate.subject_motor_alarm+","+sstate.subject_motor_fault+","+sstate.subject_motor_stop+","+sstate.lubrication_falut+","+sstate.lubrication_alarm+"); ";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|