Browse Source

审核失败代码调整

master
jianjun 5 years ago
parent
commit
1d40d60042
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  2. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java
  3. 7
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  4. 62
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -36,7 +36,6 @@ import java.util.Set;
* @author: jianjun liu * @author: jianjun liu
*/ */
@Slf4j @Slf4j
@Component
public class HttpClientManager { public class HttpClientManager {
private static int connectionTimeout = 3000;// 连接超时时间,毫秒 private static int connectionTimeout = 3000;// 连接超时时间,毫秒
private static int soTimeout = 10000;// 读取数据超时时间,毫秒 private static int soTimeout = 10000;// 读取数据超时时间,毫秒

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java

@ -8,7 +8,6 @@ import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.scan.result.SyncScanResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
/** /**
* 扫描内容工具类 * 扫描内容工具类
@ -18,7 +17,6 @@ import org.springframework.stereotype.Component;
* @date 2020-06-08 8:28 * @date 2020-06-08 8:28
**/ **/
@Slf4j @Slf4j
@Component
public class ScanContentUtils { public class ScanContentUtils {
/** /**
* desc:图片同步扫描 * desc:图片同步扫描

7
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java

@ -20,8 +20,6 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -32,6 +30,7 @@ import com.epmet.dto.result.*;
import com.epmet.service.ArticleOperateRecordService; import com.epmet.service.ArticleOperateRecordService;
import com.epmet.service.ArticleService; import com.epmet.service.ArticleService;
import com.epmet.service.DraftService; import com.epmet.service.DraftService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -48,6 +47,7 @@ import java.util.List;
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2020-06-02 * @since v1.0.0 2020-06-02
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("article") @RequestMapping("article")
public class ArticleController { public class ArticleController {
@ -227,14 +227,13 @@ public class ArticleController {
public void scanContent(TokenDto tokenDto,String draftId){ public void scanContent(TokenDto tokenDto,String draftId){
SyncScanResult syncScanResult = articleService.scanContent(tokenDto, draftId); SyncScanResult syncScanResult = articleService.scanContent(tokenDto, draftId);
if (syncScanResult == null) { if (syncScanResult == null) {
throw new RenException(EpmetErrorCode.ARTICLE_PUBLISH_ERROR.getCode(),EpmetErrorCode.ARTICLE_PUBLISH_ERROR.getMsg()); log.error("scanContent draftId:{} return result null", draftId);
} }
if (syncScanResult.isAllPass()) { if (syncScanResult.isAllPass()) {
articleService.scanAllPassPublishArticle(tokenDto, draftId); articleService.scanAllPassPublishArticle(tokenDto, draftId);
} else { } else {
articleService.updateAuditStatusFailById(draftId, syncScanResult); articleService.updateAuditStatusFailById(draftId, syncScanResult);
} }
} }

62
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -847,16 +847,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
article.setId(null); article.setId(null);
article.setDraftId(draftId); article.setDraftId(draftId);
baseDao.insert(article); baseDao.insert(article);
int order = NumConstant.ONE;
if(null != draftContents && draftContents.size() > NumConstant.ZERO){ if(null != draftContents && draftContents.size() > NumConstant.ZERO){
draftContents.forEach(content -> { draftContents.forEach(content -> {
content.setOrderNum(order+NumConstant.ONE); content.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS);
content.setOrderNum(content.getOrderNum());
ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class); ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class);
contentToInsert.setArticleId(article.getId()); contentToInsert.setArticleId(article.getId());
contentToInsert.setId(null); contentToInsert.setId(null);
articleContentDao.insert(contentToInsert); articleContentDao.insert(contentToInsert);
content.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS);
draftContentDao.updateById(content); draftContentDao.updateById(content);
}); });
} }
@ -868,12 +868,13 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
articlePublishRangeDao.insert(rangeToInsert); articlePublishRangeDao.insert(rangeToInsert);
}); });
if(null != draftCover){ if(null != draftCover){
draftCover.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS);
ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class); ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class);
coverToInsert.setArticleId(article.getId()); coverToInsert.setArticleId(article.getId());
coverToInsert.setId(null); coverToInsert.setId(null);
articleCoverDao.insert(coverToInsert); articleCoverDao.insert(coverToInsert);
draftCover.setAuditStatus(ModuleConstant.AUDIT_STATUS_PASS);
draftCoverDao.updateById(draftCover); draftCoverDao.updateById(draftCover);
} }
} }
@ -898,20 +899,28 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Override @Override
public SyncScanResult scanContent(TokenDto tokenDto, String draftId) { public SyncScanResult scanContent(TokenDto tokenDto, String draftId) {
DraftEntity draftEntity = draftDao.selectById(draftId); DraftEntity draftEntity = draftDao.selectById(draftId);
boolean isOk = true;
if (draftEntity == null) { if (draftEntity == null) {
log.error("scanContent draftId:{} is not exist", draftId); log.error("scanContent draftId:{} is not exist", draftId);
return null; isOk = false;
} }
if (!DraftConstant.AUDITING.equals(draftEntity.getStatusFlag())) { if (!DraftConstant.AUDITING.equals(draftEntity.getStatusFlag())) {
log.error("scanContent draftId:{} statusFlag:{} is not support 2 modify", draftId, draftEntity.getStatusFlag()); log.error("scanContent draftId:{} statusFlag:{} is not support 2 modify", draftId, draftEntity.getStatusFlag());
return null; isOk = false;
} }
if (!NumConstant.ZERO_STR.equals(draftEntity.getDelFlag())) { if (!NumConstant.ZERO_STR.equals(draftEntity.getDelFlag())) {
log.error("scanContent draftId:{} delFlag:{} is not support 2 modify", draftId, draftEntity.getDelFlag()); log.error("scanContent draftId:{} delFlag:{} is not support 2 modify", draftId, draftEntity.getDelFlag());
return null; isOk = false;
} }
if (!isOk) {
this.sendMsg(draftEntity.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle()));
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL);
return null;
}
SyncScanResult result = null;
try {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO();
DraftCoverDTO draftCoverDTO = draftCoverDao.selectCoverIdAndUrlByDraftId(draftId); DraftCoverDTO draftCoverDTO = draftCoverDao.selectCoverIdAndUrlByDraftId(draftId);
@ -941,17 +950,13 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
} }
SyncScanResult imgSyncScanResult = null; SyncScanResult imgSyncScanResult = null;
SyncScanResult textSyncScanResult = null; SyncScanResult textSyncScanResult = null;
try {
log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO)); log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO));
log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO)); log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO));
imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod), imgScanParamDTO); imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod), imgScanParamDTO);
textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod), textScanParamDTO); textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod), textScanParamDTO);
} catch (Exception e) {
log.error("scanContent exception",e); result = new SyncScanResult();
this.sendMsg(draftEntity.getTitle(),String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draftEntity.getTitle()));
this.updateDraftPublishStatus(draftId,DraftConstant.AUDITFAIL);
}
SyncScanResult result = new SyncScanResult();
if (imgSyncScanResult.isAllPass()) { if (imgSyncScanResult.isAllPass()) {
result.setAllPass(imgSyncScanResult.isAllPass()); result.setAllPass(imgSyncScanResult.isAllPass());
result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds()); result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds());
@ -962,19 +967,25 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds()); result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds());
result.getFailDataIds().addAll(textSyncScanResult.getFailDataIds()); result.getFailDataIds().addAll(textSyncScanResult.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);
}
return result; return result;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void scanAllPassPublishArticle(TokenDto tokenDto, String draftId){ public void scanAllPassPublishArticle(TokenDto tokenDto, String draftId){
DraftEntity draft = draftDao.selectById(draftId); DraftEntity draft = draftDao.selectById(draftId);
if (draft == null) { if (draft == null) {
log.error("scanAllPassPublishArticle draftId:{} is not exist in db", draftId);
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg());
} }
try { try {
//审核通过 //审核通过
ArticleEntity articleEntity = this.publishDraftToArticle(draft); this.publishDraftToArticle(draft);
UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId); UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId);
List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO); List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO);
this.addArticleTags(updateCustomerTagCacheDTO, draftId, tokenDto); this.addArticleTags(updateCustomerTagCacheDTO, draftId, tokenDto);
@ -993,16 +1004,20 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL); this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
} }
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void updateAuditStatusFailById(String draftId,SyncScanResult syncScanResult) { public void updateAuditStatusFailById(String draftId,SyncScanResult syncScanResult) {
DraftEntity draft = draftDao.selectById(draftId);
if (draft == null) {
log.error("updateAuditStatusFailById draftId:{} is not exist in db", draftId);
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg());
}
try {
List<String> failDataIds = syncScanResult.getFailDataIds(); List<String> failDataIds = syncScanResult.getFailDataIds();
failDataIds.forEach(id -> { failDataIds.forEach(id -> {
if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX)>=0){ if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX) >= NumConstant.ZERO) {
draftCoverDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL); draftCoverDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL);
} else { } else {
draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL); draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL);
@ -1016,6 +1031,12 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_PASS); draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_PASS);
} }
}); });
} catch (Exception e) {
log.error("scanAllPassPublishArticle update db exception", e);
this.sendMsg(draft.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draft.getTitle()));
this.updateDraftPublishStatus(draftId, DraftConstant.AUDITFAIL);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
} }
@Override @Override
@ -1158,7 +1179,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
* @param formDto * @param formDto
* @author zxc * @author zxc
*/ */
@Transactional(rollbackFor = Exception.class)
public void addArticleTags(UpdateCustomerTagCacheDTO formDto,String draftId,TokenDto tokenDto){ public void addArticleTags(UpdateCustomerTagCacheDTO formDto,String draftId,TokenDto tokenDto){
List<AddArticleTagsFormDTO> addArticleTags = new ArrayList<>(); List<AddArticleTagsFormDTO> addArticleTags = new ArrayList<>();
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo();

Loading…
Cancel
Save