Browse Source

排序增加排序请求id

wangyunpeng 3 months ago
parent
commit
19bd05139f

+ 1 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/ArticleSortResponseData.java

@@ -12,6 +12,7 @@ import java.util.List;
 @Accessors(chain = true)
 @ToString
 public class ArticleSortResponseData {
+    private String requestId;
     private List<PublishArticleData> rank_list;
     private List<PublishArticleData> filter_list;
 }

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/vo/CreatePushTaskParam.java

@@ -19,5 +19,7 @@ public class CreatePushTaskParam {
     private Integer pushType;
     //"计划推送时间戳")
     private Long pushScheduleTimestamp;
+    // 排序请求ID
+    private String sortRequestId;
     private List<PushContentParam> pushContentList;
 }

+ 4 - 4
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/ContentServiceImpl.java

@@ -160,7 +160,7 @@ public class ContentServiceImpl implements ContentService {
         return waitSortList;
     }
 
-    public List<PublishArticleData> getSortList(PlanAccount planAccount) {
+    public ArticleSortResponseData getSortList(PlanAccount planAccount) {
         ArticleSortRequest articleSortRequest = new ArticleSortRequest();
         articleSortRequest.setAccountId(planAccount.getAccountId());
         articleSortRequest.setAccountName(planAccount.getAccountName());
@@ -183,7 +183,7 @@ public class ContentServiceImpl implements ContentService {
             String message = String.format("排序结果为空 planId=%s accountName=%s", planAccount.getPlanId(), planAccount.getAccountName());
             LarkRobotUtil.sendMessage(message);
 
-            return new ArrayList<>();
+            return null;
         }
         ArticleSortResponseData data = articleSortResponse.getData();
         if (!CollectionUtils.isEmpty(data.getFilter_list())) {
@@ -204,9 +204,9 @@ public class ContentServiceImpl implements ContentService {
             String message = String.format("排序结果不足 planId=%s accountName=%s num=%s",
                     planAccount.getPlanId(), planAccount.getAccountName(), articleSortResponse.getData().getRank_list().size());
             LarkRobotUtil.sendMessage(message);
-            return new ArrayList<>();
+            return null;
         }
-        return data.getRank_list();
+        return data;
     }
 
     public List<VideoDetail> getPublishVideoDetail(PublishContent publishContent, PlanAccount planAccount, MatchVideo matchVideo) {

+ 11 - 3
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -11,6 +11,7 @@ import com.tzld.piaoquan.longarticle.dao.mapper.PublishMiniprogramMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.RootSourceMapper;
 import com.tzld.piaoquan.longarticle.model.bo.MatchContent;
 import com.tzld.piaoquan.longarticle.model.bo.VideoDetail;
+import com.tzld.piaoquan.longarticle.model.dto.ArticleSortResponseData;
 import com.tzld.piaoquan.longarticle.model.dto.MiniprogramCardRequest;
 import com.tzld.piaoquan.longarticle.model.dto.PublishArticleData;
 import com.tzld.piaoquan.longarticle.model.po.*;
@@ -471,11 +472,17 @@ public class CoreServiceImpl implements CoreService {
         }
         //获取待排序数据  数量不足会返回空list
         List<PublishArticleData> rankList = contentService.getWaitingSort(planAccount);
+        String sortRequestId = null;
         if (CollectionUtils.isEmpty(rankList)) {
             return;
         }
         if (StringUtils.isNotEmpty(planAccount.getSortStrategy())) {
-            rankList = contentService.getSortList(planAccount);
+            ArticleSortResponseData responseData = contentService.getSortList(planAccount);
+            if (Objects.isNull(responseData)) {
+                return;
+            }
+            rankList = responseData.getRank_list();
+            sortRequestId = responseData.getRequestId();
             if (CollectionUtils.isEmpty(rankList)) {
                 return;
             }
@@ -521,7 +528,7 @@ public class CoreServiceImpl implements CoreService {
             contentParam.setMiniprogramCardList(publishCardList);
             pushContentList.add(contentParam);
         }
-        CreatePushTaskParam gzhPushParam = getCreatePushTaskParam(planAccount, pushContentList);
+        CreatePushTaskParam gzhPushParam = getCreatePushTaskParam(planAccount, pushContentList, sortRequestId);
         if (gzhPushParam == null) {
             return;
         }
@@ -556,12 +563,13 @@ public class CoreServiceImpl implements CoreService {
         return publishMiniprogramList;
     }
 
-    private CreatePushTaskParam getCreatePushTaskParam(PlanAccount planAccount, List<PushContentParam> pushContentList) {
+    private CreatePushTaskParam getCreatePushTaskParam(PlanAccount planAccount, List<PushContentParam> pushContentList, String sortRequestId) {
         CreatePushTaskParam gzhPushParam = new CreatePushTaskParam();
         gzhPushParam.setPlanId(planAccount.getPlanId());
         gzhPushParam.setAccountId(planAccount.getAccountId());
         gzhPushParam.setPushType(planAccount.getPushType());
         gzhPushParam.setPushScheduleTimestamp(System.currentTimeMillis());
+        gzhPushParam.setSortRequestId(sortRequestId);
         if (StringUtils.isNotEmpty(planAccount.getPublishPushTime())) {
             String dateTimeStr = TimeZoneUtil.todayYMD(TimeZoneUtil.Timezone.china) + " " + planAccount.getPublishPushTime();
             gzhPushParam.setPushScheduleTimestamp(TimeZoneUtil.getDateStrTimestamp(dateTimeStr, "yyyy-MM-dd HH:mm:ss", TimeZoneUtil.Timezone.china));