diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java index e8b9506a9a..eaf5d8c893 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java @@ -23,19 +23,21 @@ public class ScanContentUtils { * * @return */ - public static SyncScanResult imgSyncScan(String url, ImgScanParamDTO param) { - log.debug("imgSyncScan param:", JSON.toJSONString(param)); + public static Result imgSyncScan(String url, ImgScanParamDTO param) { + log.debug("imgSyncScan param:{}", JSON.toJSONString(param)); if (StringUtils.isBlank(url) || param == null) { throw new RenException("参数错误"); } try { Result result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(param)); + log.debug("imgSyncScan result:{}", JSON.toJSONString(param)); if (result.success()) { - return JSON.parseObject(result.getData(), SyncScanResult.class); + return new Result().ok(JSON.parseObject(result.getData(), SyncScanResult.class)); } - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg()); } catch (Exception e) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + log.debug("imgSyncScan param:{}", JSON.toJSONString(param)); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); } } @@ -44,19 +46,21 @@ public class ScanContentUtils { * * @return */ - public static SyncScanResult textSyncScan(String url, TextScanParamDTO param) { - log.debug("textSyncScan param:", JSON.toJSONString(param)); + public static Result textSyncScan(String url, TextScanParamDTO param) { + log.debug("textSyncScan param:{}", JSON.toJSONString(param)); if (StringUtils.isBlank(url) || param == null) { throw new RenException("参数错误"); } try { Result result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(param)); + log.debug("textSyncScan result:{}", JSON.toJSONString(result)); if (result.success()) { - return JSON.parseObject(result.getData(), SyncScanResult.class); + return new Result().ok(JSON.parseObject(result.getData(), SyncScanResult.class)); } - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg()); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg()); } catch (Exception e) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + log.error("textSyncScan exception:", e); + return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); } } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java index 1793b368f4..fc6e316885 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -225,14 +225,18 @@ public class ArticleController { @Async public void scanContent(TokenDto tokenDto,String draftId){ - SyncScanResult syncScanResult = articleService.scanContent(tokenDto, draftId); - if (syncScanResult == null) { - log.error("scanContent draftId:{} return result null", draftId); - } - if (syncScanResult.isAllPass()) { - articleService.scanAllPassPublishArticle(tokenDto, draftId); - } else { - articleService.updateAuditStatusFailById(draftId, syncScanResult); + try { + SyncScanResult syncScanResult = articleService.scanContent(tokenDto, draftId); + if (syncScanResult == null) { + log.error("scanContent draftId:{} return result null", draftId); + } + if (syncScanResult.isAllPass()) { + articleService.scanAllPassPublishArticle(tokenDto, draftId); + } else { + articleService.updateAuditStatusFailById(draftId, syncScanResult); + } + } catch (Exception e) { + log.error("scanContent exception draftId:{} return result null", e); } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java index 6e66fe252a..9c6d312000 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java @@ -948,30 +948,40 @@ public class ArticleServiceImpl extends BaseServiceImpl imgSyncScanResult = null; + Result textSyncScanResult = null; + if(!CollectionUtils.isEmpty(imgScanParamDTO.getTasks())){ log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO)); + imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod), imgScanParamDTO); + log.info("scanContent imgSyncScanResult:{}", JSON.toJSONString(imgSyncScanResult)); + } + if(!CollectionUtils.isEmpty(textScanParamDTO.getTasks())){ log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO)); - imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod), imgScanParamDTO); - textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod), textScanParamDTO); + textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod), textScanParamDTO); + log.info("scanContent textSyncScanResult:{}", JSON.toJSONString(textSyncScanResult)); + } + result = new SyncScanResult(); - if (imgSyncScanResult.isAllPass()) { - result.setAllPass(imgSyncScanResult.isAllPass()); - result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds()); - result.getFailDataIds().addAll(imgSyncScanResult.getFailDataIds()); + SyncScanResult imgSyncScanResultData = imgSyncScanResult.getData(); + if (imgSyncScanResult.success()&&imgSyncScanResultData.isAllPass()) { + result.setAllPass(imgSyncScanResultData.isAllPass()); + result.getSuccessDataIds().addAll(imgSyncScanResultData.getSuccessDataIds()); + result.getFailDataIds().addAll(imgSyncScanResultData.getFailDataIds()); } - if (textSyncScanResult.isAllPass()) { - result.setAllPass(result.isAllPass() ? textSyncScanResult.isAllPass() : false); - result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds()); - result.getFailDataIds().addAll(textSyncScanResult.getFailDataIds()); + SyncScanResult textSyncScanResultData = textSyncScanResult.getData(); + if (textSyncScanResult.success()&&textSyncScanResultData.isAllPass()) { + result.setAllPass(result.isAllPass() ? textSyncScanResultData.isAllPass() : false); + result.getSuccessDataIds().addAll(textSyncScanResultData.getSuccessDataIds()); + result.getFailDataIds().addAll(textSyncScanResultData.getFailDataIds()); } } catch (Exception e) { log.error("scanContent exception", e); this.sendMsg(draftEntity.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle())); this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL); } + log.debug("scanContent result", JSON.toJSONString(result)); return result; } @Override