package com.fgkj.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.dao.BaseDAO;
|
import com.fgkj.dao.BattTestData;
|
import com.fgkj.dto.Batttestdata_inf;
|
import com.sqlite_DaoHelper.CallBack;
|
import com.sqlite_DaoHelper.DAOHelper;
|
import com.sqlite_DaoHelper.DBUtil;
|
|
|
public class Batttestdata_infDAOImpl implements BaseDAO, CallBack {
|
private SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
//向batttestdata_inf表中添加数据
|
public boolean add(Object obj) {
|
Batttestdata_inf b=(Batttestdata_inf)obj;
|
String sql="insert into tb_batttestdata_inf(BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
return DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{
|
b.getBattGroupId(),
|
b.getTest_record_count(),
|
b.getTest_record_count_ex(),
|
b.getTest_type(),
|
b.getRecord_time_interval(),
|
b.getData_new(),
|
b.getData_available(),
|
b.getRecord_num(),
|
b.getTest_starttime(),
|
b.getTest_starttime_ex(),
|
b.getTest_starttype(),
|
b.getRecord_time(),
|
b.getTest_timelong(),
|
b.getTest_stoptype(),
|
b.getGroup_vol(),
|
b.getTest_curr(),
|
b.getTest_cap(),
|
b.getMax_monnum(),
|
b.getMax_monvol(),
|
b.getMin_monnum(),
|
b.getMin_monvol(),
|
b.getMon_num(),
|
b.getMon_vol(),
|
b.getUpload_usr_id()
|
});
|
|
}
|
|
public boolean update(Object obj) {
|
|
return false;
|
}
|
|
//6.1电池充放电删除操作
|
public boolean del(Object obj) {
|
Batttestdata_inf tdata=(Batttestdata_inf)obj;
|
String sql="delete from tb_batttestdata_inf where num=?";
|
return DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{tdata.getNum()});
|
}
|
//电池充/放电数据管理删除
|
public String delPro(Object obj) {
|
Batttestdata_inf tdata=(Batttestdata_inf)obj;
|
String sql="delete from tb_batttestdata_inf where num="+tdata.getNum();
|
return sql;
|
}
|
//查询所有的充放电信息
|
public List searchAll() {
|
String sql="select num,BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id " +
|
" from tb_batttestdata_inf " +
|
" where tb_batttestdata_inf.data_available=1 ";
|
return DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Batttestdata_inf b=new Batttestdata_inf();
|
b.setNum(rs.getInt("num"));
|
b.setBattGroupId(rs.getInt("BattGroupId"));
|
b.setTest_record_count(rs.getInt("test_record_count"));
|
b.setTest_record_count_ex(rs.getInt("test_record_count_ex"));
|
b.setTest_type(rs.getInt("test_type"));
|
b.setRecord_time_interval(rs.getInt("record_time_interval"));
|
b.setData_new(rs.getInt("data_new"));
|
b.setData_available(rs.getInt("data_available"));
|
b.setRecord_num(rs.getInt("record_num"));
|
b.setTest_starttime(rs.getTimestamp("test_starttime"));
|
b.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex"));
|
b.setTest_starttype(rs.getInt("test_starttype"));
|
b.setRecord_time(rs.getTimestamp("record_time"));
|
b.setTest_timelong(rs.getInt("test_timelong"));
|
b.setTest_stoptype(rs.getInt("test_stoptype"));
|
b.setGroup_vol(rs.getFloat("group_vol"));
|
b.setTest_curr(rs.getFloat("test_curr"));
|
b.setTest_cap(rs.getFloat("test_cap"));
|
b.setMax_monnum(rs.getInt("max_monnum"));
|
b.setMax_monvol(rs.getFloat("max_monvol"));
|
b.setMin_monnum(rs.getInt("min_monnum"));
|
b.setMin_monvol(rs.getFloat("min_monvol"));
|
b.setMon_num(rs.getInt("mon_num"));
|
b.setMon_vol(rs.getFloat("mon_vol"));
|
b.setUpload_usr_id(rs.getInt("upload_usr_id"));
|
list.add(b);
|
//System.out.println(b);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
}
|
|
//历史数据查询
|
public List serchByCondition(Object obj) {
|
final Batttestdata_inf bti=(Batttestdata_inf)obj;
|
String sql="select tb_batttestdata_inf.num,tb_batttestdata_inf.BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id"
|
+" from tb_batttestdata_inf where "
|
+" tb_batttestdata_inf.data_available=1 " +
|
" order by test_type asc,test_starttime desc ";
|
return DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{bti.getBattGroupId()}, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Batttestdata_inf b=new Batttestdata_inf();
|
b.setNum(rs.getInt("num"));
|
b.setBattGroupId(rs.getInt("BattGroupId"));
|
b.setTest_record_count(rs.getInt("test_record_count"));
|
b.setTest_record_count_ex(rs.getInt("test_record_count_ex"));
|
b.setTest_type(rs.getInt("test_type"));
|
b.setRecord_time_interval(rs.getInt("record_time_interval"));
|
b.setData_new(rs.getInt("data_new"));
|
b.setData_available(rs.getInt("data_available"));
|
b.setRecord_num(rs.getInt("record_num"));
|
b.setTest_starttime(rs.getTimestamp("test_starttime"));
|
b.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex"));
|
b.setTest_starttype(rs.getInt("test_starttype"));
|
b.setRecord_time(rs.getTimestamp("record_time"));
|
b.setTest_timelong(rs.getInt("test_timelong"));
|
b.setTest_stoptype(rs.getInt("test_stoptype"));
|
//放电终止原因
|
|
if(bti.getNum()/100000==6185){
|
b.setTest_stoptype_reason(BattTestData.getStopType_6185(b.getTest_stoptype()));
|
}else if(bti.getNum()/100000==4016){
|
b.setTest_stoptype_reason(BattTestData.getStopType_4016(b.getTest_stoptype()));
|
}else{
|
b.setTest_stoptype_reason(BattTestData.getStopType(b.getTest_starttype(), b.getTest_stoptype()));
|
}
|
b.setGroup_vol(rs.getFloat("group_vol"));
|
b.setTest_curr(rs.getFloat("test_curr"));
|
b.setTest_cap(rs.getFloat("test_cap"));
|
b.setMax_monnum(rs.getInt("max_monnum"));
|
b.setMax_monvol(rs.getFloat("max_monvol"));
|
b.setMin_monnum(rs.getInt("min_monnum"));
|
b.setMin_monvol(rs.getFloat("min_monvol"));
|
b.setMon_num(rs.getInt("mon_num"));
|
b.setMon_vol(rs.getFloat("mon_vol"));
|
b.setUpload_usr_id(rs.getInt("upload_usr_id"));
|
b.setMoncapstd(rs.getFloat("MonCapStd"));
|
b.setMonvolstd(rs.getFloat("monvolstd"));
|
list.add(b);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
}
|
|
public List serchByInfo(Object obj) {
|
return null;
|
}
|
|
|
public List getResults(ResultSet rs) {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
|
public static void main(String[] args) {
|
Batttestdata_infDAOImpl bimpl=new Batttestdata_infDAOImpl();
|
List<Batttestdata_inf> list=bimpl.searchAll();
|
for (Batttestdata_inf b:list) {
|
System.out.println(b);
|
}
|
}
|
}
|