diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml
index 53697b265e..216ec1c8b1 100644
--- a/epmet-commons/epmet-commons-tools/pom.xml
+++ b/epmet-commons/epmet-commons-tools/pom.xml
@@ -123,6 +123,12 @@
lombok
${lombok.version}
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.2
+
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgScanParamDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgScanParamDTO.java
new file mode 100644
index 0000000000..3029a869ed
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgScanParamDTO.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.scan.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 审查参数
+ *
+ * @author jianjun liu
+ * @date 2020-06-04 21:57
+ **/
+@Data
+public class ImgScanParamDTO implements Serializable {
+
+ private static final long serialVersionUID = -5982388188212400644L;
+
+ /**
+ * 要检测的内容列表,必填
+ * remark:一组任务列表中的taskId不能相同
+ */
+ private List tasks;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgTaskDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgTaskDTO.java
new file mode 100644
index 0000000000..a724f437ee
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/ImgTaskDTO.java
@@ -0,0 +1,28 @@
+package com.epmet.commons.tools.scan.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 任务参数
+ *
+ * @author jianjun liu
+ * @email liujianjun@yunzongnet.com
+ * @date 2020-06-04 22:13
+ **/
+@Data
+public class ImgTaskDTO implements Serializable {
+
+ private static final long serialVersionUID = -747206284930578105L;
+ /**
+ * 要检测的数据id 非必填
+ *
+ * */
+ private String dataId;
+
+ /**
+ * 图片url 必填
+ */
+ private String url;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextScanParamDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextScanParamDTO.java
new file mode 100644
index 0000000000..eb10414fa8
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextScanParamDTO.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.scan.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 文本审查参数
+ *
+ * @author jianjun liu
+ * @date 2020-06-05 11:17
+ **/
+@Data
+public class TextScanParamDTO implements Serializable {
+
+ private static final long serialVersionUID = -6244354240835340471L;
+
+ /**
+ * 要检测的内容列表,必填
+ * remark:一组任务列表中的taskId不能相同
+ */
+ private List tasks;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextTaskDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextTaskDTO.java
new file mode 100644
index 0000000000..5e7791f628
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/param/TextTaskDTO.java
@@ -0,0 +1,28 @@
+package com.epmet.commons.tools.scan.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 任务参数
+ *
+ * @author jianjun liu
+ * @email liujianjun@yunzongnet.com
+ * @date 2020-06-04 22:13
+ **/
+@Data
+public class TextTaskDTO implements Serializable {
+
+ private static final long serialVersionUID = 6957195274696018630L;
+ /**
+ * 要检测的数据id 非必填
+ *
+ * */
+ private String dataId;
+
+ /**
+ * 文本内容 必填 最多不能超过10000
+ */
+ private String content;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/result/SyncScanResult.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/result/SyncScanResult.java
new file mode 100644
index 0000000000..edab5da461
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/scan/result/SyncScanResult.java
@@ -0,0 +1,42 @@
+package com.epmet.commons.tools.scan.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 检测结果
+ *
+ * @author jianjun liu
+ * @email liujianjun@yunzongnet.com
+ * @date 2020-06-05 10:52
+ **/
+@Data
+public class SyncScanResult implements Serializable {
+ /**
+ * 执行成功的任务Id集合
+ */
+ private List successDataIds = new ArrayList<>();
+ /**
+ * 执行失败的任务Id集合
+ */
+ private List failDataIds = new ArrayList<>();
+
+ /**
+ * 本地是否全部通过
+ */
+ private boolean isAllPass;
+
+ public boolean isAllPass() {
+ if (failDataIds.isEmpty() && !successDataIds.isEmpty()) {
+ return true;
+ }
+ return isAllPass;
+ }
+
+ public void setAllPass(boolean allPass) {
+ isAllPass = allPass;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
new file mode 100644
index 0000000000..5422ce563f
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
@@ -0,0 +1,172 @@
+package com.epmet.commons.tools.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.RenException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpStatus;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.springframework.util.CollectionUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * desc: http 工具类
+ * date: 2020/6/4 22:27
+ *
+ * @author: jianjun liu
+ */
+@Slf4j
+public class HttpClientManager {
+ private static int connectionTimeout = 3000;// 连接超时时间,毫秒
+ private static int soTimeout = 10000;// 读取数据超时时间,毫秒
+ /**
+ * HttpClient对象
+ */
+ private static CloseableHttpClient httpclient = HttpClients.custom().disableAutomaticRetries().build();
+
+ /*** 超时设置 ****/
+ private static RequestConfig requestConfig = RequestConfig.custom()
+ .setSocketTimeout(soTimeout)
+ .setConnectTimeout(connectionTimeout)
+ .build();//设置请求和传输超时时间
+
+ public static HttpClientManager getInstance() {
+ return SingleClass.instance;
+ }
+
+ private static class SingleClass {
+ private final static HttpClientManager instance = new HttpClientManager();
+ }
+
+ /**
+ * desc: 发送json post 请求
+ * param: url,jsonStrParam
+ * return: CallResult
+ * date: 2019/2/21 9:12
+ *
+ * @author: jianjun liu
+ */
+ public Result sendPost(String url, Map paramsMap) {
+
+ try {
+ HttpPost httppost = new HttpPost(url);
+ httppost.setConfig(requestConfig);
+ httppost.addHeader("Content-Type", "application/x-www-form-urlencoded charset=utf-8");
+
+ List list = new ArrayList();
+ for (String key : paramsMap.keySet()) {
+ list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key))));
+ }
+ UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "utf-8");
+ httppost.setEntity(urlEncodedFormEntity);
+
+ return execute(httppost);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("send exception", e);
+ return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+
+ }
+
+ /**
+ * desc: 发送json post 请求
+ * param: url,jsonStrParam
+ * return: Result
+ * date: 2019/2/21 9:12
+ *
+ * @author: jianjun liu
+ */
+ public Result sendPostByJSON(String url, String jsonStrParam) {
+
+ try {
+ HttpPost httppost = new HttpPost(url);
+ httppost.setConfig(requestConfig);
+ httppost.addHeader("Content-Type", "application/json; charset=utf-8");
+ if (StringUtils.isNotEmpty(jsonStrParam)) {
+ StringEntity se = new StringEntity(jsonStrParam, "utf-8");
+ httppost.setEntity(se);
+ }
+ return execute(httppost);
+ } catch (Exception e) {
+ log.error("send exception", e);
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+
+ }
+
+ /**
+ * desc: 发送get请求
+ * param:url, params
+ * return: CallResult
+ * date: 2019/2/21 9:16
+ *
+ * @author: jianjun liu
+ */
+ public Result sendGet(String url, Map params) {
+
+ try {
+ URIBuilder builder = new URIBuilder(url);
+ if (!CollectionUtils.isEmpty(params)) {
+ Set set = params.keySet();
+ for (String key : set) {
+ builder.setParameter(key, params.get(key) == null ? "" : String.valueOf(params.get(key)));
+ }
+ }
+ HttpGet httpGet = new HttpGet(builder.build());
+ httpGet.setConfig(requestConfig);
+ return execute(httpGet);
+ } catch (Exception e) {
+ log.error("sendGet exception", e);
+ return new Result().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+ }
+
+ private Result execute(HttpRequestBase httpMethod) {
+ CloseableHttpResponse response = null;
+ try {
+ response = httpclient.execute(httpMethod);
+ log.debug("http send response:{}", JSON.toJSONString(response));
+ if (response != null && response.getStatusLine() != null) {
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ String result = EntityUtils.toString(response.getEntity());
+ return new Result().ok(result);
+ } else {
+ log.warn("execute http method fail,httpStatus:{0}", response.getStatusLine().getStatusCode());
+ }
+ }
+ } catch (Exception e) {
+ log.error("execute exception", e);
+ new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ } finally {
+ httpMethod.releaseConnection();
+ try {
+ if (response != null) {
+ response.close();
+ }
+ } catch (IOException e) {
+ }
+ }
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+}
+
+
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
new file mode 100644
index 0000000000..cfab55c859
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ScanContentUtils.java
@@ -0,0 +1,58 @@
+package com.epmet.commons.tools.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.scan.param.ImgScanParamDTO;
+import com.epmet.commons.tools.scan.param.TextScanParamDTO;
+import com.epmet.commons.tools.scan.result.SyncScanResult;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 扫描内容工具类
+ *
+ * @author jianjun liu
+ * @email liujianjun@yunzongnet.com
+ * @date 2020-06-08 8:28
+ **/
+public class ScanContentUtils {
+ /**
+ * desc:图片同步扫描
+ *
+ * @return
+ */
+ public static SyncScanResult imgSyncScan(String url, ImgScanParamDTO param) {
+ if (StringUtils.isBlank(url) || param == null) {
+ throw new RenException("参数错误");
+ }
+ try {
+ Result result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(param));
+ if (result.success()) {
+ return JSON.parseObject(result.getData(), SyncScanResult.class);
+ }
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg());
+ } catch (Exception e) {
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
+ }
+ }
+
+ /**
+ * desc:文字同步扫描
+ *
+ * @return
+ */
+ public static SyncScanResult textSyncScan(String url, TextScanParamDTO param) {
+ if (StringUtils.isBlank(url) || param == null) {
+ throw new RenException("参数错误");
+ }
+ try {
+ Result result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(param));
+ if (result.success()) {
+ return JSON.parseObject(result.getData(), SyncScanResult.class);
+ }
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), result.getMsg());
+ } catch (Exception e) {
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
+ }
+ }
+}
diff --git a/epmet-module/gov-voice/gov-voice-server/pom.xml b/epmet-module/gov-voice/gov-voice-server/pom.xml
index 4eb00d8e54..fc82bd5754 100644
--- a/epmet-module/gov-voice/gov-voice-server/pom.xml
+++ b/epmet-module/gov-voice/gov-voice-server/pom.xml
@@ -34,6 +34,11 @@
epmet-commons-tools
2.0.0
+
+ com.epmet
+ epmet-message-client
+ 2.0.0
+
com.epmet
epmet-commons-mybatis
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java
index d2e2edecfb..c788c48844 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/ArticleConstant.java
@@ -39,4 +39,9 @@ public interface ArticleConstant {
* 下线文章操作记录表文案
*/
String OFF_LINE_ARTICLE_MSG = "%s-%s下线文章【%s】";
+
+ /**
+ * 发布文章操作记录表文案
+ */
+ String PUBLISH_ARTICLE_MSG = "%s-%s发布文章【%s】";
}
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 c9f2bf5042..9e964ac066 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
@@ -21,6 +21,7 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@@ -200,14 +201,19 @@ public class ArticleController {
Boolean isSuccess = articleService.publish(tokenDto, draftId);
if (isSuccess){
//TODO 异步校验内容
- scanContent(draftId);
+ scanContent(tokenDto,draftId);
}
return new Result().ok(isSuccess);
}
@Async
- public void scanContent(String draftId){
- articleService.scanContent(draftId);
+ public void scanContent(TokenDto tokenDto,String draftId){
+ SyncScanResult syncScanResult = articleService.scanContent(tokenDto,draftId);
+ if (syncScanResult.isAllPass()){
+ articleService.scanAllPassPublishArticle(tokenDto,draftId);
+ }else{
+ articleService.updateAuditStatusFailById(draftId,syncScanResult);
+ }
}
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java
index 0738ce4bac..1abca178e0 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftContentDao.java
@@ -18,7 +18,6 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
-import com.epmet.dto.DraftContentDTO;
import com.epmet.entity.DraftContentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -42,12 +41,14 @@ public interface DraftContentDao extends BaseDao {
* @author wangc
* @date 2020.06.05 10:28
**/
- List selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus);
+ List selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus);
/**
* desc:查询需要审核的内容
* @param draftId
* @return
*/
- List selectScanContentByDraftId(String draftId);
+ List selectScanContentByDraftId(String draftId);
+
+ int updateAuditStatusById(@Param("id")String id, @Param("auditStatus")String auditStatus);
}
\ No newline at end of file
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java
index a59d560ea1..d9bec5bd34 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftCoverDao.java
@@ -40,7 +40,7 @@ public interface DraftCoverDao extends BaseDao {
* @author wangc
* @date 2020.06.05 10:28
**/
- DraftCoverDTO selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus);
+ DraftCoverEntity selectByDraftId(@Param("draftId")String draftId,@Param("auditStatus")String auditStatus);
/**
* @Description 通过草稿Id 获取未删除的草稿封面id及地址
@@ -50,4 +50,6 @@ public interface DraftCoverDao extends BaseDao {
* @date 2020.06.05 10:28
**/
DraftCoverDTO selectCoverIdAndUrlByDraftId(@Param("draftId")String draftId);
+
+ int updateAuditStatusById(@Param("id")String id, @Param("auditStatus")String auditStatus);
}
\ No newline at end of file
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
index 9b8a977d90..3fa1c7c49b 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
@@ -19,6 +19,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@@ -166,18 +167,20 @@ public interface ArticleService extends BaseService {
**/
ArticleDetailResultDTO getArticleDetail(ResiArticleDetailFormDTO articleDetailFormDTO);
- /**
- * @Description 草稿发布文章
- * @param draftId
- * @return String 返回新发布文章的Id
- * @author wangc
- * @date 2020.06.05 09:10
- **/
- String publishDraftToArticle(String draftId);
+ /**
+ * desc:执行审核返回执行结果
+ * @param tokenDto
+ * @param draftId
+ * @return
+ */
+ SyncScanResult scanContent(TokenDto tokenDto, String draftId);
+
+ void scanAllPassPublishArticle(TokenDto tokenDto, String draftId);
/**
- * desc:异步执行审核,如果审核通过则 发布文章,否则发送站内信
+ * desc:修改审核状态为失败
* @param draftId
+ * @param syncScanResult
*/
- void scanContent(String draftId);
+ void updateAuditStatusFailById(String draftId, SyncScanResult syncScanResult);
}
\ No newline at end of file
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 9cc3425437..196b8cc9f7 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
@@ -19,28 +19,33 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.scan.param.ImgScanParamDTO;
+import com.epmet.commons.tools.scan.param.ImgTaskDTO;
+import com.epmet.commons.tools.scan.param.TextScanParamDTO;
+import com.epmet.commons.tools.scan.param.TextTaskDTO;
+import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
+import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
-import com.epmet.constant.ArticleConstant;
-import com.epmet.constant.DraftConstant;
-import com.epmet.constant.RoleKeyConstants;
-import com.epmet.constant.TagConstant;
+import com.epmet.constant.*;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
+import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.redis.ArticleRedis;
@@ -54,6 +59,7 @@ import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -111,6 +117,15 @@ public class ArticleServiceImpl extends BaseServiceImpl resultStaff = epmetUserOpenFeignClient.getCustomerStaff(formDTO.getStaffId());
- if (!resultStaff.success() || null == resultStaff.getData()) {
- throw new RenException(ArticleConstant.SELECT_STAFF_EXCEPTION);
- }
- CustomerStaffDTO staffDTO = resultStaff.getData();
+ CustomerStaffDTO staffDTO = getCustomerStaff(formDTO.getStaffId());
//4.2:查询文章表数据
ArticleEntity articleEntity = baseDao.selectById(formDTO.getArticleId());
//4.3:新增操作表数据
@@ -532,6 +545,14 @@ public class ArticleServiceImpl extends BaseServiceImpl resultStaff = epmetUserOpenFeignClient.getCustomerStaff(userId);
+ if (!resultStaff.success() || null == resultStaff.getData()) {
+ throw new RenException(ArticleConstant.SELECT_STAFF_EXCEPTION);
+ }
+ return resultStaff.getData();
+ }
+
@Override
public PageData publishedArticleList(TokenDto tokenDto, PublishedListFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize());
@@ -805,20 +826,22 @@ public class ArticleServiceImpl extends BaseServiceImpl draftContents = draftContentDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS);
- DraftCoverDTO draftCover = draftCoverDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS);
+ String draftId = draft.getId();
+ List draftContents = draftContentDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS);
+ DraftCoverEntity draftCover = draftCoverDao.selectByDraftId(draftId,ModuleConstant.AUDIT_STATUS_PASS);
List draftPublishRange = draftPublishRangeDao.selectByDraftId(draftId);
//3.生成文章以及相关记录
@@ -834,6 +857,9 @@ public class ArticleServiceImpl extends BaseServiceImpl NumConstant.ZERO){
@@ -848,51 +874,144 @@ public class ArticleServiceImpl extends BaseServiceImpl imgMap = new HashMap<>();
- Map textMap = new HashMap<>();
+
+ TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
+ ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO();
DraftCoverDTO draftCoverDTO = draftCoverDao.selectCoverIdAndUrlByDraftId(draftId);
if (draftCoverDTO != null){
- imgMap.put(ModuleConstant.SCAN_COVER_PREFIX.concat(draftCoverDTO.getId()), draftCoverDTO.getImgUrl());
+ ImgTaskDTO taskDTO = new ImgTaskDTO();
+ taskDTO.setDataId(ModuleConstant.SCAN_COVER_PREFIX.concat(draftCoverDTO.getId()));
+ taskDTO.setUrl(draftCoverDTO.getImgUrl());
+ imgScanParamDTO.getTasks().add(taskDTO);
}
- List contentDTOList = draftContentDao.selectScanContentByDraftId(draftId);
+ List contentDTOList = draftContentDao.selectScanContentByDraftId(draftId);
if(!CollectionUtils.isEmpty(contentDTOList)){
contentDTOList.forEach(content->{
String contentType = content.getContentType();
if (DraftConstant.TEXT.equals(contentType)){
//todo 内容叠加审核吧 id拼起来
- textMap.put(content.getId(),content.getContent());
+ TextTaskDTO textTaskDTO = new TextTaskDTO();
+ textTaskDTO.setDataId(content.getId());
+ textTaskDTO.setContent(content.getContent());
}else if (DraftConstant.IMG.equals(contentType)){
- imgMap.put(draftCoverDTO.getId(), draftCoverDTO.getImgUrl());
+ ImgTaskDTO taskDTO = new ImgTaskDTO();
+ taskDTO.setDataId(content.getId());
+ taskDTO.setUrl(content.getContent());
+ imgScanParamDTO.getTasks().add(taskDTO);
}
});
}
//todo 执行审核
+ SyncScanResult imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiHost.concat(imgSyncScanMethod),imgScanParamDTO);
+ SyncScanResult textSyncScanResult = ScanContentUtils.textSyncScan(scanApiHost.concat(textSyncScanMethod),textScanParamDTO);
+ SyncScanResult result = new SyncScanResult();
+ if (imgSyncScanResult.isAllPass()){
+ result.setAllPass(imgSyncScanResult.isAllPass());
+ result.getSuccessDataIds().addAll(imgSyncScanResult.getSuccessDataIds());
+ result.getFailDataIds().addAll(imgSyncScanResult.getFailDataIds());
+ }
+ if (textSyncScanResult.isAllPass()){
+ result.setAllPass(result.isAllPass()?textSyncScanResult.isAllPass():false);
+ result.getSuccessDataIds().addAll(textSyncScanResult.getSuccessDataIds());
+ result.getFailDataIds().addAll(textSyncScanResult.getFailDataIds());
+ }
+
+ return result;
+ }
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void scanAllPassPublishArticle(TokenDto tokenDto, String draftId){
+ DraftEntity draft = draftDao.selectById(draftId);
+ if (draft == null){
+ throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(),EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg());
+ }
+ try {
+ //审核通过
+ ArticleEntity articleEntity = this.publishDraftToArticle(draft);
+ UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = this.updateCustomerTag(tokenDto, draftId);
+ List updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO);
+
+ //更新redis
+ try {
+ this.updateCacheCustomerTag(updateCustomerTagCacheDTO);
+ this.updateCacheGridTag(updateGridTagCacheDTOS);
+ } catch (Exception e) {
+ log.error("scanAllPassPublishArticle update redis exception", e);
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+ } catch (Exception e) {
+ log.error("scanAllPassPublishArticle update db exception", e);
+ this.sendMsg(draft.getTitle(), String.format(ModuleConstant.MSG_ARTICLE_PUBLISH_ERROR, draft.getTitle()));
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
+ }
+
+
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public void updateAuditStatusFailById(String draftId,SyncScanResult syncScanResult) {
+ List failDataIds = syncScanResult.getFailDataIds();
+ failDataIds.forEach(id->{
+ if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX)>=0){
+ draftCoverDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_FAIL);
+ }else{
+ draftContentDao.updateAuditStatusById(id,ModuleConstant.AUDIT_STATUS_FAIL);
+ }
+ });
+ }
+
+ public Result sendMsg(String title,String content) {
+ UserMessageFormDTO formDTO = new UserMessageFormDTO();
+ formDTO.setCustomerId(loginUserUtil.getLoginUserApp());
+ formDTO.setGridId("");
+ formDTO.setUserId(loginUserUtil.getLoginUserId());
+ formDTO.setApp(AppClientConstant.APP_GOV);
+ formDTO.setTitle(String.format(ModuleConstant.MSG_TITLE,title));
+ formDTO.setMessageContent(content);
+ formDTO.setReadFlag(ReadFlagConstant.UN_READ);
+
+ return epmetMessageOpenFeignClient.saveUserMessage(formDTO);
}
/**
@@ -900,7 +1019,6 @@ public class ArticleServiceImpl extends BaseServiceImpl updateGridTag(TokenDto tokenDto,String draftId,UpdateCustomerTagCacheDTO formDto){
//获取草稿基本信息
DraftDTO draft = draftService.get(draftId);
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagServiceImpl.java
index 340516bfb6..1a625c42d1 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagServiceImpl.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagServiceImpl.java
@@ -43,7 +43,7 @@ public class TagServiceImpl implements TagService {
*/
@Override
public List resiTagList(ResiTagListFormDTO formDto) {
- //校验 在本网格是否发布过文章
+ //校验 客户在本网格是否发布过文章
Integer articleCounts = articleDao.checkPublishArticle(formDto);
if (articleCounts== NumConstant.ZERO){
return new ArrayList<>();
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java
index b12b0fef32..d9cc1d429c 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java
@@ -69,4 +69,19 @@ public interface ModuleConstant {
* */
String SCAN_COVER_PREFIX = "cover_";
+ /**
+ * 文章站内消息标题
+ * */
+ String MSG_TITLE = "您有一条文章【%s】的消息";
+
+ /**
+ * 文章未审核通过 消息内容模版
+ * */
+ String MSG_AUDIT_CONTENT = "您好,您发布的【%s】文章%s审核未通过,请重新编辑后发布,谢谢。";
+
+ /**
+ * 文章发布失败 内部错误导致
+ * */
+ String MSG_ARTICLE_PUBLISH_ERROR = "您好,你发布的【%s】文章由于网络错误未发布成功,请重新发布,谢谢。";
+
}
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml
index 879ba305a7..cf9123df0f 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml
@@ -93,3 +93,11 @@ hystrix:
ribbon:
ReadTimeout: 300000
ConnectTimeout: 300000
+
+openapi:
+ scan:
+ server:
+ host: http://localhost:8107/epmetscan/api
+ mehod:
+ imgSyncScan: /imgSyncScan
+ textSyncScan: /textSyncScan
diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
index d1066b44f6..d3be4c7e2f 100644
--- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
+++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
@@ -34,16 +34,17 @@
ORDER BY
ac.ORDER_NUM ASC
+
+