|
@@ -183,6 +183,9 @@ public class XxlJobService {
|
|
|
@Value("${preFilter.publish.content.thread.pool.size:4}")
|
|
|
private Integer preFilterPublishContentThreadPoolSize;
|
|
|
|
|
|
+ @Value("${sync.publish.content.batch.job.size:20}")
|
|
|
+ private Integer syncPublishContentBatchJobSize;
|
|
|
+
|
|
|
@XxlJob("checkPublishPlan")
|
|
|
public ReturnT<String> checkPublishPlan(String param) {
|
|
|
Long todayStart = DateUtils.getTodayStart();
|
|
@@ -1070,6 +1073,40 @@ public class XxlJobService {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ @XxlJob("syncGzhWaitingPublishContentBatch")
|
|
|
+ public ReturnT<String> syncGzhWaitingPublishContentBatch(String param) {
|
|
|
+ Long now = System.currentTimeMillis();
|
|
|
+ List<PublishPlan> planList = publishPlanRepository.getByChannelAndContentModalAndPlanTypeAndPlanStatus(ChannelEnum.wx.getVal(),
|
|
|
+ 3, 1, 1);
|
|
|
+ List<String> planIds = planList.stream().map(PublishPlan::getId).collect(Collectors.toList());
|
|
|
+ List<PublishPlanAccountDTO> accountList = publishContentMapper.getPublishPlanAccounts(planIds);
|
|
|
+ Collections.shuffle(accountList);
|
|
|
+ CountDownLatch cdl = new CountDownLatch(accountList.size());
|
|
|
+ ExecutorService thread = new CommonThreadPoolExecutor(
|
|
|
+ syncPublishContentThreadPoolSize, syncPublishContentThreadPoolSize, 0L, TimeUnit.SECONDS,
|
|
|
+ new LinkedBlockingQueue<>(),
|
|
|
+ new ThreadFactoryBuilder().setNameFormat("syncGzhWaitingPublishContentBatch-%d").build(),
|
|
|
+ new ThreadPoolExecutor.AbortPolicy());
|
|
|
+ for (int i = 0; i < syncPublishContentBatchJobSize; i++) {
|
|
|
+ PublishPlanAccountDTO account = accountList.get(i);
|
|
|
+ thread.submit(() -> {
|
|
|
+ try {
|
|
|
+ List<Content> contentList;
|
|
|
+ contentList = aigcWaitingPublishContentService.getAllContent(account.getPlanId(), account.getAccountId(), null);
|
|
|
+ savePublishContentCache(contentList, account.getPlanId(), account.getAccountId(), true, now);
|
|
|
+ } finally {
|
|
|
+ cdl.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ cdl.await();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("syncGzhWaitingPublishContentBatch error", e);
|
|
|
+ }
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
private void setPublishContentValue(PublishContentGzhWaiting item, Content content, String planId, String accountId,
|
|
|
Long updateTimestamp) {
|
|
|
item.setId(content.getId());
|