Forráskód Böngészése

Merge branch 'master' into wyp/1206-titleHisCache

# Conflicts:
#	long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java
#	long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/XxlJobController.java
wangyunpeng 7 hónapja
szülő
commit
3fbe8299e3
51 módosított fájl, 1137 hozzáadás és 385 törlés
  1. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/HttpPoolFactory.java
  2. 29 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ArticleDeleteStatusEnum.java
  3. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/FeishuRobotIdEnum.java
  4. 12 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java
  5. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/LongArticleBaseMapper.java
  6. 15 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/LongArticlesMatchVideoResponse.java
  7. 28 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishContentMiniprogramDTO.java
  8. 14 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishGzhPushContentRelDTO.java
  9. 25 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishGzhPushDTO.java
  10. 11 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/RequestResult.java
  11. 29 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/ArticleUnsafeTitle.java
  12. 50 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleAuditDelete.java
  13. 78 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleCrawlerVideo.java
  14. 40 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleVideoAudit.java
  15. 13 13
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticlesMatchVideo.java
  16. 13 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/ArticleDangerFindDeleteParam.java
  17. 10 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/ArticleVideoAuditResultParam.java
  18. 10 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/PublishContentFilterContentItem.java
  19. 11 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/PublishContentFilterParam.java
  20. 9 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/PublishContentFilterResultVO.java
  21. 5 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/WxAccessTokenRemoteService.java
  22. 66 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/WxArticleDeleteService.java
  23. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/aigc/PublishAccountRepository.java
  24. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java
  25. 15 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/ArticleUnsafeTitleRepository.java
  26. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/GetOffVideoArticleRepository.java
  27. 14 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleAuditDeleteRepository.java
  28. 17 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleCrawlerVideoRepository.java
  29. 14 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleVideoAuditRepository.java
  30. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticlesMatchVideoRepository.java
  31. 299 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java
  32. 51 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/PublishContentFilterService.java
  33. 18 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/filter/strategy/SensitiveStrategy.java
  34. 49 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java
  35. 11 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java
  36. 4 36
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java
  37. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java
  38. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java
  39. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java
  40. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java
  41. 3 8
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java
  42. 4 36
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java
  43. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java
  44. 4 36
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java
  45. 3 33
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java
  46. 4 36
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java
  47. 2 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/CrawlerDaysDecreaseStrategy.java
  48. 41 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/ArticleAuditController.java
  49. 28 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/PublishContentFilterController.java
  50. 56 6
      long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml
  51. 4 0
      long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/HttpPoolFactory.java

