📄 attachinfo.java
字号:
attachExt.setParam(":VCUST_ID", attachDao.getCust_id());
attachExt.setParam(":VATTACH_ROOT_ID", attachDao.getAttach_root_id());
attachExt.setParam(":VATTACH_NAME", strFilename);
attachExt.setParam(":VFILE_TYPE", attachDao.getFile_type());
attachExt.setParam(":VFILE_PATH", weburl);
attachExt.setParam(":VATTACH_DESC", efix);
attachExt.setParam(":VVALIDITY", "0");
tradeQuery.executeBy(attachExt.insBy("INS_BY_ALL"));
// this.outBuffer.setString("EFIX", efix);
this.outBuffer.setString("FILENAME", "/upload/" + attachDao.getUser_id() + "/" + strFilename);
return 0;
}
// 修改图片的大小
public String getImagePathByModify(String strFilename, int height, int width, String path) {
DwindlePic mypic = new DwindlePic();
String strOldImagePath = path + "/" + strFilename;
String strSmallImgPath = path + "/small/" + strFilename;
String strWebImgpath = path + "/small/" + strFilename;
try {
mypic.doZoom(height, width, strOldImagePath, strSmallImgPath);
}
catch (Exception e) {
throw new RuntimeException(e);
}
return strWebImgpath;
}
/**
* 获取附件地址
*/
public String getAttachAddr(String strRootId) throws SaasApplicationException {
AttachExt attachExt = new AttachExt();
String file_path = "";
attachExt.setParam(":VATTACH_ROOT_ID", strRootId);
attachExt.setParam(":VFILE_TYPE", "0");
attachExt.setParam(":VVALIDITY", "0");
ArrayList list = attachExt.selByList("SEL_BY_ROOT");
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
if (map.get("file_path") != null) {
file_path = map.get("file_path").toString();
}
}
return file_path;
}
/***************************************************************************************
**************************************************************************************/
/**
* 上传附件资料
*
* @throws IOException
*/
public void addAttachInfo(Buffers inbuffer) throws IOException {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入addattachinfo方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String user_id = inbuffer.getString("SESSION_USER_ID");
String root_id = inbuffer.getString("ATTACH_ROOT_ID");
String upDir = inbuffer.getStringWeb("UPLOADFILEDIR");
String attach_name = inbuffer.getStringWeb("FILE_NAME");
String attach_desc = inbuffer.getStringWeb("RSRV_STR1");
try {
AttachDAO attachDao = new AttachDAO();
attachDao.setAttach_root_id(root_id);
attachDao.setUser_id(user_id);
attachDao.setCust_id(cust_id);
attachDao.setFile_path(upDir);
attachDao.setAttach_name(attach_name);
attachDao.setFile_type("0");
attachDao.setAttach_desc(attach_desc);
iResult = addAttachInfo(attachDao);
}
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) throws SaasApplicationException {
commMethodMgr comm = new commMethodMgr();
config conf = new config();
AttachExt attachExt = new AttachExt();
conf.init();
String yinfile = conf.getString("mysqlbase.yinpath");
DwindlePic mypic = new DwindlePic();
mypic.ImgYin(yinfile,attachDao.getFile_path());
String root_id = attachDao.getAttach_root_id();
attachExt.setParam(":VATTACH_ID", comm.GenTradeId());
attachExt.setParam(":VUSER_ID", attachDao.getUser_id());
attachExt.setParam(":VCUST_ID", attachDao.getCust_id());
attachExt.setParam(":VATTACH_ROOT_ID", root_id);
attachExt.setParam(":VATTACH_NAME", attachDao.getAttach_name());
attachExt.setParam(":VFILE_TYPE", attachDao.getFile_type());
attachExt.setParam(":VFILE_PATH", attachDao.getFile_path());
attachExt.setParam(":VATTACH_DESC", attachDao.getAttach_desc());
attachExt.setParam(":VVALIDITY", "0");
tradeQuery.executeBy(attachExt.insBy("INS_BY_ALL"));
return 0;
}
// 取出已上传的附件
public ArrayList getAttachInfoByList(String root_id) throws SaasApplicationException {
AttachExt attachExt = new AttachExt();
attachExt.setParam(":VROOT_ID", root_id);
ArrayList list = attachExt.selByList("SEL_BY_ROOT_ID");
return list;
}
/**
* @param root_id
* @param iStart
* @param limit
* @return 取出图库
* @throws SaasApplicationException
*/
public ArrayList getAttachInfoByImage(String root_id, int iStart, int limit) throws SaasApplicationException {
if (iStart > 1) {
iStart = (iStart - 1) * limit;
}
else {
iStart = 0;
}
AttachExt attachExt = new AttachExt();
ArrayList list = attachExt.selByList("SEL_BY_IMAGE_ID", iStart, limit);
return list;
}
public int getAttachInfoByImage() throws SaasApplicationException {
ArrayList list = new ArrayList();
int size = 0;
AttachExt attachExt = new AttachExt();
list = attachExt.selByList("SEL_BY_IMAGE_ID_CT");
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
size = Integer.parseInt(map.get("ct").toString());
}
return size;
}
// 删除附件信息
public void delAttachInfo(Buffers inbuffer) throws IOException {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入delAttachInfo方法...");
int iResult = -1;
String attach_id = inbuffer.getStringWeb("ATTACH_ID");
try {
iResult = delAttachInfo(attach_id);
}
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("退出delAttachInfo方法...");
}
public int delAttachInfo(String attach_id) throws SaasApplicationException {
AttachExt attachExt = new AttachExt();
attachExt.setParam(":VATTACH_ID", attach_id);
tradeQuery.executeBy(attachExt.insBy("DELETE_BY_ID"));
return 0;
}
/**
* 删除附件信息
*
* @param inbuffer
* @throws IOException
*/
public void delAttachByRootId(Buffers inbuffer) throws IOException {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入delAttachByRootId方法...");
int iResult = -1;
String attach_root_id = inbuffer.getStringWeb("ATTACH_ROOT_ID");
try {
iResult = delAttachInfo(attach_root_id);
}
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("退出delAttachByRootId方法...");
}
public int delAttachByRootId(String attach_root_id) throws SaasApplicationException {
AttachExt attachExt = new AttachExt();
attachExt.setParam(":VROOT_ID", attach_root_id);
tradeQuery.executeBy(attachExt.insBy("DELETE_BY_ROOT"));
return 0;
}
// 获取5张最新上传的.jpg格式的图片路径
public ArrayList getAttachInfo() throws SaasApplicationException {
ArrayList attachList = new ArrayList();
AttachExt attachExt = new AttachExt();
attachList = attachExt.selByList("SEL_BY_JPG");
return attachList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -