蓄电池监控管理平台数据库初始化程序
Administrator
2021-07-08 56c672f46d4b901b1ee4b1ee47768ed53ec5e6a8
BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
@@ -79,9 +79,18 @@
      createTb_Batt_RTAlarm_Table(pool, recreate);
      //南京送检特有
      createTb_Batt_RSAlarm_Table(pool, recreate);
      //创建干节点状态表
      createFBS9100s_stemnode_state_Table(pool, recreate);
      //创建母联开关状态表
      createFBS9100s_buscouple_state_Table(pool, recreate);
   }
   
   
   /**
    *    创建    web_site 数据库
    * @param pool
@@ -1839,4 +1848,87 @@
         sql.close_con();
      }
   }
   /**
    * 创建干接点状态表
    * @param pool
    * @param recreate
    */
   private static void createFBS9100s_stemnode_state_Table(MysqlConnPool pool, boolean recreate) {
      String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_stemnode_state_Table;
      String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_stemnode_state_Table + " (" +
            "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
            "  `dev_id` int(11) NOT NULL," +
            "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," +
            "  `dryInputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输入状态'," +
            "  `dryOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输出状态'," +
            "  `volOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点电压输出状态'," +
            "  `sumOutputVolt` float NOT NULL DEFAULT '0' COMMENT '总输出电压'," +
            "  `sumOutputCur` float NOT NULL DEFAULT '0' COMMENT '总输出电流'," +
            "  `outputVolt1` float NOT NULL DEFAULT '0' COMMENT '输出电压1'," +
            "  `outputVolt2` float NOT NULL DEFAULT '0' COMMENT '输出电压2'," +
            "  `outputVolt3` float NOT NULL DEFAULT '0' COMMENT '输出电压3'," +
            "  `outputVolt4` float NOT NULL DEFAULT '0' COMMENT '输出电压4'," +
            "  PRIMARY KEY (`num`)," +
            "  UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
         if(true == recreate) {
            sql.sqlMysqlExecute(sql_str01);
         }
         sql.sqlMysqlExecute(sql_str02);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   /**
    * 创建母联状态表
    * @param pool
    * @param recreate
    */
   private static void createFBS9100s_buscouple_state_Table(MysqlConnPool pool, boolean recreate) {
      String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_buscouple_state_Table;
      String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_buscouple_state_Table + " (" +
            "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
            "  `dev_id` int(11) NOT NULL DEFAULT '912000001' COMMENT '设备id'," +
            "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," +
            "  `fanglei_state` int(11) NOT NULL DEFAULT '0' COMMENT '防雷状态:0:未连接;1:正常工作;2需要更换防雷设备'," +
            "  `workstate` int(11) NOT NULL DEFAULT '0' COMMENT '工作状态'," +
            "  `rlayworkmode` int(11) NOT NULL DEFAULT '0' COMMENT '空开操作状态'," +
            "  `rlyAstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入ON状态'," +
            "  `rlyBstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入OFF状态'," +
            "  `stopreson` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因'," +
            "  `volt_m1` float NOT NULL DEFAULT '0' COMMENT '电压1'," +
            "  `volt_m2` float NOT NULL DEFAULT '0' COMMENT '电压2'," +
            "  `iout` float NOT NULL DEFAULT '0' COMMENT '电流'," +
            "  `curdir` int(11) NOT NULL DEFAULT '0' COMMENT '电流方向'," +
            "  `commustate` int(11) NOT NULL DEFAULT '0' COMMENT '通信状态'," +
            "  PRIMARY KEY (`num`)," +
            "  UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" +
            ") ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
         if(true == recreate) {
            sql.sqlMysqlExecute(sql_str01);
         }
         sql.sqlMysqlExecute(sql_str02);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
}