Selaa lähdekoodia

长文托管分组群发配置

wangyunpeng 14 tuntia sitten
vanhempi
commit
f25de27294

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

@@ -14,6 +14,8 @@ public class LongArticleSystemPlanAccount {
     private String name;
     //"公众号ID")
     private String ghId;
+    //"公众号appID")
+    private String appId;
     // 发布开关(0-关闭,1-打开)
     private Integer publishOpenFlag;
 }

+ 2 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/PlanAccountService.java

@@ -2,6 +2,7 @@ package com.tzld.piaoquan.longarticle.service.local;
 
 import com.tzld.piaoquan.longarticle.model.po.longarticle.Plan;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanAccount;
+import com.tzld.piaoquan.longarticle.model.vo.LongArticleSystemPlanAccount;
 
 import java.util.List;
 
@@ -11,7 +12,7 @@ public interface PlanAccountService {
 
     void updatePlanAccount(PlanAccount planAccount);
 
-    void saveOrUpdatePlanAccount(PlanAccount planAccount);
+    void saveOrUpdatePlanAccount(PlanAccount planAccount, LongArticleSystemPlanAccount account);
 
     void saveOrUpdatePlan(Plan plan);
 

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

@@ -215,7 +215,8 @@ public class ContentServiceImpl implements ContentService {
 //            articleSortRequest.setExcludeLog(true);
         articleSortRequest.setStrategy(planAccount.getSortStrategy());
         articleSortRequest.setPublishNum(planAccount.getPublishPreNum());
-        if (Objects.equals(PublishGzhPushTypeEnum.auto_group_publish.getVal(), planAccount.getPushType())) {
+        if (Objects.equals(PublishGzhPushTypeEnum.auto_group_publish.getVal(), planAccount.getPushType())
+                || Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal())) {
             articleSortRequest.setPublishNum(planAccount.getPublishNum());
         }
         articleSortRequest.setPlanId(planAccount.getPlanId());

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

@@ -25,7 +25,6 @@ import com.tzld.piaoquan.longarticle.service.local.PlanAccountService;
 import com.tzld.piaoquan.longarticle.service.remote.AigcService;
 import com.tzld.piaoquan.longarticle.service.remote.MatchService;
 import com.tzld.piaoquan.longarticle.service.remote.VideoService;
-import com.tzld.piaoquan.longarticle.service.remote.impl.SortServiceImpl;
 import com.tzld.piaoquan.longarticle.utils.DateUtil;
 import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
 import com.tzld.piaoquan.longarticle.utils.TimeZoneUtil;
@@ -102,6 +101,7 @@ public class CoreServiceImpl implements CoreService {
     @ApolloJsonValue("${fwhGhIdList:[]}")
     private List<String> fwhGhIdList;
 
+
     public void initAccountSpecialSettings() {
         List<SpecialSettingVO> specialSettings = aigcService.getSpecialSetting();
         if (CollectionUtils.isEmpty(specialSettings)) {
@@ -234,7 +234,7 @@ public class CoreServiceImpl implements CoreService {
                 if (!CollectionUtils.isEmpty(specialAccountIds) && specialAccountIds.contains(planAccount.getAccountId())) {
                     planAccount.setSpecialNotSend(SpecialNotSendEnum.NOT_SEND.getStatusCode());
                 }
-                planAccountService.saveOrUpdatePlanAccount(planAccount);
+                planAccountService.saveOrUpdatePlanAccount(planAccount, account);
             }
             if (CollectionUtils.isEmpty(accountIdSet)) {
                 continue;
@@ -269,7 +269,7 @@ public class CoreServiceImpl implements CoreService {
             }
             for (PlanAccount planAccount : planAccountList) {
                 planAccount.setSpecialNotSend(SpecialNotSendEnum.NOT_SEND.getStatusCode());
-                planAccountService.saveOrUpdatePlanAccount(planAccount);
+                planAccountService.saveOrUpdatePlanAccount(planAccount, null);
             }
         }
 
@@ -503,7 +503,8 @@ public class CoreServiceImpl implements CoreService {
 
     public boolean checkPlanAccount(PlanAccount planAccount) {
         boolean isGzhGroupPushPlan = Objects.nonNull(planAccount.getPushType())
-                && PublishGzhPushTypeEnum.auto_group_publish.getVal().equals(planAccount.getPushType());
+                && (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.auto_group_publish.getVal())
+                || Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal()));
         boolean flag = true;
         // 固定日期
         if (planAccount.getPublishRate() == 1) {
@@ -742,7 +743,8 @@ public class CoreServiceImpl implements CoreService {
             pushContentList.add(contentParam);
         }
 
-        if (fwhGhIdList != null && fwhGhIdList.contains(planAccount.getGhId())) {
+        if (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal())
+                || (fwhGhIdList != null && fwhGhIdList.contains(planAccount.getGhId()))) {
             pushBatchGroupPushTask(planAccount, pushContentList, sendIds);
         } else {
             CreatePushTaskParam gzhPushParam = getCreatePushTaskParam(planAccount, pushContentList);
@@ -799,7 +801,8 @@ public class CoreServiceImpl implements CoreService {
             return null;
         }
         //自动群发少于最少数量不发送  例外设置数量少于最少发送数量不发送
-        if (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.auto_group_publish.getVal())
+        if ((Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.auto_group_publish.getVal())
+                || Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal()))
                 || planAccount.getIsSpecialSetting() == 1) {
             if (pushContentList.size() < planAccount.getPublishPreMinNum()) {
                 return null;
@@ -826,7 +829,8 @@ public class CoreServiceImpl implements CoreService {
             return;
         }
         //自动群发少于最少数量不发送  例外设置数量少于最少发送数量不发送
-        if (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.auto_group_publish.getVal())
+        if ((Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.auto_group_publish.getVal())
+                || Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal()))
                 || planAccount.getIsSpecialSetting() == 1) {
             if (pushContentList.size() < planAccount.getPublishPreMinNum()) {
                 return;
@@ -1023,7 +1027,8 @@ public class CoreServiceImpl implements CoreService {
                         Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal())) {
                     planAccountService.updateStatus(2, planAccountId);
                 }
-                if (fwhGhIdList != null && fwhGhIdList.contains(planAccount.getGhId())) {
+                if (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.batch_group_publish.getVal())
+                        || (fwhGhIdList != null && fwhGhIdList.contains(planAccount.getGhId()))) {
                     GroupSendResultExample groupSendResultExample = new GroupSendResultExample();
                     groupSendResultExample.createCriteria().andPushIdEqualTo(pushId);
                     List<GroupSendResult> groupSendResults = groupSendResultMapper.selectByExample(groupSendResultExample);

+ 10 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/PlanAccountServiceImpl.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.longarticle.service.local.impl;
 
+import com.tzld.piaoquan.longarticle.common.enums.PublishGzhPushTypeEnum;
 import com.tzld.piaoquan.longarticle.common.enums.SpecialNotSendEnum;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.PlanAccountMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.PlanMapper;
@@ -7,7 +8,9 @@ import com.tzld.piaoquan.longarticle.model.po.longarticle.Plan;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanAccount;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanAccountExample;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanExample;
+import com.tzld.piaoquan.longarticle.model.vo.LongArticleSystemPlanAccount;
 import com.tzld.piaoquan.longarticle.service.local.PlanAccountService;
+import com.tzld.piaoquan.longarticle.service.remote.SortService;
 import com.tzld.piaoquan.longarticle.utils.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,6 +28,9 @@ public class PlanAccountServiceImpl implements PlanAccountService {
     @Autowired
     private PlanMapper planMapper;
 
+    @Autowired
+    private SortService sortService;
+
     public void addPlanAccount(PlanAccount planAccount) {
         planAccountMapper.insertSelective(planAccount);
     }
@@ -33,7 +39,7 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         planAccountMapper.updateByPrimaryKeySelective(planAccount);
     }
 
-    public void saveOrUpdatePlanAccount(PlanAccount planAccount) {
+    public void saveOrUpdatePlanAccount(PlanAccount planAccount, LongArticleSystemPlanAccount account) {
         PlanAccountExample example = new PlanAccountExample();
         example.createCriteria().andAccountIdEqualTo(planAccount.getAccountId())
                 .andPlanIdEqualTo(planAccount.getPlanId())
@@ -41,6 +47,9 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(planAccounts)) {
             planAccountMapper.insertSelective(planAccount);
+            if (PublishGzhPushTypeEnum.batch_group_publish.getVal().equals(planAccount.getPushType())) {
+                new Thread(() -> sortService.addBatchGroupGZH(account.getGhId(), account.getAppId())).start();
+            }
         } else {
             planAccount.setId(planAccounts.get(0).getId());
             planAccount.setIsDelete(0);

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/SortService.java

@@ -6,4 +6,6 @@ import com.tzld.piaoquan.longarticle.model.dto.ArticleSortResponse;
 public interface SortService {
 
     ArticleSortResponse publishArticleSort(ArticleSortRequest request);
+
+    void addBatchGroupGZH(String ghId, String appId);
 }

+ 15 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/SortServiceImpl.java

@@ -39,4 +39,19 @@ public class SortServiceImpl implements SortService {
         return response;
     }
 
+    @Override
+    public void addBatchGroupGZH(String ghId, String appId) {
+        String apiUrl = "http://101.37.174.139:80/user/addGZH";
+        long startTime = System.currentTimeMillis();
+        try {
+            apiUrl += "?gzhId=" + ghId + "&appId=" + appId + "&groupNum=8";
+            String res = HTTP_POOL_CLIENT_UTIL_DEFAULT.get(apiUrl);
+            log.info("addBatchGroupGZH ghId={} appId={} res={}", ghId, appId, res);
+        } catch (Exception e) {
+            log.error("addBatchGroupGZH error", e);
+        }
+        long endTime = System.currentTimeMillis();
+        log.info("addBatchGroupGZH request={} needTime={}", apiUrl, endTime - startTime);
+    }
+
 }