Przeglądaj źródła

支持标准模板下载;支持自动部署账套(下载模板、解压、配置路径);

sunyj 9 lat temu
rodzic
commit
8304c434e5

+ 39 - 0
src/main/java/com/uas/report/controller/FileController.java

@@ -1,5 +1,9 @@
 package com.uas.report.controller;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.servlet.http.HttpServletResponse;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import com.uas.report.core.exception.ReportException;
 import com.uas.report.service.FileService;
+import com.uas.report.support.SysConf;
 
 /**
  * 文件操作请求
@@ -25,6 +30,15 @@ public class FileController {
 	@Autowired
 	private FileService fileService;
 
+	@Autowired
+	private SysConf sysConf;
+
+	@RequestMapping("/autoDeploy")
+	@ResponseBody
+	public String autoDeploy(String userNames) {
+		return fileService.autoDeploy(userNames);
+	}
+
 	@RequestMapping("/upload")
 	@ResponseBody
 	public String upload(String userName, String fileType, MultipartFile file) {
@@ -76,6 +90,31 @@ public class FileController {
 		fileService.download(fileService.getJrxml(userName, reportName), response);
 	}
 
+	/**
+	 * 下载标准模板
+	 * 
+	 * @param onlyData
+	 *            是否只获取数据
+	 */
+	@RequestMapping("/standardJrxmls")
+	@ResponseBody
+	public Map<String, Object> standardJrxmls(String onlyData, HttpServletResponse response) {
+		// 只返回字节数据,否则下载标准模板zip
+		if (!StringUtils.isEmpty(onlyData) && (onlyData.equals("1") || onlyData.equals("true"))) {
+			Map<String, Object> result = new HashMap<>();
+			// 不直接返回byte[],是因为客户端请求数据时,该请求可能会抛出异常,
+			// 之后客户端获取byte[]数据,进行处理时难以判断数据是文件数据还是异常信息
+			result.put("data", fileService.getStandardJrxmls());
+			return result;
+		}
+		try {
+			response.sendRedirect("download/zip?userName=" + sysConf.getStandardMaster());
+			return null;
+		} catch (IOException e) {
+			throw new ReportException(e).setDetailedMessage(e);
+		}
+	}
+
 	@RequestMapping("/delete")
 	@ResponseBody
 	public String delete(String userName, String filePath) {

+ 1 - 1
src/main/java/com/uas/report/controller/PrintController.java

@@ -221,7 +221,7 @@ public class PrintController {
 				if (result != null && result.containsKey("data")) {
 					data = (byte[]) result.remove("data");
 				}
-				if (data == null) {
+				if (ArrayUtils.isEmpty(data)) {
 					throw new ReportException("获取预览数据失败");
 				}
 				printService.writeDataToFile(file.getPath(), data);

+ 16 - 0
src/main/java/com/uas/report/service/FileService.java

@@ -12,6 +12,15 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface FileService {
 
+	/**
+	 * 自动对新部署的账套进行下载模板、解压、配置路径等操作
+	 * 
+	 * @param userNames
+	 *            账套名称,多个账套以英文逗号隔开
+	 * @return 部署结果
+	 */
+	public String autoDeploy(String userNames);
+
 	/**
 	 * 上传文件
 	 * 
@@ -34,6 +43,13 @@ public interface FileService {
 	 */
 	public String getJrxml(String userName, String reportName);
 
+	/**
+	 * 获取标准模板
+	 * 
+	 * @return 标准模板数据
+	 */
+	public byte[] getStandardJrxmls();
+
 	/**
 	 * 获取账套下的所有资源
 	 * 

+ 68 - 28
src/main/java/com/uas/report/service/impl/FileServiceImpl.java

@@ -5,18 +5,25 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.URI;
 
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.alibaba.druid.util.StringUtils;
+import com.alibaba.fastjson.JSONObject;
 import com.uas.report.core.exception.ReportException;
 import com.uas.report.service.FileService;
-import com.uas.report.support.JasperserverRestAPIConf;
+import com.uas.report.support.SysConf;
+import com.uas.report.util.FileUtils;
 import com.uas.report.util.ReportUtils;
 import com.uas.report.util.ZipUtils;
 
@@ -24,10 +31,38 @@ import com.uas.report.util.ZipUtils;
 public class FileServiceImpl implements FileService {
 
 	@Autowired
-	private JasperserverRestAPIConf jsRestAPIConf;
+	private SysConf sysConf;
 
 	private Logger logger = Logger.getLogger(getClass());
 
+	@Override
+	public String autoDeploy(String userNames) {
+		if (StringUtils.isEmpty(userNames)) {
+			throw new ReportException("参数不能为空:userNames");
+		}
+		try {
+			// 获取标准模板数据
+			JSONObject jsonObject = JSONObject.parseObject(IOUtils.toString(HttpClients.createDefault()
+					.execute(new HttpGet(URI.create(sysConf.getStandardJrxmlsUrl()))).getEntity().getContent()));
+			byte[] data = jsonObject.getBytes("data");
+			if (ArrayUtils.isEmpty(data)) {
+				throw new ReportException("标准模板获取失败");
+			}
+			// 写入本地zip文件
+			String filePath = new StringBuilder(sysConf.getLocalBaseDir()).append("/")
+					.append(sysConf.getStandardMaster()).append(".zip").toString();
+			FileUtils.create(filePath, data);
+			String[] userNameArray = userNames.split(",");
+			// 创建账套路径并解压模板zip包
+			for (String userName : userNameArray) {
+				ZipUtils.unzip(filePath, sysConf.getLocalBaseDir() + "/" + userName);
+			}
+			return "已自动部署:" + userNames;
+		} catch (UnsupportedOperationException | IOException e) {
+			throw new ReportException(e).setDetailedMessage(e);
+		}
+	}
+
 	@Override
 	public String upload(final String userName, String fileType, MultipartFile file) {
 		String message = "";
@@ -46,7 +81,7 @@ public class FileServiceImpl implements FileService {
 		}
 
 		String fileName = file.getOriginalFilename();
-		StringBuilder stringBuilder = new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/");
+		StringBuilder stringBuilder = new StringBuilder(sysConf.getLocalBaseDir()).append("/");
 		// jrxml模板和图片分别放在jrxml和Picture文件夹下,其他资源放在当前账套根路径下
 		if (fileType.equals("jrxml")) {
 			stringBuilder.append(userName).append("/").append("jrxml").append("/");
@@ -89,14 +124,39 @@ public class FileServiceImpl implements FileService {
 	@Override
 	public String getJrxml(String userName, String reportName) {
 		ReportUtils.checkParameters(userName, reportName);
-		return new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/").append(userName).append("/")
-				.append(jsRestAPIConf.getLocalJrxmlDir()).append("/").append(reportName).append(".jrxml").toString();
+		return new StringBuilder(sysConf.getLocalBaseDir()).append("/").append(userName).append("/")
+				.append(sysConf.getLocalJrxmlDir()).append("/").append(reportName).append(".jrxml").toString();
+	}
+
+	@Override
+	public byte[] getStandardJrxmls() {
+		// 压缩标准模板
+		String zipFilePath = getZip(sysConf.getStandardMaster());
+		if (zipFilePath.isEmpty()) {
+			throw new ReportException("压缩失败");
+		}
+		File zipFile = new File(zipFilePath);
+		if (!zipFile.exists()) {
+			throw new ReportException("文件不存在:" + zipFilePath);
+		}
+		if (!zipFile.isFile()) {
+			throw new ReportException("并非文件:" + zipFilePath);
+		}
+		try {
+			InputStream inputStream = new FileInputStream(zipFile);
+			byte[] data = new byte[inputStream.available()];
+			inputStream.read(data);
+			inputStream.close();
+			return data;
+		} catch (IOException e) {
+			throw new ReportException(e).setDetailedMessage(e);
+		}
 	}
 
 	@Override
 	public String getZip(String userName) {
 		// 账套路径
-		String folderPath = jsRestAPIConf.getLocalBaseDir() + "/" + userName;
+		String folderPath = sysConf.getLocalBaseDir() + "/" + userName;
 		// 压缩后的压缩包路径,与账套在同一级
 		String zipFilePath = folderPath + ".zip";
 		ZipUtils.zipFolder(folderPath, zipFilePath);
@@ -135,7 +195,7 @@ public class FileServiceImpl implements FileService {
 		if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(fileRelativePath)) {
 			throw new ReportException("参数不能为空:userName,fileRelativePath");
 		}
-		return delete(new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/").append(userName).append("/")
+		return delete(new StringBuilder(sysConf.getLocalBaseDir()).append("/").append(userName).append("/")
 				.append(fileRelativePath).toString());
 	}
 
@@ -148,28 +208,8 @@ public class FileServiceImpl implements FileService {
 		if (!file.exists()) {
 			throw new ReportException("文件不存在,不必删除:" + filePath);
 		}
-		delete(file);
+		FileUtils.delete(file);
 		return filePath;
 	}
 
-	/**
-	 * 递归删除文件(夹)
-	 * 
-	 * @param file
-	 *            文件(夹)
-	 */
-	private void delete(File file) {
-		if (file == null) {
-			return;
-		}
-		if (file.isDirectory()) {
-			File[] files = file.listFiles();
-			for (File f : files) {
-				delete(f);
-			}
-		}
-		file.delete();
-		logger.info("Deleted... " + file.getPath());
-	}
-
 }

+ 6 - 6
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -34,7 +34,7 @@ import com.itextpdf.text.pdf.PdfReader;
 import com.uas.report.core.exception.ReportException;
 import com.uas.report.service.PrintService;
 import com.uas.report.service.ResourceService;
-import com.uas.report.support.JasperserverRestAPIConf;
+import com.uas.report.support.SysConf;
 import com.uas.report.util.ContextUtils;
 import com.uas.report.util.ReportConstants;
 
@@ -64,7 +64,7 @@ import net.sf.jasperreports.export.SimplePdfReportConfiguration;
 public class PrintServiceImpl implements PrintService {
 
 	@Autowired
-	private JasperserverRestAPIConf jsRestAPIConf;
+	private SysConf sysConf;
 
 	@Autowired
 	private ResourceService resourceService;
@@ -186,7 +186,7 @@ public class PrintServiceImpl implements PrintService {
 			data = (byte[]) result.remove("data");
 			pageSize = (Integer) result.remove("pageSize");
 		}
-		if (data == null || pageSize == null) {
+		if (ArrayUtils.isEmpty(data) || pageSize == null) {
 			throw new ReportException("获取预览数据失败");
 		}
 		writeDataToFile(file.getPath(), data);
@@ -303,9 +303,9 @@ public class PrintServiceImpl implements PrintService {
 		}
 
 		// 报表路径为报表根路径REPORT_DIR + 当前账套用户名userName
-		String reportDir = new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/").append(userName).toString();
-		String jrxmlFilePath = new StringBuilder(reportDir).append("/").append(jsRestAPIConf.getLocalJrxmlDir())
-				.append("/").append(reportName).append(".jrxml").toString();
+		String reportDir = new StringBuilder(sysConf.getLocalBaseDir()).append("/").append(userName).toString();
+		String jrxmlFilePath = new StringBuilder(reportDir).append("/").append(sysConf.getLocalJrxmlDir()).append("/")
+				.append(reportName).append(".jrxml").toString();
 		File jrxmlFile = new File(jrxmlFilePath);
 		// 报表模板不存在
 		if (!jrxmlFile.exists()) {

+ 14 - 9
src/main/java/com/uas/report/service/impl/ResourceServiceImpl.java

@@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.uas.report.model.Resource;
 import com.uas.report.service.ResourceService;
 import com.uas.report.support.JasperserverRestAPIConf;
+import com.uas.report.support.SysConf;
 
 /**
  * 管理报表模板、图片等资源
@@ -42,6 +43,9 @@ public class ResourceServiceImpl implements ResourceService {
 	@Autowired
 	private JasperserverRestAPIConf jsRestAPIConf;
 
+	@Autowired
+	private SysConf sysConf;
+
 	private Logger logger = Logger.getLogger(getClass());
 
 	// 是否为windows系统
@@ -50,14 +54,14 @@ public class ResourceServiceImpl implements ResourceService {
 	@Override
 	public List<Resource> syncResources(String userName)
 			throws ClientProtocolException, URISyntaxException, IOException {
-//		logger.info("Synchronizing resources...");
+		// logger.info("Synchronizing resources...");
 		List<Resource> synchronizingResources = getSynchronizingResources(userName);
 		if (!CollectionUtils.isEmpty(synchronizingResources)) {
 			for (Resource synchronizingResource : synchronizingResources) {
 				downloadFile(synchronizingResource);
 			}
 		}
-//		logger.info("Synchronized");
+		// logger.info("Synchronized");
 		return synchronizingResources;
 	}
 
@@ -131,7 +135,7 @@ public class ResourceServiceImpl implements ResourceService {
 	 * @return 资源列表
 	 */
 	private List<Resource> getLocalResources(String userName) {
-		return getLocalResources(new File(jsRestAPIConf.getLocalBaseDir() + File.separator + userName));
+		return getLocalResources(new File(sysConf.getLocalBaseDir() + File.separator + userName));
 	}
 
 	/**
@@ -171,7 +175,7 @@ public class ResourceServiceImpl implements ResourceService {
 		// 替换"\"为"/"
 		String absolutePath = file.getAbsolutePath().replace("\\", "/");
 		// 去除文件绝对路径中前半部分,只保留自账套开始的路径
-		resource.setUri(absolutePath.replace(jsRestAPIConf.getLocalBaseDir(), ""));
+		resource.setUri(absolutePath.replace(sysConf.getLocalBaseDir(), ""));
 		return resource;
 	}
 
@@ -206,7 +210,7 @@ public class ResourceServiceImpl implements ResourceService {
 	private void downloadFile(Resource resource) throws ClientProtocolException, URISyntaxException, IOException {
 		// 如果资源是文件夹,在本地创建
 		if (resource.isFolder()) {
-			File folder = new File(jsRestAPIConf.getLocalBaseDir() + resource.getUri());
+			File folder = new File(sysConf.getLocalBaseDir() + resource.getUri());
 			if (!folder.exists()) {
 				folder.mkdirs();
 				logger.info("Mkdirs " + folder.getPath());
@@ -214,7 +218,7 @@ public class ResourceServiceImpl implements ResourceService {
 			return;
 		}
 
-		String localBaseDir = jsRestAPIConf.getLocalBaseDir();
+		String localBaseDir = sysConf.getLocalBaseDir();
 		// 如果本地资源根路径最后以资源分隔符结尾
 		if (localBaseDir.endsWith(File.separator)) {
 			localBaseDir = localBaseDir.substring(0, localBaseDir.length() - 1);
@@ -230,12 +234,12 @@ public class ResourceServiceImpl implements ResourceService {
 
 		// 下载jrxml文件(即使该远程资源并不在jrxml根路径下,比如在嵌套文件夹下),放在localBaseDir+userName+localJrxmlDir下
 		if (uri.endsWith(Resource.JRXML_RESOURCE_TYPE)) {
-			stringBuilder.append(jsRestAPIConf.getLocalJrxmlDir()).append(resourceName);
+			stringBuilder.append(sysConf.getLocalJrxmlDir()).append(resourceName);
 			downloadFile(uri, Resource.JRXML_MIME_TYPE, stringBuilder.toString());
 		}
 		// 除jrxml之外的资源视为图片,放在localBaseDir+userName+localImagesDir下
 		else {
-			stringBuilder.append(jsRestAPIConf.getLocalImagesDir()).append(resourceName);
+			stringBuilder.append(sysConf.getLocalImagesDir()).append(resourceName);
 			downloadFile(uri, Resource.IMAGE_MIME_TYPE, stringBuilder.toString());
 		}
 	}
@@ -283,7 +287,8 @@ public class ResourceServiceImpl implements ResourceService {
 		// 采用HTTP Basic验证
 		request.setHeader("Authorization", "Basic " + jsRestAPIConf.getAuthorization());
 		HttpResponse response = httpClient.execute(request);
-//		logger.info(request.getMethod() + " " + request.getURI() + " " + response.getStatusLine());
+		// logger.info(request.getMethod() + " " + request.getURI() + " " +
+		// response.getStatusLine());
 		return response;
 	}
 

+ 0 - 42
src/main/java/com/uas/report/support/JasperserverRestAPIConf.java

@@ -59,24 +59,6 @@ public class JasperserverRestAPIConf {
 	@Value("#{js_rest_api.images}")
 	private String images;
 
-	/**
-	 * 本地资源根路径
-	 */
-	@Value("#{js_rest_api.localBaseDir}")
-	private String localBaseDir;
-
-	/**
-	 * 本地资源图片路径
-	 */
-	@Value("#{js_rest_api.localImagesDir}")
-	private String localImagesDir;
-
-	/**
-	 * 本地资源jrxml模板路径
-	 */
-	@Value("#{js_rest_api.localJrxmlDir}")
-	private String localJrxmlDir;
-
 	public String getSchema() {
 		return schema;
 	}
@@ -141,28 +123,4 @@ public class JasperserverRestAPIConf {
 		this.images = images;
 	}
 
-	public String getLocalBaseDir() {
-		return localBaseDir;
-	}
-
-	public void setLocalBaseDir(String localBaseDir) {
-		this.localBaseDir = localBaseDir;
-	}
-
-	public String getLocalImagesDir() {
-		return localImagesDir;
-	}
-
-	public void setLocalImagesDir(String localImagesDir) {
-		this.localImagesDir = localImagesDir;
-	}
-
-	public String getLocalJrxmlDir() {
-		return localJrxmlDir;
-	}
-
-	public void setLocalJrxmlDir(String localJrxmlDir) {
-		this.localJrxmlDir = localJrxmlDir;
-	}
-
 }

+ 83 - 0
src/main/java/com/uas/report/support/SysConf.java

@@ -0,0 +1,83 @@
+package com.uas.report.support;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * 系统参数,通过属性文件注入
+ * 
+ * @author sunyj
+ * @since 2016年11月2日 下午5:18:06
+ */
+@Component
+public class SysConf {
+	/**
+	 * 本地资源根路径
+	 */
+	@Value("#{sys.localBaseDir}")
+	private String localBaseDir;
+
+	/**
+	 * 本地资源图片路径
+	 */
+	@Value("#{sys.localImagesDir}")
+	private String localImagesDir;
+
+	/**
+	 * 本地资源jrxml模板路径
+	 */
+	@Value("#{sys.localJrxmlDir}")
+	private String localJrxmlDir;
+
+	/**
+	 * 标准账套名称(存放标准模板)
+	 */
+	@Value("#{sys.standardMaster}")
+	private String standardMaster;
+
+	/**
+	 * 标准模板地址
+	 */
+	@Value("#{sys.standardJrxmlsUrl}")
+	private String standardJrxmlsUrl;
+
+	public String getLocalBaseDir() {
+		return localBaseDir;
+	}
+
+	public void setLocalBaseDir(String localBaseDir) {
+		this.localBaseDir = localBaseDir;
+	}
+
+	public String getLocalImagesDir() {
+		return localImagesDir;
+	}
+
+	public void setLocalImagesDir(String localImagesDir) {
+		this.localImagesDir = localImagesDir;
+	}
+
+	public String getLocalJrxmlDir() {
+		return localJrxmlDir;
+	}
+
+	public void setLocalJrxmlDir(String localJrxmlDir) {
+		this.localJrxmlDir = localJrxmlDir;
+	}
+
+	public String getStandardMaster() {
+		return standardMaster;
+	}
+
+	public void setStandardMaster(String standardMaster) {
+		this.standardMaster = standardMaster;
+	}
+
+	public String getStandardJrxmlsUrl() {
+		return standardJrxmlsUrl;
+	}
+
+	public void setStandardJrxmlsUrl(String standardJrxmlsUrl) {
+		this.standardJrxmlsUrl = standardJrxmlsUrl;
+	}
+}

+ 69 - 0
src/main/java/com/uas/report/util/FileUtils.java

@@ -0,0 +1,69 @@
+package com.uas.report.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.log4j.Logger;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.report.core.exception.ReportException;
+
+/**
+ * 文件操作工具类
+ * 
+ * @author sunyj
+ * @since 2016年11月3日 上午9:24:04
+ */
+public class FileUtils {
+
+	private static final Logger logger = Logger.getLogger(FileUtils.class);
+
+	/**
+	 * 创建文件
+	 * 
+	 * @param filePath
+	 *            文件路径
+	 * @param data
+	 *            数据
+	 */
+	public static void create(String filePath, byte[] data) {
+		if (StringUtils.isEmpty(filePath) || ArrayUtils.isEmpty(data)) {
+			throw new ReportException("参数不能为空:filePath,data");
+		}
+		File file = new File(filePath);
+		if (!file.getParentFile().exists()) {
+			file.getParentFile().mkdirs();
+		}
+		try {
+			FileOutputStream fos = new FileOutputStream(file);
+			fos.write(data);
+			fos.flush();
+			logger.info("Created..." + file.getPath());
+			fos.close();
+		} catch (IOException e) {
+			throw new ReportException(e).setDetailedMessage(e);
+		}
+	}
+
+	/**
+	 * 递归删除文件(夹)
+	 * 
+	 * @param file
+	 *            文件(夹)
+	 */
+	public static void delete(File file) {
+		if (file == null) {
+			return;
+		}
+		if (file.isDirectory()) {
+			File[] files = file.listFiles();
+			for (File f : files) {
+				delete(f);
+			}
+		}
+		file.delete();
+		logger.info("Deleted... " + file.getPath());
+	}
+}

+ 8 - 7
src/main/java/com/uas/report/util/ZipUtils.java

@@ -40,7 +40,7 @@ public class ZipUtils {
 		}
 		File folder = new File(sourceFolderPath);
 		if (!folder.exists() || !folder.isDirectory()) {
-			throw new ReportException("路径不存在或并非文件夹:" + sourceFolderPath);
+			throw new ReportException("路径不存在或并非文件夹:" + sourceFolderPath);
 		}
 		File[] files = folder.listFiles();
 		if (files.length < 0) {
@@ -51,7 +51,7 @@ public class ZipUtils {
 			ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(zipFilePath));
 			putNextEntryFromFolder(zipOutputStream, folder, "");
 			zipOutputStream.close();
-			logger.info("zip completed");
+			logger.info("Zip finished to... " + zipFilePath);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
@@ -71,7 +71,6 @@ public class ZipUtils {
 		File[] files = folder.listFiles();
 		try {
 			for (File file : files) {
-				logger.info("zip... " + prefix + file.getName());
 				if (file.isDirectory()) {
 					putNextEntryFromFolder(zipOutputStream, file, prefix + file.getName() + File.separator);
 				} else {
@@ -83,6 +82,7 @@ public class ZipUtils {
 					}
 					inputStream.close();
 				}
+				logger.info("Ziped from... " + file.getPath());
 			}
 		} catch (IOException e) {
 			e.printStackTrace();
@@ -119,25 +119,26 @@ public class ZipUtils {
 			Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
 			while (zipEntries.hasMoreElements()) {
 				ZipEntry zipEntry = zipEntries.nextElement();
-				logger.info("unzip... " + zipEntry.getName());
 				InputStream inputStream = zipFile.getInputStream(zipEntry);
 				File outFile = new File(folder.getPath() + File.separator + zipEntry.getName());
 				if (!outFile.getParentFile().exists()) {
 					outFile.getParentFile().mkdirs();
 				}
-				OutputStream outputStream = new FileOutputStream(
-						folder.getPath() + File.separator + zipEntry.getName());
+
+				String fileName = folder.getPath() + File.separator + zipEntry.getName();
+				OutputStream outputStream = new FileOutputStream(fileName);
 				int b;
 				while ((b = inputStream.read()) != -1) {
 					outputStream.write(b);
 				}
 				inputStream.close();
 				outputStream.close();
+				logger.info("Unziped to... " + fileName);
 			}
 			zipFile.close();
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
-		logger.info("unzip completed");
+		logger.info("Unzip finished from... " + zipFilePath);
 	}
 }

+ 1 - 5
src/main/resources/dev/js-rest-api.properties

@@ -5,14 +5,10 @@ contextRoot=jasperserver
 rest=rest_v2
 resources=resources
 authorization=amFzcGVyYWRtaW46amFzcGVyYWRtaW4=
-images=Picture
-localBaseDir=C:/sunyj/reports/60
 #host=localhost
 #port=8081
 #contextRoot=jasperserver
 #rest=rest_v2
 #resources=resources
 #authorization=amFzcGVyYWRtaW46emh1aTEqOA==
-#localBaseDir=C:/sunyj/reports/local
-localImagesDir=/Picture
-localJrxmlDir=/jrxml
+images=Picture

+ 6 - 0
src/main/resources/dev/sys.properties

@@ -0,0 +1,6 @@
+localBaseDir=C:/sunyj/reports/60
+#localBaseDir=C:/sunyj/reports/local
+localImagesDir=/Picture
+localJrxmlDir=/jrxml
+standardMaster=STANDARD_MASTER
+standardJrxmlsUrl=http://localhost:8090/report/file/standardJrxmls?onlyData=1

+ 4 - 0
src/main/resources/spring/applicationContext.xml

@@ -15,6 +15,10 @@
 	<context:property-placeholder location="classpath*:${profile}/*.properties" />
 	<!-- 注册spring上下文对象 -->
 	<bean class="com.uas.report.support.ApplicationContextRegister" />
+
+	<!-- 系统参数注入 -->
+	<util:properties id="sys"
+		location="classpath:${profile}/sys.properties" />
 	<!-- jasperserver rest_v2 api 相关参数注入 -->
 	<util:properties id="js_rest_api"
 		location="classpath:${profile}/js-rest-api.properties" />

+ 1 - 4
src/main/resources/test/js-rest-api.properties

@@ -5,7 +5,4 @@ contextRoot=jasperserver
 rest=rest_v2
 resources=resources
 authorization=amFzcGVyYWRtaW46amFzcGVyYWRtaW4=
-images=Picture
-localBaseDir=/data/reports
-localImagesDir=/Picture
-localJrxmlDir=/jrxml
+images=Picture

+ 5 - 0
src/main/resources/test/sys.properties

@@ -0,0 +1,5 @@
+localBaseDir=/data/reports
+localImagesDir=/Picture
+localJrxmlDir=/jrxml
+standardJrxmls=STANDARD_JRXML
+standardJrxmlsUrl=http://192.168.253.60:8090/report/file/standardJrxmls?onlyData=1

+ 17 - 3
src/main/webapp/WEB-INF/views/index.html

@@ -35,8 +35,7 @@
 							%20rownum<15&printType=EXCEL</li></u>
 				</ol>
 			</ol>
-		</div>
-		<div id="rightContainer">
+
 			<h2>2. 上传、下载、删除</h2>
 			<ol>
 				<strong><li class="title1">上传</li></strong>
@@ -57,7 +56,22 @@
 				</ol>
 			</ol>
 
-			<h2>3. 接口</h2>
+		</div>
+		<div id="rightContainer">
+			<h2>3. 标准模板</h2>
+			<ol>
+				<strong><li class="title1">标准模板</li></strong>
+				<ol>
+					<u><li class="href">file/standardJrxmls</li></u>
+					<u><li class="href">file/standardJrxmls?onlyData=1</li></u>
+				</ol>
+				<strong><li class="title1">自动部署新账套</li></strong>
+				<ol>
+					<u><li class="href">file/autoDeploy?userNames=UAS,UAS_TEST</li></u>
+				</ol>
+			</ol>
+
+			<h2>4. 接口</h2>
 			<ol>
 				<strong><li class="title2">打印接口</li></strong>
 				<ol>

+ 3 - 3
src/main/webapp/resources/css/index.css

@@ -3,7 +3,7 @@ body {
 }
 
 h2 {
-	margin-top: 10px;
+	margin-top: 20px;
 	margin-bottom: 10px;
 }
 
@@ -14,14 +14,14 @@ h2 {
 
 #leftContainer {
 	float: left;
-	width: 38%;
+	width: 50%;
 	margin-left: 2%;
 	margin-right: 2%;
 }
 
 #rightContainer {
 	float: right;
-	width: 54%;
+	width: 42%;
 	margin-left: 2%;
 	margin-right: 2%;
 }

+ 2 - 4
src/main/webapp/resources/js/upload/app.js

@@ -17,9 +17,9 @@ $(':file').change(function() {
  * 上传文件
  */
 function upload() {
+	$('#progressDiv').css("display", "hidden");
 	var value = document.getElementById("file").value;
 	if (!value) {
-		$('#progressDiv').css("display", "hidden");
 		$("#result").html("文件为空,无法进行上传!");
 		return;
 	}
@@ -29,14 +29,12 @@ function upload() {
 	var ext = value.substring(value.lastIndexOf(".") + 1);
 	if (fileType == "jrxml" || fileType == "zip") {
 		if (fileType != ext) {
-			$('#progressDiv').css("display", "hidden");
 			$("#result").html("文件并非" + fileType);
 			return;
 		}
 	} else if (fileType == "image") {
 		if (!/^(gif|jpg|jpeg|png|bmp|tiff|pcx|tga|exif|fpx|svg|psd|cdr|pcd|dxf|ufo|eps|ai|raw)$/
 				.test(ext)) {
-			$('#progressDiv').css("display", "hidden");
 			$("#result").html("文件并非图片");
 			return;
 		}
@@ -44,7 +42,7 @@ function upload() {
 
 	// 创建FormData对象,初始化为form表单中的数据
 	var formData = new FormData($('form')[0]);
-	var userName = getParameter("userName") || "UAS";
+	var userName = getParameter("userName") || "tmp";
 	formData.append('userName', userName);
 	formData.append('fileType', fileType);