综合管理平台数据库数据模拟程序
Administrator
2021-03-25 335a3b0a6a6f27d0f7097b27c6614c66f5946676
Demo_Manage_Simul/src/com/thread/Manage_Simul_SQL.java
@@ -9,6 +9,8 @@
import com.base.Com;
import com.mode.Device_Inf;
import com.mode.Dynamicload_State_rt;
import com.mode.Electric_State_2kw;
import com.mode.Electric_state;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
@@ -50,7 +52,19 @@
         sql.close_con();
      }
   }
   //插入负载默认数据
   public static void insertDynamicload(MysqlConnPool conn_pool, Dynamicload_State_rt state) {
      String sql_str = " replace into " + Sql_Mysql.Tb_Dynamicload_State_Rt_Table + "(dev_id) values("+state.getDev_id()+")";
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   //加载负载实时数据
   public static void updateDynamicload(MysqlConnPool conn_pool, Dynamicload_State_rt state) {
      String sql_str = " UPDATE  " + Sql_Mysql.Tb_Dynamicload_State_Rt_Table 
@@ -95,4 +109,94 @@
         sql.close_con();
      }
   }
   //插入4MW电源默认数据
   public static void insert4MWPower(MysqlConnPool conn_pool, Electric_state state) {
      String sql_str = " replace into " + Sql_Mysql.Tb_Electric_State_Table + "(electric_id) values("+state.getElectric_id()+")";
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   //加载4MW电源实时数据
   public static void update4MWPower(MysqlConnPool conn_pool, Electric_state state) {
      String sql_str = " update "+ Sql_Mysql.Tb_Electric_State_Table  +" "
            + " SET case_trip_output = "+state.case_trip_output+","
            +"  record_time='" + Com.getDateTimeFormat(state.getRecord_time(), Com.DTF_YMDhms)+"',"
            + " fault_reset_signal = "+state.fault_reset_signal+","
            + " high_vol_switch_status = "+state.high_vol_switch_status+","
            + " stop_button = "+state.stop_button+","
            + " main_cabinet_fan_status = "+state.main_cabinet_fan_status+","
            + " trans_cabinet_door_lock = "+state.trans_cabinet_door_lock+","
            + " trans_cabinet_overtem_alarm = "+state.trans_cabinet_overtem_alarm+","
            + " trans_cabinet_overtem_trip = "+state.trans_cabinet_overtem_trip+","
            + " qs1_state = "+state.qs1_state+","
            + " qs2_state = "+state.qs2_state+","
            + " switch_cabinet_door_status = "+state.switch_cabinet_door_status+","
            + " alldcvol = "+state.alldcvol+","
            + " alldccurr = "+state.alldccurr+","
            + " conn_flag = "+state.conn_flag+" "
            + " WHERE electric_id ="+state.electric_id;
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   //插入2MW电源默认数据
   public static void insert2MWPower(MysqlConnPool conn_pool, Electric_State_2kw state) {
      String sql_str = " replace into " + Sql_Mysql.Tb_Electric2mw_State_Table + "(electric2KW_id) values("+state.getElectric2KW_id()+")";
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   //加载2MW电源实时数据
   public static void update2MWPower(MysqlConnPool conn_pool, Electric_State_2kw state) {
      String sql_str = " UPDATE "+Sql_Mysql.Tb_Electric2mw_State_Table +
            " Set brachdcvol= " + state.brachdcvol +
            ",record_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) +
            "',brachdccurr=" + state.brachdccurr +
            ",alldcvol=" + state.alldcvol +
            ",alldccurr=" + state.alldccurr +
            ",stopchargevol_one=" + state.stopchargevol_one +
            ",stopchargevol_two=" + state.stopchargevol_two +
            ",stopchargevol_three=" + state.stopchargevol_three +
            ",stopchargevol_four=" + state.stopchargevol_four +
            ",stopchargevol_five=" + state.stopchargevol_five +
            ",controlangle=" + state.controlangle +
            ",localgivevol=" + state.localgivevol +
            ",volset=" + state.volset +
            ",localgivecurr=" + state.localgivecurr +
            ",currset=" + state.currset +
            ",chargecurr_one=" + state.chargecurr_one +
            ",chargecurr_two=" + state.chargecurr_two +
            ",chargecurr_three=" + state.chargecurr_three +
            ",chargecurr_four=" + state.chargecurr_four +
            ",chargecurr_five=" + state.chargecurr_five +
            ",consvolmode_chargecurr=" +state.consvolmode_chargecurr+
            " Where electric2KW_id = " + state.electric2KW_id;
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
}