@@ -17,7 +17,7 @@ public final class HttpPoolFactory {
             HttpClientFactory.create(1000, 30000, 200, 200, 0, 5000);
 
     private static CloseableHttpClient ThirtySecond =
-            HttpClientFactory.create(30000, 30000, 200, 200, 0, 30000);
+            HttpClientFactory.create(1000, 60000, 200, 200, 0, 5000);
 
 
     public static CloseableHttpClient defaultPool() {

+ 29 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ArticleDeleteStatusEnum.java

@@ -0,0 +1,29 @@
+package com.tzld.longarticle.recommend.server.common.enums.recommend;
+
+import lombok.Getter;
+
+@Getter
+public enum ArticleDeleteStatusEnum {
+
+    WAITING(0, "WAITING"),
+    SUCCESS(1, "SUCCESS"),
+    FAIL(2, "FAIL"),
+    ;
+
+    private int code;
+    private String msg;
+
+    ArticleDeleteStatusEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public static ArticleDeleteStatusEnum getByCode(int code) {
+        for (ArticleDeleteStatusEnum statusEnum : ArticleDeleteStatusEnum.values()) {
+            if (statusEnum.getCode() == code) {
+                return statusEnum;
+            }
+        }
+        return null;
+    }
+}

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/FeishuRobotIdEnum.java

@@ -9,6 +9,7 @@ public enum FeishuRobotIdEnum {
     RECOMMEND("长文排序报警群", "07026a9f-43f5-448b-ba40-a8d71bd6e634"),
     JOB("定时任务报警群", "186c9798-5b6a-4ff8-b7fc-4ce4b6ea5076"),
     DAILY("长文每日更新报警群", "b44333f2-16c0-4cb1-af01-d135f8704410"),
+    ARTICLE_DELETE("文章删除报警群", "2262caec-3f52-4a93-9fa5-da2382a21482"),
 
     ;
 

+ 12 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -44,4 +44,16 @@ public interface AigcBaseMapper {
     List<ProducePlanExeRecord> getAllByProducePlanId(List<String> producePlanIds);
 
     List<PublishPlanAccountNotifyDTO> checkPublishPlanAccount();
+
+    List<PublishContentMiniprogramDTO> getPublishContentByTraceIdIn(List<String> traceIds);
+
+    List<PublishGzhPushContentRelDTO> getPushContentRelByPublishContentIdIn(List<String> publishContentIds);
+
+    List<PublishGzhPushDTO> getPushByPushIdIn(List<String> pushIds);
+
+    List<PublishGzhPushContentRelDTO> getGroupPushRelByPushIdIn(List<String> pushIds);
+
+    PublishContentDTO getPublishContentById(String publishContentId);
+
+    List<PublishContentDTO> getPublishContentBySourceIdIn(List<String> sourceIds);
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/LongArticleBaseMapper.java

@@ -63,4 +63,6 @@ public interface LongArticleBaseMapper {
     int countNeedMatchVideos(Long id);
 
     List<PublishSingleVideoSource> getPublishSingleVideoSource(ArticleVideoPoolSourceParam param);
+
+    List<String> getFilterColdLongArticleTitle();
 }

+ 15 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/LongArticlesMatchVideoResponse.java

@@ -0,0 +1,15 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class LongArticlesMatchVideoResponse {
+    private String uid;
+    private Object source;
+    private String kimiTitle;
+    private long videoID;
+    private String videoCover;
+    private String videoPath;
+    private String videoOSS;
+    private String rootSourceID;
+}

+ 28 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishContentMiniprogramDTO.java

@@ -0,0 +1,28 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class PublishContentMiniprogramDTO {
+    private Long id;
+    private String publishContentId;
+    private String rootShareId;
+    private String source;
+    private Integer bizType;
+    private String programId;
+    private String programName;
+    private String programAvatar;
+    private String productionCover;
+    private String productionName;
+    private String productionPath;
+    private String videoUrl;
+    private Integer hideFlag;
+    private Integer status;
+    private String traceId;
+    private String errorMsg;
+    private String version;
+    private Integer miniprogramUseType;
+    private Long createTimestamp;
+    private Long updateTimestamp;
+    private String resultData;
+}

+ 14 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishGzhPushContentRelDTO.java

@@ -0,0 +1,14 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class PublishGzhPushContentRelDTO {
+
+    private Long id;
+    private String pushId;
+    private String planId;
+    private String publishContentId;
+    private String userGroupId;
+
+}

+ 25 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishGzhPushDTO.java

@@ -0,0 +1,25 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class PublishGzhPushDTO {
+    private String pushId;
+    private String planId;
+    private Integer pushType;
+    private String publishAccountId;
+    private Integer pushStatus;
+    private Integer publishStatus;
+    private String errorCode;
+    private String errorMsg;
+    private Integer pushRetryCount;
+    private Long pushRetryTimestamp;
+    private Integer publishRetryCount;
+    private Long publishRetryTimestamp;
+    private String draftMediaId;
+    private Long draftCreateTime;
+    private String groupPushMsgId;
+    private String robopostId;
+    private Long pushScheduleTimestamp;
+    private Long pushFinishTimestamp;
+}

+ 11 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/RequestResult.java

@@ -0,0 +1,11 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class RequestResult<T> {
+    private boolean success;
+    private T response;
+    private String failReason;
+    private String responseStr;
+}

+ 29 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/ArticleUnsafeTitle.java

@@ -0,0 +1,29 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "article_unsafe_title")
+public class ArticleUnsafeTitle {
+    @Id
+    @Column(name = "title_md5")
+    private String titleMd5;
+    @Column(name = "title")
+    private String title;
+    @Column(name = "status")
+    private Integer status;
+    @Column(name = "create_timestamp")
+    private Long createTimestamp;
+    @Column(name = "update_timestamp")
+    private Long updateTimestamp;
+}

+ 50 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleAuditDelete.java

@@ -0,0 +1,50 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "long_article_audit_delete")
+public class LongArticleAuditDelete {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "gh_id")
+    private String ghId;
+
+    @Column(name = "msg_id")
+    private String msgId;
+
+    @Column(name = "`index`")
+    private Integer index;
+
+    @Column(name = "push_id")
+    private String pushId;
+
+    @Column(name = "push_type")
+    private Integer pushType;
+
+    @Column(name = "publish_content_id")
+    private String publishContentId;
+
+    @Column(name = "status")
+    private Integer status;
+
+    @Column(name = "fail_reason")
+    private String failReason;
+
+    @Column(name = "create_timestamp")
+    private Long createTimestamp;
+
+    @Column(name = "finish_timestamp")
+    private Long finishTimestamp;
+}

+ 78 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleCrawlerVideo.java

@@ -0,0 +1,78 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "long_articles_crawler_videos")
+public class LongArticleCrawlerVideo {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "content_id")
+    private String contentId;
+
+    @Column(name = "out_video_id")
+    private String outVideoId;
+
+    @Column(name = "platform")
+    private String platform;
+
+    @Column(name = "video_title")
+    private String videoTitle;
+
+    @Column(name = "play_count")
+    private Integer playCount;
+
+    @Column(name = "like_count")
+    private Integer likeCount;
+
+    @Column(name = "share_count")
+    private Integer shareCount;
+
+    @Column(name = "publish_time")
+    private Date publishTime;
+
+    @Column(name = "crawler_time")
+    private Date crawlerTime;
+
+    @Column(name = "duration")
+    private Integer duration;
+
+    @Column(name = "video_url")
+    private String videoUrl;
+
+    @Column(name = "cover_url")
+    private String coverUrl;
+
+    @Column(name = "download_status")
+    private Integer downloadStatus;
+
+    @Column(name = "video_oss_path")
+    private String videoOssPath;
+
+    @Column(name = "cover_oss_path")
+    private String coverOssPath;
+
+    @Column(name = "user_id")
+    private String userId;
+
+    @Column(name = "trace_id")
+    private String traceId;
+
+    @Column(name = "score")
+    private Double score;
+
+    @Column(name = "is_illegal")
+    private Integer isIllegal;
+}

+ 40 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleVideoAudit.java

@@ -0,0 +1,40 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "long_articles_video_audit")
+public class LongArticleVideoAudit {
+
+    @Id
+    @Column(name = "video_id")
+    private Long videoId;
+
+    @Column(name = "content_id")
+    private String contentId;
+
+    @Column(name = "trace_id")
+    private String traceId;
+
+    @Column(name = "oss_path")
+    private String ossPath;
+
+    @Column(name = "status")
+    private Integer status;
+
+    @Column(name = "fail_reason")
+    private String failReason;
+
+    @Column(name = "create_timestamp")
+    private Long createTimestamp;
+
+    @Column(name = "finish_timestamp")
+    private Long finishTimestamp;
+}

+ 13 - 13
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticlesMatchVideo.java

@@ -19,37 +19,37 @@ public class LongArticlesMatchVideo {
      */
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "id", nullable = false, unique = true, columnDefinition = "int(16) COMMENT '自增 id'")
+    @Column(name = "id")
     private Integer id;
 
     /**
      * 唯一追踪 id
      */
-    @Column(name = "trace_id", nullable = false, length = 64, columnDefinition = "varchar(64) COMMENT '唯一追踪 id'")
+    @Column(name = "trace_id")
     private String traceId;
 
     /**
      * 文章 id
      */
-    @Column(name = "content_id", length = 64, columnDefinition = "varchar(64) COMMENT '文章 id'")
+    @Column(name = "content_id")
     private String contentId;
 
     /**
      * 流量池等级
      */
-    @Column(name = "flow_pool_level", length = 32, columnDefinition = "varchar(32) COMMENT '流量池等级 '")
+    @Column(name = "flow_pool_level")
     private String flowPoolLevel;
 
     /**
      * 公众号 Id
      */
-    @Column(name = "gh_id", length = 32, columnDefinition = "varchar(32) COMMENT '公众号 Id'")
+    @Column(name = "gh_id")
     private String ghId;
 
     /**
      * 公众号名称
      */
-    @Column(name = "account_name", length = 64, columnDefinition = "varchar(64) COMMENT '公众号名称'")
+    @Column(name = "account_name")
     private String accountName;
 
     /**
@@ -62,43 +62,43 @@ public class LongArticlesMatchVideo {
      * 101 - 有一个进程正在处理这条记录
      * 99 - 处理失败
      */
