| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <%@page import="java.util.Date"%>
- <%@page import="java.text.SimpleDateFormat"%>
- <%@page import="org.springframework.http.HttpStatus"%>
- <%@page import="com.uas.cr.util.HttpUtil.Response"%>
- <%@page import="com.uas.cr.util.FlexJsonUtil"%>
- <%@page import="java.util.ArrayList"%>
- <%@page import="java.util.HashMap"%>
- <%@page import="java.util.Map"%>
- <%@page import="com.uas.cr.util.HttpUtil"%>
- <%@ page import="com.jspsmart.upload.File"%>
- <%@ page import="com.jspsmart.upload.SmartUpload"%>
- <%@ page import="java.util.List"%>
- <%@ page import="java.sql.PreparedStatement"%>
- <%@ page import="java.sql.Connection"%>
- <%@ page import="com.uas.cr.util.DBConnection"%>
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <%@ page import="com.uas.cr.util.FileUtil"%>
- <%@ page import="java.net.URLEncoder"%>
- <%@ page import="java.io.*"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="content-Type" contentType="text/html;charset=UTF-8">
- <link rel="shortcut icon" type="image/x-icon" href="img/u.png" />
- <title>上传</title>
- </head>
- <body>
- <%try {
- SmartUpload su = new SmartUpload();
- su.initialize(pageContext);
- su.service(request, response);
- su.setTotalMaxFileSize(100000000);
- su.upload();
- String uu = su.getRequest().getParameter("uu");
- String reportBusi = su.getRequest().getParameter("reportBusi");
- String description = su.getRequest().getParameter("description");
- String reportPageName = su.getRequest().getParameter("reportPageName");
- String name = su.getRequest().getParameter("userName");
- File suFile = su.getFiles().getFile(0);
- String fileName = suFile.getFilePathName();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd H-m-s");
- String date = sdf.format(new Date());
- if (!suFile.isMissing()) {
- String realPath = application.getRealPath(request.getRequestURI());
- java.io.File transFile = new java.io.File(realPath);
- realPath = transFile.getParentFile().getParentFile().getParentFile().getPath() + "/rpt";
- String backupPath = transFile.getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getPath() + "/rpt";
- java.io.File fileTemp = new java.io.File(realPath);
- java.io.File backupfileTemp = new java.io.File(backupPath);
- if (!fileTemp.exists()) {
- fileTemp.mkdir();
- }
- if (!backupfileTemp.exists()) {
- backupfileTemp.mkdir();
- }
- realPath = realPath + "/" + uu;
- backupPath = backupfileTemp + "/" + uu;
- fileTemp = new java.io.File(realPath);
- backupfileTemp = new java.io.File(backupPath);
- if (!fileTemp.exists()) {
- fileTemp.mkdir();
- }
- if (!backupfileTemp.exists()) {
- backupfileTemp.mkdir();
- }
- realPath = realPath + "/";
- backupPath = backupPath + "/";
- backupPath = backupPath +date+ suFile.getFilePathName();
- realPath = realPath + suFile.getFilePathName();
- fileTemp = new java.io.File(realPath);
- DBConnection db = new DBConnection();
- Connection con = db.createCon();
- PreparedStatement pre = null;
- if(fileTemp.exists()) {
- pre = con.prepareStatement("update REPORT$CONFIG set RE_PAGENAME= ? where RE_ENUU= ? and RE_REPORTNAME= ?");
- pre.setString(1, reportPageName);
- pre.setLong(2, Long.parseLong(uu));
- pre.setString(3, suFile.getFilePathName());
- }else {
- pre = con.prepareStatement(
- "insert into REPORT$CONFIG(RE_ID, RE_ENUU, RE_REPORTNAME, RE_PAGENAME) values (REPORT$CONFIG_seq.nextval, ?, ?, ?)");
- pre.setLong(1, Long.parseLong(uu));
- pre.setString(2, suFile.getFilePathName());
- pre.setString(3, reportPageName);
- }
- suFile.saveAs(realPath);
- suFile.saveAs(backupPath);
- pre.executeUpdate();
- Map<String, String> map = new HashMap<String, String>();
- List<Map<String, String>> list = new ArrayList<Map<String, String>>();
- map.put("enuu", uu);
- map.put("reportBusi", reportBusi);
- map.put("description", description);
- map.put("fileName", fileName);
- map.put("name", name);
- list.add(map);
- String data = FlexJsonUtil.toJsonArrayDeep(list);
- Map<String, String> mapFile = new HashMap<String, String>();
- mapFile.put("data", data);
- com.uas.cr.util.HttpUtil.Response res = HttpUtil.sendPostRequest(
- "http://10.10.100.81:8080/public/upReport/message", mapFile, true);
- out.println("文件上传成功,请刷新管理台页面! ");
- if((pre != null)&&(!pre.isClosed())) {
- pre.close();
- }
- if(db != null) {
- db.closeCon(con);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- out.println("上传文件失败!报错信息:");
- out.println(e.getMessage());
- }%>
- </body>
- </html>
|