| | |
| | | //续航时间的查询
|
| | | public List serchByCondition(Object obj) {
|
| | | Batt_endurance bendurance=(Batt_endurance) obj;
|
| | | String sql="select distinct num,deviceid,tb_batt_endurance.stationid,endurance_state,real_cap,tb_batt_endurance.moncapstd,real_curr,endurance_timelong " +
|
| | | ",db_battinf.tb_battinf.StationName " +
|
| | | String sql="select distinct tb_batt_endurance.num,tb_batt_endurance.deviceid,tb_batt_endurance.stationid,real_cap,tb_batt_endurance.moncapstd,real_curr,endurance_theory_timelong,endurance_actual_timelong,is_out_stand " +
|
| | | ",db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.StationName1,db_battinf.tb_battinf.StationName2 " +
|
| | | " from web_site.tb_batt_endurance,db_battinf.tb_battinf " +
|
| | | " where tb_batt_endurance.stationid=db_battinf.tb_battinf.stationid " ;
|
| | | //机房筛选
|
| | | String stationSql=" and tb_batt_endurance.stationid like ?";
|
| | | String stationSql=" and db_battinf.tb_battinf.StationName like ? and db_battinf.tb_battinf.StationName1 like ? and db_battinf.tb_battinf.StationName2 like ?";
|
| | | sql+=stationSql;
|
| | | //续航状态
|
| | | String enduranceSqlT=" and endurance_state=? ";
|
| | | String enduranceSqlF=" and endurance_state!=? ";//全部
|
| | | if(bendurance.getEndurance_state()==0){
|
| | | sql+=enduranceSqlF;
|
| | | }else{
|
| | | sql+=enduranceSqlT;
|
| | | }
|
| | | //续航时间
|
| | | String timelongSqlT=" and endurance_timelong<=? ";//小于某一时间
|
| | | String timelongSqlF=" and endurance_timelong!=?";//全部
|
| | | if(bendurance.getEndurance_timelong()==0){
|
| | | //实际续航时间
|
| | | String timelongSqlT=" and endurance_actual_timelong<=? ";//小于某一时间
|
| | | String timelongSqlF=" and endurance_actual_timelong!=? ";//全部
|
| | | if(bendurance.getEndurance_actual_timelong()==0){
|
| | | sql+=timelongSqlF;
|
| | | }else{
|
| | | sql+=timelongSqlT;
|
| | | }
|
| | | //是否掉站
|
| | | String is_out_standSqlT=" and is_out_stand!=? ";//全部
|
| | | String is_out_standSqlF=" and is_out_stand=? ";
|
| | | if(bendurance.getIs_out_stand()==100){
|
| | | sql+=is_out_standSqlT;
|
| | | }else{
|
| | | sql+=is_out_standSqlF;
|
| | | }
|
| | | //排序时间
|
| | | String orderSql=" order by endurance_timelong asc";
|
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+bendurance.getStationid()+"%",bendurance.getEndurance_state(),bendurance.getEndurance_timelong()}, new CallBack() {
|
| | | String orderSql=" order by endurance_actual_timelong asc ";
|
| | | sql+=orderSql;
|
| | | //System.out.println(sql);
|
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+bendurance.getStationName()+"%","%"+bendurance.getStationName1()+"%","%"+bendurance.getStationName2()+"%",bendurance.getEndurance_actual_timelong(),bendurance.getIs_out_stand()}, new CallBack() {
|
| | |
|
| | | public List getResults(ResultSet rs) {
|
| | | List list=new ArrayList();
|
| | |
| | | b.setNum(rs.getInt("num"));
|
| | | b.setDeviceId(rs.getInt("deviceId"));
|
| | | b.setStationid(rs.getString("stationid"));
|
| | | b.setEndurance_state(rs.getInt("endurance_state"));
|
| | | b.setReal_cap(rs.getFloat("real_cap"));
|
| | | b.setMoncapstd(rs.getFloat("moncapstd"));
|
| | | b.setReal_curr(rs.getFloat("real_curr"));
|
| | | b.setEndurance_timelong(rs.getInt("endurance_timelong"));
|
| | | b.setNote(rs.getString("stationname"));
|
| | | b.setEndurance_theory_timelong(rs.getInt("endurance_theory_timelong"));
|
| | | b.setEndurance_actual_timelong(rs.getInt("endurance_actual_timelong"));
|
| | | b.setStationName(rs.getString("stationname"));
|
| | | b.setStationName1(rs.getString("stationname1"));
|
| | | b.setStationName2(rs.getString("stationname2"));
|
| | | list.add(b);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | |
| | | // TODO Auto-generated method stub
|
| | | return null;
|
| | | }
|
| | | public static void main(String[] args) {
|
| | | Batt_enduranceImpl bimpl=new Batt_enduranceImpl();
|
| | | Batt_endurance ben=new Batt_endurance();
|
| | | ben.setStationName("");
|
| | | ben.setStationName1("");
|
| | | ben.setStationName2("");
|
| | | ben.setEndurance_actual_timelong(120);
|
| | | ben.setIs_out_stand(100);
|
| | | List list=bimpl.serchByCondition(ben);
|
| | | System.out.println(list.size());
|
| | | }
|
| | |
|
| | | }
|