吉安感知网项目-后端
linwei
5 days ago aba829f97bc8c0c7828727676edf4a2c2bd0b282
drone-ops/drone-resource/src/main/java/org/sxkj/resource/feign/AttachClient.java
@@ -26,6 +26,7 @@
import org.sxkj.resource.vo.AttachTypeStatisticsVO;
import org.sxkj.resource.vo.AttachVO;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -73,9 +74,9 @@
      attach.setOrderByCreateTime(true);
      attach.setAreaCode(HeaderUtils.getAreaCode());
      List<Integer> integers = Arrays.asList(0, 2, 4, 5);
      List<String> integers = Arrays.asList("0", "2", "4", "5");
      attach.setResultTypes(integers);
      List<Integer> resultTypes = attach.getResultTypes();
      List<String> resultTypes = attach.getResultTypes();
      String wordOrderType = attach.getWordOrderType();
      settingResultType(attach, wordOrderType, resultTypes);
@@ -95,7 +96,6 @@
      Page<AttachVO> page = new Page<>(1, 2000); // 或者 Integer.MAX_VALUE
      List<AttachVO> aiAttachImages = attachService.findAiAttachImages(page, attach);
      AttachVO.settingNickName(aiAttachImages);
      return aiAttachImages;
   }
@@ -105,7 +105,7 @@
    * @param wordOrderType
    * @param resultTypes
    */
   private static void settingResultType(AttachVO attach, String wordOrderType, List<Integer> resultTypes) {
   private static void settingResultType(AttachVO attach, String wordOrderType, List<String> resultTypes) {
      if (!StringUtils.isEmpty(wordOrderType) && !CollectionUtils.isEmpty(resultTypes)) {
         if ("-1".equals(wordOrderType)) {
            attach.setWordOrderType(null);
@@ -122,15 +122,21 @@
   }
   @Override
   public BladeFile saveAttachFile(MultipartFile file, String fileName) throws IOException {
      BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, file.getInputStream());
      // 步骤1: 将文件转换为字节数组,避免流重置异常
      byte[] bytes = file.getBytes();
      // 步骤2: 使用字节数组输入流上传文件
      BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, new ByteArrayInputStream(bytes));
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile, null);
      bladeFile.setAttachId(attachId);
      return bladeFile;
   }
   @Override
   public BladeFile saveAttachFile(MultipartFile file, String fileName, Integer type) throws IOException {
      BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, file.getInputStream());
   public BladeFile saveAttachFile(MultipartFile file, String fileName, List<List<String>> type) throws IOException {
      // 步骤1: 将文件转换为字节数组,避免流重置异常
      byte[] bytes = file.getBytes();
      // 步骤2: 使用字节数组输入流上传文件
      BladeFile bladeFile = ossBuilder.template().putFile(pojo.getBucket(),fileName, new ByteArrayInputStream(bytes));
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile, type);
      bladeFile.setAttachId(attachId);
      return bladeFile;
@@ -145,11 +151,14 @@
    */
   @Override
   public BladeFile putFile(MultipartFile file, String fileName) throws IOException {
      BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
      // 步骤1: 将文件转换为字节数组,避免流重置异常
      byte[] bytes = file.getBytes();
      // 步骤2: 使用字节数组输入流上传文件
      BladeFile bladeFile = ossBuilder.template().putFile(fileName, new ByteArrayInputStream(bytes));
      return bladeFile;
   }
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile, Integer type) {
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile, List<List<String>> type) {
      String fileExtension = FileUtil.getFileExtension(fileName);
      Attach attach = new Attach();
      attach.setDomainUrl(bladeFile.getDomain());
@@ -236,7 +245,7 @@
         saveAttachFile(new MockMultipartFile( mediaFile.getName(),
            mediaFile.getName(),
            "application/octet-stream",
            new FileInputStream(mediaFile)), name, Attach.RESULT_TYPE_VEDIO_SHOW);
            new FileInputStream(mediaFile)), name, null);
         log.info("第{}个视频保存入库完成...", (i + 1));
      }