-    @Column(name = "content_status", nullable = false, columnDefinition = "int(8) DEFAULT '0' COMMENT '内容状态'")
+    @Column(name = "content_status")
     private Integer contentStatus = 0;
 
     /**
      * 文章状态 id 的修改时间
      */
-    @Column(name = "content_status_update_time", columnDefinition = "int(16) COMMENT '文章状态 id 的修改时间'")
+    @Column(name = "content_status_update_time")
     private Long contentStatusUpdateTime;
 
     /**
      * 是否请求成功, 1表示成功
      */
-    @Column(name = "success_status", nullable = false, columnDefinition = "int(1) DEFAULT '0' COMMENT '是否请求成功, 1表示成功'")
+    @Column(name = "success_status")
     private Integer successStatus = 0;
 
     /**
      * 请求时间
      */
-    @Column(name = "request_timestamp", nullable = false, columnDefinition = "int(16) COMMENT '请求时间'")
+    @Column(name = "request_timestamp")
     private Long requestTimestamp;
 
     /**
      * 更新时间
      */
-    @Column(name = "update_time", nullable = false, columnDefinition = "datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'")
+    @Column(name = "update_time")
     private Date updateTime;
 
     /**
      * 结果
      */
     @Lob
-    @Column(name = "response", columnDefinition = "text COMMENT '结果'")
+    @Column(name = "response")
     private String response;
 
     /**
      * 处理次数
      */
-    @Column(name = "process_times", nullable = false, columnDefinition = "int(1) NOT NULL DEFAULT '0' COMMENT '处理次数'")
+    @Column(name = "process_times")
     private Integer processTimes = 0;
 }

+ 13 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/ArticleDangerFindDeleteParam.java

@@ -0,0 +1,13 @@
+package com.tzld.longarticle.recommend.server.model.param;
+
+import lombok.Data;
+
+@Data
+public class ArticleDangerFindDeleteParam {
+
+    private String ghId;
+    private String accountName;
+    private String title;
+    private String wxSn;
+
+}

+ 10 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/ArticleVideoAuditResultParam.java

@@ -0,0 +1,10 @@
+package com.tzld.longarticle.recommend.server.model.param;
+
+import lombok.Data;
+
+@Data
+public class ArticleVideoAuditResultParam {
+    private Long videoId;
+    private Integer result;
+    private String failReason;
+}

+ 10 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/PublishContentFilterContentItem.java

@@ -0,0 +1,10 @@
+package com.tzld.longarticle.recommend.server.model.param;
+
+import lombok.Data;
+
+@Data
+public class PublishContentFilterContentItem {
+    private String sourceId;
+    private String poolLevel;
+    private String title;
+}

+ 11 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/PublishContentFilterParam.java

@@ -0,0 +1,11 @@
+package com.tzld.longarticle.recommend.server.model.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class PublishContentFilterParam {
+    private String ghId;
+    private List<PublishContentFilterContentItem> contentList;
+}

+ 9 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/PublishContentFilterResultVO.java

@@ -0,0 +1,9 @@
+package com.tzld.longarticle.recommend.server.model.vo;
+
+import lombok.Data;
+
+@Data
+public class PublishContentFilterResultVO {
+    private String sourceId;
+    private String filterReason;
+}

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/WxAccessTokenRemoteService.java

@@ -42,6 +42,11 @@ public class WxAccessTokenRemoteService {
     private Map<String, Map<String, String>> gzhConfig;
 
     public String getAccessToken(String gzhId) {
+        try {
+            return cache.getUnchecked(gzhId);
+        } catch (Exception e) {
+            log.error("get user error gzhId {} ", gzhId, e);
+        }
         return cache.getUnchecked(gzhId);
     }
 

+ 66 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/WxArticleDeleteService.java

@@ -0,0 +1,66 @@
+package com.tzld.longarticle.recommend.server.remote;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.model.dto.RequestResult;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+@Service
+@Slf4j
+public class WxArticleDeleteService {
+
+    private OkHttpClient client;
+
+    @PostConstruct
+    public void init() {
+        client = new OkHttpClient().newBuilder()
+                .connectTimeout(15, TimeUnit.MINUTES)
+                .readTimeout(15, TimeUnit.MINUTES)
+                .writeTimeout(15, TimeUnit.MINUTES)
+                .build();
+
+    }
+    public RequestResult<String> deleteArticle(String token, String msgId, int index) {
+        RequestResult<String> result = new RequestResult<>();
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("msg_id", msgId);
+        jsonBody.put("article_idx", index);
+        try {
+            MediaType mediaType = MediaType.parse("application/json");
+            RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(jsonBody));
+            Request request = new Request.Builder()
+                    .url("https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=" + token)
+                    .method("POST", body)
+                    .addHeader("Content-Type", "application/json")
+                    .addHeader("Authorization", "Bearer sk-5DqYCa88kche6nwIWjLE1p4oMm8nXrR9kQMKbBolNAWERu7q")
+                    .build();
+            Response response = client.newCall(request).execute();
+
+            String responseContent = response.body().string();
+            result.setResponseStr(responseContent);
+            log.info("wx delete api responseContent = {}", responseContent);
+            if (response.isSuccessful()) {
+                JSONObject obj = JSONObject.parseObject(responseContent);
+                if (Objects.nonNull(obj) && obj.containsKey("errcode") && obj.getInteger("errcode") == 0) {
+                    result.setSuccess(true);
+                    result.setResponse(obj.toJSONString());
+                } else {
+                    result.setFailReason("response empty");
+                }
+            } else {
+                JSONObject json = JSONObject.parseObject(responseContent);
+                result.setFailReason("request error code:" + response.code() + " message:" + json.getString("error"));
+            }
+        } catch (Exception e) {
+            log.error("wx delete api error", e);
+            result.setSuccess(false);
+            result.setFailReason("request error" + e.getMessage());
+        }
+        return result;
+    }
+}

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/aigc/PublishAccountRepository.java

@@ -12,4 +12,8 @@ public interface PublishAccountRepository extends JpaRepository<PublishAccount,
     List<PublishAccount> getAllByGhIdIn(List<String> ghIds);
 
     PublishAccount getByGhId(String ghId);
+
+    List<PublishAccount> getByIdIn(List<String> publishAccountIds);
+
+    PublishAccount getById(String publishAccountId);
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java

@@ -36,4 +36,6 @@ public interface ArticleRepository extends JpaRepository<Article, String> {
     int countByGhIdAndTypeAndItemIndex(String ghId, String val, Integer itemIndex);
 
     List<Article> getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(List<String> ghIds, long l, String number);
+
+    List<Article> getByTitleMd5(String titleMd5);
 }

