Просмотр исходного кода

Merge branch 'master' of http://192.168.1.43:3000/git/sass-lab-distributed-java

zhuchangxue лет назад: 3
Родитель
Сommit
870eb4bb5a

+ 0 - 1
zd-modules/zd-forward/src/main/java/com/zd/forward/serivce/FireImageService.java

@@ -111,7 +111,6 @@ public class FireImageService {
         int code = analysisData.getCode();
         if (code==-1){
             log.error("==============请求失败:{}=================",analysisData.getMsg());
-            throw new ServiceException(analysisData.getMsg());
         }else {
             log.info("===============向算法服务发送数据完成====================");
             Map<String, Object> result = (Map<String, Object>) Optional.ofNullable(analysisData.getResult()).orElse(Collections.emptyMap());

+ 8 - 4
zd-modules/zd-forward/src/main/java/com/zd/forward/utils/HttpUtils.java

@@ -20,9 +20,16 @@ import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 
+/**
+ * @author Administrator
+ */
 @Slf4j
 public class HttpUtils {
 
+    private HttpUtils() {
+        throw new IllegalStateException("HttpUtils class");
+    }
+
     /**
      * 构造算法文件逆流
      */
@@ -31,8 +38,6 @@ public class HttpUtils {
             //设置请求头
             HttpHeaders headers = new HttpHeaders();
             headers.setContentType(MediaType.MULTIPART_FORM_DATA);
-            // 文件本地存储收集
-            //FileUploadUtils.upload(localFilePath, file);
             //MultipartFile 转为临时文件
             File uploadFile = multipartFileToFile(file);
             //文件转为文件系统资源
@@ -65,6 +70,7 @@ public class HttpUtils {
 
     public static File multipartFileToFile(MultipartFile file) throws IOException {
         String originalFilename = file.getOriginalFilename() == null ? "" : file.getOriginalFilename();
+        assert originalFilename!=null;
         String[] filename = originalFilename.split("\\.");
         File toFile = File.createTempFile(filename[0], "." + filename[1]);
         file.transferTo(toFile);
@@ -116,11 +122,9 @@ public class HttpUtils {
         ResponseEntity<ImgPostResponse<DataPostAnalysisRespDto>> response = restTemplate.exchange(algorithmYml.getImgPostUrl(), HttpMethod.POST, files, reference);
         if (response.getStatusCode() != HttpStatus.OK) {
             log.error("算法服务请求异常,请查看算服务器");
-            throw new ServiceException("算法服务请求异常,请查看算服务器");
         }
         if (response.getBody() == null) {
             log.error("算法服务接口返回异常");
-            throw new ServiceException("算法服务接口返回异常");
         }
         return response.getBody();
     }