| | |
| | | import com.whyc.pojo.SOP; |
| | | import com.whyc.pojo.SOPFileType; |
| | | import com.whyc.pojo.SOPProduct; |
| | | import com.whyc.pojo.Software; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.DateUtil; |
| | |
| | | |
| | | sopProductList.add(product); |
| | | } |
| | | //存储excel文件,/sop_submit/xxx_202306250506.xlsx |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | |
| | | //存储excel文件,/sop_submit/xxx_202306250506.xlsx(改,不存粗excel了) |
| | | /*String originalFilename = multipartFile.getOriginalFilename(); |
| | | String[] fileNameSplit = originalFilename.split("\\."); |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(new Date()); |
| | | String newFileName = fileNameSplit[0]+"_"+dateFormat+"."+fileNameSplit[1]; |
| | | |
| | | String fileUrl = FileUtil.saveFile(multipartFile,"/sop_submit/"+newFileName); |
| | | sop.setFileUrl(fileUrl); |
| | | sop.setFileUrl(fileUrl);*/ |
| | | |
| | | sopProductList = sopProductList.stream().filter(product -> !product.getCode().equals("")).collect(Collectors.toList()); |
| | | sop.setSopProductList(sopProductList); |
| | |
| | | } |
| | | |
| | | @Transactional |
| | | public Response add(SOP sop) throws IOException { |
| | | public Response add(SOP sop,MultipartFile multipartFile) throws IOException { |
| | | List<SOPProduct> sopProductList = sop.getSopProductList(); |
| | | String fileUrlTemp = sop.getFileUrl(); |
| | | fileUrlTemp = fileUrlTemp.replace("sop_submit", "sop"); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String[] fileNameSplit = originalFilename.split("\\."); |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(new Date()); |
| | | String newFileName = fileNameSplit[0]+"_"+dateFormat+"."+fileNameSplit[1]; |
| | | String fileUrlTemp = FileUtil.saveFile(multipartFile,"/sop/"+newFileName); |
| | | //String fileUrlTemp = sop.getFileUrl(); |
| | | //fileUrlTemp = fileUrlTemp.replace("sop_submit", "sop"); |
| | | sop.setFileUrl(fileUrlTemp); |
| | | mapper.insert(sop); |
| | | if(sopProductList.size()>0) { |
| | |
| | | productService.insertBatch(sopProductList); |
| | | } |
| | | //文件转移 |
| | | String fileUrl = sop.getFileUrl(); |
| | | /*String fileUrl = sop.getFileUrl(); |
| | | String projectDir = CommonUtil.getProjectDir(); |
| | | String filePathFrom = projectDir + File.separator + fileUrl.replace("sop","sop_submit"); |
| | | File fileFrom = new File(filePathFrom); |
| | |
| | | if(!fileTo.getParentFile().exists()){ |
| | | fileTo.getParentFile().mkdirs(); |
| | | } |
| | | FileCopyUtils.copy(fileFrom,fileTo); |
| | | FileCopyUtils.copy(fileFrom,fileTo);*/ |
| | | |
| | | //新增的文件类型,追加到表中 |
| | | List<SOPFileType> typeList = new LinkedList<>(); |