📄 attachinfo.java
字号:
package com.saas.biz.attachMgr;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; //import com.saas.biz.commen.ExifInfoWrapper;
import com.saas.biz.commen.commMethodMgr;
import com.saas.biz.commen.DwindlePic;
import com.saas.biz.commen.config;
import com.saas.biz.dao.attachDAO.AttachExt;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.saas.sys.buffer.Buffers;
import com.saas.biz.dao.attachDAO.*;
import com.saas.biz.dao.enquirytrackDAO.EnquirytrackExt;
import com.saas.sys.dbm.*;
public class Attachinfo {
Logger log;
commMethodMgr commen;
ArrayList queryResult = new ArrayList();
Buffers inBuffer;
Buffers outBuffer;
Dbtable tradeQuery;
public Attachinfo() {
log = new Logger(this);
commen = new commMethodMgr();
tradeQuery = new Dbtable();
}
public void setTradeQuery(Dbtable tradeQuery) {
this.tradeQuery = tradeQuery;
}
public Dbtable getTradeQuery() {
return this.tradeQuery;
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
public Buffers getOutBuffer() {
return this.outBuffer;
}
public ArrayList getQueryResult() {
return this.queryResult;
}
public void setQueryResult(ArrayList queryResult) {
this.queryResult = queryResult;
}
public String getAttachPath(String strRootId, String strAttachType, String strValidity) throws SaasApplicationException {
ArrayList attachList = new ArrayList();
AttachExt attachExt = new AttachExt();
String file_path = "";
attachExt.setParam(":VATTACH_ROOT_ID", strRootId);
attachExt.setParam(":VFILE_TYPE", strAttachType);
attachExt.setParam(":VVALIDITY", strValidity);
attachList = attachExt.selByList("SEL_BY_ROOT");
if (attachList == null) {
file_path = "/upload/default.gif";
return file_path;
}
Iterator it = attachList.iterator();
HashMap searchMap = (HashMap) it.next();
if (searchMap.get("file_path") != "")
file_path = searchMap.get("file_path").toString();
else
file_path = "/upload/default.gif";
return file_path;
}
// 获取用户头像信息
public String getAttachPathByUserFace(String strRootId) throws SaasApplicationException {
ArrayList attachList = new ArrayList();
AttachExt attachExt = new AttachExt();
String file_path = "";
attachExt.setParam(":VATTACH_ROOT_ID", strRootId);
attachExt.setParam(":VFILE_TYPE", "U");
attachExt.setParam(":VVALIDITY", "0");
attachList = attachExt.selByList("SEL_BY_ROOT");
if (attachList == null) {
file_path = "/upload/UserDefault.gif";
return file_path;
}
Iterator it = attachList.iterator();
HashMap searchMap = (HashMap) it.next();
if (searchMap.get("file_path") != "") {
file_path = searchMap.get("file_path").toString();
}
else {
file_path = "/upload/UserDefault.gif";
}
return file_path;
}
public ArrayList getAttachList(String strRootId, String strAttachType, String strValidity) throws SaasApplicationException {
ArrayList attachList = new ArrayList();
AttachExt attachExt = new AttachExt();
attachExt.setParam(":VATTACH_ROOT_ID", strRootId);
attachExt.setParam(":VFILE_TYPE", strAttachType);
attachExt.setParam(":VVALIDITY", strValidity);
attachList = attachExt.selByList("SEL_BY_ROOT");
return attachList;
}
public ArrayList getAttachInfo(String strAttachId) throws SaasApplicationException {
ArrayList attachList = new ArrayList();
AttachExt attachExt = new AttachExt();
attachExt.setParam(":VATTACH_ID", strAttachId);
attachList = attachExt.selByList("SEL_BY_ID");
return attachList;
}
// **************************shijun add**************************//
/**
* @param inbuffer
*/
public void addAttachinfo(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入addattachinfo方法...");
int iResult = -1;
try {
commMethodMgr comm = new commMethodMgr();
String imageId = inbuffer.getString("ATTACH_ROOT_ID");
String upDir = inbuffer.getString("UPLOADFILEDIR");
AttachDAO attachDao = new AttachDAO();
attachDao.setAttach_root_id(inbuffer.getString("ATTACH_ROOT_ID"));
attachDao.setUser_id(inbuffer.getString("SESSION_USER_ID"));
attachDao.setCust_id(inbuffer.getString("SESSION_CUST_ID"));
attachDao.setFile_path(upDir);
attachDao.setFile_type(inbuffer.isFieldExist("FILE_TYPE") ? inbuffer.getString("FILE_TYPE") : "0");
String headDir = upDir.substring(0, upDir.lastIndexOf("/"));
iResult = addAttachinfo(attachDao, headDir);
}
catch (SaasApplicationException e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "业务处理失败!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
}
log.LOG_INFO("退出addattachinfo方法...");
}
public int addAttachinfo(AttachDAO attachDao, String realdir) throws SaasApplicationException {
commMethodMgr comm = new commMethodMgr();
AttachExt attachExt = new AttachExt();
String[] OldimagePath = attachDao.getFile_path().trim().split("/");
String efix = "";
String strFilename = OldimagePath[OldimagePath.length - 1];
log.LOG_INFO("====" + strFilename);
try {
log.LOG_INFO("====" + new String(strFilename.getBytes("GBK"), "ISO-8859-1"));
}
catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
// ExifInfoWrapper exifwrapper = new ExifInfoWrapper();
// exifwrapper.getExifInfoWrapper(attachDao.getFile_path());
// String efix = exifwrapper.getImageEfix();
if (attachDao.getFile_type().equals("A")) {
AttachExt attachUPExt = new AttachExt();
attachUPExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachUPExt.setParam(":VFILE_TYPE", "A");
attachUPExt.setParam(":VVALIDITY", "1");
tradeQuery.executeBy(attachUPExt.insBy("UP_BY_TYPE"));
String strWebImgpath = getImagePathByModify(strFilename, 60, 60, realdir);
attachDao.setFile_path("/upload/" + attachDao.getUser_id() + "/small/" + strFilename);
}
else if (attachDao.getFile_type().equals("B")) {
AttachExt attachUPExt = new AttachExt();
attachUPExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachUPExt.setParam(":VFILE_TYPE", "B");
attachUPExt.setParam(":VVALIDITY", "1");
tradeQuery.executeBy(attachUPExt.insBy("UP_BY_TYPE"));
String strWebImgpath = getImagePathByModify(strFilename, 120, 120, realdir);
attachDao.setFile_path("/upload/" + attachDao.getUser_id() + "/small/" + strFilename);
}
else if (attachDao.getFile_type().equals("C")) {
AttachExt attachUPExt = new AttachExt();
attachUPExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachUPExt.setParam(":VFILE_TYPE", "C");
attachUPExt.setParam(":VVALIDITY", "1");
tradeQuery.executeBy(attachUPExt.insBy("UP_BY_TYPE"));
String strWebImgpath = getImagePathByModify(strFilename, 120, 160, realdir);
attachDao.setFile_path("/upload/" + attachDao.getUser_id() + "/small/" + strFilename);
}
else if (attachDao.getFile_type().equals("U"))// 用户头像
{
AttachExt attachUPExt = new AttachExt();
attachUPExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachUPExt.setParam(":VFILE_TYPE", "U");
attachUPExt.setParam(":VVALIDITY", "0");
tradeQuery.executeBy(attachUPExt.insBy("DELETE_BY_ROOT_TYPE"));
String strWebImgpath = getImagePathByModify(strFilename, 120, 160, realdir);
attachDao.setFile_path("/upload/" + attachDao.getUser_id() + "/small/" + strFilename);
}
else {
AttachExt attachUPExt = new AttachExt();
attachUPExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachUPExt.setParam(":VFILE_TYPE", "0");
attachUPExt.setParam(":VVALIDITY", "1");
tradeQuery.executeBy(attachUPExt.insBy("UP_BY_TYPE"));
attachDao.setFile_path("/upload/" + strFilename);
}
String attach_id = comm.GenTradeId();
String weburl = "/upload/" + attachDao.getCust_id() + "/" + strFilename;
attachExt.setParam(":VATTACH_ID", attach_id);
attachExt.setParam(":VUSER_ID", attachDao.getUser_id());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -