| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.FileCopyUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | |
| | | sopProductList.forEach(product -> product.setSopId(sop.getId())); |
| | | 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<>(); |
| | |
| | | } |
| | | } |
| | | List<SOPFileType> recordListInDB = fileTypeService.getAllInDB(typeList); |
| | | List<SOPFileType> newRecordList = new LinkedList<>(); |
| | | if(typeList.size()!=recordListInDB.size()) { |
| | | List<SOPFileType> newRecordList = new LinkedList<>(); |
| | | |
| | | List<String> uploadTypeStrList = typeList.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | List<String> dbTypeStrList = recordListInDB.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | Date now = new Date(); |
| | | for (int i = 0; i < uploadTypeStrList.size(); i++) { |
| | | String uploadTypeStr = uploadTypeStrList.get(i); |
| | | if(!dbTypeStrList.contains(uploadTypeStr)){ |
| | | SOPFileType sopFileType = new SOPFileType(); |
| | | sopFileType.setType1(uploadTypeStr.split(";")[0]); |
| | | sopFileType.setType2(uploadTypeStr.split(";")[1]); |
| | | sopFileType.setCreateTime(now); |
| | | newRecordList.add(sopFileType); |
| | | List<String> uploadTypeStrList = typeList.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | List<String> dbTypeStrList = recordListInDB.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | Date now = new Date(); |
| | | for (int i = 0; i < uploadTypeStrList.size(); i++) { |
| | | String uploadTypeStr = uploadTypeStrList.get(i); |
| | | if (!dbTypeStrList.contains(uploadTypeStr)) { |
| | | SOPFileType sopFileType = new SOPFileType(); |
| | | sopFileType.setType1(uploadTypeStr.split(";")[0]); |
| | | sopFileType.setType2(uploadTypeStr.split(";")[1]); |
| | | sopFileType.setCreateTime(now); |
| | | newRecordList.add(sopFileType); |
| | | } |
| | | } |
| | | if (newRecordList.size() > 0) { |
| | | fileTypeService.addBatch(newRecordList); |
| | | } |
| | | } |
| | | fileTypeService.addBatch(newRecordList); |
| | | |
| | | return new Response().setII(1,"上传完成"); |
| | | } |