+ 15 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/ArticleUnsafeTitleRepository.java

@@ -0,0 +1,15 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleUnsafeTitle;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface ArticleUnsafeTitleRepository extends JpaRepository<ArticleUnsafeTitle, String> {
+
+    ArticleUnsafeTitle getByTitleMd5(String titleMd5);
+
+    List<ArticleUnsafeTitle> getByStatus(Integer status);
+}

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/GetOffVideoArticleRepository.java

@@ -11,4 +11,5 @@ public interface GetOffVideoArticleRepository extends JpaRepository<GetOffVideoA
 
     List<GetOffVideoArticle> getByPublishTimeBetween(Long startTime, Long endTime);
 
+    List<GetOffVideoArticle> getByPublishTimeGreaterThanEqual(Long publishTime);
 }

+ 14 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleAuditDeleteRepository.java

@@ -0,0 +1,14 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticleAuditDelete;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface LongArticleAuditDeleteRepository extends JpaRepository<LongArticleAuditDelete, Long> {
+    List<LongArticleAuditDelete> getByStatus(Integer status);
+
+    List<LongArticleAuditDelete> getByPublishContentIdIn(List<String> publishContentIds);
+}

+ 17 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleCrawlerVideoRepository.java

@@ -0,0 +1,17 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticleCrawlerVideo;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface LongArticleCrawlerVideoRepository extends JpaRepository<LongArticleCrawlerVideo, Long> {
+
+    List<LongArticleCrawlerVideo> getByTraceIdIn(List<String> traceIds);
+
+    List<LongArticleCrawlerVideo> getByVideoOssPath(String ossPath);
+
+}

+ 14 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleVideoAuditRepository.java

@@ -0,0 +1,14 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticleVideoAudit;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface LongArticleVideoAuditRepository extends JpaRepository<LongArticleVideoAudit, Long> {
+    LongArticleVideoAudit getByVideoId(Long videoId);
+
+    List<LongArticleVideoAudit> getByVideoIdIn(List<Long> videoIds);
+}

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticlesMatchVideoRepository.java

@@ -10,4 +10,6 @@ import java.util.List;
 public interface LongArticlesMatchVideoRepository extends JpaRepository<LongArticlesMatchVideo, Integer> {
 
     List<LongArticlesMatchVideo> getByTraceIdIn(List<String> traceIds);
+
+    LongArticlesMatchVideo getByTraceId(String traceId);
 }

+ 299 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java

@@ -0,0 +1,299 @@
+package com.tzld.longarticle.recommend.server.service.recommend;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.google.common.collect.Lists;
+import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleDeleteStatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.model.dto.*;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
+import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
+import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
+import com.tzld.longarticle.recommend.server.model.param.ArticleVideoAuditResultParam;
+import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
+import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
+import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
+import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.*;
+import com.tzld.longarticle.recommend.server.util.DateUtils;
+import com.tzld.longarticle.recommend.server.util.Md5Util;
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class ArticleAuditService {
+
+    @Autowired
+    private GetOffVideoArticleRepository getOffVideoArticleRepository;
+    @Autowired
+    private LongArticlesMatchVideoRepository longArticlesMatchVideoRepository;
+    @Autowired
+    private LongArticleCrawlerVideoRepository longArticleCrawlerVideoRepository;
+    @Autowired
+    private LongArticleAuditDeleteRepository longArticleAuditDeleteRepository;
+    @Autowired
+    private LongArticleVideoAuditRepository longArticleVideoAuditRepository;
+    @Autowired
+    private WxArticleDeleteService wxArticleDeleteService;
+    @Autowired
+    private WxAccessTokenRemoteService wxAccessTokenRemoteService;
+    @Autowired
+    private AigcBaseMapper aigcBaseMapper;
+    @Autowired
+    private PublishAccountRepository publishAccountRepository;
+    @Autowired
+    private ArticleRepository articleRepository;
+    @Autowired
+    private ArticleUnsafeTitleRepository articleUnsafeTitleRepository;
+
+
+    @XxlJob("articleVideoAudit")
+    public ReturnT<String> articleVideoAudit(String param) {
+        long publishTime = DateUtils.getTodayStart();
+        if (StringUtils.hasText(param)) {
+            publishTime = DateUtils.getStartOfDay(param, "yyyyMMdd");
+        }
+        List<GetOffVideoArticle> getOffVideoArticleList = getOffVideoArticleRepository.getByPublishTimeGreaterThanEqual(publishTime);
+        List<String> traceIds = getOffVideoArticleList.stream().map(GetOffVideoArticle::getTraceId).distinct().collect(Collectors.toList());
+        if (CollectionUtil.isEmpty(traceIds)) {
+            return ReturnT.SUCCESS;
+        }
+        List<LongArticlesMatchVideo> longArticlesMatchVideoList = longArticlesMatchVideoRepository.getByTraceIdIn(traceIds);
+        Map<String, LongArticlesMatchVideo> longarticlesMatchVideoMap = longArticlesMatchVideoList.stream()
+                .collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
+        for (String traceId : traceIds) {
+            LongArticlesMatchVideo longArticlesMatchVideo = longarticlesMatchVideoMap.get(traceId);
+            List<LongArticlesMatchVideoResponse> responseList = JSONArray.parseArray(longArticlesMatchVideo.getResponse()
+                    , LongArticlesMatchVideoResponse.class);
+            List<Long> videoIds = responseList.stream().map(LongArticlesMatchVideoResponse::getVideoID).collect(Collectors.toList());
+            List<LongArticleVideoAudit> existsList = longArticleVideoAuditRepository.getByVideoIdIn(videoIds);
+            List<Long> existsVideoIds = existsList.stream().map(LongArticleVideoAudit::getVideoId).collect(Collectors.toList());
+            for (LongArticlesMatchVideoResponse response : responseList) {
+                if (existsVideoIds.contains(response.getVideoID())) {
+                    continue;
+                }
+                LongArticleVideoAudit videoAudit = new LongArticleVideoAudit();
+                videoAudit.setVideoId(response.getVideoID());
+                videoAudit.setTraceId(traceId);
+                videoAudit.setContentId(longArticlesMatchVideo.getContentId());
+                videoAudit.setOssPath(response.getVideoOSS());
+                videoAudit.setStatus(StatusEnum.ZERO.getCode());
+                videoAudit.setCreateTimestamp(System.currentTimeMillis());
+                longArticleVideoAuditRepository.save(videoAudit);
+                // todo 调用PQ 审核视频
+            }
+        }
+
+        return ReturnT.SUCCESS;
+    }
+
+    /**
+     * 视频审核结果处理
+     */
+    public void articleVideoAuditResult(ArticleVideoAuditResultParam param) {
+        LongArticleVideoAudit longArticleVideoAudit = longArticleVideoAuditRepository.getByVideoId(param.getVideoId());
+        if (param.getResult() == 1) {
+            // 审核通过,更新文章状态
+            longArticleVideoAudit.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
+            longArticleVideoAudit.setFinishTimestamp(System.currentTimeMillis());
+            longArticleVideoAuditRepository.save(longArticleVideoAudit);
+        } else {
+            // 审核不通过,删除文章
+            longArticleVideoAudit.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
+            longArticleVideoAudit.setFailReason(param.getFailReason());
+            longArticleVideoAudit.setFinishTimestamp(System.currentTimeMillis());
+            longArticleVideoAuditRepository.save(longArticleVideoAudit);
+            // 构建删除文章记录 并保存
+            saveDeleteRecord(longArticleVideoAudit.getOssPath());
+        }
+    }
+
+    private void saveDeleteRecord(String ossPath) {
+        List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoRepository.getByVideoOssPath(ossPath);
+        List<String> traceIds = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getTraceId).collect(Collectors.toList());
+        List<PublishContentMiniprogramDTO> publishContentList = aigcBaseMapper.getPublishContentByTraceIdIn(traceIds);
+        List<String> publishContentIds = publishContentList.stream().map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
+        buildArticleAuditDelete(publishContentIds);
+    }
+
+    private void buildArticleAuditDelete(List<String> publishContentIds) {
+        if (CollectionUtils.isEmpty(publishContentIds)) {
+            return;
+        }
+        List<LongArticleAuditDelete> existList = longArticleAuditDeleteRepository.getByPublishContentIdIn(publishContentIds);
+        List<String> existContentIds = existList.stream().map(LongArticleAuditDelete::getPublishContentId).collect(Collectors.toList());
+        publishContentIds = publishContentIds.stream().filter(id -> !existContentIds.contains(id)).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(publishContentIds)) {
+            return;
+        }
+        List<PublishGzhPushContentRelDTO> pushContentRelList = aigcBaseMapper.getPushContentRelByPublishContentIdIn(publishContentIds);
+        if (CollectionUtils.isEmpty(pushContentRelList)) {
+            return;
+        }
+        List<String> pushIds = pushContentRelList.stream().map(PublishGzhPushContentRelDTO::getPushId).collect(Collectors.toList());
+        Map<String, String> publishPushIdMap = pushContentRelList.stream()
+                .collect(Collectors.toMap(PublishGzhPushContentRelDTO::getPublishContentId,
+                        PublishGzhPushContentRelDTO::getPushId,
+                         (o1, o2) -> o2));
+        List<PublishGzhPushDTO> pushList = aigcBaseMapper.getPushByPushIdIn(pushIds);
+        Map<String, PublishGzhPushDTO> pushDTOMap = pushList.stream()
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, Function.identity()));
+        Map<String, String> pushIdMap = pushList.stream().filter(o -> StringUtils.hasText(o.getGroupPushMsgId()))
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, PublishGzhPushDTO::getGroupPushMsgId));
+        List<String> publishAccountIds = pushList.stream().map(PublishGzhPushDTO::getPublishAccountId).collect(Collectors.toList());
+        Map<String, String> pushAccountMap = pushList.stream()
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, PublishGzhPushDTO::getPublishAccountId));
+        List<PublishAccount> publishAccountList = publishAccountRepository.getByIdIn(publishAccountIds);
+        Map<String, String> publishAccountMap = publishAccountList.stream()
+                .collect(Collectors.toMap(PublishAccount::getId, PublishAccount::getGhId));
+        List<PublishGzhPushContentRelDTO> groupPushRelList = aigcBaseMapper.getGroupPushRelByPushIdIn(pushIds);
+        Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
+                .collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
+        // 删除文章
+        for (String publishContentId : publishContentIds) {
+            String pushId = publishPushIdMap.get(publishContentId);
+            if (!StringUtils.hasText(pushId)) {
+                deleteFailAlarm(publishContentId, "无推送记录", 0);
+                continue;
+            }
+            PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
+            if (Objects.isNull(publishGzhPushDTO)) {
+                deleteFailAlarm(publishContentId, "无推送记录", 0);
+                continue;
+            }
+            String publishAccountId = pushAccountMap.get(pushId);
+            String ghId = publishAccountMap.get(publishAccountId);
+            List<PublishGzhPushContentRelDTO> relList = groupPushRelMap.get(pushId).stream()
+                    .sorted(Comparator.comparing(PublishGzhPushContentRelDTO::getId)).collect(Collectors.toList());
+            int index = 1;
+            for (int i = 0; i < relList.size(); i++) {
+                if (relList.get(i).getPublishContentId().equals(publishContentId)) {
+                    index = i + 1;
+                    break;
+                }
+            }
+            if (!publishGzhPushDTO.getPushType().equals(PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
+                PushTypeEnum pushTypeEnum = PushTypeEnum.from(publishGzhPushDTO.getPushType());
+                deleteFailAlarm(publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index);
+                continue;
+            }
+            String groupPushMsgId = pushIdMap.get(pushId);
+            if (!StringUtils.hasText(groupPushMsgId)) {
+                deleteFailAlarm(publishContentId, "无推送MsgId", index);
+                continue;
+            }
+            LongArticleAuditDelete delete = new LongArticleAuditDelete();
+            delete.setGhId(ghId);
+            delete.setMsgId(groupPushMsgId);
+            delete.setPushId(pushId);
+            delete.setPushType(publishGzhPushDTO.getPushType());
+            delete.setPublishContentId(publishContentId);
+            delete.setIndex(index);
+            delete.setStatus(StatusEnum.ZERO.getCode());
+            delete.setCreateTimestamp(System.currentTimeMillis());
+            longArticleAuditDeleteRepository.save(delete);
+        }
+    }
+
+    /**
+     * 删除审核不通过,已发布文章
+     */
+    @XxlJob("articleVideoDelete")
+    public ReturnT<String> articleVideoDelete(String param) {
+        List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(ArticleDeleteStatusEnum.WAITING.getCode());
+        for (LongArticleAuditDelete delete : dealList) {
+            try {
+                if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
+                    // 获取token
+                    String token = wxAccessTokenRemoteService.getAccessToken(delete.getGhId());
+                    // 删除文章
+                    RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
+                    if (result.isSuccess()) {
+                        delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
+                    } else {
+                        delete.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
+                        delete.setFailReason(result.getFailReason());
+                    }
+                } else {
+                    deleteFailAlarm(delete.getPublishContentId(), "非自动群发", delete.getIndex());
+                    delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
+                }
+                delete.setFinishTimestamp(System.currentTimeMillis());
+                longArticleAuditDeleteRepository.save(delete);
+            } catch (Exception e) {
+                log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+
+    private void deleteFailAlarm(String publishContentId, String typeMsg, Integer index) {
+        PublishContentDTO publishContent = aigcBaseMapper.getPublishContentById(publishContentId);
+        PublishAccount publishAccount = publishAccountRepository.getById(publishContent.getPublishAccountId());
+        String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
+        // 无法自动删除 发送飞书通知 人工删除
+        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
+                "【文章删除失败】\n"
+                        + "账号名称: " + publishAccount.getName() + "\n"
+                        + "账号ghId: " + publishAccount.getGhId() + "\n"
+                        + "发布日期: " + publishTime + "\n"
+                        + "位置: " + index + "\n"
+                        + "标题: " + publishContent.getTitle() + "\n"
+                        + "原因: " + typeMsg);
+    }
+
+    public void titleDangerFindDelete(ArticleDangerFindDeleteParam param) {
+        String titleMd5 = Md5Util.encoderByMd5(param.getTitle());
+        // 根据标题查找已发布文章
+        List<Article> articleList = articleRepository.getByTitleMd5(titleMd5);
+        List<String> ghIds = articleList.stream().map(Article::getGhId).distinct().collect(Collectors.toList());
+        List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
+        List<PublishContentParam> publishContentParamList = publishAccountList.stream().map(account -> {
+            PublishContentParam item = new PublishContentParam();
+            item.setTitle(param.getTitle());
+            item.setPublishAccountId(account.getId());
+            return item;
+        }).collect(Collectors.toList());
+        List<PublishContentDTO> publishContents = new ArrayList<>();
+        for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
+            publishContents.addAll(aigcBaseMapper.getPublishContentByTitle(partitions));
+        }
+        if (CollectionUtils.isEmpty(publishContents)) {
+            return;
+        }
+        // 查找该生成内容下所有已发布内容
+        List<String> sourceIds = publishContents.stream().map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
+        publishContents = aigcBaseMapper.getPublishContentBySourceIdIn(sourceIds);
+
+        // 根据已发布文章查找推送id 并删除
+        List<String> publishContentIds = publishContents.stream().map(PublishContentDTO::getId).collect(Collectors.toList());
+        buildArticleAuditDelete(publishContentIds);
+        buildArticleUnsafeTitle(titleMd5, param.getTitle());
+    }
+
+    private void buildArticleUnsafeTitle(String titleMd5, String title) {
+        ArticleUnsafeTitle unsafeTitle = new ArticleUnsafeTitle();
+        unsafeTitle.setTitle(title);
+        unsafeTitle.setTitleMd5(titleMd5);
+        unsafeTitle.setStatus(StatusEnum.ONE.getCode());
+        unsafeTitle.setCreateTimestamp(System.currentTimeMillis());
+        articleUnsafeTitleRepository.save(unsafeTitle);
+    }
+
+}

