Browse Source

tomcat的bin目录下临时文件删除操作

user5 3 years ago
parent
commit
ce3560aee1

+ 15 - 0
src/main/java/com/jeeplus/modules/projectcontentinfo/service/ProjectReportRecordService.java

@@ -1423,6 +1423,13 @@ public class ProjectReportRecordService extends CrudService<ProjectReportRecordD
 			if (!file.isDirectory()) {
 				file.delete();
 			}
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+time + "备考表.doc");
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
 		}
 		return uploadPath;
 	}
@@ -1510,6 +1517,14 @@ public class ProjectReportRecordService extends CrudService<ProjectReportRecordD
 			if (!file.isDirectory()) {
 				file.delete();
 			}
+
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+time + "文件目录.doc");
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
 		}
 		return uploadPath;
 	}

+ 8 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectMessageNewService.java

@@ -4213,6 +4213,14 @@ public class RuralProjectMessageNewService extends CrudService<RuralProjectMessa
             if (!file.isDirectory()) {
                 file.delete();
             }
+
+            //获取tomcat的路径
+            String tomcatFilePath=System.getProperty("catalina.home");
+            //删除tomcat目录下的处理后的文件信息
+            File tomcatFile = new File(tomcatFilePath+"/bin/"+time + "文件目录.doc");
+            if (tomcatFile.isFile()) {
+                tomcatFile.delete();
+            }
         }
         return uploadPath;
     }

+ 9 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectRecordTwoService.java

@@ -454,6 +454,15 @@ public class RuralProjectRecordTwoService  extends CrudService<RuralProjectMessa
             if (!file.isDirectory()) {
                 file.delete();
             }
+
+            //获取tomcat的路径
+            String tomcatFilePath=System.getProperty("catalina.home");
+            //删除tomcat目录下的处理后的文件信息
+            File tomcatFile = new File(tomcatFilePath+"/bin/"+time + "文件目录.doc");
+            if (tomcatFile.isFile()) {
+                tomcatFile.delete();
+            }
+
         }
         return uploadPath;
     }

+ 460 - 1
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/RuralProjectRecordsService.java

@@ -3,9 +3,14 @@
  */
 package com.jeeplus.modules.ruralprojectrecords.service;
 
+import com.alibaba.fastjson.JSON;
+import com.github.junrar.Archive;
+import com.github.junrar.rarfile.FileHeader;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.persistence.Page;
 import com.jeeplus.common.service.CrudService;
 import com.jeeplus.common.utils.*;
@@ -40,6 +45,7 @@ import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectRecordsDao;
 import com.jeeplus.modules.ruralprojectrecords.dao.RuralWorkProjectUserDao;
 import com.jeeplus.modules.ruralprojectrecords.entity.*;
 import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
+import com.jeeplus.modules.ruralprojectrecords.utils.ImportExcelUtil;
 import com.jeeplus.modules.serialnum.service.SerialNumTplService;
 import com.jeeplus.modules.sys.dao.UserDao;
 import com.jeeplus.modules.sys.entity.*;
@@ -76,19 +82,29 @@ import org.activiti.engine.history.HistoricTaskInstance;
 import org.activiti.engine.history.HistoricTaskInstanceQuery;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZFile;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.math.BigDecimal;
+import java.net.URI;
 import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 /**
  * 项目登记Service
@@ -98,6 +114,10 @@ import java.util.*;
 @Service
 @Transactional(readOnly = true)
 public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsDao, RuralProjectRecords> {
+
+	private final static String directory = Global.getConfig("remoteServer.directory");
+
+	private static Logger logger = LoggerFactory.getLogger(RuralProjectRecordsService.class);
 	/**
 	 * 阿里云文件服务器前缀
 	 */
@@ -2879,7 +2899,7 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
 
 	/**
 	 * 根据报告号查询项目信息
-	 * @param reportNumber
+	 * @param projectId
 	 * @return
 	 */
 	public Integer getEfficientProjectFlingbatchRelationByProjectId(String projectId) {
@@ -2939,4 +2959,443 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
 	}
 
 
