📄 searchdaoimpl.java
字号:
package com.zte.webfile.dao;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.zte.webfile.dal.DataAdapter;
import com.zte.webfile.dto.FileDTO;
import com.zte.webfile.tool.Tool;
public class searchDAOImpl implements searchDAOInterface {
private final static Logger log = Logger.getLogger(DataAdapter.class);
/**
* 查询用户对应文件名的ID
*
* @param filename
* 文件名
* @return 用户对应文件名的ID
* @throws Exception
*/
public Vector searchID(String filename) {
// 定义返回值
Vector list = new Vector();
// 从配置文件中读取sql语句
String sql_searchID = new Tool().getProperties("searchID");
Vector arg = new Vector();
arg.add(filename);
// 接受返回信息
try {
list = DataAdapter.getData(sql_searchID, arg);
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
/**
* 按文件名搜索文件信息
*
* @param filename
* 文件名
* @return 文件信息
* @throws Exception
*/
public HashMap searchFileName(String fowner, String filename) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfilename = new Tool().getProperties("searchfilename");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add("%" + filename + "%");
arg.add(fowner);
arg.add("%" + filename + "%");
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfilename, arg);
if (vt == null) {
return map;
} else {
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
path = String.valueOf(row.get(c).toString());
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 按文件类型搜索文件信息
*
* @param filetype
* 文件类型
* @return 文件信息
* @throws Exception
*/
public HashMap searchFileType(String fowner, String filetype) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfiletype = new Tool().getProperties("searchfiletype");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add(filetype);
arg.add(fowner);
arg.add(filetype);
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfiletype, arg);
if (vt == null) {
return map;
} else {
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
path = String.valueOf(row.get(c).toString());
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 按文件上传时间搜索文件信息
*
* @param fileuploadtime
* 文件上传时间
* @return 文件信息
* @throws Exception
*/
public HashMap searchFileUpLoadTime(String fowner, String fileuploadtime) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfileuploadtime = new Tool()
.getProperties("searchfileuploadtime");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add(fileuploadtime);
arg.add(fowner);
arg.add(fileuploadtime);
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfileuploadtime, arg);
if (vt == null) {
return map;
} else {
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
path = String.valueOf(row.get(c).toString());
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 按文件上传人搜索文件信息
*
* @param fileowner
* 文件上传人
* @return 文件信息
* @throws Exception
*/
public HashMap searchFileOwner(String fileowner) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfileowner = new Tool()
.getProperties("searchfileowner");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add("%" + fileowner + "%");
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfileowner, arg);
if (vt == null) {
return map;
} else {
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
path = String.valueOf(row.get(c).toString());
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 按文件夹搜索文件信息
*
* @param folder
* 文件夹名称
* @return 文件信息
* @throws Exception
*/
public HashMap searchFolder(String fowner, String folder) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfolder = new Tool().getProperties("searchfolder");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add("%" + folder + "%");
arg.add(fowner);
arg.add("%" + folder + "%");
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfolder, arg);
if (vt == null) {
return map;
} else {
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
path = String.valueOf(row.get(c).toString());
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 查询此文件名下的所有文件信息
*
* @param id
* 文件ID
* @return 文件信息
* @throws Exception
*/
public HashMap searchFile(Integer id) {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchfile = new Tool().getProperties("searchfile");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add(id);
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchfile, arg);
if (vt == null) {
System.out.println("is null!!");
} else {
System.out.println("vtsize" + vt.size());
for (int j = 0; j < vt.size(); j++) {
Vector row = (Vector) vt.get(j);
int ID = Integer.valueOf(row.get(0).toString());
map.put((fileArray[0] + j).trim(), ID);
for (int c = 1; c < fileArray.length; c++) {
String path = "";
if (row.get(c) != null) {
if (c == 3) {
String p = String
.valueOf(row.get(c).toString());
double d = Double.parseDouble(p);
path = String.valueOf(div(d, 1048576, 3));
} else {
path = String.valueOf(row.get(c).toString());
}
}
map.put((fileArray[c] + j).trim(), path.trim());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* 查询此共享文件夹下的所有文件信息
*
* @param 无
* @return 文件信息
* @throws Exception
*/
public HashMap searchShareFile() {
// 定义返回值
Vector vt = new Vector();
HashMap map = new HashMap();
// 从配置文件中读取sql语句
String sql_searchsharefile = new Tool()
.getProperties("searchsharefile");
String file = new Tool().getProperties("fileArray");
String[] fileArray = file.split(",");
Vector arg = new Vector();
arg.add(0);
// 接受返回信息
try {
vt = DataAdapter.getData(sql_searchsharefile, arg);
if (vt == null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -