From c7ba8fe4f32df1aa0d937cb080fc90597210ebb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=B5=A9?= Date: Wed, 27 Mar 2024 19:47:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8E=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DocumentSplitServiceImpl.java | 40 ++++++++++--------- .../controller/OnlyOfficeController.java | 21 +++++----- .../split/service/impl/FileSpiltService.java | 6 +-- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java index 2d16910..615aafe 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java @@ -321,16 +321,22 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { @Override public void run() { //拆分 - int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT,splitSource); - + int count = -1; + try{ + count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT,splitSource); + }catch (Exception e){ + log.error("拆分标准失败:" + e.getMessage()); + } + // 拆分结果(0-拆分失败、1-拆分成功) + int successful = 1; + sarFileSplitInfoEO.setSplitResult("成功"); + if(count == -1){ + successful = 0; + sarFileSplitInfoEO.setSplitResult("失败"); + } // 如果是外部系统调用 if (StringUtils.equals(splitSource, CommonConstant.SPLIT_SOURCE_2)) { log.info("拆分结果回调开始========================================================="); - // 拆分结果(0-拆分失败、1-拆分成功) - int successful = 1; - if(count == -1){ - successful = 0; - } try { // 推送拆分结果 RestTemplate restTemplate = new RestTemplate(); @@ -339,14 +345,14 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { headers.add("Authorization",token); // 创建MultiValueMap对象,用于存储请求参数 - MultiValueMap params = new LinkedMultiValueMap<>(); - params.add("standardCode", sarFileSplitInfoEO.getSerialNumber()); - params.add("docId", sarFileSplitInfoEO.getId()); - params.add("brief", ""); - params.add("successful", successful); + Map params = new HashMap<>(); + params.put("standardCode", sarFileSplitInfoEO.getSerialNumber()); + params.put("docId", sarFileSplitInfoEO.getId()); + params.put("brief", ""); + params.put("successful", successful); // 使用HttpEntity对象包装请求体和请求头 - HttpEntity> requestEntity = new HttpEntity<>(params, headers); + HttpEntity> requestEntity = new HttpEntity<>(params, headers); // 发送POST请求并获取响应 ResponseEntity responseEntity = restTemplate.postForEntity(bydSplitResultUrl, requestEntity, String.class); @@ -358,12 +364,8 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { log.error("拆分结果回调结果失败:" + ex.getMessage()); } log.info("拆分结果回调结束========================================================="); - - } - - if(count == -1){ - throw new JeroBootException("文档格式错误,请检查文档内容!"); } + sarFileSplitInfoService.updateById(sarFileSplitInfoEO); } }); thread.start(); @@ -1295,7 +1297,7 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { String infoId = UUID.randomUUID().toString().replace("-", ""); sarFileSplitInfoEO.setId(infoId); } - sarFileSplitInfoEO.setSplitResult("成功"); + sarFileSplitInfoEO.setSplitResult("拆分中"); sarFileSplitInfoEO.setSplitStatus(SplitEnum.SPLIT_STATUS2.getValue()); sarFileSplitInfoEO.setAuthor(userId); sarFileSplitInfoEO.setCreateTime(now); diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java index 7037b21..b82df16 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java @@ -535,6 +535,7 @@ public class OnlyOfficeController { // 查询总次数 int queryCount = 0; OnlineFileLog createTimeLatestOnlineFileLog = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount); + final String oldOnlineFileId = createTimeLatestOnlineFileLog.getId(); OnlineFileLog createTimeLatestOnlineFileLog2 = createTimeLatestOnlineFileLog; if (null != createTimeLatestOnlineFileLog) { @@ -584,7 +585,7 @@ public class OnlyOfficeController { }catch (Exception ex){ ex.printStackTrace(); logger.error("基线版本文件上传失败:" + ex.getMessage()); - return Result.error("更新基线信息失败!"); +// return Result.error("更新基线信息失败!"); } logger.info("基线版本文件上传接口结束=========================================="); @@ -599,12 +600,12 @@ public class OnlyOfficeController { headers.add("Authorization",token); // 创建MultiValueMap对象,用于存储请求参数 - MultiValueMap params = new LinkedMultiValueMap<>(); - params.add("fileId", createTimeLatestOnlineFileLog2.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id) - params.add("docId", createTimeLatestOnlineFileLog2.getId()); // 基线文档主键id + Map params = new HashMap<>(); + params.put("fileId", createTimeLatestOnlineFileLog2.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id) + params.put("docId", createTimeLatestOnlineFileLog2.getId()); // 基线文档主键id // 使用HttpEntity对象包装请求体和请求头 - HttpEntity> requestEntity = new HttpEntity<>(params, headers); + HttpEntity> requestEntity = new HttpEntity<>(params, headers); // 发送POST请求并获取响应 ResponseEntity responseEntity = restTemplate.postForEntity(bydSaveBaseLineDocIdUrl, requestEntity, String.class); @@ -618,12 +619,12 @@ public class OnlyOfficeController { }catch (Exception ex){ ex.printStackTrace(); logger.error("推送保存基线版本文件信息失败:" + ex.getMessage()); - return Result.error("更新基线信息失败!"); +// return Result.error("更新基线信息失败!"); } logger.info("推送保存基线版本文件信息结束=========================================="); // this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog); - this.onlineFileLogDao.deleteById(createTimeLatestOnlineFileLog.getId()); + this.onlineFileLogDao.deleteById(oldOnlineFileId); } else { return Result.error("更新基线信息失败!"); } @@ -679,10 +680,10 @@ public class OnlyOfficeController { headers.add("appId",appId); headers.add("Authorization",token); // 创建MultiValueMap对象,用于存储请求参数 - MultiValueMap params = new LinkedMultiValueMap<>(); - params.add("fileId", fileId); + Map params = new HashMap<>(); + params.put("fileId", fileId); // 使用HttpEntity对象包装请求体和请求头 - HttpEntity> requestEntity = new HttpEntity<>(params, headers); + HttpEntity> requestEntity = new HttpEntity<>(params, headers); // 发送POST请求并获取响应 ResponseEntity responseEntity = restTemplate.postForEntity(unlockUrl, requestEntity, String.class); String body = responseEntity.getBody(); diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java index c5945ff..62391d2 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java @@ -225,12 +225,12 @@ public class FileSpiltService { headers.setContentType(MediaType.APPLICATION_JSON); // 创建MultiValueMap对象,用于存储请求参数 - MultiValueMap params = new LinkedMultiValueMap<>(); + Map params = new HashMap<>(); String fileId = sarFileSplitInfoEO.getId(); - params.add("fileId", fileId); + params.put("fileId", fileId); // 使用HttpEntity对象包装请求体和请求头 - HttpEntity> requestEntity = new HttpEntity<>(params, headers); + HttpEntity> requestEntity = new HttpEntity<>(params, headers); // 发送POST请求并获取响应 ResponseEntity responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);