+ 51 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/PublishContentFilterService.java

@@ -0,0 +1,51 @@
+package com.tzld.longarticle.recommend.server.service.recommend;
+
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
+import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
+import com.tzld.longarticle.recommend.server.model.param.PublishContentFilterContentItem;
+import com.tzld.longarticle.recommend.server.model.param.PublishContentFilterParam;
+import com.tzld.longarticle.recommend.server.model.vo.PublishContentFilterResultVO;
+import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+@Service
+@Slf4j
+public class PublishContentFilterService {
+
+    @Autowired
+    private LongArticleBaseMapper longArticleBaseMapper;
+
+    public List<PublishContentFilterResultVO> publishContentFilter(PublishContentFilterParam param) {
+        List<PublishContentFilterResultVO> result = new ArrayList<>();
+        if (CollectionUtils.isEmpty(param.getContentList())) {
+            return result;
+        }
+        List<String> filterTitleList = longArticleBaseMapper.getFilterColdLongArticleTitle();
+        List<Set<Character>> firstSecondTitleCache = TitleSimilarCheckUtil.makeCache(filterTitleList);
+        for (PublishContentFilterContentItem contentItem : param.getContentList()) {
+            if (!StringUtils.hasText(contentItem.getTitle())) {
+                continue;
+            }
+            boolean isDuplicate = false;
+            if (ContentPoolEnum.autoArticlePoolLevel4.getContentPool().equals(contentItem.getPoolLevel())) {
+                isDuplicate = TitleSimilarCheckUtil.isDuplicateContentByCache(contentItem.getTitle(),
+                        firstSecondTitleCache, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD);
+            }
+            if (isDuplicate) {
+                PublishContentFilterResultVO vo = new PublishContentFilterResultVO();
+                vo.setSourceId(contentItem.getSourceId());
+                vo.setFilterReason("退场机制过滤");
+                result.add(vo);
+            }
+        }
+        return result;
+    }
+}

+ 18 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/filter/strategy/SensitiveStrategy.java

@@ -1,26 +1,27 @@
 package com.tzld.longarticle.recommend.server.service.recommend.filter.strategy;
 
-import cn.hutool.core.collection.CollectionUtil;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
+import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleSensitive;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleUnsafeTitle;
 import com.tzld.longarticle.recommend.server.remote.ArticleSensitiveRemoteService;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleSensitiveRepository;
-import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleSensitive;
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleUnsafeTitleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterParam;
 import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterResult;
 import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterStrategy;
-import com.tzld.longarticle.recommend.server.util.Md5Util;
 import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
-import java.util.concurrent.CountDownLatch;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.stream.Collectors;
 
 @Component
 @Slf4j
