package com.fgkj.dao.impl;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.fgkj.actions.ActionUtil;
|
import com.fgkj.dao.BaseDAO;
|
import com.fgkj.dao.CallBack;
|
import com.fgkj.dao.DAOHelper;
|
import com.fgkj.db.DBUtil;
|
import com.fgkj.dto.Batt_history;
|
import com.opensymphony.xwork2.Action;
|
|
public class Batt_historyImpl implements BaseDAO,CallBack{
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Batt_history batt_his=new Batt_history();
|
batt_his.setNum(rs.getInt("num"));
|
batt_his.setDev_id(rs.getInt("dev_id"));
|
batt_his.setBattGroupId(rs.getInt("battGroupId"));
|
batt_his.setBatt_count(rs.getInt("batt_count"));
|
batt_his.setBatt_state(rs.getInt("batt_state"));
|
batt_his.setRec_datetime(rs.getTimestamp("rec_datetime"));
|
batt_his.setOnline_vol(rs.getFloat("online_vol"));
|
batt_his.setGroup_vol(rs.getFloat("group_vol"));
|
batt_his.setGroup_tmp(rs.getFloat("group_tmp"));
|
batt_his.setGroup_curr(rs.getFloat("group_curr"));
|
batt_his.setMon_vols(rs.getString("mon_vols"));
|
batt_his.setMon_tmps(rs.getString("mon_tmps"));
|
batt_his.setMon_ress(rs.getString("mon_ress"));
|
batt_his.setMon_sers(rs.getString("mon_sers"));
|
batt_his.setMon_conn_ress(rs.getString("mon_conn_ress"));
|
batt_his.setMon_caps(rs.getString("mon_caps"));
|
batt_his.setNote(rs.getString("note"));
|
list.add(batt_his);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
|
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() {
|
String sql="select distinct(num),dev_id,battgroupid,batt_count,batt_state,rec_datetime" +
|
",online_vol,group_vol,group_tmp,group_curr,mon_vols,mon_tmps,mon_ress,mon_sers" +
|
",mon_conn_ress,mon_caps,note " +
|
" from db_batt_history.tb_batt_91000001_2017_12 " +
|
" order by rec_datetime asc";
|
List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Batt_history batt_his=new Batt_history();
|
batt_his.setNum(rs.getInt("num"));
|
batt_his.setDev_id(rs.getInt("dev_id"));
|
batt_his.setBattGroupId(rs.getInt("battGroupId"));
|
batt_his.setBatt_count(rs.getInt("batt_count"));
|
batt_his.setBatt_state(rs.getInt("batt_state"));
|
batt_his.setRec_datetime(rs.getTimestamp("rec_datetime"));
|
batt_his.setOnline_vol(rs.getFloat("online_vol"));
|
batt_his.setGroup_vol(rs.getFloat("group_vol"));
|
batt_his.setGroup_tmp(rs.getFloat("group_tmp"));
|
batt_his.setGroup_curr(rs.getFloat("group_curr"));
|
batt_his.setMon_vols(rs.getString("mon_vols"));
|
batt_his.setMon_tmps(rs.getString("mon_tmps"));
|
batt_his.setMon_ress(rs.getString("mon_ress"));
|
batt_his.setMon_sers(rs.getString("mon_sers"));
|
batt_his.setMon_conn_ress(rs.getString("mon_conn_ress"));
|
batt_his.setMon_caps(rs.getString("mon_caps"));
|
batt_his.setNote(rs.getString("note"));
|
list.add(batt_his);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
return list;
|
}
|
//查询所有的历史实时数据
|
public List serchByCondition(Object obj) {
|
Batt_history batt_his=(Batt_history) obj;
|
int year=ActionUtil.getDateYear(batt_his.getRec_datetime());
|
int month=ActionUtil.getDateMonth(batt_his.getRec_datetime());
|
String sql="";
|
String baseSql="select distinct(num),dev_id,battgroupid,batt_count,batt_state,rec_datetime" +
|
",online_vol,group_vol,group_tmp,group_curr,mon_vols,mon_tmps,mon_ress,mon_sers" +
|
",mon_conn_ress,mon_caps,note " +
|
" from db_batt_history.tb_batt_"+batt_his.getDev_id()+"_"+year+"_"+month+
|
" where battgroupid=? ";
|
//时间条件选择
|
String timeSql=" and rec_datetime>=? and rec_datetime<=? ";
|
//按照时间排序
|
String orderSql=" order by rec_datetime asc";
|
sql=baseSql+timeSql+orderSql;
|
//System.out.println(sql);
|
List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{batt_his.getBattGroupId(),batt_his.getRec_datetime(),batt_his.getRec_datetime1()}, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Batt_history batt_his=new Batt_history();
|
batt_his.setNum(rs.getInt("num"));
|
batt_his.setDev_id(rs.getInt("dev_id"));
|
batt_his.setBattGroupId(rs.getInt("battGroupId"));
|
batt_his.setBatt_count(rs.getInt("batt_count"));
|
batt_his.setBatt_state(rs.getInt("batt_state"));
|
batt_his.setRec_datetime(rs.getTimestamp("rec_datetime"));
|
batt_his.setOnline_vol(rs.getFloat("online_vol"));
|
batt_his.setGroup_vol(rs.getFloat("group_vol"));
|
batt_his.setGroup_tmp(rs.getFloat("group_tmp"));
|
batt_his.setGroup_curr(rs.getFloat("group_curr"));
|
batt_his.setMon_vols(rs.getString("mon_vols"));
|
batt_his.setMon_tmps(rs.getString("mon_tmps"));
|
batt_his.setMon_ress(rs.getString("mon_ress"));
|
batt_his.setMon_sers(rs.getString("mon_sers"));
|
batt_his.setMon_conn_ress(rs.getString("mon_conn_ress"));
|
batt_his.setMon_caps(rs.getString("mon_caps"));
|
batt_his.setNote(rs.getString("note"));
|
list.add(batt_his);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
return list;
|
}
|
|
public List serchByInfo(Object obj) {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
|
}
|