| | |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.MailDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ZipUtils; |
| | | import com.whyc.mapper.BOMFeedbakMapper; |
| | | import com.whyc.mapper.DocUserMapper; |
| | | import com.whyc.mapper.ProductHistoryMapper; |
| | |
| | | //压缩包的路径及格式为: doc_file/feedback_bom/username_time.zip |
| | | String username = ActionUtil.getUser().getName(); |
| | | long time = date.getTime(); |
| | | String feedbackZipPath = "feedback_bom" + File.separator + username + "_" + time+".zip"; |
| | | List<File> fileList = new LinkedList<>(); |
| | | //String feedbackZipPath = "feedback_bom" + File.separator + username + "_" + time+".zip"; |
| | | //List<File> fileList = new LinkedList<>(); |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String feedbackDirSuffix = "feedback_bom" + File.separator + username + File.separator + time + File.separator; |
| | | String feedbackDir = rootFile + feedbackDirSuffix; |
| | | File fileDir = new File(feedbackDir); |
| | | if (!fileDir.exists()) { |
| | | fileDir.mkdirs(); |
| | | } |
| | | if(multipartFileList!=null && multipartFileList.size()!=0){ |
| | | for (int i = 0; i < multipartFileList.size(); i++) { |
| | | MultipartFile multipartFile = multipartFileList.get(i); |
| | |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String feedbackPath = "feedback_bom" + File.separator + fileName + "_" + time + suffix; |
| | | File file = new File(rootFile + feedbackPath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | String feedbackPath = feedbackDir + fileName + suffix; |
| | | File file = new File(feedbackPath); |
| | | |
| | | multipartFile.transferTo(file); |
| | | fileList.add(file); |
| | | //fileList.add(file); |
| | | } |
| | | ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath))); |
| | | feedback.setFile("doc_file" + File.separator + feedbackZipPath); |
| | | //ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath))); |
| | | feedback.setFile("doc_file" + File.separator + feedbackDirSuffix); |
| | | } |
| | | //删除已经被压缩的文件 |
| | | for (File file : fileList) { |
| | | file.delete(); |
| | | } |
| | | //for (File file : fileList) { |
| | | // file.delete(); |
| | | //} |
| | | //保存 |
| | | feedback.setCreateTime(date); |
| | | feedback.setConfirmStatus(0); |