|  | @@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.InputStream;
 | 
	
		
			
				|  |  |  import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
	
		
			
				|  | @@ -170,6 +171,14 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              //获取当前用户
 | 
	
		
			
				|  |  |              BladeUser user = SecureUtil.getUser();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //删除文件
 | 
	
		
			
				|  |  | +            List<StandardFile> list = standardFileService.list(Wrappers.<StandardFile>lambdaQuery()
 | 
	
		
			
				|  |  | +                    .eq(StandardFile::getStandardId, id));
 | 
	
		
			
				|  |  | +            for (StandardFile standardFile : list) {
 | 
	
		
			
				|  |  | +                deleteFile(standardFile.getId());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //更新西悉尼
 | 
	
		
			
				|  |  |              int update = baseMapper.update(null, Wrappers.<PrivateStandard>lambdaUpdate()
 | 
	
		
			
				|  |  |                      .set(PrivateStandard::getIsDeleted, 1)
 | 
	
		
			
				|  |  |                      .set(PrivateStandard::getUpdateUser, user.getUserId())
 | 
	
	
		
			
				|  | @@ -177,8 +186,6 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
 | 
	
		
			
				|  |  |                      .or()
 | 
	
		
			
				|  |  |                      .eq(PrivateStandard::getParentId, id)
 | 
	
		
			
				|  |  |              );
 | 
	
		
			
				|  |  | -            //TODO 后续还要删除规范详细信息
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              int update1 = standardInfoMapper.update(null, Wrappers.<StandardInfo>lambdaUpdate()
 | 
	
		
			
				|  |  |                      .set(StandardInfo::getIsDeleted, 1)
 | 
	
	
		
			
				|  | @@ -188,6 +195,7 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
 | 
	
		
			
				|  |  |              standardInfoJoinMapper.updateJoin(user.getUserId(), 1, id);
 | 
	
		
			
				|  |  |              //TODo 还要删除与表单的关联信息
 | 
	
		
			
				|  |  |              standardInfoPrivateJoinMapper.updateJoin(user.getUserId(), 1, id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              return update > 0;
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
	
		
			
				|  | @@ -215,6 +223,73 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return false;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public boolean updateTypeByTwo(List<PrivateStandardDTO> data,
 | 
	
		
			
				|  |  | +                                   List<Long> delIds,
 | 
	
		
			
				|  |  | +                                   List<Long> delFileIds,
 | 
	
		
			
				|  |  | +                                   MultipartFile[] allFiles) {
 | 
	
		
			
				|  |  | +        BladeUser user = SecureUtil.getUser();
 | 
	
		
			
				|  |  | +        //先删除文件
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            List<StandardFile> standardFiles = standardFileService.listByIds(delFileIds);
 | 
	
		
			
				|  |  | +            for (StandardFile standardFile : standardFiles) {
 | 
	
		
			
				|  |  | +                this.deleteFile(standardFile.getId());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //删除规范文件
 | 
	
		
			
				|  |  | +            for (Long delId : delIds) {
 | 
	
		
			
				|  |  | +                delete(delId);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            throw new ServiceException("Oss删除文件失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            // 文件索引计数器
 | 
	
		
			
				|  |  | +            int fileIndex = 0;
 | 
	
		
			
				|  |  | +            for (PrivateStandardDTO dto : data) {
 | 
	
		
			
				|  |  | +                // 获取当前对象需要的文件数量
 | 
	
		
			
				|  |  | +                int fileCount = dto.getFilesCount();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 为当前对象分配文件
 | 
	
		
			
				|  |  | +                MultipartFile[] objectFiles = new MultipartFile[fileCount];
 | 
	
		
			
				|  |  | +                for (int i = 0; i < fileCount; i++) {
 | 
	
		
			
				|  |  | +                    objectFiles[i] = allFiles[fileIndex++];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                dto.setFiles(objectFiles);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //先上传文件,上传成功在执行添加
 | 
	
		
			
				|  |  | +                List<StandardFile> standardFiles = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for (MultipartFile file : dto.getFiles()) {
 | 
	
		
			
				|  |  | +                    StandardFile standardFile = new StandardFile();
 | 
	
		
			
				|  |  | +                    standardFile.setId(SnowFlakeUtil.getId());
 | 
	
		
			
				|  |  | +                    standardFile.setStandardId(dto.getId());
 | 
	
		
			
				|  |  | +                    standardFile.setCreateUser(user.getUserId());
 | 
	
		
			
				|  |  | +                    String originalFilename = file.getOriginalFilename();
 | 
	
		
			
				|  |  | +                    standardFile.setFileName(originalFilename);
 | 
	
		
			
				|  |  | +                    originalFilename = "standard/" + dto.getId() + "|" + originalFilename;
 | 
	
		
			
				|  |  | +                    MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream());
 | 
	
		
			
				|  |  | +                    //Oss上传 传特殊文件名 在oss中做特殊路径处理
 | 
	
		
			
				|  |  | +                    BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    standardFile.setStandardFileUrl(bladeFile.getLink());
 | 
	
		
			
				|  |  | +                    standardFiles.add(standardFile);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //创建数据
 | 
	
		
			
				|  |  | +                PrivateStandard privateStandard = BeanUtil.copyProperties(dto, PrivateStandard.class);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //添加新文件
 | 
	
		
			
				|  |  | +                standardFileService.saveBatch(standardFiles);
 | 
	
		
			
				|  |  | +                //修改
 | 
	
		
			
				|  |  | +                baseMapper.updateById(privateStandard);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        } catch (IOException e) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException(e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |