src/main/java/com/whyc/pojo/DefectiveProducts.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/DefectiveProductsHistory.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/DefectiveProductsHistoryService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/DefectiveProductsService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/util/FileUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/pojo/DefectiveProducts.java
@@ -52,6 +52,10 @@ @ApiModelProperty(value = "附件url") private String fileUrl; @TableField(exist = false) @ApiModelProperty(value = "附件url的文件名") private List nameList; @ApiModelProperty(value = "型号") private String type; src/main/java/com/whyc/pojo/DefectiveProductsHistory.java
@@ -12,6 +12,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; /** * <p> @@ -65,5 +66,9 @@ @ApiModelProperty(value = "处理的文件路径") private String delUrl; @ApiModelProperty(value = "处理的文件") @TableField(exist = false) private List hisNameList; } src/main/java/com/whyc/service/DefectiveProductsHistoryService.java
@@ -67,7 +67,7 @@ e.printStackTrace(); } } defectiveHis.setDelUrl("doc_file" + File.separator + defectiveDirSuffix); defectiveHis.setDelUrl( File.separator + defectiveDirSuffix); } mapper.insert(defectiveHis); } src/main/java/com/whyc/service/DefectiveProductsService.java
@@ -15,6 +15,7 @@ import com.whyc.pojo.DocUser; import com.whyc.util.ActionUtil; import com.whyc.util.CommonUtil; import com.whyc.util.FileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -82,7 +83,7 @@ multipartFile.transferTo(file); } //ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath))); defective.setFileUrl("doc_file" + File.separator + defectiveDirSuffix); defective.setFileUrl( File.separator + defectiveDirSuffix); } @@ -131,6 +132,23 @@ public Response getDefectiveLimit(DefectiveDto defectiveDto) { PageHelper.startPage(defectiveDto.getPageCurr(),defectiveDto.getPageSize()); List<DefectiveProducts> list=mapper.getDefectiveLimit(defectiveDto); String rootFile = CommonUtil.getRootFile();//主路径 for (DefectiveProducts defective:list) { String filePath=defective.getFileUrl(); if(filePath!=null&&!filePath.isEmpty()){ defective.setNameList(FileUtil.getFileNameWithOutDirectory(rootFile+filePath)); } List<DefectiveProductsHistory> hisList=defective.getHisList(); if(hisList!=null&&hisList.size()>0){ for (DefectiveProductsHistory his:defective.getHisList()) { String hisDelPath=his.getDelUrl(); if(hisDelPath!=null&&!hisDelPath.isEmpty()){ his.setHisNameList(FileUtil.getFileNameWithOutDirectory(rootFile+hisDelPath)); } } } } PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"不良品首页推送"); } src/main/java/com/whyc/util/FileUtil.java
@@ -9,10 +9,12 @@ import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class FileUtil { public static List<String> getStaticFilePath(File file, List<String> list){ @@ -265,6 +267,21 @@ proc.waitFor(); } //读取文件夹下的所有文件(不读取文件夹内的文件) public static List getFileNameWithOutDirectory(String filePath) { File folder = new File(filePath); // 文件夹路径 List nameList=new ArrayList(); File[] listOfFiles = folder.listFiles(); if (listOfFiles != null) { for (File file : listOfFiles) { if (file.isFile()) { nameList.add(file.getName()); } } } return nameList; } //private static void decompressRar(File file, String outputFolder) throws IOException, RarException { // Archive archive = new Archive(file); // FileHeader fileHeader = archive.nextFileHeader();