@@ -30,6 +31,8 @@ public class SensitiveStrategy implements FilterStrategy {
     private ArticleSensitiveRemoteService articleSensitiveRemoteService;
     @Autowired
     private ArticleSensitiveRepository articleSensitiveRepository;
+    @Autowired
+    private ArticleUnsafeTitleRepository articleUnsafeTitleRepository;
 
     @ApolloJsonValue("${UnSafeTitles:[]}")
     private static List<String> UnSafeTitles;
@@ -54,8 +57,14 @@ public class SensitiveStrategy implements FilterStrategy {
 //        if (CollectionUtil.isNotEmpty(articleSensitiveList)) {
 //            articleSensitiveMap = articleSensitiveList.stream().collect(Collectors.toMap(ArticleSensitive::getMd5, o -> o));
 //        }
-
-        List<Set<Character>> unsafeTitleCache = TitleSimilarCheckUtil.makeCache(UnSafeTitles);
+        List<String> allUnSafeTitles = UnSafeTitles;
+        List<ArticleUnsafeTitle> articleUnsafeTitleList = articleUnsafeTitleRepository.getByStatus(StatusEnum.ONE.getCode());
+        if (CollectionUtils.isNotEmpty(articleUnsafeTitleList)) {
+            for (ArticleUnsafeTitle articleUnsafeTitle : articleUnsafeTitleList) {
+                allUnSafeTitles.add(articleUnsafeTitle.getTitle());
+            }
+        }
+        List<Set<Character>> unsafeTitleCache = TitleSimilarCheckUtil.makeCache(allUnSafeTitles);
         for (Content content : param.getContents()) {
             try {
                 if (TitleSimilarCheckUtil.isDuplicateContentByCache(content.getTitle(), unsafeTitleCache,

+ 49 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java

@@ -8,10 +8,15 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategy
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.strategy.FwhColdStartRankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 import static com.tzld.longarticle.recommend.server.common.constant.SceneConstants.FWH_COLD_START;
 
@@ -39,7 +44,7 @@ public class RankService {
 
     }
 
-    public static void printSortLog(String strategy, String accountName, List<Content> contentList) {
+    public static void printSortLog(String strategy, String accountName, String position, List<Content> contentList) {
         JSONArray jsonArray = new JSONArray();
         if (CollectionUtil.isEmpty(contentList)) {
             return;
@@ -52,6 +57,48 @@ public class RankService {
             obj.put("scoreMap", content.getScoreMap());
             jsonArray.add(obj);
         }
-        log.info("{} 账号名称 {} 头条评分结果 {}", strategy, accountName, JSONObject.toJSONString(jsonArray));
+        log.info("{} 账号名称 {} {}评分结果 {}", strategy, accountName, position, JSONObject.toJSONString(jsonArray));
+    }
+
+    public static void commonAddSecondContent(List<Content> result,
+                                              String[] publishPool, String[] contentPools,
+                                              Map<String, List<Content>> contentMap,
+                                              Map<Integer, AccountIndexReplacePoolConfig> indexReplacePoolConfigMap) {
+        List<Content> pool = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            int i = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
+            int j = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
+            result.add(pool.get(i));
+            // 替补 头条内容不足使用次条内容
+            if (result.size() == 1 && pool.size() > 1) {
+                while (i == j && pool.size() > 1) {
+                    j = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
+                    if (i != j) {
+                        publishPool[0] = contentPools[1];
+                        result.add(pool.get(1));
+                        break;
+                    }
+                }
+            }
+        } else {
+            // 替补 根据设置替补内容池查找内容进行替补
+            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
+            if (Objects.nonNull(replacePoolConfig)) {
+                List<Content> poolReplace = contentMap.get(replacePoolConfig.getContentPool());
+                if (CollectionUtils.isNotEmpty(poolReplace)) {
+                    publishPool[1] = replacePoolConfig.getContentPool();
+                    result.add(poolReplace.get(0));
+                }
+            }
+        }
+    }
+
+    public static void commonAdd38Content(RankParam param, List<Content> result, String[] contentPools,
+                                          Map<String, List<Content>> contentMap, String strategy) {
+        List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
+            RankService.printSortLog(strategy, param.getAccountName(), "3-8", pool.subList(0, Math.min(pool.size(), 200)));
+            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
+        }
     }
 }

+ 11 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java

@@ -51,6 +51,9 @@ public class HisJumpRankStrategy implements RankStrategy {
             if (contentPools[0].equals(item.getContent().getContentPoolType())
                     || contentPools[1].equals(item.getContent().getContentPoolType())) {
                 score = item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
+                        ScoreStrategyEnum.CATEGORY.value())
                         + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
                 if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
                     score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
@@ -59,6 +62,9 @@ public class HisJumpRankStrategy implements RankStrategy {
                 }
             } else {
                 score = item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
+                        ScoreStrategyEnum.CATEGORY.value())
                         + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
                         + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
                         + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
@@ -84,7 +90,7 @@ public class HisJumpRankStrategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.HIS_JUMP_STRATEGY.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.HIS_JUMP_STRATEGY.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             int i = RandomUtils.nextInt(0, Math.min(pool1.size(), 20));
             result.add(pool1.get(i));
@@ -113,7 +119,10 @@ public class HisJumpRankStrategy implements RankStrategy {
         // 3-8
         List<Content> pool = contentMap.get(contentPools[2]);
         if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
+            int slotNum = param.getSize() - result.size();
+            List<Content> subPool = pool.subList(0, Math.min(pool.size(), 30));
+            Collections.shuffle(subPool);
+            result.addAll(subPool.subList(0, Math.min(subPool.size(), slotNum)));
         }
 
         RankStrategy.deduplication(result, contentMap, publishPool);

+ 4 - 36
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java

@@ -1,23 +1,20 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -112,39 +109,10 @@ public class RankV10Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV10.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java

@@ -15,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -122,7 +121,7 @@ public class RankV11Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV11.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV11.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -130,39 +129,10 @@ public class RankV11Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV11.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java

@@ -15,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -122,7 +121,7 @@ public class RankV12Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV12.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV12.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -130,39 +129,10 @@ public class RankV12Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV12.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java

@@ -15,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -123,7 +122,7 @@ public class RankV13Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV13.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV13.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -131,39 +130,10 @@ public class RankV13Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV13.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java

@@ -15,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -123,7 +122,7 @@ public class RankV14Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV14.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV14.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -131,39 +130,10 @@ public class RankV14Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV14.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 8
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java

@@ -1,15 +1,13 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
@@ -119,10 +117,7 @@ public class RankV3Strategy implements RankStrategy {
         }
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV3.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 4 - 36
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java

@@ -1,22 +1,19 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -102,39 +99,10 @@ public class RankV4Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV4.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java

@@ -16,7 +16,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -111,7 +110,7 @@ public class RankV5Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV5.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV5.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -119,39 +118,10 @@ public class RankV5Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV5.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 4 - 36
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java

@@ -1,22 +1,19 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -104,39 +101,10 @@ public class RankV7Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV7.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 3 - 33
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java

@@ -15,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreServic
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -106,7 +105,7 @@ public class RankV8Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV8.getStrategy(), param.getAccountName(), pool1);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV8.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -114,39 +113,10 @@ public class RankV8Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV8.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 4 - 36
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java

@@ -1,22 +1,19 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -104,39 +101,10 @@ public class RankV9Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        List<Content> pool2 = contentMap.get(contentPools[1]);
-        if (CollectionUtils.isNotEmpty(pool2)) {
-            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-            result.add(pool2.get(i));
-            // 替补 头条内容不足使用次条内容
-            if (result.size() == 1 && pool2.size() > 1) {
-                while (i == j && pool2.size() > 1) {
-                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
-                    if (i != j) {
-                        publishPool[0] = contentPools[1];
-                        result.add(pool2.get(1));
-                        break;
-                    }
-                }
-            }
-        } else {
-            // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
-        }
+        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV9.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/CrawlerDaysDecreaseStrategy.java

@@ -47,9 +47,9 @@ public class CrawlerDaysDecreaseStrategy implements ScoreStrategy {
     }
 
     private Double getContentScore(Content content, long now) {
-        double maxReleaseScore = -0.15;
+        double maxReleaseScore = -0.3;
         double minScoreDays = 7;
-        double maxScoreDays = 60.0;
+        double maxScoreDays = 120.0;
         long timestamp = Optional.ofNullable(content.getRootPublishTimestamp()).orElse(content.getCrawlerTimestamp());
         int days = (int) ((now - timestamp) / 86400000);
         if (days < minScoreDays) {

+ 41 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/ArticleAuditController.java

@@ -0,0 +1,41 @@
+package com.tzld.longarticle.recommend.server.web.recommend;
+
+import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
+import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
+import com.tzld.longarticle.recommend.server.model.param.ArticleVideoAuditResultParam;
+import com.tzld.longarticle.recommend.server.service.recommend.ArticleAuditService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/articleAudit")
+@Slf4j
+public class ArticleAuditController {
+
+    @Autowired
+    private ArticleAuditService service;
+
+
+    @GetMapping("/articleVideoAudit")
+    public void articleVideoAudit(String dateStr) {
+        service.articleVideoAudit(dateStr);
+    }
+
+    @PostMapping("/articleVideoAuditResult")
+    public CommonResponse<Void> articleVideoAuditResult(@RequestBody ArticleVideoAuditResultParam param) {
+        service.articleVideoAuditResult(param);
+        return CommonResponse.success();
+    }
+
+    @PostMapping("/titleDangerFindDelete")
+    public CommonResponse<Void> titleDangerFindDelete(@RequestBody ArticleDangerFindDeleteParam param) {
+        service.titleDangerFindDelete(param);
+        return CommonResponse.success();
+    }
+
+    @GetMapping("/articleVideoDelete")
+    public void articleVideoDelete() {
+        service.articleVideoDelete(null);
+    }
+}

+ 28 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/PublishContentFilterController.java

@@ -0,0 +1,28 @@
+package com.tzld.longarticle.recommend.server.web.recommend;
+
+import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
+import com.tzld.longarticle.recommend.server.model.param.PublishContentFilterParam;
+import com.tzld.longarticle.recommend.server.model.vo.PublishContentFilterResultVO;
+import com.tzld.longarticle.recommend.server.service.recommend.PublishContentFilterService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/filter")
+@Slf4j
+public class PublishContentFilterController {
+
+    @Autowired
+    private PublishContentFilterService service;
+
+    @PostMapping("/publishContent")
+    public CommonResponse<List<PublishContentFilterResultVO>> publishContentFilter(@RequestBody PublishContentFilterParam param) {
+        return CommonResponse.success(service.publishContentFilter(param));
+    }
+}

+ 56 - 6
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -9,7 +9,8 @@
 
     <select id="getPublishContentByTitle"
             resultType="com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO">
-        select content.*, output.output as title
+        select content.id, content.plan_id, content.source_type, content.source_id, content.crawler_channel_content_id,
+               content.publish_account_id, content.publish_timestamp, output.output as title
         from publish_content content
         join publish_content_output output
           on content.id = output.publish_content_id and output.content_type = 3 AND output.select_status = 1
@@ -20,11 +21,6 @@
         </foreach>
     </select>
 
-    <select id="getPublishPlanById"
-            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.PublishPlan">
-        select * from publish_plan where id = #{planId}
-    </select>
-
     <select id="getMiniProgramTask"
             resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.PublishPlanMiniprogramTask">
         select * from publish_plan_miniprogram_task where
@@ -220,5 +216,59 @@
         where pp.plan_status = 1 and pp.channel = 5 and pp.content_modal = 3 and ppa.publish_open_flag = 0
     </select>
 
+    <select id="getPublishContentByTraceIdIn"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishContentMiniprogramDTO">
+        select * from publish_content_miniprogram where trace_id in
+        <foreach collection="traceIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getPushContentRelByPublishContentIdIn"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishGzhPushContentRelDTO">
+        select pgpcr.*
+        from publish_gzh_push_content_rel pgpcr
+        join publish_gzh_push pgp on pgpcr.push_id = pgp.push_id
+        where pgpcr.publish_content_id in
+        <foreach collection="publishContentIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getPushByPushIdIn"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishGzhPushDTO">
+        select * from publish_gzh_push where push_id in
+        <foreach collection="pushIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getGroupPushRelByPushIdIn"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishGzhPushContentRelDTO">
+        select * from publish_gzh_push_content_rel where push_id in
+        <foreach collection="pushIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        order by id
+    </select>
+
+    <select id="getPublishContentById"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO">
+        select content.id, content.publish_timestamp, content.publish_account_id, output.output as title
+        from publish_content content
+         join publish_content_output output
+          on content.id = output.publish_content_id and output.content_type = 3 AND output.select_status = 1
+        where content.id = #{publishContentId}
+    </select>
+
+    <select id="getPublishContentBySourceIdIn"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO">
+        select id, plan_id, source_type, source_id, crawler_channel_content_id, publish_account_id, publish_timestamp
+        from publish_content
+        where status = 2 and source_id in
+        <foreach collection="sourceIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
 
 </mapper>

+ 4 - 0
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -239,4 +239,8 @@
         </if>
     </select>
 
+    <select id="getFilterColdLongArticleTitle" resultType="java.lang.String">
+        select title from cold_start_title_pool where status in (-1, 1)
+    </select>
+
 </mapper>