| | |
| | |
|
| | | 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;
|
| | |
| | | //获取当前最大的stationid和battgroupid
|
| | | int maxs=42000000;//最大stationid
|
| | | int maxb=1000001;//最大battgroupid
|
| | | 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);
|
| | |
| | | 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()+"," +
|
| | |
| | | boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, null);
|
| | | return bl;
|
| | | }
|
| | | |
| | | //设置电池组充电电流阈值
|
| | | public boolean update_charge(Object obj){
|
| | | BattInf binf=(BattInf) obj;
|
| | | String sql = "update db_battinf.tb_battinf set charge_curr_max=? where BattGroupId=?";
|
| | | boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{binf.getCharge_curr_max(),binf.getBattGroupId()});
|
| | | return bl;
|
| | | }
|
| | | //删除电池组(多个)
|
| | | public boolean del(Object obj) {
|
| | | List<BattInf> list=(List<BattInf>) obj;
|
| | |
| | | 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) {
|
| | |
| | |
|
| | | 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
|
| | |
| | | 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){
|
| | |
| | | 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) {
|
| | |
| | | }
|
| | | 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
|
| | |
| | | });
|
| | | 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;
|
| | | }
|
| | | //-----------根据蓄电池组查不重复的MonCount(monNum)(单体编号)
|
| | | public List serchByMonNum(Object obj){
|
| | |
| | | " where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " +
|
| | | " and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " +
|
| | | " and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " +
|
| | | " and db_user.tb_user_inf.uid=?" +
|
| | | " and db_user.tb_user_inf.uid=? and db_battinf.tb_battinf.Station_install=1 " +
|
| | | " limit 1";
|
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() {
|
| | |
|
| | |
| | | //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) {
|