From d04cea72d0c721f9e7e65d3074c5546ac6eb594f Mon Sep 17 00:00:00 2001 From: 81041 <81041@DESKTOP-025NVD9> Date: 星期五, 11 一月 2019 14:51:17 +0800 Subject: [PATCH] 修改系统批量 --- gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java | 395 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 388 insertions(+), 7 deletions(-) diff --git a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java index 8bdfe54..ee5eb46 100644 --- a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java +++ b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java @@ -90,6 +90,14 @@ } maxb++; sql_str.add(sql); + + String baoji_sql_main="REPLACE into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) values('100011','"+binf.getStationId()+"',"+binf.getBattGroupId()+")"; + sql_str.add(baoji_sql_main); + + // System.out.println(baoji_sql_main); + String baoji_sql="REPLACE into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) " + + " SELECT baoji_group_id,'"+binf.getStationId()+"',"+binf.getBattGroupId()+" from db_user.tb_user_battgroup_baojigroup_usr where uid="+((User_inf)ActionUtil.getUser()).getUId(); + sql_str.add(baoji_sql); { String msg="娣诲姞"+binf.getStationName()+"鏈烘埧"+binf.getBattGroupId()+"鐢垫睜缁勭殑淇℃伅"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg); @@ -452,10 +460,11 @@ } return dev_id; } - //鍒ゆ柇鏂板鐨勭數姹犵粍鏄惁瀛樺湪 + //鍒ゆ柇鏂板鐨勬満鎴挎槸鍚﹀瓨鍦� public List judgeBatt(Object obj){ BattInf binf=(BattInf) obj; - String sql="select distinct stationid from db_battinf.tb_battinf where stationname=? limit 1"; + String sql="select distinct(StationId) " + + "from db_battinf.tb_battinf where stationname=? limit 1"; List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getStationName()}, new CallBack() { public List getResults(ResultSet rs) { @@ -474,7 +483,8 @@ }); return list; } - //鍒ゆ柇鏂板鐨勭數姹犵粍鏄惁瀛樺湪 + + //鍒ゆ柇鏂板鐨勬満鎴挎槸鍚﹀瓨鍦� public boolean judgeBattInOrNot(Object obj){ BattInf binf=(BattInf) obj; String sql="select distinct stationid from db_battinf.tb_battinf where stationname=? limit 1"; @@ -4344,21 +4354,381 @@ }); return list; } + //鏌ヨbattinf涓渶澶х殑battgroupid + //鏌ヨ鍑哄綋鍓嶅瓨鍦ㄥ唴瀛樹腑鏈�澶х殑鐢垫睜缁刬d(寰堥噸瑕�**********) + public int searchMaxBattgroupId(){ + String sql=" select max(battgroupId) as id from db_battinf.tb_battinf limit 1"; + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { + + public List getResults(ResultSet rs) { + List list=new ArrayList(); + try { + while(rs.next()){ + int battgroupid=1010000; + if(rs.getString("id")!=null){ + battgroupid=rs.getInt("id"); + } + list.add(battgroupid); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return list; + } + }); + int battgroupid=0; + if(list!=null&&list.size()>0){ + battgroupid=(Integer) list.get(list.size()-1); + } + return battgroupid; + } + //鎵归噺璁剧疆鏀剧數鍙傛暟鏃讹紝鏍规嵁鐪佸競鍖猴紝鐢垫睜鍗曚綋鍨嬪彿锛堜紡鏁帮級锛岀粍鏁扮瓫閫夊嚭鐢垫睜缁� + public List serchByDischarge(Object obj) { + BattInf binf=(BattInf) obj; + //Page page=binf.getPage(); + /*Connection conn=DBUtil.getConn(); + String numberSql=" SELECT FOUND_ROWS() number";SQL_CALC_FOUND_ROWS*/ + String sql=" select distinct(StationId),StationName,StationName1,StationName2,StationName3,StationName4,StationName5,StationIp,FBSDeviceId," + + "FBSDeviceName,GroupIndexInFBSDevice,db_battinf.tb_battinf.battgroupId,battGroupName,battGroupNum" + + ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,Load_curr,DisCurrMax" + + ",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 GroupIndexInFBSDevice=? and MonVolStd=? and Station_install=1 "; + //+ " limit ?,? ";StationName1 like ? and StationName2 like ? and StationName3 like ? and StationName5 like ? " + //,(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%", + //鏉′欢 + String sql0=" and stationid=? "; //鍏蜂綋鏈烘埧 + String sql1=" and stationname1=? ";//鐪� + String sql2=" and stationname2=? ";//甯� + String sql5=" and stationname5=? ";//鍖哄幙 + switch (binf.getNum()) { + case 0: + sql+=sql0; + break; + case 1: + sql+=sql1; + break; + case 2: + sql+=sql2; + break; + case 5: + sql+=sql5; + break; + default: + return null; + } + + //鎺掑簭 + String orderSql=" order by StationId asc,GroupIndexInFBSDevice asc "; + sql+=orderSql; + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[] {binf.getGroupIndexInFBSDevice(),binf.getMonVolStd(),binf.getStationName()}, new CallBack() { + + @Override + public List getResults(ResultSet rs) { + List list=new ArrayList(); + try { + while(rs.next()) { + BattInf binf = new BattInf(); + binf.setNum(0); + binf.setStationId(rs.getString("stationId")); + binf.setStationName(rs.getString("stationName")); + binf.setStationName1(rs.getString("stationName1")); + binf.setStationName2(rs.getString("stationName2")); + binf.setStationName3(rs.getString("stationName3")); + binf.setStationName4(rs.getString("stationName4")); + binf.setStationName5(rs.getString("stationName5")); + binf.setStationIp(rs.getString("stationIp")); + binf.setFBSDeviceId(rs.getInt("fBSDeviceId")); + + /*binf.setFbsDeviceIp(rs.getString("fbsDeviceIp")); + binf.setFbsDeviceIp_YM(rs.getString("fbsDeviceIp_YM")); + binf.setFbsDeviceIp_WG(rs.getString("fbsDeviceIp_WG"));*/ + binf.setFBSDeviceName(rs.getString("fBSDeviceName")); + binf.setGroupIndexInFBSDevice(rs.getInt("groupIndexInFBSDevice")); + binf.setBattGroupId(rs.getInt("battGroupId")); + binf.setBattGroupNum(rs.getInt("battGroupNum")); + binf.setBattGroupName(rs.getString("battGroupName")); + /*binf.setBattGroupNum(rs.getInt("battGroupNum")); + binf.setFloatVolLevel(rs.getFloat("floatVolLevel")); + binf.setOfflineVolLevel(rs.getFloat("offlineVolLevel")); + binf.setBattFloatCurrent(rs.getFloat("battFloatCurrent"));*/ + binf.setMonCount(rs.getInt("monCount")); + binf.setMonCapStd(rs.getFloat("monCapStd")); + binf.setMonVolStd(rs.getFloat("monVolStd")); + binf.setMonResStd(rs.getFloat("monResStd")); + binf.setMonSerStd(rs.getFloat("monSerStd")); + /*binf.setMonVolLowToAvg(rs.getFloat("monVolLowToAvg")); + binf.setBattProducer(rs.getString("battProducer")); + binf.setBattModel(rs.getString("battModel")); + binf.setBattProductDate(rs.getDate("battProductDate")); + binf.setBattInUseDate(rs.getDate("battInUseDate")); + binf.setInstall_user(rs.getString("install_user"));*/ + binf.setLoad_curr(rs.getFloat("load_curr")); + + binf.setDisCurrMax(rs.getFloat("disCurrMax")); + /*binf.setStation_phone(rs.getString("station_phone")); + binf.setStation_install(rs.getInt("station_install"));*/ + + + binf.setStationName9(rs.getString("dev_version")); + list.add(binf); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return list; + } + }); + /*//鍘绘帀limit鏉′欢鍚庣殑鎬绘暟 + int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql); + //System.out.println("number: "+number); + if(list!=null&&list.size()>0){ + list.get(list.size()-1).setNum(number); + }*/ + return list; + } + //鎵归噺璁剧疆鏀剧數鍙傛暟鏃讹紝鏍规嵁鐪佸競鍖猴紝鐢垫睜鍗曚綋鍨嬪彿锛堜紡鏁帮級锛岀粍鏁扮瓫閫夊嚭鐢垫睜缁� + public List serchByBatt_param(Object obj) { + BattInf binf=(BattInf) obj; + //Page page=binf.getPage(); + /*Connection conn=DBUtil.getConn(); + String numberSql=" SELECT FOUND_ROWS() number";SQL_CALC_FOUND_ROWS*/ + String sql=" select distinct(db_battinf.tb_battinf.StationId),StationName,StationName1,StationName2,StationName3,StationName4,StationName5,StationIp,FBSDeviceId," + + "FBSDeviceName,battGroupNum" + + ",MonCount,MonCapStd,monVolStd,monResStd,MonSerStd,Load_curr,DisCurrMax,montmpstd,floatVolLevel,offlineVolLevel,battFloatCurrent" + + ",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 MonVolStd=? and Station_install=1 "; + //+ " limit ?,? ";StationName1 like ? and StationName2 like ? and StationName3 like ? and StationName5 like ? " + //,(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%", + //鏉′欢 + String sql0=" and db_battinf.tb_battinf.stationid=? "; //鍏蜂綋鏈烘埧 + String sql1=" and stationname1=? ";//鐪� + String sql2=" and stationname2=? ";//甯� + String sql5=" and stationname5=? ";//鍖哄幙 + switch (binf.getNum()) { + case 0: + sql+=sql0; + break; + case 1: + sql+=sql1; + break; + case 2: + sql+=sql2; + break; + case 5: + sql+=sql5; + break; + default: + return null; + } + + //鎺掑簭 + String orderSql=" order by StationId asc,GroupIndexInFBSDevice asc "; + sql+=orderSql; + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[] {binf.getMonVolStd(),binf.getStationName()}, new CallBack() { + + @Override + public List getResults(ResultSet rs) { + List list=new ArrayList(); + try { + while(rs.next()) { + BattInf binf = new BattInf(); + binf.setNum(0); + binf.setStationId(rs.getString("stationId")); + binf.setStationName(rs.getString("stationName")); + binf.setStationName1(rs.getString("stationName1")); + binf.setStationName2(rs.getString("stationName2")); + binf.setStationName3(rs.getString("stationName3")); + binf.setStationName4(rs.getString("stationName4")); + binf.setStationName5(rs.getString("stationName5")); + binf.setStationIp(rs.getString("stationIp")); + binf.setFBSDeviceId(rs.getInt("fBSDeviceId")); + + /*binf.setFbsDeviceIp(rs.getString("fbsDeviceIp")); + binf.setFbsDeviceIp_YM(rs.getString("fbsDeviceIp_YM")); + binf.setFbsDeviceIp_WG(rs.getString("fbsDeviceIp_WG"));*/ + binf.setFBSDeviceName(rs.getString("fBSDeviceName")); + binf.setBattGroupNum(rs.getInt("battGroupNum")); + + binf.setFloatVolLevel(rs.getFloat("floatVolLevel")); + binf.setOfflineVolLevel(rs.getFloat("offlineVolLevel")); + binf.setBattFloatCurrent(rs.getFloat("battFloatCurrent")); + binf.setMonCount(rs.getInt("monCount")); + binf.setMonCapStd(rs.getFloat("monCapStd")); + binf.setMonVolStd(rs.getFloat("monVolStd")); + binf.setMonResStd(rs.getFloat("monResStd")); + binf.setMonSerStd(rs.getFloat("monSerStd")); + binf.setMonTmpStd(rs.getFloat("monTmpStd")); + /*binf.setMonVolLowToAvg(rs.getFloat("monVolLowToAvg")); + binf.setBattProducer(rs.getString("battProducer")); + binf.setBattModel(rs.getString("battModel")); + binf.setBattProductDate(rs.getDate("battProductDate")); + binf.setBattInUseDate(rs.getDate("battInUseDate")); + binf.setInstall_user(rs.getString("install_user"));*/ + binf.setLoad_curr(rs.getFloat("load_curr")); + + binf.setDisCurrMax(rs.getFloat("disCurrMax")); + /*binf.setStation_phone(rs.getString("station_phone")); + binf.setStation_install(rs.getInt("station_install"));*/ + + + binf.setStationName9(rs.getString("dev_version")); + list.add(binf); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return list; + } + }); + /*//鍘绘帀limit鏉′欢鍚庣殑鎬绘暟 + int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql); + //System.out.println("number: "+number); + if(list!=null&&list.size()>0){ + list.get(list.size()-1).setNum(number); + }*/ + return list; + } + //鎵归噺璁剧疆绯荤粺鍙傛暟鏃讹紝鏍规嵁鐪佸競鍖猴紝鐢垫睜鍗曚綋鍨嬪彿锛堜紡鏁帮級锛岀粍鏁扮瓫閫夊嚭鐢垫睜缁�<杩橀渶瑕佽幏鍙栧疄闄呭閲�> + public List serchBySys_param(Object obj) { + BattInf binf=(BattInf) obj; + //Page page=binf.getPage(); + /*Connection conn=DBUtil.getConn(); + String numberSql=" SELECT FOUND_ROWS() number";SQL_CALC_FOUND_ROWS*/ + String sql=" select distinct(tb_battinf.StationId),StationName,StationName1,StationName2,StationName3,StationName4,StationName5,StationIp,FBSDeviceId," + + "FBSDeviceName,count(FBSDeviceId) as batt_num" + + ",MonCount,monVolStd,monResStd,MonSerStd,Load_curr,DisCurrMax,montmpstd,floatVolLevel,offlineVolLevel,battFloatCurrent" + + ",GROUP_CONCAT(tb_battinf.MonCapStd order by groupIndexInFBSDevice separator '/' ) as moncapstds " + + ",db_ram_db.tb_fbs9100_state.dev_version" + + ",web_site.tb_batt_endurance.real_cap_group1 ,web_site.tb_batt_endurance.real_cap_group2,web_site.tb_batt_endurance.real_cap_group3,web_site.tb_batt_endurance.real_cap_group4 " + + " from db_battinf.tb_battinf,db_ram_db.tb_fbs9100_state,web_site.tb_batt_endurance " + + " where db_battinf.tb_battinf.FBSDeviceId=db_ram_db.tb_fbs9100_state.dev_id " + + " and db_battinf.tb_battinf.FBSDeviceId=web_site.tb_batt_endurance.deviceid " + + " and MonVolStd=? and Station_install=1 "; + //+ " limit ?,? ";StationName1 like ? and StationName2 like ? and StationName3 like ? and StationName5 like ? " + //,(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize(),"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%", + //鏉′欢 + String sql0=" and db_battinf.tb_battinf.stationid=? "; //鍏蜂綋鏈烘埧 + String sql1=" and stationname1=? ";//鐪� + String sql2=" and stationname2=? ";//甯� + String sql5=" and stationname5=? ";//鍖哄幙 + switch (binf.getNum()) { + case 0: + sql+=sql0; + break; + case 1: + sql+=sql1; + break; + case 2: + sql+=sql2; + break; + case 5: + sql+=sql5; + break; + default: + return null; + } + + //鎺掑簭 + String orderSql=" GROUP BY FBSDeviceId order by StationId asc,GroupIndexInFBSDevice asc "; + sql+=orderSql; + //System.out.println(sql); + List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[] {binf.getMonVolStd(),binf.getStationName()}, new CallBack() { + + @Override + public List getResults(ResultSet rs) { + List list=new ArrayList(); + try { + while(rs.next()) { + BattInf binf = new BattInf(); + binf.setNum(0); + binf.setStationId(rs.getString("stationId")); + binf.setStationName(rs.getString("stationName")); + binf.setStationName1(rs.getString("stationName1")); + binf.setStationName2(rs.getString("stationName2")); + binf.setStationName3(rs.getString("stationName3")); + binf.setStationName4(rs.getString("stationName4")); + binf.setStationName5(rs.getString("stationName5")); + binf.setStationIp(rs.getString("stationIp")); + binf.setFBSDeviceId(rs.getInt("fBSDeviceId")); + + /*binf.setFbsDeviceIp(rs.getString("fbsDeviceIp")); + binf.setFbsDeviceIp_YM(rs.getString("fbsDeviceIp_YM")); + binf.setFbsDeviceIp_WG(rs.getString("fbsDeviceIp_WG"));*/ + binf.setFBSDeviceName(rs.getString("fBSDeviceName")); + binf.setBattGroupNum(rs.getInt("batt_num")); + + binf.setFloatVolLevel(rs.getFloat("floatVolLevel")); + binf.setOfflineVolLevel(rs.getFloat("offlineVolLevel")); + binf.setBattFloatCurrent(rs.getFloat("battFloatCurrent")); + binf.setMonCount(rs.getInt("monCount")); + //binf.setMonCapStd(rs.getFloat("monCapStd")); + + binf.setMoncapstds(rs.getString("moncapstds")); + binf.setReal_cap_group1(rs.getFloat("real_cap_group1")); + binf.setReal_cap_group2(rs.getFloat("real_cap_group2")); + binf.setReal_cap_group3(rs.getFloat("real_cap_group3")); + binf.setReal_cap_group4(rs.getFloat("real_cap_group4")); + + binf.setMonVolStd(rs.getFloat("monVolStd")); + binf.setMonResStd(rs.getFloat("monResStd")); + binf.setMonSerStd(rs.getFloat("monSerStd")); + binf.setMonTmpStd(rs.getFloat("monTmpStd")); + /*binf.setMonVolLowToAvg(rs.getFloat("monVolLowToAvg")); + binf.setBattProducer(rs.getString("battProducer")); + binf.setBattModel(rs.getString("battModel")); + binf.setBattProductDate(rs.getDate("battProductDate")); + binf.setBattInUseDate(rs.getDate("battInUseDate")); + binf.setInstall_user(rs.getString("install_user"));*/ + binf.setLoad_curr(rs.getFloat("load_curr")); + + binf.setDisCurrMax(rs.getFloat("disCurrMax")); + /*binf.setStation_phone(rs.getString("station_phone")); + binf.setStation_install(rs.getInt("station_install"));*/ + + + binf.setStationName9(rs.getString("dev_version")); + list.add(binf); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return list; + } + }); + /*//鍘绘帀limit鏉′欢鍚庣殑鎬绘暟 + int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql); + //System.out.println("number: "+number); + if(list!=null&&list.size()>0){ + list.get(list.size()-1).setNum(number); + }*/ + return list; + } public static void main(String[] args) throws ParseException { //new BattInfImpl().searchAll(); BattInfImpl biml = new BattInfImpl(); BattInf binf = new BattInf(); - binf.setNum(1002); + binf.setNum(0); binf.setBattGroupId(1000001); - binf.setStationName("骞胯タ鐪�-鐧捐壊-GX鐧捐壊涔愪笟鍘跨珛鏂板皬鍖篧F-BTS璁惧"); + binf.setStationName("42000611"); binf.setStationName1(""); binf.setStationName2(""); binf.setStationName3(""); + binf.setStationName5(""); binf.setBattGroupName(""); binf.setBattProducer("1"); binf.setStationId("42000575"); + binf.setGroupIndexInFBSDevice(0); + binf.setMonVolStd(12f); User_inf uinf=new User_inf(); uinf.setUId(1002); @@ -4395,8 +4765,19 @@ System.out.println(list.size());*/ /*int nums=biml.serchByInstall_count(uinf); System.out.println(nums);*/ - boolean bl=biml.judgeBattInOrNot(binf); - System.out.println(bl); + /*boolean bl=biml.judgeBattInOrNot(binf); + System.out.println(bl);*/ + List<BattInf> list=biml.serchBySys_param(binf); + for (BattInf b : list) { + System.out.println(b); + } + /*List<BattInf> list=biml.serchByDischarge(binf); + for (BattInf b : list) { + System.out.println(b); + }*/ + /*List list=biml.judgeBatt(binf); + System.out.println(list);*/ + //System.out.println(list.size()); } public List getResults(ResultSet rs) { -- Gitblit v1.9.1