%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="com.tenwa.reckon.util.UUIDUtil"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="com.amarsoft.are.jbo.impl.BizObjectTableMapper"%>
<%@page import="com.amarsoft.awe.util.DBKeyHelp"%>
<%@page import="com.amarsoft.awe.common.attachment.*"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/IncludeBegin.jsp"%>
<%
AmarsoftUpload myAmarsoftUpload = new AmarsoftUpload();
myAmarsoftUpload.initialize(pageContext);
myAmarsoftUpload.upload();
// 当前时间
java.util.Date dateNow = new java.util.Date();
SimpleDateFormat sdfTemp = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
String date = sdfTemp.format(dateNow);
String date1 = date;
date1 = date1.replace(" ", "");
date1 = date1.replace(":", "");
date1 = date1.replace("/", "");
// 服务器保存文件名称 (年月日_本地文件名)
String sFileSaveMode = CurConfig.getConfigure("FileSaveMode");
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
String sFileNameType = CurConfig.getConfigure("FileNameType");
String sFlowImagePath = CurConfig.getConfigure("FlowImagePath");
String FLOW_NO = "";
String FLOW_NAME = "";
String APP_FLOW_NAME = "";
String FILE_NAME = "";
String sFileName = "";
sFileName = (String)myAmarsoftUpload.getRequest().getParameter("IMAGE_NAME");
sFileName = StringFunction.getFileName(sFileName);
sFileName = URLDecoder.decode(URLDecoder.decode(sFileName,"UTF-8"),"UTF-8");
String RandomName = date1 + "_" + sFileName;
String FILE_PATH = "";
int FILE_SIZE = 0;
String POSITION = "";
String sFullPath = "";
String id = CurPage.getParameter("id");
if (StringUtils.isNotBlank(id)) {
BizObjectManager bomAppFlowShow = JBOFactory.getBizObjectManager("jbo.app.APP_FLOW_SHOW");
BizObject bo1 = bomAppFlowShow.createQuery("select FILE_NAME from O where ID ='" + id + "' ").getSingleResult(false);
if(bo1 != null){
FILE_NAME = bo1.getAttribute("FILE_NAME").toString();
}
POSITION = CurPage.getParameter("POSITION");
APP_FLOW_NAME = CurPage.getParameter("APP_FLOW_NAME");
APP_FLOW_NAME = URLDecoder.decode(APP_FLOW_NAME,"UTF-8");
FILE_PATH = "";
FILE_SIZE = 0;
if (!FILE_NAME.equals(sFileName)) {
FILE_PATH = sFlowImagePath + "/" + RandomName;
if (!myAmarsoftUpload.getFiles().getFile(0).isMissing()){
try {
if(sFileSaveMode.equals("Disk")) {
// 获取全路径
sFullPath = sFileSavePath + sFlowImagePath+"/"+RandomName;
// 保存服务器文件
myAmarsoftUpload.getFiles().getFile(0).saveAs(sFullPath);
FILE_SIZE = myAmarsoftUpload.getFiles().getFile(0).getSize();
}
} catch(Exception e){
System.out.println(e);
out.println("An error occurs : " + e.toString());
myAmarsoftUpload = null;
%>
<% return;} }
}
try {
String sql = "update o set ";
sql += "POSITION='" + POSITION +"' ";
sql += ",APP_FLOW_NAME='" + APP_FLOW_NAME +"' ";
if (StringUtils.isNotBlank(sFileName)) {
sql += ",FILE_NAME='" + sFileName +"' ";
sql += ",FILE_PATH='" + FILE_PATH +"' ";
sql += ",FILE_SIZE='" + FILE_SIZE +"' ";
}
sql += "where 1=1 and id='" + id + "'";
BizObjectManager bomcr = JBOFactory
.getBizObjectManager("jbo.app.APP_FLOW_SHOW");
JBOTransaction jbot = JBOFactory.createJBOTransaction();
jbot.join(bomcr);
int count = bomcr
.createQuery(sql).executeUpdate();
jbot.commit();
} catch(Exception e){
System.out.println(e);
out.println("An error occurs : " + e.toString());
myAmarsoftUpload = null;
%>
<%
return;
}
} else {
// 流程号
FLOW_NO = CurPage.getParameter("FLOW_NO");
FLOW_NAME = null;
BizObjectManager bom1 = JBOFactory.getBizObjectManager("jbo.app.APP_FLOW_SHOW");
BizObject bo3 = bom1.createQuery("select flow_no from O where 1=1 and flow_no=:FlowNo")
.setParameter("FlowNo", FLOW_NO).getSingleResult(false);
if(bo3 != null){
%>
<%
return;
}
BizObjectManager bom = JBOFactory.getBizObjectManager("jbo.sys.FLOW_CATALOG");
BizObject bo2 = bom.createQuery("select flowname from O where FlowNo =:FlowNo ")
.setParameter("FlowNo", FLOW_NO).getSingleResult(false);
if(bo2 != null){
FLOW_NAME = bo2.getAttribute("flowname").toString();
}
// 流程位置
POSITION = CurPage.getParameter("POSITION");
// 流程显示名
APP_FLOW_NAME = CurPage.getParameter("APP_FLOW_NAME");
if (StringUtils.isBlank(APP_FLOW_NAME)) {
APP_FLOW_NAME = FLOW_NAME;
}
APP_FLOW_NAME = StringFunction.getFileName(APP_FLOW_NAME);
APP_FLOW_NAME = URLDecoder.decode(APP_FLOW_NAME,"UTF-8");
if (!myAmarsoftUpload.getFiles().getFile(0).isMissing()){
try {
if(sFileSaveMode.equals("Disk")) {
// 获取全路径
sFullPath = sFileSavePath + sFlowImagePath+"/"+RandomName;
// 保存服务器文件
myAmarsoftUpload.getFiles().getFile(0).saveAs(sFullPath);
FILE_SIZE = myAmarsoftUpload.getFiles().getFile(0).getSize();
// 保存APP_FLOW_SHOW
BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.app.APP_FLOW_SHOW");
JBOTransaction jbot = JBOFactory.createJBOTransaction();
jbot.join(bm);
BizObject bo = bm.newObject();
String uuid = UUIDUtil.getUUID();
bo.setAttributeValue("id", uuid);
bo.setAttributeValue("FLOW_NO", FLOW_NO);
bo.setAttributeValue("FLOW_NAME", FLOW_NAME);
bo.setAttributeValue("APP_FLOW_NAME", APP_FLOW_NAME);
bo.setAttributeValue("FILE_NAME", sFileName);
bo.setAttributeValue("FILE_PATH", sFlowImagePath + "/" + RandomName);
bo.setAttributeValue("FILE_SIZE", FILE_SIZE);
bo.setAttributeValue("POSITION", POSITION);
bm.saveObject(bo);
jbot.commit();
}
} catch(Exception e){
System.out.println(e);
out.println("An error occurs : " + e.toString());
myAmarsoftUpload = null;
%>
<%return;
}
}
}
%>
<%@ include file="/IncludeEnd.jsp"%>