| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ZipUtils; |
| | | import com.whyc.mapper.BOMFeedbakMapper; |
| | | import com.whyc.mapper.DocUserMapper; |
| | | import com.whyc.pojo.BOMFeedback; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.Software; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.MailUtil; |
| | |
| | | * 2.附件存储 |
| | | * 3.邮件发送 |
| | | * @param feedback bom问题反馈 |
| | | * @param multipartFile |
| | | * @param multipartFileList |
| | | * @return response |
| | | */ |
| | | public Response submitFeedback(BOMFeedback feedback, MultipartFile multipartFile) throws IOException, MessagingException { |
| | | public Response submitFeedback(BOMFeedback feedback, List<MultipartFile> multipartFileList) throws IOException, MessagingException { |
| | | Date date = new Date(); |
| | | if(multipartFile!=null){ |
| | | //存储文件 |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | //压缩包的路径及格式为: 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 rootFile = CommonUtil.getRootFile(); |
| | | 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(".")); |
| | |
| | | file.mkdirs(); |
| | | } |
| | | multipartFile.transferTo(file); |
| | | feedback.setFile("doc_file"+File.separator+feedbackPath); |
| | | fileList.add(file); |
| | | } |
| | | } |
| | | ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath))); |
| | | //删除已经被压缩的文件 |
| | | for (File file : fileList) { |
| | | file.delete(); |
| | | } |
| | | feedback.setFile("doc_file" + File.separator + feedbackZipPath); |
| | | //保存 |
| | | feedback.setCreateTime(date); |
| | | feedback.setConfirmStatus(0); |