apzl_leasing/WebContent/Ample/Doc/DocListUploadNew.jsp
2021-07-26 19:05:46 +08:00

106 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@page import="java.io.File"
%><%@page import="org.apache.commons.io.FileUtils"
%><%@page import="com.amarsoft.are.jbo.BizObject"
%><%@page import="com.amarsoft.are.jbo.BizObjectManager"
%><%@page import="com.amarsoft.are.jbo.JBOFactory"
%><%@page import="org.apache.commons.fileupload.FileItem"
%><%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"
%><%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"
%>
<%@ page import="com.amarsoft.are.jbo.JBOException" %>
<%@ page import="java.util.regex.Pattern" %>
<%@ page import="java.util.regex.Matcher" %>
<%@ page contentType="text/html; charset=GBK"
%><%@ include file="/IncludeBeginMDAJAX.jsp"%><%
//1.创建DiskFileItemFactory对象配置缓存用
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
// 2. 创建 ServletFileUpload对象
ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
// 3. 设置文件名称编码
servletFileUpload.setHeaderEncoding("utf-8");
List<FileItem> items = servletFileUpload.parseRequest(request);
String inputTime = StringFunction.getTodayNow(); //附件编号上传时间
InputStream is = null;
//当一次传多个图片时会多次执行这个页面下面for循环只是将参数读取出来将普通数据封装为map然后将map传给写入数据库的方法。
Map<String,String> params = new HashMap<String,String>();
for (FileItem fileItem : items) {
if (fileItem.isFormField()) { // >> 普通数据
String fieldValue = fileItem.getString("utf-8");
String fieldName = fileItem.getFieldName();
params.put(fieldName,fieldValue);
ARE.getLog().info(fieldName + ": " + fieldValue);
} else {
//获取文件的实际内容
is = fileItem.getInputStream();
}
}
//找出配置的存储路径
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
String uuid = java.util.UUID.randomUUID().toString().replaceAll("-", "");
String sFullPath = com.tenwa.officetempalte.util.FileOperatorUtil.getuploadFileDir(sFileSavePath) + uuid + "_" + params.get("name");
params.put("filePath",sFullPath);
params.put("inputTime",inputTime);
params.put("inputUserId",CurUser.getUserID());
try{
if(Integer.parseInt(params.get("size")) <= 0){
throw new Exception("上传文件失败,请联系管理员!");
}
//保存实体文件
FileUtils.copyInputStreamToFile(is, new File(sFullPath));
//保存文件信息
fileInfoSave(params,Sqlca);
Sqlca.commit();
}catch (Exception e){
e.printStackTrace();
Sqlca.rollback();
out.print("FAILED");
}
%>
<%!
public void fileInfoSave(Map<String,String> params,Transaction Sqlca) throws JBOException {
if(params.size()>0){
BizObjectManager frfBom = JBOFactory.getBizObjectManager("jbo.oti.FC_REQUEST_FILE",Sqlca);
List<BizObject> frfBoList = frfBom.createQuery("DEL_FLAG='0' and FC_REQUEST_ID=:fcRequestId and FC_FLOW_TYPE=:fcFlowType and FC_FILE_CODE=:fcFileCode")
.setParameter("fcRequestId",params.get("fcRequestId")).setParameter("fcFlowType",params.get("fcFlowType")).setParameter("fcFileCode",params.get("fcFileCode")).getResultList(true);
String fcFlowTypeName = frfBoList.get(0).getAttribute("FC_FLOW_TYPE_NAME").toString();
String fcFileCodeName = frfBoList.get(0).getAttribute("FC_FILE_CODE_NAME").toString();
String fcResValue = frfBoList.get(0).getAttribute("FC_RES_VALUE").toString();
for(BizObject bo : frfBoList){
bo.setAttributeValue("FC_FILE_STS","2");
bo.setAttributeValue("FC_FILE_STS_DESC","用户添加待补传");
}
BizObject frfBo = frfBom.newObject();
frfBo.setAttributeValue("FC_REQUEST_ID",params.get("fcRequestId"));
frfBo.setAttributeValue("FC_FLOW_TYPE",params.get("fcFlowType"));
frfBo.setAttributeValue("FC_FLOW_TYPE_NAME",fcFlowTypeName);
frfBo.setAttributeValue("FC_FILE_CODE",params.get("fcFileCode"));
frfBo.setAttributeValue("FC_FILE_CODE_NAME",fcFileCodeName);
String fileType = params.get("type");
String fcFileType = fileType.substring(fileType.lastIndexOf("/")+1).toLowerCase();
frfBo.setAttributeValue("FC_FILE_TYPE",fcFileType);
frfBo.setAttributeValue("FILE_TYPE",fileType);
frfBo.setAttributeValue("FILE_NAME",params.get("name"));
frfBo.setAttributeValue("FILE_PATH",params.get("filePath"));
frfBo.setAttributeValue("FC_FILE_STS","2");
frfBo.setAttributeValue("FC_FILE_STS_DESC","用户添加待补传");
frfBo.setAttributeValue("FC_RES_VALUE",fcResValue);
frfBo.setAttributeValue("CREATE_TIME",params.get("inputTime"));
frfBo.setAttributeValue("UPDATE_TIME",params.get("inputTime"));
frfBo.setAttributeValue("DEL_FLAG","0");
frfBo.setAttributeValue("INPUTTIME",params.get("inputTime"));
frfBo.setAttributeValue("INPUTUSER",params.get("inputUserId"));
frfBom.saveObject(frfBo);
}
}
%>
<%@ include file="/IncludeEndAJAX.jsp"%>