|
|
@@ -1,6 +1,7 @@
|
|
|
package com.jzg.quote.huatai.api.component;
|
|
|
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
+import com.jzg.commons.text.CharsetKit;
|
|
|
import com.jzg.quotation.commons.entity.vo.image.InsuranceImageVo;
|
|
|
import com.jzg.quote.huatai.api.constant.enums.ImageTypeCode;
|
|
|
import com.jzg.quote.huatai.api.entity.request.HuaTaiSaveFileIdxRequest;
|
|
|
@@ -13,12 +14,10 @@ import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -48,7 +47,7 @@ public class HuiTaiUploadImageComponent {
|
|
|
try {
|
|
|
u = new URL(url);
|
|
|
} catch (MalformedURLException e) {
|
|
|
- throw new SystemException("华泰文件上传路劲解析失败");
|
|
|
+ throw new SystemException("华泰文件上传路径解析失败");
|
|
|
}
|
|
|
String domain = u.getProtocol() + "://" + u.getAuthority();
|
|
|
String query = u.getQuery();
|
|
|
@@ -64,8 +63,9 @@ public class HuiTaiUploadImageComponent {
|
|
|
HuaTaiImageInitParamResponse initParamResponse = initParam(domain, token);
|
|
|
List<HuaTaiImageInitParamResponse.TypeSelectVosDTO.ChildrenDTO> childrenDTO = initParamResponse.getChildrenDTO();
|
|
|
// 使用map 存储上传类型和图片
|
|
|
- Map<String, List<InsuranceImageVo.ImageDTO>> map = new HashMap<>();
|
|
|
+ Map<String, List<String>> map = new HashMap<>();
|
|
|
for (InsuranceImageVo insuranceImageVo : imageVoList) {
|
|
|
+ List<String> imageIds = new ArrayList<>();
|
|
|
for (InsuranceImageVo.ImageDTO imageDTO : insuranceImageVo.getImageBase64List()) {
|
|
|
String imageType = insuranceImageVo.getImageCode();//影像类型编码
|
|
|
String fileName = imageDTO.getImageName();
|
|
|
@@ -78,10 +78,10 @@ public class HuiTaiUploadImageComponent {
|
|
|
try {
|
|
|
HuaTaiImageInitParamResponse.TypeSelectVosDTO.ChildrenDTO childrenDTO1 =
|
|
|
HuaTaiImageInitParamResponse.filteringTypeCode(childrenDTO, fileTypeEnum.getCode());
|
|
|
- /* 涉及业务表
|
|
|
- FileuploadResult fileupload = fileupload(domain, token, initParamResponse, imageDTO.getFilePath(), file);
|
|
|
+
|
|
|
+ FileuploadResult fileupload = fileupload(domain, token, initParamResponse, imageDTO.getImageBase64Str(), file);
|
|
|
saveFileIdx(domain, token, initParamResponse, fileupload, fileName, childrenDTO1);
|
|
|
- map.put(insuranceImageVo.getImageCode(), imageDTO.getImageId());*/
|
|
|
+ imageIds.add(imageDTO.getImageId());
|
|
|
} catch (Exception e) {
|
|
|
insImagesUploadCacheComponent.setUploadImageCache(companyId, map);
|
|
|
throw new SystemException(fileTypeEnum.getName() + "上传异常, 请重试");
|
|
|
@@ -90,11 +90,10 @@ public class HuiTaiUploadImageComponent {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ map.put(insuranceImageVo.getImageCode(), imageIds);
|
|
|
}
|
|
|
|
|
|
insImagesUploadCacheComponent.setUploadImageCache(companyId, map);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -116,14 +115,14 @@ public class HuiTaiUploadImageComponent {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 文件上传返回文件路劲
|
|
|
+ * 文件上传返回文件路径
|
|
|
*
|
|
|
- * @return 文件路劲
|
|
|
+ * @return 文件路径
|
|
|
*/
|
|
|
- private FileuploadResult fileupload(String domain, String token, HuaTaiImageInitParamResponse initParamResponse, String path,
|
|
|
+ private FileuploadResult fileupload(String domain, String token, HuaTaiImageInitParamResponse initParamResponse, String imageBase64Str,
|
|
|
String fileName) {
|
|
|
- File file = new File(path);
|
|
|
- byte[] bytes = file2byte(file);
|
|
|
+ Charset charset = Charset.forName(CharsetKit.UTF_8);
|
|
|
+ byte[] bytes = imageBase64Str.getBytes(charset);
|
|
|
double v = (double) bytes.length / 1024;
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.setAccept(Collections.singletonList(MediaType.MULTIPART_FORM_DATA));
|