对接比亚迪相关接口异常处理.
This commit is contained in:
+23
-17
@@ -345,27 +345,33 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
|||||||
if(count == -1){
|
if(count == -1){
|
||||||
successful = 0;
|
successful = 0;
|
||||||
}
|
}
|
||||||
// 推送拆分结果
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
// 推送拆分结果
|
||||||
HttpHeaders headers = new HttpHeaders();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
// 创建MultiValueMap对象,用于存储请求参数
|
// 创建MultiValueMap对象,用于存储请求参数
|
||||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||||
params.add("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
params.add("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||||
params.add("docId", sarFileSplitInfoEO.getId());
|
params.add("docId", sarFileSplitInfoEO.getId());
|
||||||
params.add("brief", "");
|
params.add("brief", "");
|
||||||
params.add("successful", successful);
|
params.add("successful", successful);
|
||||||
|
|
||||||
// 使用HttpEntity对象包装请求体和请求头
|
// 使用HttpEntity对象包装请求体和请求头
|
||||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(bydSplitResultUrl, requestEntity, String.class);
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(bydSplitResultUrl, requestEntity, String.class);
|
||||||
String body = responseEntity.getBody();
|
String body = responseEntity.getBody();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||||
|
log.info("拆分结果回调结果:" + body);
|
||||||
|
}catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
log.error("拆分结果回调结果失败:" + ex.getMessage());
|
||||||
|
}
|
||||||
log.info("拆分结果回调结束=========================================================");
|
log.info("拆分结果回调结束=========================================================");
|
||||||
log.info("拆分结果回调结果:" + body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count == -1){
|
if(count == -1){
|
||||||
|
|||||||
+44
-39
@@ -530,58 +530,63 @@ public class OnlyOfficeController {
|
|||||||
logger.info("更新基线信息结束==========================================");
|
logger.info("更新基线信息结束==========================================");
|
||||||
|
|
||||||
logger.info("推送保存基线版本文件信息开始==========================================");
|
logger.info("推送保存基线版本文件信息开始==========================================");
|
||||||
// 推送保存基线版本文件信息
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
// 推送保存基线版本文件信息
|
||||||
HttpHeaders headers = new HttpHeaders();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
// 创建MultiValueMap对象,用于存储请求参数
|
// 创建MultiValueMap对象,用于存储请求参数
|
||||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||||
params.add("fileId", createTimeLatestOnlineFileLog.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id)
|
params.add("fileId", createTimeLatestOnlineFileLog.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id)
|
||||||
params.add("docId", createTimeLatestOnlineFileLog.getId()); // 基线文档主键id
|
params.add("docId", createTimeLatestOnlineFileLog.getId()); // 基线文档主键id
|
||||||
|
|
||||||
// 使用HttpEntity对象包装请求体和请求头
|
// 使用HttpEntity对象包装请求体和请求头
|
||||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(bydSaveBaseLineDocIdUrl, requestEntity, String.class);
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(bydSaveBaseLineDocIdUrl, requestEntity, String.class);
|
||||||
String body = responseEntity.getBody();
|
String body = responseEntity.getBody();
|
||||||
logger.info("推送保存基线版本文件信息结果:" + body);
|
logger.info("推送保存基线版本文件信息结果:" + body);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
logger.error("推送保存基线版本文件信息失败:" + ex.getMessage());
|
||||||
|
}
|
||||||
logger.info("推送保存基线版本文件信息结束==========================================");
|
logger.info("推送保存基线版本文件信息结束==========================================");
|
||||||
|
|
||||||
|
|
||||||
// 将这个文件上传至比亚迪文件系统.并将该接口返回的data中的文件id,更新到该条数据中.
|
// 将这个文件上传至比亚迪文件系统.并将该接口返回的data中的文件id,更新到该条数据中.
|
||||||
logger.info("基线版本文件上传接口开始==========================================");
|
logger.info("基线版本文件上传接口开始==========================================");
|
||||||
RestTemplate restTemplate2 = new RestTemplate();
|
try {
|
||||||
|
RestTemplate restTemplate2 = new RestTemplate();
|
||||||
|
|
||||||
// // 添加 FormHttpMessageConverter,用于处理文件上传
|
HttpHeaders headers2 = new HttpHeaders();
|
||||||
// List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
|
headers2.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||||
// messageConverters.add(new FormHttpMessageConverter());
|
|
||||||
// restTemplate2.setMessageConverters(messageConverters);
|
|
||||||
|
|
||||||
HttpHeaders headers2 = new HttpHeaders();
|
// 创建MultiValueMap对象,用于存储请求参数
|
||||||
headers2.setContentType(MediaType.MULTIPART_FORM_DATA);
|
MultiValueMap<String, Object> params2 = new LinkedMultiValueMap<>();
|
||||||
|
|
||||||
// 创建MultiValueMap对象,用于存储请求参数
|
// 将文件转换为FileSystemResource对象,并将其添加到MultiValueMap中
|
||||||
MultiValueMap<String, Object> params2 = new LinkedMultiValueMap<>();
|
String attFileId = createTimeLatestOnlineFileLog.getAttFileId();
|
||||||
|
OSSFile ossFile = ossFileService.getById(attFileId);
|
||||||
|
File file = new File(filePath + ossFile.getUrl());
|
||||||
|
FileSystemResource fileResource = new FileSystemResource(file);
|
||||||
|
params2.add("file", fileResource);
|
||||||
|
|
||||||
// 将文件转换为FileSystemResource对象,并将其添加到MultiValueMap中
|
// 使用HttpEntity对象包装请求体和请求头
|
||||||
String attFileId = createTimeLatestOnlineFileLog.getAttFileId();
|
HttpEntity<MultiValueMap<String, Object>> requestEntity2 = new HttpEntity<>(params2, headers2);
|
||||||
OSSFile ossFile = ossFileService.getById(attFileId);
|
|
||||||
File file = new File(filePath + ossFile.getUrl());
|
|
||||||
FileSystemResource fileResource = new FileSystemResource(file);
|
|
||||||
params2.add("file", fileResource);
|
|
||||||
|
|
||||||
// 使用HttpEntity对象包装请求体和请求头
|
// 发送POST请求并获取响应
|
||||||
HttpEntity<MultiValueMap<String, Object>> requestEntity2 = new HttpEntity<>(params2, headers2);
|
ResponseEntity<String> responseEntity2 = restTemplate2.postForEntity(bydUploadFileUrl, requestEntity2, String.class);
|
||||||
|
String body2 = responseEntity2.getBody();
|
||||||
// 发送POST请求并获取响应
|
JSONObject jsonObject2 = JSONObject.parseObject(body2);
|
||||||
ResponseEntity<String> responseEntity2 = restTemplate2.postForEntity(bydUploadFileUrl, requestEntity2, String.class);
|
String data = jsonObject2.getString("data");
|
||||||
String body2 = responseEntity2.getBody();
|
createTimeLatestOnlineFileLog.setBydJxFileId(data);
|
||||||
JSONObject jsonObject2 = JSONObject.parseObject(body2);
|
logger.info("基线版本文件上传接口结果:" + body2);
|
||||||
String data = jsonObject2.getString("data");
|
}catch (Exception ex){
|
||||||
createTimeLatestOnlineFileLog.setBydJxFileId(data);
|
ex.printStackTrace();
|
||||||
logger.info("基线版本文件上传接口结果:" + body2);
|
logger.error("基线版本文件上传失败:" + ex.getMessage());
|
||||||
|
}
|
||||||
logger.info("基线版本文件上传接口结束==========================================");
|
logger.info("基线版本文件上传接口结束==========================================");
|
||||||
|
|
||||||
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
||||||
|
|||||||
+22
-14
@@ -192,23 +192,31 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
splitFileIs = MinioUtil.download(readFilePath);
|
splitFileIs = MinioUtil.download(readFilePath);
|
||||||
} else {
|
} else {
|
||||||
// 根据byd传过来的文件下载路径获取文件。
|
log.info("下载文档开始=========================================================");
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
try {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
// 根据byd传过来的文件下载路径获取文件。
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
// 创建MultiValueMap对象,用于存储请求参数
|
// 创建MultiValueMap对象,用于存储请求参数
|
||||||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
String fileId = sarFileSplitInfoEO.getId();
|
String fileId = sarFileSplitInfoEO.getId();
|
||||||
params.add("fileId", fileId);
|
params.add("fileId", fileId);
|
||||||
|
|
||||||
// 使用HttpEntity对象包装请求体和请求头
|
// 使用HttpEntity对象包装请求体和请求头
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);
|
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);
|
||||||
// 获取文件流
|
// 获取文件流
|
||||||
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
log.error("调用比亚迪下载文档接口失败:" + ex.getMessage());
|
||||||
|
throw new JeroBootException("调用比亚迪下载文档接口失败!");
|
||||||
|
}
|
||||||
|
log.info("下载文档结束=========================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs) {
|
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user