+
+	/**
+	 * MultipartFile转File
+	 * @param file
+	 * @return
+	 * @throws IOException
+	 */
+	public static File transformMultipartFile( MultipartFile file) throws IOException {
+		File srcFile = null;
+		//MultipartFile转File
+		if (file.equals("") || file.getSize() <= 0) {
+			file = null;
+		} else {
+			InputStream ins = null;
+			ins = file.getInputStream();
+			srcFile = new File(file.getOriginalFilename());
+			inputStreamToFile(ins, srcFile);
+			ins.close();
+		}
+		return srcFile;
+	}
+
+
+	/**
+	 * 获取流文件
+	 * @param ins
+	 * @param file
+	 */
+	public static void inputStreamToFile(InputStream ins, File file) {
+		try {
+			OutputStream os = new FileOutputStream(file);
+			int bytesRead = 0;
+			byte[] buffer = new byte[8192];
+			while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+				os.write(buffer, 0, bytesRead);
+			}
+			os.close();
+			ins.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		}
+	}
+
+	/**
+	 * 压缩文件处理
+	 * @param projectRecords
+	 * @param file
+	 * @throws IllegalStateException
+	 * @throws IOException
+	 */
+	@Transactional(readOnly = false)
+	public Integer compressFileManage(RuralProjectRecords projectRecords, MultipartFile file) throws IllegalStateException, IOException {
+		//MultipartFile转File
+		File srcFile = transformMultipartFile(file);
+		//获取文件暂存路径
+		String destDirPath= null;
+		if(System.getProperty("os.name").toLowerCase().contains("win")){
+			destDirPath = Global.getConfig("windowsPath")+"/temporaryFile";
+		}else{
+			destDirPath = Global.getConfig("linuxPath")+"/temporaryFile";
+		}
+		// 判断源文件是否存在
+		if (!srcFile.exists()) {
+			throw new RuntimeException(srcFile.getPath() + "所指文件不存在");
+		}
+		//获取文件的后缀名
+		String fileName = srcFile.getName();
+		String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
+		//根据文件后缀进行解压缩
+		switch (suffix){
+			case "zip" :
+				unZipFile(srcFile,destDirPath);
+				break;
+			case "7z" :
+				un7zFile(srcFile,destDirPath);
+				break;
+			case "rar" :
+				realExtract(srcFile,destDirPath,"C:\\Program Files\\WinRAR\\WinRAR.exe");
+				break;
+		}
+		//对压缩文件进行处理并返回
+		return this.subProjectFileManage(projectRecords,destDirPath);
+	}
+
+	/**
+	 * zip文件解压
+	 * @param file
+	 */
+	public static void unZipFile(File file,String destDirPath){
+		// 开始解压
+		ZipFile zipFile = null;
+		try {
+			//zipFile = new ZipFile(file);
+			//添加解压编码,解决解压报错问题
+			zipFile = new ZipFile(file, Charset.forName("GBK"));
+			Enumeration<?> entries = zipFile.entries();
+			while (entries.hasMoreElements()) {
+				ZipEntry entry = (ZipEntry) entries.nextElement();
+				System.out.println("解压" + entry.getName());
+				// 如果是文件夹,就创建个文件夹
+				if (entry.isDirectory()) {
+					String dirPath = destDirPath + "/" + entry.getName();
+					File dir = new File(dirPath);
+					dir.mkdirs();
+				} else {
+					// 如果是文件,就先创建一个文件,然后用io流把内容copy过去
+					File targetFile = new File(destDirPath + "/" + entry.getName());
+					// 保证这个文件的父文件夹必须要存在
+					if(!targetFile.getParentFile().exists()){
+						targetFile.getParentFile().mkdirs();
+					}
+					targetFile.createNewFile();
+					// 将压缩文件内容写入到这个文件中
+					InputStream is = zipFile.getInputStream(entry);
+					FileOutputStream fos = new FileOutputStream(targetFile);
+					int len;
+					byte[] buf = new byte[1024];
+					while ((len = is.read(buf)) != -1) {
+						fos.write(buf, 0, len);
+					}
+					// 关流顺序,先打开的后关闭
+					fos.close();
+					is.close();
+				}
+			}
+		} catch (Exception e) {
+			logger.error("Exception e:"+e);
+		} finally {
+			if(zipFile != null){
+				try {
+					zipFile.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+					logger.error("Exception e:"+e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * 7z文件解压
+	 * @param srcFile
+	 */
+	public static void un7zFile(File srcFile,String destDirPath) {
+		//开始解压
+		SevenZFile zIn = null;
+		try {
+			zIn = new SevenZFile(srcFile);
+			SevenZArchiveEntry entry = null;
+			File file = null;
+			while ((entry = zIn.getNextEntry()) != null) {
+				if (!entry.isDirectory()) {
+					file = new File(destDirPath, entry.getName());
+					if (!file.exists()) {
+						new File(file.getParent()).mkdirs();//创建此文件的上级目录
+					}
+					OutputStream out = new FileOutputStream(file);
+					BufferedOutputStream bos = new BufferedOutputStream(out);
+					int len = -1;
+					byte[] buf = new byte[1024];
+					while ((len = zIn.read(buf)) != -1) {
+						bos.write(buf, 0, len);
+					}
+					// 关流顺序,先打开的后关闭
+					bos.close();
+					out.close();
+				}
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		} finally {
+			if(zIn != null){
+				try {
+					zIn.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+					logger.error("Exception e:"+e);
+				}
+			}
+		}
+	}
+	/**
+	 * 采用命令行方式解压文件
+	 * @param zipFile 压缩文件
+	 * @param destDir 解压结果路径
+	 * @param cmdPath WinRAR.exe的路径,也可以在代码中写死
+	 * @return
+	 */
+	public static boolean realExtract(File zipFile, String destDir,String cmdPath) {
+		// 解决路径中存在/..格式的路径问题
+		destDir = new File(destDir).getAbsoluteFile().getAbsolutePath();
+		while(destDir.contains("..")) {
+			String[] sepList = destDir.split("\\\\");
+			destDir = "";
+			for (int i = 0; i < sepList.length; i++) {
+				if(!"..".equals(sepList[i]) && i < sepList.length -1 && "..".equals(sepList[i+1])) {
+					i++;
+				} else {
+					destDir += sepList[i] + File.separator;
+				}
+			}
+		}
+
+		boolean bool = false;
+		if (!zipFile.exists()) {
+			return false;
+		}
+
+		// 开始调用命令行解压,参数-o+是表示覆盖的意思
+		String cmd = cmdPath + " X -o+ " + zipFile + " " + destDir;
+		System.out.println(cmd);
+		try {
+			Process proc = Runtime.getRuntime().exec(cmd);
+			if (proc.waitFor() != 0) {
+				if (proc.exitValue() == 0) {
+					bool = false;
+				}
+			} else {
+				bool = true;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		}
+		System.out.println("解压" + (bool ? "成功" : "失败"));
+		return bool;
+	}
+	/**
+	 * 根据父项目信息和压缩文件解压路径进行数据处理
+	 * @param projectRecords
+	 * @param destDirPath
+	 */
+	@Transactional(readOnly = false)
+	public Integer subProjectFileManage(RuralProjectRecords projectRecords,String destDirPath){
+		Integer result = 0;
+		File file = null;
+		try {
+			file = new File(destDirPath);
+			File[] files = file.listFiles();
+			Arrays.sort(files);
+			if(files.length > 1){
+				for (int i = 0; i<files.length;i++){
+					if (files[i].isFile()){
+						InputStreamReader reader = null;
+						reader = new InputStreamReader(new FileInputStream(files[i]));
+						BufferedReader bufferedReader = new BufferedReader(reader);
+						String line = "";
+						line = bufferedReader.readLine();
+						while (line != null){
+							System.out.println(files[i].getName()+":"+line);
+							line = bufferedReader.readLine();
+						}
+						bufferedReader.close();
+					}
+				}
+			}else{
+				while (files.length == 1){
+					files = getFiles(files[0].toURI());
+				}
+				for (File fileInfo: files) {
+					//判断fileInfo是文件而不是文件夹
+					if(!fileInfo.isFile()){
+						this.disposeAccessory(files,projectRecords);
+					}
+				}
+			}
+
+		}  catch (Exception e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		}finally {
+			deleteAllFilesOfDir(file);
+		}
+		return result;
+	}
+
+	/**
+	 * 根据地址获取File文件
+	 * @param destDirPath
+	 * @return
+	 */
+	public static File[] getFiles(URI destDirPath){
+		File file = new File(destDirPath);
+		File[] files = file.listFiles();
+		return files;
+	}
+
+
+	public void disposeAccessory(File[] files,RuralProjectRecords projectRecords){
+		List<Workattachment> workAttachments = Lists.newArrayList();
+		//再次遍历
+		for (File fileInfo: files) {
+			//判断fileInfo是文件夹而不是文件
+			if(fileInfo.isDirectory()){
+				//获取文件的后缀名
+				String fileName = fileInfo.getName();
+				//获取对应文件名
+				String suffix = projectRecords.getProjectName()+"-"+projectRecords.getId();
+				//判断是否为当前项目的对应文件夹
+				if(com.jeeplus.common.utils.StringUtils.isNotBlank(suffix) && fileName.equals(suffix)){
+					File[] fileList = getFiles(fileInfo.toURI());
+					for (File file: fileList) {
+						//创建附件信息
+						if(file.isDirectory() && "成果文件".equals(file.getName())){
+							File[] attachmentList = getFiles(file.toURI());
+							for (File attachment: attachmentList) {
+								if(attachment.isFile()){
+									String uploadUrl = uploadUrl(transformFile(attachment),"subAttachmentFile");
+									Workattachment work = new Workattachment();
+									work.setUrl(uploadUrl);
+									work.setDivIdType("_subAttachment");
+									work.setAttachmentName(attachment.getName());
+									work.setDelFlag("0");
+									work.setAttachmentId(projectRecords.getId());
+									workAttachments.add(work);
+								}
+							}
+							//projectRecords.setWorkAttachments(workAttachments);
+						}else if(file.isDirectory() && "依据性文件".equals(file.getName())){
+							File[] attachmentList = getFiles(file.toURI());
+							for (File attachment: attachmentList) {
+								if(attachment.isFile()){
+									String uploadUrl = uploadUrl(transformFile(attachment),"subGistdataFile");
+									Workattachment work = new Workattachment();
+									work.setUrl(uploadUrl);
+									work.setDivIdType("_subGistdata");
+									work.setAttachmentName(attachment.getName());
+									work.setDelFlag("0");
+									work.setAttachmentId(projectRecords.getId());
+									workAttachments.add(work);
+								}
+							}
+							//projectRecords.setWorkAttachments(workAttachments);
+						}else if(file.isDirectory() && "其他文件".equals(file.getName())){
+							File[] attachmentList = getFiles(file.toURI());
+							for (File attachment: attachmentList) {
+								if(attachment.isFile()){
+									String uploadUrl = uploadUrl(transformFile(attachment),"subOtherFile");
+									Workattachment work = new Workattachment();
+									work.setUrl(uploadUrl);
+									work.setDivIdType("_subOther");
+									work.setAttachmentName(attachment.getName());
+									work.setDelFlag("0");
+									work.setAttachmentId(projectRecords.getId());
+									workAttachments.add(work);
+								}
+							}
+							//projectRecords.setWorkAttachments(workAttachments);
+						}
+					}
+				}
+			}
+		}
+	}
+
+
+
+	/**
+	 * File转MultipartFile
+	 * @param file
+	 * @return
+	 */
+	public static MultipartFile transformFile(File file){
+		InputStream inputStream = null;
+		MultipartFile multipartFile = null;
+		try {
+			inputStream = new FileInputStream(file);
+			multipartFile = new MockMultipartFile(file.getName(), inputStream);
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		} catch (IOException e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		}
+		return multipartFile;
+	}
+
+	/**
+	 * 附件上传
+	 * @param file
+	 * @returngetSessionTimeout
+	 */
+	public static String uploadUrl(MultipartFile file,String storeAs){
+		String path = "";
+		if(System.getProperty("os.name").toLowerCase().contains("win")){
+			path = Global.getConfig("remoteServer.winDirectory");
+		}else{
+			path = Global.getConfig("remoteServer.directory");
+		}
+		path = path+ "/"+"subProject" + new Date().getTime() + "/" + file.getName() ;
+		BOSClientUtil bosClientUtil = new BOSClientUtil();
+		InputStream inputStream = null;
+		try {
+			inputStream = file.getInputStream();
+		} catch (IOException e) {
+			e.printStackTrace();
+			logger.error("Exception e:"+e);
+		}
+		//通过百度云进行文件上传
+		//String uploadUrl = bosClientUtil.upload(path, inputStream);
+		//通过阿里云进行文件上传
+		OSSClientUtil ossUtil = new OSSClientUtil();
+
+		String realPath =directory.replace("/","")+datePath()+"/subProject/"+storeAs+"/";
+		String uploadUrl = ossUtil.uploadFile2OSS(inputStream, realPath, file.getName());
+		uploadUrl = Global.getAliDownloadUrl() + "/" + realPath + file.getName();
+		return uploadUrl;
+	}
+
+
+	private static String datePath(){
+
+		Calendar date = Calendar.getInstance();
+		String year = String.valueOf(date.get(Calendar.YEAR));
+		String month = String.valueOf(date.get(Calendar.MONTH)+1);
+		String day = String.valueOf(date.get(Calendar.DAY_OF_MONTH));
+		String path = "/"+year+"/"+month+"/"+day;
+		return path;
+	}
+	/**
+	 * 删除解压文件
+	 * @param path
+	 */
+	public static void deleteAllFilesOfDir(File path) {
+		if (!path.exists())
+			return;
+		if (path.isFile()) {
+			path.delete();
+			return;
+		}
+		File[] files = path.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			deleteAllFilesOfDir(files[i]);
+		}
+		path.delete();
+	}
 }

+ 28 - 6
src/main/java/com/jeeplus/modules/ruralprojectrecords/service/SubProjectInfoService.java

@@ -6,6 +6,7 @@ import com.github.junrar.rarfile.FileHeader;
 import com.google.common.collect.Lists;
 import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.persistence.Page;
 import com.jeeplus.common.service.CrudService;
 import com.jeeplus.common.utils.MenuStatusEnum;
@@ -54,6 +55,9 @@ import java.util.Enumeration;
 @Service
 @Transactional(readOnly = true)
 public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubProjectInfo> {
+
+    private final static String directory = Global.getConfig("remoteServer.directory");
+
     private static Logger logger = LoggerFactory.getLogger(SubProjectInfoService.class);
     @Autowired
     private WorkattachmentDao workattachmentDao;
@@ -375,7 +379,7 @@ public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubPro
                             File[] attachmentList = getFiles(file.toURI());
                             for (File attachment: attachmentList) {
                                 if(attachment.isFile()){
-                                    String uploadUrl = uploadUrl(transformFile(attachment));
+                                    String uploadUrl = uploadUrl(transformFile(attachment),"subAttachmentFile");
                                     Workattachment work = new Workattachment();
                                     work.setUrl(uploadUrl);
                                     work.setDivIdType("_subAttachment");
@@ -390,7 +394,7 @@ public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubPro
                             File[] attachmentList = getFiles(file.toURI());
                             for (File attachment: attachmentList) {
                                 if(attachment.isFile()){
-                                    String uploadUrl = uploadUrl(transformFile(attachment));
+                                    String uploadUrl = uploadUrl(transformFile(attachment),"subGistdataFile");
                                     Workattachment work = new Workattachment();
                                     work.setUrl(uploadUrl);
                                     work.setDivIdType("_subGistdata");
@@ -405,7 +409,7 @@ public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubPro
                             File[] attachmentList = getFiles(file.toURI());
                             for (File attachment: attachmentList) {
                                 if(attachment.isFile()){
-                                    String uploadUrl = uploadUrl(transformFile(attachment));
+                                    String uploadUrl = uploadUrl(transformFile(attachment),"subOtherFile");
                                     Workattachment work = new Workattachment();
                                     work.setUrl(uploadUrl);
                                     work.setDivIdType("_subOther");
@@ -428,14 +432,14 @@ public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubPro
      * @param file
      * @returngetSessionTimeout
      */
-    public static String uploadUrl(MultipartFile file){
+    public static String uploadUrl(MultipartFile file,String storeAs){
         String path = "";
         if(System.getProperty("os.name").toLowerCase().contains("win")){
             path = Global.getConfig("remoteServer.winDirectory");
         }else{
             path = Global.getConfig("remoteServer.directory");
         }
-        path = path+ "/"+"subProject" + new Date().getTime() + "/" + file.getName();
+        path = path+ "/"+"subProject" + new Date().getTime() + "/" + file.getName() ;
         BOSClientUtil bosClientUtil = new BOSClientUtil();
         InputStream inputStream = null;
         try {
@@ -444,10 +448,28 @@ public class SubProjectInfoService extends CrudService<SubProjectInfoDao, SubPro
             e.printStackTrace();
             logger.error("Exception e:"+e);
         }
-        String uploadUrl = bosClientUtil.upload(path, inputStream);
+        //通过百度云进行文件上传
+        //String uploadUrl = bosClientUtil.upload(path, inputStream);
+        //通过阿里云进行文件上传
+        OSSClientUtil ossUtil = new OSSClientUtil();
+
+        String realPath =directory.replace("/","")+datePath()+"/subProject/"+storeAs+"/";
+        String uploadUrl = ossUtil.uploadFile2OSS(inputStream, realPath, file.getName());
+        uploadUrl = Global.getAliDownloadUrl() + "/" + realPath + file.getName();
         return uploadUrl;
     }
 
+
+    private static String datePath(){
+
+        Calendar date = Calendar.getInstance();
+        String year = String.valueOf(date.get(Calendar.YEAR));
+        String month = String.valueOf(date.get(Calendar.MONTH)+1);
+        String day = String.valueOf(date.get(Calendar.DAY_OF_MONTH));
+        String path = "/"+year+"/"+month+"/"+day;
+        return path;
+    }
+
     /**
      * 根据地址获取File文件
      * @param destDirPath

+ 44 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralCostProjectRecordsController.java

@@ -28,6 +28,7 @@ import com.jeeplus.modules.projectrecord.service.ProjectPlanService;
 import com.jeeplus.modules.ruralprojectrecords.entity.ImportBRuralProjectRecords;
 import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
 import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectcontentinfo;
+import com.jeeplus.modules.ruralprojectrecords.entity.SubProjectInfo;
 import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectMessageService;
 import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
@@ -63,6 +64,8 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.ConstraintViolationException;
+import java.io.File;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.text.SimpleDateFormat;
@@ -1060,4 +1063,45 @@ public class RuralCostProjectRecordsController extends BaseController {
 			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralCostProjectRecords/?repage";
 		}
 	}
+
+	/**
+	 * 跳转上传压缩文件页
+	 * @param projectRecords
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "importFile")
+	public String importFile(RuralProjectRecords projectRecords, Model model) {
+		model.addAttribute("projectRecords", projectRecords);
+		model.addAttribute("Global", new Global());
+		return "modules/ruralprojectrecords/compress/projectFileForm";
+	}
+
+	/**
+	 * 对压缩文件进行处理
+	 * @param subProjectInfo
+	 * @param file
+	 * @return
+	 * @throws IllegalStateException
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "importCompressFile")
+	@ResponseBody
+	public Integer importCompressFile(RuralProjectRecords projectRecords, MultipartFile file) throws IllegalStateException, IOException {
+		Integer result = null;
+		try {
+			result = projectRecordsService.compressFileManage(projectRecords, file);
+		}catch (Exception e){
+
+		}finally {
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+file.getOriginalFilename());
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
+		}
+		return result;
+	}
 }

+ 15 - 5
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectMessageElectronicSealController.java

@@ -739,15 +739,25 @@ public class RuralProjectMessageElectronicSealController extends BaseController
             cfg.setDirectoryForTemplateLoading(path);
             //选择对应的ftl文件
             template = cfg.getTemplate("projectSignature.ftl","UTF-8");
+            File docFile = new File("报告号【"+number + "】报告签章.doc");
+            FreemarkerUtil.generateFile(data,template,docFile);
+            ResponseUtil.docResponse("报告号【"+number + "】项目名称:" + projectName + " 报告签章.doc",docFile,response);
+            //将生成的文件上传到阿里云中
+            ruralProjectMessageElectronicSealService.uploadOss(projectReportData,docFile);
         } catch (IOException e) {
             e.printStackTrace();
+        }finally {
+
+            //获取tomcat的路径
+            String tomcatFilePath=System.getProperty("catalina.home");
+            //删除tomcat目录下的处理后的文件信息
+            File tomcatFile = new File(tomcatFilePath+"/bin/"+"报告号【"+number + "】报告签章.doc");
+            if (tomcatFile.isFile()) {
+                tomcatFile.delete();
+            }
         }
 
-        File docFile = new File("报告号【"+number + "】报告签章.doc");
-        FreemarkerUtil.generateFile(data,template,docFile);
-        ResponseUtil.docResponse("报告号【"+number + "】项目名称:" + projectName + " 报告签章.doc",docFile,response);
-        //将生成的文件上传到阿里云中
-        ruralProjectMessageElectronicSealService.uploadOss(projectReportData,docFile);
+
     }
 
     /**

+ 68 - 57
src/main/java/com/jeeplus/modules/workcalendar/service/WorkCalendarTaskService.java

@@ -127,75 +127,86 @@ public class WorkCalendarTaskService  {
      * 月度报表
      */
     //每个月最后一天晚上23点推送
-    /*@Scheduled(cron= "0 0 23 L * ?")
+    //@Scheduled(cron= "0 0 23 L * ?")
+    @Scheduled(cron= "0 0 23 28-31 * ?")
     public void getStatementCompanyComprehensiveOnMonth() {
-        logger.info("-----------公司级—项目月度报表(开始)------------------");
-        projectRecordsService.saveProjectReportedListByAdvent();
-        logger.info("------------公司级—项目月度报表(结束)------------------");
-        logger.info("-----------公司级—开票月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—开票月度报表(结束)------------------");
-        logger.info("-----------公司级—报销月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—报销月度报表(结束)------------------");
-        logger.info("-----------公司级—合同月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—合同月度报表(结束)------------------");
-
+        final Calendar c = Calendar.getInstance();
+        if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)){
+            //当月最后一天
+            logger.info("-----------公司级—项目月度报表(开始)------------------");
+            projectRecordsService.saveProjectReportedListByAdvent();
+            logger.info("------------公司级—项目月度报表(结束)------------------");
+            logger.info("-----------公司级—开票月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—开票月度报表(结束)------------------");
+            logger.info("-----------公司级—报销月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—报销月度报表(结束)------------------");
+            logger.info("-----------公司级—合同月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—合同月度报表(结束)------------------");
+
+
+            logger.info("-----------部门级—项目月度报表(开始)------------------");
+            projectRecordsService.saveProjectReportedListByAdvent();
+            logger.info("------------部门级—项目月度报表(结束)------------------");
+            logger.info("-----------部门级—开票月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—开票月度报表(结束)------------------");
+            logger.info("-----------部门级—报销月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—报销月度报表(结束)------------------");
+            logger.info("-----------部门级—合同月度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—合同月度报表(结束)------------------");
+        }
 
-        logger.info("-----------部门级—项目月度报表(开始)------------------");
-        projectRecordsService.saveProjectReportedListByAdvent();
-        logger.info("------------部门级—项目月度报表(结束)------------------");
-        logger.info("-----------部门级—开票月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—开票月度报表(结束)------------------");
-        logger.info("-----------部门级—报销月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—报销月度报表(结束)------------------");
-        logger.info("-----------部门级—合同月度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—合同月度报表(结束)------------------");
-    }*/
+    }
 
     /**
      * 季度报表
      */
     //每个季度最后一天晚上23点推送
-    /*@Scheduled(cron= "0 0 23 L 3,6,9,12 ?")
+    //@Scheduled(cron= "0 0 23 L 3,6,9,12 ?")
+    @Scheduled(cron= "0 0 23 28-31 3,6,9,12 ?")
     public void getStatementCompanyComprehensiveOnQuarter() {
-        logger.info("-----------公司级—项目季度报表(开始)------------------");
-        projectRecordsService.saveProjectReportedListByAdvent();
-        logger.info("------------公司级—项目季度报表(结束)------------------");
-        logger.info("-----------公司级—开票季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—开票季度报表(结束)------------------");
-        logger.info("-----------公司级—报销季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—报销季度报表(结束)------------------");
-        logger.info("-----------公司级—合同季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------公司级—合同季度报表(结束)------------------");
-
-
-        logger.info("-----------部门级—项目季度报表(开始)------------------");
-        projectRecordsService.saveProjectReportedListByAdvent();
-        logger.info("------------部门级—项目季度报表(结束)------------------");
-        logger.info("-----------部门级—开票季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—开票季度报表(结束)------------------");
-        logger.info("-----------部门级—报销季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—报销季度报表(结束)------------------");
-        logger.info("-----------部门级—合同季度报表(开始)------------------");
-        projectRecordsService.saveProjectRecordListByAdvent();
-        logger.info("------------部门级—合同季度报表(结束)------------------");
-    }*/
+        final Calendar c = Calendar.getInstance();
+        if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)){
+            //当月最后一天
+            logger.info("-----------公司级—项目季度报表(开始)------------------");
+            projectRecordsService.saveProjectReportedListByAdvent();
+            logger.info("------------公司级—项目季度报表(结束)------------------");
+            logger.info("-----------公司级—开票季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—开票季度报表(结束)------------------");
+            logger.info("-----------公司级—报销季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—报销季度报表(结束)------------------");
+            logger.info("-----------公司级—合同季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------公司级—合同季度报表(结束)------------------");
+
+
+            logger.info("-----------部门级—项目季度报表(开始)------------------");
+            projectRecordsService.saveProjectReportedListByAdvent();
+            logger.info("------------部门级—项目季度报表(结束)------------------");
+            logger.info("-----------部门级—开票季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—开票季度报表(结束)------------------");
+            logger.info("-----------部门级—报销季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—报销季度报表(结束)------------------");
+            logger.info("-----------部门级—合同季度报表(开始)------------------");
+            projectRecordsService.saveProjectRecordListByAdvent();
+            logger.info("------------部门级—合同季度报表(结束)------------------");
+        }
+    }
 
     /**
      * 年度报表
      */
     //每年最后一天晚上23点推送
-    /*@Scheduled(cron= "0 0 23 31 12 ?")
+    @Scheduled(cron= "0 0 23 31 12 ?")
     public void getStatementCompanyComprehensiveOnYear() {
         logger.info("-----------公司级—项目年度报表(开始)------------------");
         projectRecordsService.saveProjectReportedListByAdvent();
@@ -223,6 +234,6 @@ public class WorkCalendarTaskService  {
         logger.info("-----------部门级—合同年度报表(开始)------------------");
         projectRecordsService.saveProjectRecordListByAdvent();
         logger.info("------------部门级—合同年度报表(结束)------------------");
-    }*/
+    }
 
 }

+ 33 - 7
src/main/java/com/jeeplus/modules/workfullmanage/web/WorkFullManageController.java

@@ -921,6 +921,15 @@ public class WorkFullManageController extends BaseController {
 			System.out.println();
 		} catch (MalformedURLException e) {
 			e.printStackTrace();
+		}finally {
+
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+"工程造价咨询质量控制流程单.doc");
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
 		}
 		return "http://4pwi9k.natappfree.cc" + url;
 	}
@@ -945,14 +954,23 @@ public class WorkFullManageController extends BaseController {
 			cfg.setDirectoryForTemplateLoading(path);
 			//选择对应的ftl文件
 			template = cfg.getTemplate("massControl.ftl","UTF-8");
+
+			File docFile = new File("工程造价咨询质量控制流程单.doc");
+			FreemarkerUtil.generateFile(data,template,docFile);
+			ResponseUtil.docResponse("工程造价咨询质量控制流程单.doc",docFile,response);
 		} catch (IOException e) {
 			e.printStackTrace();
+		}finally {
+
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+"工程造价咨询质量控制流程单.doc");
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
 		}
 
-		File docFile = new File("工程造价咨询质量控制流程单.doc");
-		FreemarkerUtil.generateFile(data,template,docFile);
-		ResponseUtil.docResponse("工程造价咨询质量控制流程单.doc",docFile,response);
-
 	}
 	/**
 	 * 下载签发流程单信息
@@ -974,13 +992,21 @@ public class WorkFullManageController extends BaseController {
 			cfg.setDirectoryForTemplateLoading(path);
 			//选择对应的ftl文件
 			template = cfg.getTemplate("issueProcess.ftl","UTF-8");
+			File docFile = new File("咨询报告书(底稿)签发流程表.doc");
+			FreemarkerUtil.generateFile(data,template,docFile);
+			ResponseUtil.docResponse("咨询报告书(底稿)签发流程表.doc",docFile,response);
 		} catch (IOException e) {
 			e.printStackTrace();
+		}finally {
+			//获取tomcat的路径
+			String tomcatFilePath=System.getProperty("catalina.home");
+			//删除tomcat目录下的处理后的文件信息
+			File tomcatFile = new File(tomcatFilePath+"/bin/"+"咨询报告书(底稿)签发流程表.doc");
+			if (tomcatFile.isFile()) {
+				tomcatFile.delete();
+			}
 		}
 
-		File docFile = new File("咨询报告书(底稿)签发流程表.doc");
-		FreemarkerUtil.generateFile(data,template,docFile);
-		ResponseUtil.docResponse("咨询报告书(底稿)签发流程表.doc",docFile,response);
 
 	}
 

+ 32 - 0
src/main/webapp/webpage/modules/ruralprojectrecords/cost/ruralCostProjectRecordsList.jsp

@@ -309,6 +309,37 @@
 			});
 
 		}
+
+
+
+		function btnImport(id){
+			top.layer.open({
+				type: 2,
+				area: ['25%', '50%'],
+				title: "上传文件",
+				content: "${ctx}/ruralProject/ruralCostProjectRecords/importFile?id="+id+"&projectType=2",
+				//  btn: ['确定', '关闭'],
+				yes: function (index, layero) {
+					var body = top.layer.getChildFrame('body', index);
+					var inputForm = body.find('#inputForm');
+					var top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
+					inputForm.attr("target", top_iframe);//表单提交成功后,从服务器返回的url在当前tab中展示
+					inputForm.validate();
+					if (inputForm.valid()) {
+						loading("正在提交,请稍等...");
+						inputForm.submit();
+					} else {
+						return;
+					}
+					top.layer.close(index);//关闭对话框。
+				},
+				cancel: function (index) {
+				}
+				,end: function () {
+					location.reload();
+				}
+			});
+		}
 	</script>
 </head>
 <body>
@@ -583,6 +614,7 @@
 						if(d.recordStatus != undefined && d.recordStatus =="1")
 						{
 							xml+="<a href=\"#\" onclick=\"openDialogView('文件上传', '${ctx}/ruralProject/ruralCostProjectRecords/formAccessory?id=" + d.id + "','95%', '95%')\" class=\"layui-btn layui-btn-xs layui-bg-blue\" > 上传文件</a>";
+							/*xml+="<a href=\"#\" onclick=\"btnImport('" + d.id + "')\" class=\"layui-btn layui-btn-xs layui-bg-blue\" > 导入压缩文件</a>";*/
 						}
 						if(d.reportDataFlag != undefined && d.reportDataFlag =="1")
 						{