package com.fgkj.dao.impl;
|
|
import java.io.File;
|
import java.sql.Blob;
|
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.CallBack;
|
import com.fgkj.dao.DAOHelper;
|
import com.fgkj.db.DBUtil;
|
import com.fgkj.dto.User_Chart;
|
import com.fgkj.dto.User_inf;
|
|
public class User_ChartImpl implements BaseDAO,CallBack{
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
User_Chart uchart=new User_Chart();
|
uchart.setNum(rs.getInt("num"));
|
uchart.setChart_name(rs.getString("chart_name"));
|
uchart.setChart_file(rs.getString("chart_file"));
|
uchart.setChart_logo_blob(rs.getBlob("chart_logo"));
|
uchart.setChart_normal_blob(rs.getBlob("chart_normal"));
|
uchart.setChart_behind_blob(rs.getBlob("chart_behind"));
|
uchart.setChart_warn_blob(rs.getBlob("chart_warn"));
|
uchart.setChart_timeout_blob(rs.getBlob("chart_timeout"));
|
list.add(uchart);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
return list;
|
|
}
|
//添加图标
|
public boolean add(Object obj) {
|
User_Chart uchart=(User_Chart) obj;
|
List list=new ArrayList();
|
list.add(uchart.getChart_name());
|
list.add(uchart.getChart_file());
|
list.add(uchart.getChart_logo());
|
list.add(uchart.getChart_normal());
|
list.add(uchart.getChart_behind());
|
list.add(uchart.getChart_warn());
|
list.add(uchart.getChart_timeout());
|
list.add(uchart.getChart_nuclear_cap());
|
list.add(uchart.getChart_dev_alarm());
|
list.add(uchart.getChart_pre_charge());
|
list.add(uchart.getChart_online_charge());
|
String sql="insert into web_site.tb_user_Chart(chart_name,chart_file,Chart_logo,Chart_normal,Chart_behind,Chart_warn,Chart_timeout,Chart_nuclear_cap,Chart_dev_alarm,Chart_pre_charge,Chart_online_charge) values(?,?,?,?,?,?,?,?,?,?,?)";
|
boolean bl=DAOHelper.executeUpdatePicture(DBUtil.getConn(), sql, list);
|
return bl;
|
}
|
//修改图标信息
|
public boolean update(Object obj) {
|
User_Chart uchart=(User_Chart) obj;
|
List list=new ArrayList();
|
String sql="update web_site.tb_user_Chart SET";
|
//logo图片
|
String logoSql=" Chart_logo=? ";
|
if(uchart.getChart_logo()!=null&&uchart.getChart_logo().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_logo());
|
sql+=logoSql;
|
}
|
//normal图片
|
String normalSql=" Chart_normal=? ";
|
if(uchart.getChart_normal()!=null&&uchart.getChart_normal().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_normal());
|
sql+=normalSql;
|
}
|
//behind图片
|
String behindSql=" Chart_behind=? ";
|
if(uchart.getChart_behind()!=null&&uchart.getChart_behind().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_behind());
|
sql+=behindSql;
|
}
|
//warn图片
|
String warnSql=" Chart_warn=? ";
|
if(uchart.getChart_warn()!=null&&uchart.getChart_warn().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_warn());
|
sql+=warnSql;
|
}
|
//time_out图片
|
String time_outSql=" Chart_timeout=? ";
|
if(uchart.getChart_timeout()!=null&&uchart.getChart_timeout().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_timeout());
|
sql+=time_outSql;
|
}
|
//nuclear_cap图片
|
String nuclear_capSql=" Chart_nuclear_cap=? ";
|
if(uchart.getChart_nuclear_cap()!=null&&uchart.getChart_nuclear_cap().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_nuclear_cap());
|
sql+=nuclear_capSql;
|
}
|
//dev_alarm图片
|
String dev_alarmSql=" Chart_dev_alarm=? ";
|
if(uchart.getChart_dev_alarm()!=null&&uchart.getChart_dev_alarm().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_dev_alarm());
|
sql+=dev_alarmSql;
|
}
|
//pre_charge图片
|
String pre_chargeSql=" Chart_pre_charge=? ";
|
if(uchart.getChart_pre_charge()!=null&&uchart.getChart_pre_charge().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_pre_charge());
|
sql+=pre_chargeSql;
|
}
|
//online_charge图片
|
String online_chargeSql=" Chart_online_charge=? ";
|
if(uchart.getChart_online_charge()!=null&&uchart.getChart_online_charge().length()>0){
|
if(list.size()>0){
|
sql+=",";
|
}
|
list.add(uchart.getChart_online_charge());
|
sql+=online_chargeSql;
|
}
|
//endSql
|
String endSql=" where chart_file=?";
|
list.add(uchart.getChart_file());
|
sql+=endSql;
|
//System.out.println(list.size()+" "+sql);
|
boolean bl=DAOHelper.executeUpdatePicture(DBUtil.getConn(), sql, list);
|
return bl;
|
}
|
//删除图标
|
public boolean del(Object obj) {
|
User_Chart uchart=(User_Chart) obj;
|
List list=new ArrayList();
|
list.add(uchart.getChart_file());
|
String sql="delete from web_site.tb_user_Chart where chart_file=?";
|
boolean bl=DAOHelper.executeUpdatePicture(DBUtil.getConn(), sql, list);
|
return bl;
|
}
|
//查询所有chart_file
|
public List searchAll() {
|
String sql="select num,chart_name,chart_file from web_site.tb_user_Chart order by num ";
|
List list=DAOHelper.executeQueryPicture(sql, DBUtil.getConn(), null, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
User_Chart uchart=new User_Chart();
|
uchart.setNum(rs.getInt("num"));
|
uchart.setChart_name(rs.getString("chart_name"));
|
uchart.setChart_file(rs.getString("chart_file"));
|
list.add(uchart);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
return list;
|
}
|
//根据用户id查图表
|
public List serchByCondition(Object obj) {
|
User_inf uinf=(User_inf) obj;
|
String sql="select distinct(chart_file) from web_site.tb_user_Chart,db_user.tb_user_inf " +
|
" where web_site.tb_user_Chart.chart_name=db_user.tb_user_inf.ujobgroup " +
|
" and db_user.tb_user_inf.uname=?" ;
|
List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{uinf.getUName()},new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
User_Chart uchart=new User_Chart();
|
uchart.setChart_file(rs.getString("chart_file"));
|
list.add(uchart);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
return list;
|
}
|
//根据chart_file和列名查询图片(Chart_name放列名字)
|
public List serchByInfo(Object obj){
|
final User_Chart uchart=(User_Chart) obj;
|
String sql="select "+uchart.getChart_name()+" from web_site.tb_user_Chart where chart_file=? ";
|
List list=DAOHelper.executeQueryPicture(sql, DBUtil.getConn(), new Object[]{uchart.getChart_file()}, new CallBack() {
|
|
public List getResults(ResultSet rs) {
|
List list=new ArrayList();
|
try {
|
while(rs.next()){
|
Blob blob=rs.getBlob(uchart.getChart_name());
|
list.add(blob);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return list;
|
}
|
});
|
return list;
|
|
}
|
|
}
|