Przeglądaj źródła

增加定时任务更新次数

xueyiming 1 miesiąc temu
rodzic
commit
b69369479c

+ 22 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/job/PlanAccountJob.java

@@ -1,7 +1,11 @@
 package com.tzld.piaoquan.longarticle.job;
 
+import com.tzld.piaoquan.longarticle.dao.mapper.crawler.ArticleUseGroupMapper;
+import com.tzld.piaoquan.longarticle.model.po.crawler.ArticleUseGroup;
+import com.tzld.piaoquan.longarticle.model.po.crawler.ArticleUseGroupExample;
 import com.tzld.piaoquan.longarticle.service.local.CoreService;
 import com.tzld.piaoquan.longarticle.service.local.CoverService;
+import com.tzld.piaoquan.longarticle.utils.DateUtil;
 import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -21,7 +25,7 @@ public class PlanAccountJob {
     private CoverService coverService;
 
     @Autowired
-    private RedisTemplate<String, Object> redisTemplate;
+    private ArticleUseGroupMapper articleUseGroupMapper;
 
     @XxlJob("initAccountSpecialSettingsJob")
     public ReturnT<String> initAccountSpecialSettings(String param) {
@@ -89,4 +93,21 @@ public class PlanAccountJob {
         }
         return ReturnT.SUCCESS;
     }
+
+    @XxlJob("updateRemainingCountJob")
+    public ReturnT<String> updateRemainingCount(String param) {
+        try {
+            int dayOfMonth = DateUtil.getDayOfMonth();
+            if (dayOfMonth == 1) {
+                ArticleUseGroup articleUseGroup = new ArticleUseGroup();
+                articleUseGroup.setRemainingCount(4);
+                ArticleUseGroupExample example = new ArticleUseGroupExample();
+                example.createCriteria().andIdGreaterThan(0L);
+                articleUseGroupMapper.updateByExampleSelective(articleUseGroup, example);
+            }
+        } catch (Exception e) {
+            log.error("updateRemainingCount error", e);
+        }
+        return ReturnT.SUCCESS;
+    }
 }

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

@@ -828,20 +828,20 @@ public class CoreServiceImpl implements CoreService {
             remainingCount = articleUseGroupMapper.selectRemainingCountByGzhId(planAccount.getGhId(), null);
         }
         if (remainingDaysInCurrentMonth > 0 && remainingCount != null && remainingCount / remainingDaysInCurrentMonth > 0) {
-            Integer count = articleUseGroupMapper.selectFansBeforePublishCount(planAccount.getGhId());
-            FwhDailyPublishDetail fwhDailyPublishDetail = new FwhDailyPublishDetail();
-            fwhDailyPublishDetail.setAccountName(planAccount.getAccountName());
-            fwhDailyPublishDetail.setGhId(planAccount.getGhId());
-            fwhDailyPublishDetail.setPublishDate(DateUtil.getThatDayDateString());
-            fwhDailyPublishDetail.setFansBeforePublish(count);
-            fwhDailyPublishDetail.setPublishTimesBeforePublish(remainingCount);
-            fwhDailyPublishDetailMapper.insertSelective(fwhDailyPublishDetail);
             List<String> needSendOpenIds = articleUseGroupMapper.selectOpenIds(planAccount.getGhId(), remainingCount / remainingDaysInCurrentMonth);
             sendOpenIds.addAll(needSendOpenIds);
         }
         if (CollectionUtils.isEmpty(sendOpenIds)) {
             return;
         }
+        Integer count = articleUseGroupMapper.selectFansBeforePublishCount(planAccount.getGhId());
+        FwhDailyPublishDetail fwhDailyPublishDetail = new FwhDailyPublishDetail();
+        fwhDailyPublishDetail.setAccountName(planAccount.getAccountName());
+        fwhDailyPublishDetail.setGhId(planAccount.getGhId());
+        fwhDailyPublishDetail.setPublishDate(DateUtil.getThatDayDateString());
+        fwhDailyPublishDetail.setFansBeforePublish(count);
+        fwhDailyPublishDetail.setPublishTimesBeforePublish(articleUseGroupMapper.selectRemainingCountByGzhId(planAccount.getGhId(), null));
+        fwhDailyPublishDetailMapper.insertSelective(fwhDailyPublishDetail);
         int batchSize = 10000; // 每组大小
         int totalSize = sendOpenIds.size();
         List<PublishContent> publishContentList = publicContentService.getPublishContentById(sendIds);

+ 6 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/DateUtil.java

@@ -60,6 +60,12 @@ public class DateUtil {
         return (int) (ChronoUnit.DAYS.between(today, lastDayOfMonth) + 1);
     }
 
+    public static int getDayOfMonth() {
+        LocalDate today = LocalDate.now();
+        // 获取今天是本月的第几天
+        return today.getDayOfMonth();
+    }
+
 
 
 }