| | |
| | | import com.dev.btse.data.FBS9100_VCData;
|
| | | import com.dev.fgcd.data.FGCD_BattTestParam;
|
| | | import com.dev.fgcd.data.FGCD_StateAndParam;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile.FBOFile;
|
| | |
|
| | | public class FGCD_SocketClient_Thread_SQL {
|
| | |
|
| | |
| | | sql.sqlMysqlExecute(str3);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | // TODO Auto-generated catch block
|
| | | sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam():" + e.toString(), e);
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入或更新当前设备状态
|
| | | * @param con_pool
|
| | | * @param dev_id
|
| | | */
|
| | | public static void insertFBS9100StateTableOnRam(MysqlConnPool con_pool,int dev_id) {
|
| | | String sql_str_que = "Select * from "+ Sql_Mysql.FBS9100State_Table + " Where dev_id = " + dev_id;
|
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.FBS9100State_Table +
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入当前设备默认数据
|
| | | * @param pool
|
| | | * @param dev_id
|
| | | */
|
| | | public static void insertTb_Fgcd_Filedownload_Table(MysqlConnPool pool,int dev_id) {
|
| | | String sql_str = " SELECT * FROM " + Sql_Mysql.Tb_Fgcd_Filedownload_Table + |
| | | " WHERE dev_id = " + dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str);
|
| | | if(!res.next()) {
|
| | | sql.sqlMysqlExecute(" insert into " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +"(dev_id) values("+dev_id+")" );
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入当前设备默认数据
|
| | | * @param pool
|
| | | * @param dev_id
|
| | | */
|
| | | public static void updateTb_Fgcd_Filedownload_Table(MysqlConnPool pool,FGCD_TestFBOFile fbo) {
|
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " SET op_cmd = "+fbo.op_cmd+"," + |
| | | " file_count = " + fbo.file_total;
|
| | | if(fbo.file_count > 0) {
|
| | | //当前文件数大于0
|
| | | for(int i=0;i<fbo.file_count;i++) {
|
| | | FBOFile file = fbo.files[i];
|
| | | sql_str += ",file_name"+(i+1)+"='"+file.filename+"'"
|
| | | + ",file_index"+(i+1)+"="+file.file_index
|
| | | + ",test_timelong"+(i+1)+"="+file.test_timelong
|
| | | + ",data_type"+(i+1)+"="+file.data_type
|
| | | + ",test_curr"+(i+1)+"="+file.test_curr
|
| | | + ",test_cap"+(i+1)+"="+file.test_cap
|
| | | + ",cap_std"+(i+1)+"="+file.cap_std
|
| | | + ",mon_count"+(i+1)+"="+file.mon_count
|
| | | + ",mon_vol"+(i+1)+"="+file.monvol_type
|
| | | + ",stop_type"+(i+1)+"="+file.teststop_reason;
|
| | | }
|
| | | }
|
| | | sql_str += " where dev_id = " + fbo.dev_id;
|
| | | Sql_Mysql sql = null;
|
| | | try {
|
| | | sql = new Sql_Mysql(pool);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | } |
| | | |
| | | /**
|
| | | * 读取当前设备状态
|
| | | * @param pool
|
| | | * @param file
|
| | | */
|
| | | public static void queryTb_Fgcd_Filedownload_Table(MysqlConnPool pool,FGCD_TestFBOFile file) {
|
| | | String sql_str = " SELECT * FROM " + Sql_Mysql.Tb_Fgcd_Filedownload_Table + |
| | | " WHERE dev_id = " + file.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str);
|
| | | if(res.next()) {
|
| | | file.battgroupid = res.getInt("BattGroupId");
|
| | | file.file_index = res.getInt("file_index");
|
| | | file.op_cmd = res.getInt("op_cmd");
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 创建 tb_fbs9100_state 表并且将设备id和设备hip插入到表中
|
| | |
| | | /***********************************************************************************/
|
| | | public static void updateFbs9100StateOnlyByDev_Id(MysqlConnPool con_pool, FGCD_StateAndParam m_pm)
|
| | | {
|
| | | String sql_str_sel = "SELECT dev_res_test_state " + |
| | | String sql_str_sel = "SELECT dev_res_test_state,dev_alarmstate " + |
| | | " FROM " + Sql_Mysql.FBS9100State_Table +
|
| | | " WHERE dev_id = " + m_pm.dev_id;
|
| | |
|
| | | ResultSet res = null;
|
| | | Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
| | | int dev_alarm_state = 0;
|
| | | try {
|
| | | //sql.logger.debug(sql_str);
|
| | | res = sql.sqlMysqlQuery(sql_str_sel); //查询当前设备的锁定状态
|
| | | if(res.next()) {
|
| | | m_pm.sysState.tmp_alm_lock = res.getInt("dev_res_test_state");
|
| | | dev_alarm_state = res.getInt("dev_alarmstate");
|
| | | }
|
| | | m_pm.sysState.checkTmpAlmState();
|
| | | m_pm.sysState.checkTmpAlmState(dev_alarm_state);
|
| | | String sql_str_base = Sql_Mysql.FBS9100State_Table
|
| | | + " SET "
|
| | | + "dev_id=" + m_pm.dev_id + ", "
|
| | |
| | | if((m_pm.sysState.dev_captest_stop_type>=0) && (m_pm.sysState.dev_captest_stop_type<50)) {
|
| | | sql_str_base += ", ";
|
| | | sql_str_base += "dev_last_captest_stop_type=" + m_pm.sysState.dev_captest_stop_type;
|
| | | }
|
| | | if(m_pm.sysState.dev_alarm == 1) {
|
| | | //更新当前状态
|
| | | sql.sqlMysqlExecute(" update " + Sql_Mysql.FBS9100State_Table +" Set dev_alarmstate = "+m_pm.sysState.dev_alarm+" where dev_id = "+m_pm.dev_id+" AND dev_alarmstate != 2" );
|
| | | }else {
|
| | | //更新当前告警状态
|
| | | sql.sqlMysqlExecute(" update " + Sql_Mysql.FBS9100State_Table +" Set dev_alarmstate = "+m_pm.sysState.dev_alarm+" where dev_id = "+m_pm.dev_id);
|
| | | }
|
| | |
|
| | | String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + m_pm.dev_id;
|
| | |
| | | //String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
| | | Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
| | | try {
|
| | | //sql.logger.debug(sql_str_replace);
|
| | | //sql.logger.info(sql_str_update);
|
| | | sql.sqlMysqlExecute(sql_str_update);
|
| | | } catch (SQLException e) {
|
| | | sql.logger.error("FGCD_SocketClient_Thread_SQL.updateFbs9100SetParamBydev_id():" + e.toString(), e);
|