81041
2018-10-31 f8192dde9dbdbd063dec8f234a99df4ef57917eb
gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java
@@ -230,6 +230,48 @@
      }
      return list;
   }
   //根据维护区和机房名称查询电池组信息(电池组信息配置)
   public List searchInform1(Object obj){
      Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj;
      BattInf binf=bmd.getBinf();
      Page page=bmd.getPage();
      Connection conn= DBUtil.getConn();
      String numberSql=" SELECT FOUND_ROWS() number";
      String sql="select SQL_CALC_FOUND_ROWS distinct(StationId),StationId_ex,StationName1,StationName2,StationName3,StationName,FBSDeviceId  " +
             " From db_battinf.tb_battinf " +
             " limit ?,?";
      List<BattInf> list=DAOHelper.executeQueryLimit(sql,conn, new Object[]{(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize()},new CallBack() {
         public List getResults(ResultSet rs) {
            List list = new ArrayList<BattInf>();
            int id=0;
            try {
               while (rs.next()) {
                  BattInf binf = new BattInf();
                  binf.setStationId(rs.getString("stationId"));
                  binf.setStationName1(rs.getString("stationName1"));
                  binf.setStationName2(rs.getString("stationName2"));
                  binf.setStationName3(rs.getString("stationName3"));
                  binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                  binf.setStationName(rs.getString("stationName"));
                  binf.setStationId_ex(rs.getString("stationId_ex"));
                  list.add(binf);
               }
            } catch (SQLException e) {
               e.printStackTrace();
            }
            return list;
         }
      });
      //去掉limit条件后的总数
      int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql);
      if(list!=null&&list.size()>0){
         list.get(list.size()-1).setNum(number);
      }
      return list;
   }
   //添加电池组时查询出最大的机房id和电池组id
   public List searchMaxId(){
      String sql="select max(stationid) as maxs,max(battgroupid) as maxb from db_battinf.tb_battinf limit 1";
@@ -3365,16 +3407,75 @@
      } );
      return list;
   }
   //查询管理的机房(左侧导航第三层,查所有的机房,num中存放uid)
   public List serchStationName3(Object obj){
   //查询管理的县/区(左侧导航第三层,查所有的县/区)
   public List serchStationName5(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,stationid,fbsdeviceid,FBSDeviceName  " +
      String sql="select DISTINCT stationName5,StationName1,StationName2   " +
            " FROM db_battinf.tb_battinf " +
            " where StationId in(" +
            " select distinct db_user.tb_user_battgroup_baojigroup_battgroup.StationId from db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr where db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id  and db_user.tb_user_battgroup_baojigroup_usr.uId=?" +
            " ) and StationName1 like ? and StationName2 like ?  " +
            " ORDER BY CONVERT( StationName USING gbk ) COLLATE gbk_chinese_ci ASC ";
      //System.out.println(sql);
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getNum(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%"},new CallBack() {
         public List getResults(ResultSet rs) {
            List list=new ArrayList();
               try {
                  while(rs.next()){
                     BattInf batt = new BattInf();
                     batt.setStationName1(rs.getString("stationName1"));
                     batt.setStationName2(rs.getString("stationName2"));
                     batt.setStationName5(rs.getString("stationName5"));
                     list.add(batt);
                  }
               } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
               }
            return list;
         }
      } );
      return list;
   }
   //查询管理的县/区(左侧导航第三层,查所有的县/区)
   public List serchStationName5_all(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT stationName5,StationName1,StationName2  " +
            " FROM db_battinf.tb_battinf " +
            " where StationName1 like ? and StationName2 like ?  " +
            " ORDER BY CONVERT( StationName USING gbk ) COLLATE gbk_chinese_ci ASC ";
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getNum(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%"},new CallBack() {
         public List getResults(ResultSet rs) {
            List list=new ArrayList();
               try {
                  while(rs.next()){
                     BattInf batt = new BattInf();
                     batt.setStationName1(rs.getString("stationName1"));
                     batt.setStationName2(rs.getString("stationName2"));
                     batt.setStationName5(rs.getString("stationName5"));
                     list.add(batt);
                  }
               } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
               }
            return list;
         }
      } );
      return list;
   }
   //查询管理的机房(左侧导航第四层,查所有的机房,num中存放uid)
   public List serchStationName3(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,StationName5,stationid,fbsdeviceid,FBSDeviceName  " +
            " FROM db_battinf.tb_battinf " +
            " where StationId in(" +
            " select distinct db_user.tb_user_battgroup_baojigroup_battgroup.StationId from db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr where db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id  and db_user.tb_user_battgroup_baojigroup_usr.uId=?" +
            " ) and StationName1 like ? and StationName2 like ? and StationName5 like ?  " +
            " ORDER BY CONVERT( StationName USING gbk ) COLLATE gbk_chinese_ci ASC ";
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getNum(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName5()+"%"},new CallBack() {
         
         public List getResults(ResultSet rs) {
            List list=new ArrayList();
@@ -3385,6 +3486,7 @@
                     batt.setStationName1(rs.getString("stationName1"));
                     batt.setStationName2(rs.getString("stationName2"));
                     batt.setStationName3(rs.getString("stationName3"));
                     batt.setStationName5(rs.getString("stationName5"));
                     batt.setStationId(rs.getString("stationId"));
                     batt.setFBSDeviceName(rs.getString("fBSDeviceName"));
                     batt.setFBSDeviceId(rs.getInt("fBSDeviceId"));
@@ -3399,14 +3501,14 @@
      } );
      return list;
   }
   //查询管理的机房(左侧导航第三层,查所有的机房)
   //查询管理的机房(左侧导航第四层,查所有的机房)
   public List serchStationName3_all(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,stationid,fbsdeviceid,FBSDeviceName  " +
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,StationName5,stationid,fbsdeviceid,FBSDeviceName  " +
            " FROM db_battinf.tb_battinf " +
            " where StationName1 like ? and StationName2 like ?  " +
            " where StationName1 like ? and StationName2 like ?  and StationName5 like ? " +
            " ORDER BY CONVERT( StationName USING gbk ) COLLATE gbk_chinese_ci ASC ";
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%"},new CallBack() {
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName5()+"%"},new CallBack() {
         
         public List getResults(ResultSet rs) {
            List list=new ArrayList();
@@ -3417,6 +3519,7 @@
                     batt.setStationName1(rs.getString("stationName1"));
                     batt.setStationName2(rs.getString("stationName2"));
                     batt.setStationName3(rs.getString("stationName3"));
                     batt.setStationName5(rs.getString("stationName5"));
                     batt.setStationId(rs.getString("stationId"));
                     batt.setFBSDeviceName(rs.getString("fBSDeviceName"));
                     batt.setFBSDeviceId(rs.getInt("fBSDeviceId"));
@@ -3433,11 +3536,11 @@
   }
   
   
   //根据机房id查询机房下的电池组信息(左侧导航第四层,根据机房查询下面的电池组,num中存放uid)
   //根据机房id查询机房下的电池组信息(左侧导航第五层,根据机房查询下面的电池组,num中存放uid)
   public List serchBattByStation(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT StationName,StationId,StationIP,FBSDeviceId,BattGroupName,BattGroupName1,BattGroupName2,MonCount,battgroupId,MonCapStd,MonVolStd,MonResStd,MonSerStd,BattProducer,BattInUseDate,GroupIndexInFBSDevice,Load_curr,DisCurrMax " +
            "from db_battinf.tb_battinf  where StationName1 like ? and StationName2 like ?  and  StationName like ?  ";
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,StationName5,StationId,stationid_ex,StationIP,FBSDeviceId,BattGroupName,BattGroupName1,BattGroupName2,MonCount,battgroupId,MonCapStd,MonVolStd,MonResStd,MonSerStd,BattProducer,BattInUseDate,GroupIndexInFBSDevice,Load_curr,DisCurrMax " +
            "from db_battinf.tb_battinf  where StationName1 like ? and StationName2 like ?   and  StationName like ? and StationName5 like ?  ";
       //机房id
      String idSqlT=" and  Stationid like ? ";
      sql+=idSqlT;
@@ -3450,7 +3553,7 @@
      String orderSql=" ORDER BY StationName1,battgroupId ";
      sql+=orderSql;
      //System.out.println(sql);
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationId()+"%",binf.getNum()},new CallBack() {
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationName5()+"%","%"+binf.getStationId()+"%",binf.getNum()},new CallBack() {
         
         public List getResults(ResultSet rs) {
            List list = new ArrayList();
@@ -3458,7 +3561,12 @@
               while (rs.next()) {
                  BattInf batt = new BattInf();
                  batt.setStationName(rs.getString("stationName"));
                  batt.setStationName1(rs.getString("stationName1"));
                  batt.setStationName2(rs.getString("stationName2"));
                  batt.setStationName3(rs.getString("stationName3"));
                  batt.setStationName5(rs.getString("stationName5"));
                  batt.setStationId(rs.getString("StationId"));
                  batt.setStationId_ex(rs.getString("stationId_ex"));
                  batt.setStationIp(rs.getString("StationIP"));
                  batt.setBattGroupName(rs.getString("BattGroupName").trim());
                  batt.setBattGroupName1(rs.getString("BattGroupName1").trim());
@@ -3485,11 +3593,11 @@
      });
      return list;
      }
   //根据机房id查询机房下的电池组信息(左侧导航第四层,根据机房查询下面的电池组,num中存放uid)
   //根据机房id查询机房下的电池组信息(左侧导航第五层,根据机房查询下面的电池组,num中存放uid)
   public List serchBattByStation_all(Object obj){
      BattInf binf=(BattInf) obj;
      String sql="select DISTINCT StationName,StationId,StationIP,FBSDeviceId,BattGroupName,BattGroupName1,BattGroupName2,MonCount,battgroupId,MonCapStd,MonVolStd,MonResStd,MonSerStd,BattProducer,BattInUseDate,GroupIndexInFBSDevice " +
            "from db_battinf.tb_battinf  where StationName1 like ? and StationName2 like ?  and  StationName like ?  ";
      String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,StationName4,StationName5,StationId,StationIP,FBSDeviceId,BattGroupName,BattGroupName1,BattGroupName2,MonCount,battgroupId,MonCapStd,MonVolStd,MonResStd,MonSerStd,BattProducer,BattInUseDate,GroupIndexInFBSDevice " +
            "from db_battinf.tb_battinf  where StationName1 like ? and StationName2 like ?  and  StationName like ? and StationName5 like ? ";
       //机房id
      String idSqlT=" and  Stationid like ? ";
      sql+=idSqlT;
@@ -3502,7 +3610,7 @@
      String orderSql=" ORDER BY StationName1,battgroupId ";
      sql+=orderSql;
      //System.out.println(sql);
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationId()+"%"},new CallBack() {
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationName5()+"%","%"+binf.getStationId()+"%"},new CallBack() {
         
         public List getResults(ResultSet rs) {
            List list = new ArrayList();
@@ -3510,6 +3618,10 @@
               while (rs.next()) {
                  BattInf batt = new BattInf();
                  batt.setStationName(rs.getString("stationName"));
                  batt.setStationName1(rs.getString("stationName1"));
                  batt.setStationName2(rs.getString("stationName2"));
                  batt.setStationName3(rs.getString("stationName3"));
                  batt.setStationName5(rs.getString("stationName5"));
                  batt.setStationId(rs.getString("StationId"));
                  batt.setStationIp(rs.getString("StationIP"));
                  batt.setBattGroupName(rs.getString("BattGroupName").trim());
@@ -3628,7 +3740,12 @@
            " from db_battinf.tb_battinf " +
            " left outer join (select * from db_battinf.tb_battinf_rebuild where tb_battinf_rebuild.rebuild_clear_type=1 ) as battinf_re " +
            " on BattGroupId=battinf_re.new_battgroupid or BattGroupId=battinf_re.old_battgroupid " +
            " where stationname2 like ? ";
            " where stationname2 like ?  ";
      //用户管理
      String userSql=" and StationId in(" +
            " select distinct db_user.tb_user_battgroup_baojigroup_battgroup.StationId from db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr where db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id  and db_user.tb_user_battgroup_baojigroup_usr.uId=?" +
            " ) ";
      sql+=userSql;
      //选中品牌一致
      String producerSqlT=" order by BattProducer,MonCapStd,MonVolStd,BattGroupId ";//一致
      String producerSqlF=" order by MonCapStd,MonVolStd,BattGroupId ";//不一致
@@ -3637,7 +3754,7 @@
      }else{
         sql+=producerSqlF;
      }
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName2()+"%"}, new CallBack() {
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName2()+"%",binf.getNum()}, new CallBack() {
         
         public List getResults(ResultSet rs) {
            List<BattInf> list=new ArrayList();
@@ -3704,7 +3821,12 @@
            " left outer join (select * from db_battinf.tb_battinf_rebuild where tb_battinf_rebuild.rebuild_clear_type=1 ) as battinf_re " +
            " on BattGroupId=battinf_re.new_battgroupid or BattGroupId=battinf_re.old_battgroupid " +
            " where stationname1 like ? and stationname2 like ? and stationname3 like ?  and battgroupname like ?  and battgroupid=? ";
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%","%"+binf.getBattGroupName()+"%",binf.getBattGroupId()}, new CallBack() {
      //用户管理
      String userSql=" and StationId in(" +
            " select distinct db_user.tb_user_battgroup_baojigroup_battgroup.StationId from db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr where db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id  and db_user.tb_user_battgroup_baojigroup_usr.uId=?" +
            " ) ";
      sql+=userSql;
      List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%","%"+binf.getBattGroupName()+"%",binf.getBattGroupId(),binf.getNum()}, new CallBack() {
         
         public List getResults(ResultSet rs) {
            List<BattInf> list=new ArrayList();
@@ -3769,11 +3891,12 @@
      
      BattInfImpl biml = new BattInfImpl();
      BattInf binf = new BattInf();
      binf.setNum(1002);
      binf.setBattGroupId(1000001);
      binf.setStationName("");
      binf.setStationName1("");
      binf.setStationName2("");
      binf.setStationName3("武汉源暢实验室1");
      binf.setStationName3("");
      binf.setBattGroupName("");
      binf.setBattProducer("1");
      User_inf uinf=new User_inf();
@@ -3801,10 +3924,12 @@
      //List<BattInf> list=biml.serchByTestType(bmd);
      //List<BattInf> list=biml.serchGroupAssess(bmd);
      //List<BattInf> list=biml.serchMakeGroup(binf);
      List<BattInf> list=biml.serchGroupByInfor(binf);
      for (BattInf b : list) {
      //List<BattInf> list=biml.serchGroupByInfor(binf);
      //List<BattInf> list=biml.searchInform1(bmd);
      List<BattInf> list=biml.serchStationName5(binf);
      /*for (BattInf b : list) {
         System.out.println(b);
      }
      }*/
      System.out.println(list.size());
   }