fix(asms): 同步问题

This commit is contained in:
yjz
2024-03-01 22:36:31 +08:00
parent f05f22a9ec
commit 5d578edb01
2 changed files with 52 additions and 35 deletions
File diff suppressed because one or more lines are too long
@@ -399,25 +399,33 @@ public class SynchronizationAsmsService {
String articleContent = eMap.get("articleContent");
// 处理图片
if (articleContent.contains("<img src=")){
String urlSuffix = articleContent.substring(articleContent.indexOf("getImg"),
articleContent.indexOf("\" alt"));
String imageUrl = asmsPostUtil.getHost() + urlSuffix;
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
// 获取图片
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.USER_AGENT, "Mozilla/5.0");
headers.set(HttpHeaders.ACCEPT, MediaType.ALL_VALUE);
HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<byte[]> responseEntity = restTemplate.exchange(imageUrl, HttpMethod.GET, entity, byte[].class);
if (HttpStatus.OK == responseEntity.getStatusCode()) {
byte[] imageBytes = responseEntity.getBody();
MultipartFile file = new MockMultipartFile(fileName, fileName,"application/octet-stream" ,imageBytes);
// 上传图片
OSSFile oSSFile = ossFileService.uploadLocalForSplit(file, "", "", "");
log.info("-------" + articleContent);
// base64
if (articleContent.contains("base64")){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<p>").append("<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"")
.append(oSSFile.getUrl()).append("\">").append("</p>");
stringBuilder.append("<p>").append(articleContent).append("</p>");
articleContent = stringBuilder.toString();
}else {
String urlSuffix = articleContent.substring(articleContent.indexOf("getImg"),
articleContent.indexOf("\" alt"));
String imageUrl = asmsPostUtil.getHost() + urlSuffix;
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
// 获取图片
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.USER_AGENT, "Mozilla/5.0");
headers.set(HttpHeaders.ACCEPT, MediaType.ALL_VALUE);
HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<byte[]> responseEntity = restTemplate.exchange(imageUrl, HttpMethod.GET, entity, byte[].class);
if (HttpStatus.OK == responseEntity.getStatusCode()) {
byte[] imageBytes = responseEntity.getBody();
MultipartFile file = new MockMultipartFile(fileName, fileName, "application/octet-stream", imageBytes);
// 上传图片
OSSFile oSSFile = ossFileService.uploadLocalForSplit(file, "", "", "");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<p>").append("<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"")
.append(oSSFile.getUrl()).append("\">").append("</p>");
articleContent = stringBuilder.toString();
}
}
}
// 处理表格