hdw
2019-01-19 7f953d9aa0e7d4fcbe3c366c7f9f0b3f847f12bd
gx_tieta/src/com/fgkj/dao/impl/ram/Fbs9100s_dfu_stateImpl.java
@@ -24,21 +24,21 @@
    //升级插入
   public boolean add(Object obj) {
      Fbs9100s_dfu_state dfu=(Fbs9100s_dfu_state) obj;
      String sql=" REPLACE into db_ram_db.tb_fbs9100s_dfu_state (dev_id,dfu_file,dfu_wr_stat,dfu_data_blocknum) values (?,?,?,?)";
      boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{dfu.getDev_id(),dfu.getDfu_file(),dfu.getDfu_wr_stat(),dfu.getDfu_data_blocknum()});
      String sql=" REPLACE into db_ram_db.tb_fbs9100s_dfu_state (dev_id,dfu_file,dfu_wr_stat,dfu_data_blocknum,dfu_file_len) values (?,?,?,?,?)";
      boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{dfu.getDev_id(),dfu.getDfu_file(),dfu.getDfu_wr_stat(),dfu.getDfu_data_blocknum(),dfu.getDfu_file_len()});
      return bl;
   }
   //批量升级插入(所有属性传到stationName中)
   //批量升级插入(所有属性传到stationName中,文件大小的值放在num中)
   public boolean addPro(Object obj) {
      BattInf binf=(BattInf) obj;
      String sql=" REPLACE into db_ram_db.tb_fbs9100s_dfu_state(dev_id,dfu_file,dfu_wr_stat,dfu_data_blocknum) " +
            " SELECT  DISTINCT fBSDeviceId,'avr_dfu.uc3',1,1 FROM  db_battinf.tb_battinf " +
            " where ";
      String sql=" REPLACE into db_ram_db.tb_fbs9100s_dfu_state(dev_id,dfu_wr_stat,dfu_data_blocknum) " +
            " SELECT  DISTINCT fBSDeviceId,1,1 FROM db_battinf.tb_battinf " +
            " where fBSDeviceId not in(select DISTINCT dev_id from db_ram_db.tb_fbs9100s_dfu_state where dfu_en=true)  ";
      //条件
      String sql0=" stationid=? "; //具体机房
      String sql1=" stationname1=? ";//省
      String sql2=" stationname2=? ";//市
      String sql5=" stationname5=? ";//区县
      String sql0=" and stationid=? "; //具体机房
      String sql1=" and stationname1=? ";//省
      String sql2=" and stationname2=? ";//市
      String sql5=" and stationname5=? ";//区县
      switch (binf.getNum()) {
      case 0:
         sql+=sql0;
@@ -62,13 +62,17 @@
    //表格显示批量插入的机房信息
   public List serchInserStation(Object obj){
      BattInf binf=(BattInf) obj; 
      String sql="SELECT  DISTINCT fBSDeviceId,stationId,stationname,stationname1,stationname2,stationname3,stationname5 from db_battinf.tb_battinf " +
            " where ";
      String sql="SELECT  DISTINCT fBSDeviceId,fBSDeviceName,stationId,stationname,stationname1,stationname2,stationname3,stationname5 " +
            ",db_ram_db.tb_fbs9100_state.dev_id,db_ram_db.tb_fbs9100_state.dev_version" +
            " from db_battinf.tb_battinf,db_ram_db.tb_fbs9100_state " +
            " where db_battinf.tb_battinf.fBSDeviceId=db_ram_db.tb_fbs9100_state.dev_id " +
            " and db_battinf.tb_battinf.station_install=1 " +
            " and ";
      //条件
      String sql0=" stationid=? "; //具体机房
      String sql1=" stationname1=? ";//省
      String sql2=" stationname2=? ";//市
      String sql5=" stationname5=? ";//区县
      String sql0="  stationid=? "; //具体机房
      String sql1="  stationname1=? ";//省
      String sql2="  stationname2=? ";//市
      String sql5="  stationname5=? ";//区县
      switch (binf.getNum()) {
      case 0:
         sql+=sql0;
@@ -102,6 +106,7 @@
                  binf.setStationName5(rs.getString("stationName5"));
                  binf.setStationId(rs.getString("stationId"));
                  binf.setFBSDeviceName(rs.getString("fBSDeviceName"));
                  binf.setStationIp(rs.getString("dev_version"));
                  list.add(binf);
               }
            } catch (SQLException e) {
@@ -116,7 +121,7 @@
   //批量升级前验证升级的设备必须处于在线监测状态(9100state的workstate为0)
   public List judgeStation(Object obj){
      List<Integer> list=(List<Integer>) obj;
      String sql=" select distinct dev_id,db_battinf.tb_battinf.stationname3 from db_ram_db.tb_fbs9100_state,db_battinf.tb_battinf  " +
      String sql=" select distinct dev_id,db_battinf.tb_battinf.stationname,db_battinf.tb_battinf.stationname3 from db_ram_db.tb_fbs9100_state,db_battinf.tb_battinf  " +
            " where db_ram_db.tb_fbs9100_state.dev_id=db_battinf.tb_battinf.fBSDeviceId  and dev_workstate=0 and dev_id in(";
      String devSql="";
      Object[] object=new Object[list.size()];
@@ -142,6 +147,7 @@
               while(rs.next()){
                  BattInf binf=new BattInf();
                  binf.setFBSDeviceId(rs.getInt("dev_id"));
                  binf.setStationName(rs.getString("stationName"));
                  binf.setStationName3(rs.getString("stationName3"));
                  list.add(binf);
               }
@@ -169,7 +175,7 @@
      if(list!=null&&list.size()>0){
         for (int i = 0; i < list.size(); i++) {
            Fbs9100s_dfu_state dfu=list.get(i);
            String sql="update db_ram_db.tb_fbs9100s_dfu_state set dfu_en=true,dfu_wr_stat=1, dfu_data_blocknum=1 where dev_id="+dfu.getDev_id();
            String sql="update db_ram_db.tb_fbs9100s_dfu_state set dfu_en=true,dfu_wr_stat=1, dfu_data_blocknum=1,dfu_file='"+dfu.getDfu_file()+"'  where dev_id="+dfu.getDev_id();
            sql_str.add(sql);
            {
               String msg="升级"+dfu.getDev_id()+"设备";
@@ -186,10 +192,47 @@
      // TODO Auto-generated method stub
      return false;
   }
    //查询出所有处于升级的设备
   public List searchAll() {
      // TODO Auto-generated method stub
      return null;
      String sql=" select distinct db_ram_db.tb_fbs9100s_dfu_state.dev_id,db_battinf.tb_battinf.stationname,db_battinf.tb_battinf.stationId,db_battinf.tb_battinf.fBSDeviceName " +
            ",sysVersion_new,softVersion_new,sysVersion_dev,softVersion_dev,dfu_file,dfu_en,dfu_wr_stat,dfu_data_blocknum,dfu_data_blocklen,dfu_file_len " +
            ",db_ram_db.tb_fbs9100_state.dev_version" +
            " from  db_ram_db.tb_fbs9100s_dfu_state,db_battinf.tb_battinf,db_ram_db.tb_fbs9100_state " +
            " where db_ram_db.tb_fbs9100s_dfu_state.dev_id=db_battinf.tb_battinf.fBSDeviceId  " +
            " and db_ram_db.tb_fbs9100s_dfu_state.dev_id=db_ram_db.tb_fbs9100_state.dev_id " +
            " and dfu_en=1";
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null , new CallBack() {
         public List getResults(ResultSet rs) {
            List list=new ArrayList();
            try {
               while(rs.next()){
                  Fbs9100s_dfu_state dfu=new Fbs9100s_dfu_state();
                  dfu.setDev_id(rs.getInt("dev_id"));
                  dfu.setSysVersion_new(rs.getInt("sysVersion_new"));
                  dfu.setSoftVersion_new(rs.getInt("softVersion_new"));
                  dfu.setSysVersion_dev(rs.getInt("sysVersion_dev"));
                  dfu.setSoftVersion_dev(rs.getInt("softVersion_dev"));
                  dfu.setDfu_file(rs.getString("dfu_file"));
                  dfu.setDfu_en(rs.getInt("dfu_en"));
                  dfu.setDfu_wr_stat(rs.getInt("dfu_wr_stat"));
                  dfu.setDfu_data_blocknum(rs.getInt("dfu_data_blocknum"));
                  dfu.setDfu_file_len(rs.getInt("dfu_file_len"));
                  dfu.setDfu_data_blocklen(rs.getInt("dfu_data_blocklen"));
                  dfu.setStationName(rs.getString("stationName"));
                  dfu.setStationId(rs.getString("stationId"));
                  dfu.setfBSDeviceName(rs.getString("fBSDeviceName"));
                  dfu.setNote(rs.getString("dev_version"));
                  list.add(dfu);
               }
            } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }
            return list;
         }
      });
      return list;
   }
    //升级界面实时刷新
   public List serchByCondition(Object obj) {
@@ -229,6 +272,7 @@
                  dfu.setDfu_en(rs.getInt("dfu_en"));
                  dfu.setDfu_wr_stat(rs.getInt("dfu_wr_stat"));
                  dfu.setDfu_data_blocknum(rs.getInt("dfu_data_blocknum"));
                  dfu.setDfu_file_len(rs.getInt("dfu_file_len"));
                  dfu.setDfu_data_blocklen(rs.getInt("dfu_data_blocklen"));
                  list.add(dfu);
               }
@@ -241,20 +285,19 @@
      });
      return listAll;
   }
   public List serchByInfo(Object obj) {
      // TODO Auto-generated method stub
      return null;
   }
    public static void main(String[] args) {
   Fbs9100s_dfu_stateImpl fimpl=new Fbs9100s_dfu_stateImpl();
   List list=new ArrayList();
   list.add(910000002);
   list.add(910000577);
   list.add(910000534);
   list.add(910000001);
   /*list.add(910000577);
   list.add(910000534);*/
   BattInf binf=new BattInf();
   binf.setNum(1);
   binf.setStationName("湖北省");
   binf.setStationName("广西省");
   
   /*List<Fbs9100s_dfu_state> listAll=fimpl.serchByCondition(list);
   for (Fbs9100s_dfu_state dfu : listAll) {
@@ -264,12 +307,22 @@
   for (BattInf binf : listAll) {
      System.out.println(binf.getStationName3()+" "+binf.getFBSDeviceId());
   }*/
   /*
   boolean bl=fimpl.addPro(binf);
   /*boolean bl=fimpl.addPro(binf);
   System.out.println(bl);*/
   List<BattInf> listAll=fimpl.serchInserStation(binf);
   /*List<BattInf> listAll=fimpl.serchInserStation(binf);
   for (BattInf b : listAll) {
      System.out.println(b.getStationName3()+" "+b.getFBSDeviceId());
   }
   System.out.println(listAll.size());*/
   /*List<Fbs9100s_dfu_state> listAll=fimpl.searchAll();
   for (Fbs9100s_dfu_state dfu : listAll) {
      System.out.println(dfu);
   }*/
   List<Fbs9100s_dfu_state> listAll=fimpl.searchAll();
   for (Fbs9100s_dfu_state dfu : listAll) {
      System.out.println(dfu);
   }
   System.out.println(listAll.size());
}
}