| | |
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class Central_DataParsing_Thread_SQL {
|
| | | |
| | | /**
|
| | | * 插入或更新设备通讯状态
|
| | | * @param pool
|
| | | * @param motor
|
| | | */
|
| | | public static void insertOrUpdateTb_Device_StateTable(MysqlConnPool pool,Motor_inf motor) {
|
| | | String sql_str_sel = " Select dev_id from " + Sql_Mysql.Tb_Device_State + " Where dev_id = " + motor.getDev_id();
|
| | | String sql_str_upd = " UPDATE " + Sql_Mysql.Tb_Device_State + " SET comm_status = " + motor.conn_state + " WHERE dev_id = " + motor.getDev_id();
|
| | | String sql_str_ins = " INSERT INTO "+Sql_Mysql.Tb_Device_State+"(dev_id,comm_status) VALUES("+motor.getDev_id()+","+motor.conn_state+");";
|
| | | ResultSet res = null;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(res.next()) {
|
| | | sql.sqlMysqlExecute(sql_str_upd);
|
| | | }else {
|
| | | sql.sqlMysqlExecute(sql_str_ins);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 更新设备的通讯状态
|
| | | * @param pool
|
| | | * @param motor
|
| | | */
|
| | | public static void updateTb_Device_StateTable(MysqlConnPool pool,Motor_inf motor) {
|
| | | String sql_str = " UPDATE "+Sql_Mysql.Tb_Device_State+" SET comm_status = "+motor.conn_state+",record_time='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"' WHERE dev_id = "+motor.getDev_id();
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 加载集中监控平台设备设备信息
|
| | |
| | | */
|
| | | public static void insertOrUpdateTb_Central_Monitor_Sys_St(MysqlConnPool pool,Central_ST_Data stdata) {
|
| | | String sql_str_sel = " select dev_id from " + Sql_Mysql.Tb_Central_Monitor_Sys_St + " where dev_id = " + stdata.getDev_id();
|
| | | String sql_str_ins = " intsert into " + Sql_Mysql.Tb_Central_Monitor_Sys_St + "(dev_id) values("+stdata.getDev_id()+")";
|
| | | String sql_str_ins = " insert into " + Sql_Mysql.Tb_Central_Monitor_Sys_St + "(dev_id) values("+stdata.getDev_id()+")";
|
| | | String sql_str_upd = " update " + Sql_Mysql.Tb_Central_Monitor_Sys_St + ""
|
| | | + " SET record_time '" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
|
| | | + " SET record_time = '" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
|
| | | + "',switch_close_1st_2500A = " + stdata.getSwitch_close_1st_2500A()
|
| | | + ",switch_open_1st_2500A = " + stdata.getSwitch_open_1st_2500A()
|
| | | + ",switch_fault_1st_2500A = " + stdata.getSwitch_fault_1st_2500A()
|
| | |
| | | */
|
| | | public static void insertOrUpdateTb_Central_Monitor_Sys_Rt(MysqlConnPool pool,Central_RT_Data rtdata) {
|
| | | String sql_str_sel = " select dev_id from " + Sql_Mysql.Tb_Central_Monitor_Sys_Rt + " where dev_id = " + rtdata.getDev_id();
|
| | | String sql_str_ins = " intsert into " + Sql_Mysql.Tb_Central_Monitor_Sys_Rt + "(dev_id) values("+rtdata.getDev_id()+")";
|
| | | String sql_str_ins = " insert into " + Sql_Mysql.Tb_Central_Monitor_Sys_Rt + "(dev_id) values("+rtdata.getDev_id()+")";
|
| | | String sql_str_upd = " update " + Sql_Mysql.Tb_Central_Monitor_Sys_Rt + ""
|
| | | + " SET record_time '" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
|
| | | + " SET record_time = '" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
|
| | | + "',switch_close = " + rtdata.getSwitch_close()
|
| | | + ",switch_open = " + rtdata.getSwitch_open()
|
| | | + ",switch_fault = " + rtdata.getSwitch_fault()
|