package com.fgkj.dao.impl; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; 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.LimitNumberFactory; import com.fgkj.dao.UinfDaoFactory; import com.fgkj.db.DBUtil; import com.fgkj.dto.BattInf; import com.fgkj.dto.Battinf_apply; import com.fgkj.dto.Page; import com.fgkj.dto.User_inf; import com.fgkj.dto.User_log; import com.fgkj.dto.ram.FBS9100; import com.fgkj.dto.ram.Fbs9100_state; import com.fgkj.services.User_logService; public class Battinf_applyImpl implements BaseDAO,CallBack{ public List getResults(ResultSet rs) { // TODO Auto-generated method stub return null; } //添加申请 public boolean add(Object obj) { List list=(List) obj; List listU=new ArrayList();//存放user_log ArrayList sql_str=new ArrayList(); //获取当前最大的stationid和battgroupid int maxs=BattinfGroupFactory.searchStationId(); int maxb=BattinfGroupFactory.searchMaxBattgroupId(); if(list!=null && list.size()>0){ for (int i = 0; i < list.size(); i++) { Battinf_apply bapply=list.get(i); int uid=((User_inf)ActionUtil.getUser()).getUId(); bapply.setApply_uid(uid); BattInf binf=bapply.getBinf(); //验证新添加的机房是否存在 List listS=(new BattInfImpl()).judgeBatt(binf); if(listS!=null&&listS.size()>0){ binf.setStationId((String) listS.get(listS.size()-1)); }else{ binf.setStationId(String.valueOf(maxs)); } binf.setBattGroupId(maxb); String sql = "insert into db_battinf.tb_battinf_apply(" + "apply_uid,apply_date,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" + ") values("+bapply.getApply_uid()+",'"+DAOHelper.sdf.format(bapply.getApply_date())+"','"+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()+"')"; if(binf.getStationId().equals(maxs)){ maxs++; } maxb++; sql_str.add(sql); { String msg=((User_inf)ActionUtil.getUser()).getUId()+"申请添加"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的信息"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg); listU.add(ulog); } } } Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); (new User_logService()).addPro(listU);//将用户的操作记录下来 return bl; } //确认申请(多条) public boolean update(Object obj) { List list=(List) obj; List listU=new ArrayList();//存放user_log ArrayList sql_str=new ArrayList(); if(list!=null&&list.size()>0){ for (int i = 0; i < list.size(); i++) { Battinf_apply bapply=list.get(i); bapply.setConfrim_uid(((User_inf)ActionUtil.getUser()).getUId()); BattInf binf=bapply.getBinf(); binf.setStation_install(1); String sql_update_apply=" update db_battinf.tb_battinf_apply set confrim_uid="+bapply.getConfrim_uid()+",apply_en=1 where battgrouoid="+binf.getBattGroupId(); sql_str.add(sql_update_apply); String sql_insert_binf="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,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.getStation_install()+")"; sql_str.add(sql_insert_binf); { String msg="确认添加"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的信息"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); listU.add(ulog); } } } Boolean bl=false; boolean en=BattinfGroupFactory.backup_battinf(); if(en){ bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); }else{ return false; } (new User_logService()).addPro(listU);//将用户的操作记录下来 return bl; } //验收申请(多条) public boolean check(Object obj) { List list=(List) obj; List listU=new ArrayList();//存放user_log ArrayList sql_str=new ArrayList(); if(list!=null&&list.size()>0){ for (int i = 0; i < list.size(); i++) { Battinf_apply bapply=list.get(i); BattInf binf=bapply.getBinf(); bapply.setCheck_uid(((User_inf)ActionUtil.getUser()).getUId()); String sql_update_apply=" update db_battinf.tb_battinf_apply set check_uid="+bapply.getCheck_uid()+",check_en=1 where battgrouoid="+binf.getBattGroupId(); sql_str.add(sql_update_apply); { String msg="验收"+binf.getStationName()+"机房"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); listU.add(ulog); } } } Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); (new User_logService()).addPro(listU);//将用户的操作记录下来 return bl; } //申请人再我的申请页面的修改操作 public boolean updatePro(Object obj){ List list=(List) obj; List listU=new ArrayList();//存放user_log ArrayList sql_str=new ArrayList(); if(list!=null&&list.size()>0){ for (int i = 0; i < list.size(); i++) { Battinf_apply bapply=list.get(i); bapply.setApply_uid(((User_inf)ActionUtil.getUser()).getUId()); BattInf binf=bapply.getBinf(); //System.out.println(binf); /* String sql_update_apply= "update db_battinf.tb_battinf_apply set StationName='"+binf.getStationName()+"',StationName1='"+binf.getStationName1()+"',StationName2='"+binf.getStationName2()+"',StationName3='"+binf.getStationName3()+"',StationName4='"+binf.getStationName4()+"',StationName5='"+binf.getStationName5()+"',StationIp='"+binf.getStationIp()+"'," + "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 num="+bapply.getNum(); */ String sql_update_apply = "replace into db_battinf.tb_battinf_apply(" + "apply_uid,apply_date,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" + ") values("+bapply.getApply_uid()+",'"+DAOHelper.sdf.format(bapply.getApply_date())+"','"+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()+"')"; sql_str.add(sql_update_apply); { String msg="修改申请的"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的信息"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); listU.add(ulog); } } } Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); (new User_logService()).addPro(listU);//将用户的操作记录下来 return bl; } //我的申请中取消申请多条 public boolean del(Object obj) { List list=(List) obj; List listU=new ArrayList();//存放user_log ArrayList sql_str=new ArrayList(); if(list!=null&&list.size()>0){ for (int i = 0; i < list.size(); i++) { Battinf_apply bapply=list.get(i); BattInf binf=bapply.getBinf(); String sql_del_apply=" delete from db_battinf.tb_battinf_apply where battgroupid="+binf.getBattGroupId(); sql_str.add(sql_del_apply); { String msg="取消"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的申请"; User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); listU.add(ulog); } } } Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); (new User_logService()).addPro(listU);//将用户的操作记录下来 return bl; } public List searchAll() { return null; } //查询出所有需要确认的申请 public List serchByCondition(Object obj) { Page page=(Page) obj; Connection conn=DBUtil.getConn(); String numberSql=" SELECT FOUND_ROWS() number"; String sql=" select SQL_CALC_FOUND_ROWS distinct num,apply_uid,confrim_uid,check_uid,check_en,apply_date,apply_en,apply_note,StationId,StationName,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 " + " from db_battinf.tb_battinf_apply " + " where apply_en=0 order by apply_date desc" + " limit ?,? "; List 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(); try { while(rs.next()){ Battinf_apply apply=new Battinf_apply(); apply.setNum(rs.getInt("num")); apply.setApply_uid(rs.getInt("apply_uid")); apply.setApply_name((new User_infImpl()).changeUidToUname(apply.getApply_uid())); apply.setConfrim_uid(rs.getInt("confrim_uid")); apply.setConfirm_name((new User_infImpl()).changeUidToUname(apply.getConfrim_uid())); apply.setApply_en(rs.getInt("apply_en")); apply.setCheck_uid(rs.getInt("check_uid")); apply.setCheck_en(rs.getInt("check_en")); apply.setCheck_uname((new User_infImpl()).changeUidToUname(apply.getCheck_en())); apply.setApply_date(rs.getTimestamp("apply_date")); apply.setApply_note(rs.getString("apply_note")); BattInf binf=new BattInf(); 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.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.setLoad_curr(rs.getFloat("load_curr")); binf.setInstall_user(rs.getString("install_user")); binf.setDisCurrMax(rs.getFloat("disCurrMax")); binf.setStation_phone(rs.getString("station_phone")); apply.setBinf(binf); list.add(apply); } } 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).setApply_note(String.valueOf(number)); } return list; } //查询出当前存在内存中最大的设备的id(很重要**********) public int searchMaxdevId_apply(){ String sql="select max(FbsDeviceId) as id from db_battinf.tb_battinf_apply 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 dev_id=0; if(rs.getString("id")!=null){ dev_id=rs.getInt("id"); } list.add(dev_id); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); int dev_id=0; if(list!=null&&list.size()>0){ dev_id=(Integer) list.get(list.size()-1); } return dev_id; } //查询出当前存在内存中最大的stationid很重要**********) public int searchMaxId_apply(){ String sql="select max(StationId) as id from db_battinf.tb_battinf_apply 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 id=0; if(rs.getString("id") != null){ id=Integer.parseInt(rs.getString("id")); } list.add(id); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); int stationid=0; if(list!=null&&list.size()>0){ stationid=(Integer) list.get(list.size()-1); } return stationid; } //查询出当前存在内存中最大的电池组的id(很重要**********) public int searchMaxBattgroupId_apply(){ String sql=" select max(battgroupId) as id from db_battinf.tb_battinf_apply 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=0; 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 serchByInfo(Object obj) { Battinf_apply bapply=(Battinf_apply) obj; BattInf b=bapply.getBinf(); Page page=b.getPage(); Connection conn=DBUtil.getConn(); String numberSql=" SELECT FOUND_ROWS() number"; String sql=" select SQL_CALC_FOUND_ROWS distinct num,apply_uid,confrim_uid,apply_date,apply_en,apply_note,StationId,StationName,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 " + " from db_battinf.tb_battinf_apply " + " where apply_en=? and apply_uid=? order by apply_date desc " + " limit ?,? "; List list=DAOHelper.executeQueryLimit(sql, conn, new Object[]{bapply.getApply_en(),bapply.getNum(),(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Battinf_apply apply=new Battinf_apply(); apply.setNum(rs.getInt("num")); apply.setApply_uid(rs.getInt("apply_uid")); apply.setApply_name((new User_infImpl()).changeUidToUname(apply.getApply_uid())); apply.setConfrim_uid(rs.getInt("confrim_uid")); apply.setConfirm_name((new User_infImpl()).changeUidToUname(apply.getConfrim_uid())); apply.setApply_en(rs.getInt("apply_en")); apply.setApply_date(rs.getTimestamp("apply_date")); apply.setApply_note(rs.getString("apply_note")); BattInf binf=new BattInf(); 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.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.setLoad_curr(rs.getFloat("load_curr")); binf.setInstall_user(rs.getString("install_user")); binf.setDisCurrMax(rs.getFloat("disCurrMax")); binf.setStation_phone(rs.getString("station_phone")); apply.setBinf(binf); list.add(apply); } } 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).setApply_note(String.valueOf(number)); } return list; } //申请人修改待审核的申请时的查询 public List serchbystationId(Object obj){ Battinf_apply bapply=(Battinf_apply) obj; BattInf b=bapply.getBinf(); String sql=" select distinct num,apply_uid,confrim_uid,apply_date,apply_en,apply_note,StationId,StationName,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 " + " from db_battinf.tb_battinf_apply " + " where apply_en=0 and apply_uid=? and stationid=? order by apply_date desc " ; List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{bapply.getNum(),b.getStationId()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Battinf_apply apply=new Battinf_apply(); apply.setNum(rs.getInt("num")); apply.setApply_uid(rs.getInt("apply_uid")); apply.setApply_name((new User_infImpl()).changeUidToUname(apply.getApply_uid())); apply.setConfrim_uid(rs.getInt("confrim_uid")); apply.setConfirm_name((new User_infImpl()).changeUidToUname(apply.getConfrim_uid())); apply.setApply_en(rs.getInt("apply_en")); apply.setApply_date(rs.getTimestamp("apply_date")); apply.setApply_note(rs.getString("apply_note")); BattInf binf=new BattInf(); 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.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.setLoad_curr(rs.getFloat("load_curr")); binf.setInstall_user(rs.getString("install_user")); binf.setDisCurrMax(rs.getFloat("disCurrMax")); binf.setStation_phone(rs.getString("station_phone")); apply.setBinf(binf); list.add(apply); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); return list; } //判断新增的电池组是否存在 public boolean judgeBattInOrNot(Object obj){ BattInf binf=(BattInf) obj; String sql="select distinct stationid from db_battinf.tb_battinf_apply where stationname=? limit 1"; List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getStationName()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ String stationid=rs.getString("stationid"); list.add(stationid); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); if(list!=null&&list.size()>0){ return true; }else{ return false; } } //申请表中已审批通过的设备连接数 public List devCommNum() { String sql=" select distinct db_battinf.tb_battinf_apply.FbsDeviceId,dev_commcount " + " from db_battinf.tb_battinf_apply,db_ram_db.tb_fbs9100_state " + " where apply_en=1 and db_battinf.tb_battinf_apply.FbsDeviceId=db_ram_db.tb_fbs9100_state.dev_id " + " order by apply_date desc" ; List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { @Override public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()) { Fbs9100_state fbs=new Fbs9100_state(); fbs.setDev_id(rs.getInt("FbsDeviceId")); fbs.setDev_commcount(rs.getInt("dev_commcount")); list.add(fbs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } }); return list; } public static void main(String[] args) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date1 = sdf.parse("2000-01-01 00:00:00"); Date date2 = sdf.parse("2020-01-01 23:59:59"); Battinf_applyImpl bimpl=new Battinf_applyImpl(); Battinf_apply bapply=new Battinf_apply(); bapply.setApply_date(ActionUtil.getSimpDate(date2)); bapply.setApply_uid(1002); BattInf binf=new BattInf(); binf.setStationName("广西省-百色-GX百色乐业县立新小区WF-BTS设备"); binf.setStationName1("湖北省"); binf.setStationName2("荆门市"); binf.setStationName3("测试设备机房2"); binf.setStationName4("BTS设备"); binf.setStationName5("沙洋县"); binf.setStationId("4011100"); binf.setStationIp(""); binf.setFBSDeviceId(910001000); binf.setFbsDeviceIp("127.0.0.1"); binf.setFbsDeviceIp_YM("255.255.255.0"); binf.setFbsDeviceIp_WG("127.0.0.1"); binf.setFBSDeviceName("设备名称"); binf.setGroupIndexInFBSDevice(1); binf.setBattGroupId(1000005); binf.setBattGroupNum(2); binf.setBattGroupName("电池组1"); binf.setFloatVolLevel(54f); binf.setOfflineVolLevel(42.9f ); binf.setBattFloatCurrent(10f); binf.setMonCount(24); binf.setMonCapStd(300f); binf.setMonVolStd(2f); binf.setMonResStd(0.2f); binf.setMonSerStd(5000f); binf.setMonVolLowToAvg(0.05f ); binf.setLoad_curr(15f); binf.setDisCurrMax(39.5f); binf.setStation_phone("98765432198"); binf.setBattProducer(""); binf.setBattModel(""); binf.setBattProductDate(ActionUtil.getSimpDate(date1)); binf.setBattInUseDate(ActionUtil.getSimpDate(date2)); binf.setInstall_user(""); Page page=new Page(); page.setPageCurr(1); page.setPageSize(10); binf.setPage(page); bapply.setBinf(binf); /*List list=bimpl.serchByCondition(page); System.out.println(list.size());*/ /*List list=new ArrayList(); list.add(bapply); boolean bl=bimpl.add(list); System.err.println(bl);*/ /*int dev_id=BattinfGroupFactory.searchmaxdev_id(); System.out.println(dev_id); int station_id=BattinfGroupFactory.searchStationId(); System.out.println(station_id); int battgroup_id=BattinfGroupFactory.searchMaxBattgroupId(); System.out.println(battgroup_id);*/ /*boolean bl=bimpl.judgeBattInOrNot(binf); System.out.println(bl);*/ /*List list=bimpl.devCommNum(); for (Fbs9100_state f : list) { System.out.println(f.getDev_id()+" "+f.getDev_commcount()); }*/ } }