|
@@ -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();
|
|
|
+ }
|
|
|
}
|