From 363b9b705d13fd6c3eeff2766d8543e2887ca15a Mon Sep 17 00:00:00 2001 From: 81041 <81041@192.168.10.25> Date: 星期四, 06 十二月 2018 14:11:28 +0800 Subject: [PATCH] 删除电池组信息前备份 --- gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java | 159 +++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 119 insertions(+), 40 deletions(-) diff --git a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java index b5ff2d0..df1f70b 100644 --- a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java +++ b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java @@ -17,6 +17,7 @@ import com.fgkj.actions.ActionUtil; import com.fgkj.dao.BaseDAO; +import com.fgkj.dao.BattinfGroupFactory; import com.fgkj.dao.CallBack; import com.fgkj.dao.DAOHelper; import com.fgkj.dao.FBS9100_ComBase; @@ -34,6 +35,7 @@ import com.fgkj.dto.Batttestdata; import com.fgkj.dto.Batttestdata_inf; import com.fgkj.dto.Batttestdatastop; +import com.fgkj.dto.Database_backup; import com.fgkj.dto.Limit; import com.fgkj.dto.Page; import com.fgkj.dto.RoleLimit; @@ -53,11 +55,12 @@ //鑾峰彇褰撳墠鏈�澶х殑stationid鍜宐attgroupid int maxs=42000000;//鏈�澶tationid int maxb=1000001;//鏈�澶attgroupid - List maxList=(new BattInfImpl()).searchMaxId(); - if(maxList!=null&&maxList.size()>0){ + maxs=BattinfGroupFactory.searchStationId(); + maxb=BattinfGroupFactory.searchMaxBattgroupId(); + /*if(maxList!=null&&maxList.size()>0){ maxs=(Integer) maxList.get(0)+1; - maxb=(Integer) maxList.get(1)+1; - } + //maxb=(Integer) maxList.get(1)+1; + }*/ if(list!=null && list.size()>0){ for (int i = 0; i < list.size(); i++) { BattInf binf=list.get(i); @@ -72,12 +75,12 @@ String sql = "insert into db_battinf.tb_battinf(" + "StationId,StationName,StationName1,StationName2,StationName3,StationName4,StationName5,StationIp,FBSDeviceId,FbsDeviceIp,FbsDeviceIp_YM,FbsDeviceIp_WG," + "FBSDeviceName,GroupIndexInFBSDevice,battgroupId,BattGroupNum,BattGroupName,FloatVolLevel,OfflineVolLevel,BattFloatCurrent" + - ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,MonVolLowToAvg,BattProducer,BattModel,BattProductDate,BattInUseDate,Load_curr,install_user,DisCurrMax,station_phone" + + ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,MonVolLowToAvg,BattProducer,BattModel,BattProductDate,BattInUseDate,Load_curr,install_user,DisCurrMax,station_phone,Station_install" + ") values('"+binf.getStationId()+"','"+binf.getStationName()+"','"+binf.getStationName1()+"','"+binf.getStationName2()+"','"+binf.getStationName3()+"','"+binf.getStationName4()+"','"+binf.getStationName5()+ "','"+binf.getStationIp()+"',"+binf.getFBSDeviceId()+",'"+binf.getFbsDeviceIp()+"','"+binf.getFbsDeviceIp_YM()+"','"+binf.getFbsDeviceIp_WG()+"','"+binf.getFBSDeviceName()+"',"+binf.getGroupIndexInFBSDevice()+ ","+binf.getBattGroupId()+","+binf.getBattGroupNum()+",'"+binf.getBattGroupName()+"',"+binf.getFloatVolLevel()+","+binf.getOfflineVolLevel()+","+binf.getBattFloatCurrent()+ ","+binf.getMonCount()+","+binf.getMonCapStd()+","+binf.getMonVolStd()+","+binf.getMonResStd()+","+binf.getMonSerStd()+","+binf.getMonVolLowToAvg()+ - ",'"+binf.getBattProducer()+"','"+binf.getBattModel()+"','"+DAOHelper.sdf.format(binf.getBattProductDate())+"','"+DAOHelper.sdf.format(binf.getBattInUseDate())+"',"+binf.getLoad_curr()+",'"+binf.getInstall_user()+"',"+binf.getDisCurrMax()+",'"+binf.getStation_phone()+"')"; + ",'"+binf.getBattProducer()+"','"+binf.getBattModel()+"','"+DAOHelper.sdf.format(binf.getBattProductDate())+"','"+DAOHelper.sdf.format(binf.getBattInUseDate())+"',"+binf.getLoad_curr()+",'"+binf.getInstall_user()+"',"+binf.getDisCurrMax()+",'"+binf.getStation_phone()+"',"+binf.getStation_install()+")"; if(binf.getStationId().equals(maxs)){ maxs++; @@ -110,16 +113,17 @@ binf.setStationId((String) listS.get(listS.size()-1)); }else{ //鑾峰彇褰撳墠鏈�澶х殑stationid - List maxList=(new BattInfImpl()).searchMaxId(); - if(maxList!=null&&maxList.size()>0){ + int maxs=BattinfGroupFactory.searchStationId(); + binf.setStationId(String.valueOf(maxs)); + /*if(maxList!=null&&maxList.size()>0){ int maxs=(Integer) maxList.get(0)+1; binf.setStationId(String.valueOf(maxs)); - } + }*/ } String sql = "update db_battinf.tb_battinf set StationId='"+binf.getStationId()+"',StationName='"+binf.getStationName()+"',StationName1='"+binf.getStationName1()+"',StationName2='"+binf.getStationName2()+"',StationName3='"+binf.getStationName3()+"',StationName4='"+binf.getStationName4()+"',StationName5='"+binf.getStationName5()+"',StationIp='"+binf.getStationIp()+"',FBSDeviceId="+binf.getFBSDeviceId()+",FbsDeviceIp='"+binf.getFbsDeviceIp()+"'," + "FBSDeviceName='"+binf.getFBSDeviceName()+"',GroupIndexInFBSDevice="+binf.getGroupIndexInFBSDevice()+",BattGroupNum="+binf.getBattGroupNum()+",BattGroupName='"+binf.getBattGroupName()+"',FloatVolLevel="+binf.getFloatVolLevel()+",OfflineVolLevel="+binf.getOfflineVolLevel()+",BattFloatCurrent="+binf.getBattFloatCurrent()+"," + "MonCount="+binf.getMonCount()+",MonCapStd="+binf.getMonCapStd()+",monVolStd="+binf.getMonVolStd()+",monResStd="+binf.getMonResStd()+",MonSerStd="+binf.getMonSerStd()+",MonVolLowToAvg="+binf.getMonVolLowToAvg()+",BattProducer='"+binf.getBattProducer()+"',BattModel='"+binf.getBattModel()+"',BattProductDate='"+DAOHelper.sdf.format(binf.getBattProductDate())+"',BattInUseDate='"+DAOHelper.sdf.format(binf.getBattInUseDate())+"', " - +" Load_curr="+binf.getLoad_curr()+",install_user='"+binf.getInstall_user()+"',DisCurrMax="+binf.getDisCurrMax()+",station_phone='"+binf.getStation_phone()+"' where battgroupId="+binf.getBattGroupId(); + +" Load_curr="+binf.getLoad_curr()+",install_user='"+binf.getInstall_user()+"',DisCurrMax="+binf.getDisCurrMax()+",station_phone='"+binf.getStation_phone()+"',Station_install="+binf.getStation_install()+" where battgroupId="+binf.getBattGroupId(); sql_str.add(sql); { String msg="淇敼"+binf.getStationName()+"鏈烘埧"+binf.getBattGroupId()+"鐢垫睜缁勭殑淇℃伅"; @@ -148,6 +152,19 @@ } //鍒犻櫎鐢垫睜缁�(澶氫釜) public boolean del(Object obj) { + { + Database_backup baseup=new Database_backup(); + baseup.setBackup_en(1); + baseup.setDatabase_name("db_battinf"); + baseup.setTable_name("tb_battinf"); + (new Database_backupImpl()).update(baseup); + try { + Thread.sleep(1000*3); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + };//鍑虹幇鍒犻櫎鎿嶄綔鏃讹紝鍏堝浠芥暟鎹簱琛� List<BattInf> list=(List<BattInf>) obj; ArrayList sql_str=new ArrayList(); List<User_log> listU=new ArrayList<User_log>();//瀛樻斁user_log @@ -176,7 +193,7 @@ String numberSql=" SELECT FOUND_ROWS() number"; String sql="select SQL_CALC_FOUND_ROWS distinct(StationId),StationName1,StationName2,StationName3,StationName4,StationName5,StationIp,FBSDeviceId,FbsDeviceIp_YM,FbsDeviceIp_WG,FbsDeviceIp," + "FBSDeviceName,GroupIndexInFBSDevice,battgroupId,BattGroupNum,BattGroupName,FloatVolLevel,OfflineVolLevel,BattFloatCurrent" + - ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,MonVolLowToAvg,BattProducer,BattModel,BattProductDate,BattInUseDate,Load_curr,install_user,DisCurrMax,station_phone " + + ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,MonVolLowToAvg,BattProducer,BattModel,BattProductDate,BattInUseDate,Load_curr,install_user,DisCurrMax,station_phone,Station_install " + " From db_battinf.tb_battinf " + " Where StationName like ? and StationName1 like ? and StationName2 like ? and StationName5 like ? " + " order by StationId " + @@ -224,6 +241,7 @@ binf.setInstall_user(rs.getString("install_user")); binf.setDisCurrMax(rs.getFloat("disCurrMax")); binf.setStation_phone(rs.getString("station_phone")); + binf.setStation_install(rs.getInt("station_install")); list.add(binf); } @@ -354,8 +372,9 @@ 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"; + public int searchMaxId(){ + //,max(battgroupid) as maxb + String sql="select max(stationid) as stationid_maxs from db_battinf.tb_battinf limit 1"; List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { public List getResults(ResultSet rs) { @@ -364,15 +383,15 @@ while(rs.next()){ int maxs=42000000; - int maxb=1000001; - if(rs.getString("maxs") != null){ - maxs=Integer.parseInt(rs.getString("maxs")); + //int maxb=1000001; + if(rs.getString("stationid_maxs") != null){ + maxs=Integer.parseInt(rs.getString("stationid_maxs")); } - if(rs.getInt("maxb")!=0){ + /*if(rs.getInt("maxb")!=0){ maxb=rs.getInt("maxb"); - } + }*/ list.add(maxs); - list.add(maxb); + //list.add(maxb); } } catch (SQLException e) { // TODO Auto-generated catch block @@ -381,7 +400,11 @@ return list; } }); - return list; + int stationid=0; + if(list!=null&&list.size()>0){ + stationid=(Integer) list.get(list.size()-1); + } + return stationid; } //鍒ゆ柇鏂板鐨勭數姹犵粍鏄惁瀛樺湪 public List judgeBatt(Object obj){ @@ -1083,11 +1106,11 @@ public int serchByDeviceId(Object obj){ User_inf uinf=(User_inf) obj; String sql=" SELECT COUNT(DISTINCT fbsdeviceid) number FROM db_battinf.tb_battinf " + - " left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " + - " left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " + - " left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " + - " where db_user.tb_user_inf.uid=? and db_battinf.tb_battinf.Station_install=1 " + - " limit 1"; + " 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 db_battinf.tb_battinf.station_install=1"; List<BattInf> list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() { public List getResults(ResultSet rs) { @@ -1112,24 +1135,25 @@ } return number; } - //鏌ヨ璁惧鎬绘暟(鍏ㄩ儴) - public int serchByDeviceId_all(Object obj){ + //鏌ュ崟浣撴�绘暟(宸插畨瑁呯殑鍗曚綋) + public int serchByInstall_count(Object obj){ User_inf uinf=(User_inf) obj; - String sql=" SELECT COUNT(DISTINCT fbsdeviceid) number FROM db_battinf.tb_battinf " + - " left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " + - " left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " + - " left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " + - " where db_user.tb_user_inf.uid=? " + - " limit 1"; - List<BattInf> list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() { + String sql=" SELECT sum(moncount) as nums 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 db_battinf.tb_battinf.station_install=1"; + //System.out.println(sql); + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); + int nums=0;//鍗曚綋鎬绘暟 try { while(rs.next()){ - BattInf binf=new BattInf(); - binf.setNum(rs.getInt("number")); - list.add(binf); + nums=rs.getInt("nums"); + list.add(nums); } } catch (SQLException e) { // TODO Auto-generated catch block @@ -1141,9 +1165,62 @@ }); int number=0;//瀛樻斁鎬绘暟 if(list!=null&&list.size()>0){ - number=list.get(list.size()-1).getNum(); + number=(Integer) list.get(list.size()-1); } return number; + } + //鏌ヨ璁惧鎬绘暟(鍏ㄩ儴) + public List serchByDeviceId_all(Object obj){ + User_inf uinf=(User_inf) obj; + String sql=" SELECT DISTINCT fbsdeviceid,station_install,monvolstd 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=? " + + " ) "; + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() { + + public List getResults(ResultSet rs) { + List list=new ArrayList(); + int num_2_install=0;//2v宸插畨瑁� + int num_2=0;//2v鍏ㄩ儴 + int num_12_install=0;//12v宸插畨瑁� + int num_12=0;//12v鍏ㄩ儴 + int num_install=0;//宸插畨瑁� + int num=0;//鍏ㄩ儴 + try { + while(rs.next()){ + int insatll=rs.getInt("station_install"); + float monvolstd=rs.getFloat("monvolstd"); + if(insatll==1){ + num_install+=1; + if(monvolstd==2.0){ + num_2_install+=1; + }else{ + num_12_install+=1; + } + } + if(monvolstd==2.0){ + num_2+=1; + }else{ + num_12+=1; + } + num+=1; + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + list.add(num_2_install); + list.add(num_2); + list.add(num_12_install); + list.add(num_12); + list.add(num_install); + list.add(num); + return list; + } + + }); + return list; } //-----------鏍规嵁钃勭數姹犵粍鏌ヤ笉閲嶅鐨凪onCount(monNum)锛堝崟浣撶紪鍙凤級 public List serchByMonNum(Object obj){ @@ -4236,12 +4313,14 @@ //List<BattInf> list=biml.serchGroupByInfor(binf); //List<BattInf> list=biml.searchInform1(bmd); //<BattInf> list=biml.serchStationName5(binf); - List<BattInf> list=biml.serchBattAllInfoByStationId(binf); + /*List<BattInf> list=biml.serchBattAllInfoByStationId(binf); //List<BattInf> list=biml.searchInform_ky(); for (BattInf b : list) { System.out.println(b); } - System.out.println(list.size()); + System.out.println(list.size());*/ + int nums=biml.serchByInstall_count(uinf); + System.out.println(nums); } public List getResults(ResultSet rs) { -- Gitblit v1.9.1