package com.fgkj.dao.impl.Ld9; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.fgkj.dao.BaseDAO; import com.fgkj.dao.BattTestData; import com.fgkj.dao.CallBack; import com.fgkj.dao.DAOHelper; import com.fgkj.db.DBUtil; import com.fgkj.dto.Batttestdata_inf; import com.fgkj.dto.Ld9testdata_inf; public class Ld9testdata_infImpl implements BaseDAO,CallBack{ public List getResults(ResultSet rs) { // TODO Auto-generated method stub return null; } public boolean add(Object obj) { // TODO Auto-generated method stub return false; } public boolean update(Object obj) { // TODO Auto-generated method stub return false; } public boolean del(Object obj) { // TODO Auto-generated method stub return false; } public List searchAll() { // TODO Auto-generated method stub return null; } //历史数据查询 public List serchByCondition(Object obj) { Ld9testdata_inf ld9_inf=(Ld9testdata_inf)obj; String sql="select num,BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,record_num,test_starttime,test_starttime_ex,record_time,test_timelong,test_stoptype,test_stopreason,group_vol,test_curr,test_cap,mon_num,mon_vol,max_monvol,min_monvol " + " from db_ld9_testdata.tb_ld9testdata_inf where BattGroupId=? " + " order by test_starttime desc "; List list= DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{ld9_inf.getBattGroupId()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Ld9testdata_inf ld9=new Ld9testdata_inf(); ld9.setNum(rs.getInt("num")); ld9.setBattGroupId(rs.getInt("BattGroupId")); ld9.setTest_record_count(rs.getInt("test_record_count")); ld9.setTest_record_count_ex(rs.getInt("test_record_count_ex")); ld9.setTest_type(rs.getInt("test_type")); ld9.setRecord_time_interval(rs.getInt("record_time_interval")); ld9.setRecord_num(rs.getInt("record_num")); ld9.setTest_starttime(rs.getTimestamp("test_starttime")); ld9.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex")); ld9.setRecord_time(rs.getTimestamp("record_time")); ld9.setTest_timelong(rs.getInt("test_timelong")); ld9.setTest_stoptype(rs.getInt("test_stoptype")); //放电终止原因 ld9.setTest_stopreason(rs.getInt("test_stopreason")); ld9.setGroup_vol(rs.getFloat("group_vol")); ld9.setTest_curr(rs.getFloat("test_curr")); ld9.setTest_cap(rs.getFloat("test_cap")); ld9.setMon_num(rs.getInt("mon_num")); ld9.setMon_vol(rs.getFloat("mon_vol")); ld9.setMax_monvol(rs.getFloat("max_monvol")); ld9.setMin_monvol(rs.getFloat("min_monvol")); list.add(ld9); //System.out.println(b); } } catch (SQLException e) { e.printStackTrace(); } return list; } }); return list; } //历史数据查询(根据电池组id查询所有的放电单体) public List serchByInfo(Object obj) { Ld9testdata_inf ld9_inf=(Ld9testdata_inf)obj; String sql="select distinct BattGroupId,mon_num,count(test_record_count) as nums " + " from db_ld9_testdata.tb_ld9testdata_inf where BattGroupId=? " + " group BY mon_num " + " order by mon_num asc "; List list= DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{ld9_inf.getBattGroupId()}, new CallBack() { public List getResults(ResultSet rs) { List list=new ArrayList(); try { while(rs.next()){ Ld9testdata_inf ld9=new Ld9testdata_inf(); ld9.setBattGroupId(rs.getInt("BattGroupId")); ld9.setMon_num(rs.getInt("mon_num")); ld9.setNum(rs.getInt("nums")); list.add(ld9); //System.out.println(b); } } catch (SQLException e) { e.printStackTrace(); } return list; } }); return list; } public static void main(String[] args) { Ld9testdata_infImpl limpl=new Ld9testdata_infImpl(); Ld9testdata_inf ld9=new Ld9testdata_inf(); ld9.setBattGroupId(1000006); List list=limpl.serchByInfo(ld9); for (Ld9testdata_inf ld : list) { System.out.println(ld); } } }