|
@@ -69,6 +69,9 @@ public class CoreServiceImpl implements CoreService {
|
|
|
@Autowired
|
|
|
private RootSourceMapper rootSourceMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PublicContentServiceImpl publicContentService;
|
|
|
+
|
|
|
@Override
|
|
|
public void initPlanAccount() {
|
|
|
List<LongArticleSystemPlan> allLongArticleSystemPlans = aigcService.getAllLongArticleSystemPlan();
|
|
@@ -214,6 +217,9 @@ public class CoreServiceImpl implements CoreService {
|
|
|
}
|
|
|
|
|
|
private boolean checkPlanAccount(PlanAccount planAccount) {
|
|
|
+ boolean isGzhGroupPushPlan = Objects.nonNull(planAccount.getPushType())
|
|
|
+ && (PublishGzhPushTypeEnum.auto_group_publish.getVal().equals(planAccount.getPushType())
|
|
|
+ || PublishGzhPushTypeEnum.batch_group_publish.getVal().equals(planAccount.getPushType()));
|
|
|
boolean flag = true;
|
|
|
// 固定日期
|
|
|
if (planAccount.getPublishRate() == 1) {
|
|
@@ -225,7 +231,7 @@ public class CoreServiceImpl implements CoreService {
|
|
|
}
|
|
|
}
|
|
|
// 指定时间
|
|
|
- if (StringUtils.isNotEmpty(planAccount.getPublishPushTime())) {
|
|
|
+ if (isGzhGroupPushPlan && StringUtils.isNotEmpty(planAccount.getPublishPushTime())) {
|
|
|
LocalTime currentTime = TimeZoneUtil.currentTime(TimeZoneUtil.Timezone.china);
|
|
|
LocalTime pushTime = LocalTime.parse(planAccount.getPublishPushTime());
|
|
|
if (currentTime.isBefore(pushTime.minusMinutes(20))) {
|
|
@@ -243,7 +249,9 @@ public class CoreServiceImpl implements CoreService {
|
|
|
if (planAccount.getPublishTimeInterval() != null) {
|
|
|
// 找到该账号最近发布的内容,判断时间间隔
|
|
|
PublishContentExample example = new PublishContentExample();
|
|
|
- example.createCriteria().andStatusIn(Arrays.asList(1, 2)).andCreateTimeGreaterThan(DateUtil.getThatDayDate());
|
|
|
+ example.createCriteria().andStatusIn(Arrays.asList(1, 2))
|
|
|
+ .andCreateTimeGreaterThan(DateUtil.getThatDayDate())
|
|
|
+ .andPlanAccountIdEqualTo(planAccount.getId());
|
|
|
example.setOrderByClause("create_time desc");
|
|
|
List<PublishContent> publishContents = publishContentMapper.selectByExample(example);
|
|
|
if (!CollectionUtils.isEmpty(publishContents)) {
|
|
@@ -254,23 +262,53 @@ public class CoreServiceImpl implements CoreService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- PublishContentExample example = new PublishContentExample();
|
|
|
- example.createCriteria().andStatusIn(Arrays.asList(1, 2)).andCreateTimeGreaterThan(DateUtil.getThatDayDate());
|
|
|
- long sendCount = publishContentMapper.countByExample(example);
|
|
|
+ int sendCount = publicContentService.getSendCount(planAccount.getId());
|
|
|
+ if (isGzhGroupPushPlan) {
|
|
|
+ //公众号群发每天只能成功发布一次
|
|
|
+ if (sendCount >= 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //公众号群发每天最多尝试3次
|
|
|
+ if (planAccount.getRetryCount() >= 3) {
|
|
|
+ planAccount.setStatus(3);
|
|
|
+ planAccountMapper.updateByPrimaryKeySelective(planAccount);
|
|
|
+ LarkRobotUtil.sendMessage("计划发布失败3次,请查看 账号计划id为" + planAccount.getPlanId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
Integer publishNum = planAccount.getPublishNum();
|
|
|
if (publishNum == null || publishNum == 0) {
|
|
|
+ LarkRobotUtil.sendMessage("发布数量设置为0 planAccountId=" + planAccount.getId());
|
|
|
return false;
|
|
|
}
|
|
|
if (sendCount >= publishNum) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (planAccount.getRetryCount() >= 3) {
|
|
|
- planAccount.setStatus(3);
|
|
|
- planAccountMapper.updateByPrimaryKeySelective(planAccount);
|
|
|
- LarkRobotUtil.sendMessage("计划发布失败3次,请查看 账号计划id为" + planAccount.getPlanId());
|
|
|
- return false;
|
|
|
- }
|
|
|
|
|
|
+ int todayNeedSendCount = publishNum - sendCount;
|
|
|
+ // 本次推送数量
|
|
|
+ Integer prePushNum = planAccount.getPublishPreNum();
|
|
|
+ if (Objects.isNull(prePushNum)) {
|
|
|
+ prePushNum = 1;
|
|
|
+ }
|
|
|
+ //如果预计推送数量大于剩余推送数量 本次数量设置为剩余推送数量
|
|
|
+ if (prePushNum > todayNeedSendCount) {
|
|
|
+ prePushNum = todayNeedSendCount;
|
|
|
+ }
|
|
|
+ // 自动发布消息,每次暂时限定发布一条
|
|
|
+ if (PublishGzhPushTypeEnum.robopost.getVal().equals(planAccount.getPushType())) {
|
|
|
+ prePushNum = 1;
|
|
|
+ }
|
|
|
+ // 本次最少推送数量
|
|
|
+ Integer preMinPushNum = planAccount.getPublishPreMinNum();
|
|
|
+ if (Objects.isNull(preMinPushNum)) {
|
|
|
+ preMinPushNum = prePushNum;
|
|
|
+ }
|
|
|
+ if (preMinPushNum > prePushNum) {
|
|
|
+ preMinPushNum = prePushNum;
|
|
|
+ }
|
|
|
+ planAccount.setPublishPreNum(prePushNum);
|
|
|
+ planAccount.setPublishPreMinNum(preMinPushNum);
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
@@ -293,16 +331,7 @@ public class CoreServiceImpl implements CoreService {
|
|
|
// articleSortRequest.setStrategy("ArticleRankRandom");
|
|
|
// articleSortRequest.setExcludeLog(true);
|
|
|
articleSortRequest.setStrategy(planAccount.getSortStrategy());
|
|
|
- if (Objects.equals(planAccount.getPushType(), PublishGzhPushTypeEnum.manual_push.getVal())) {
|
|
|
- PublishContentExample publishContentExample = new PublishContentExample();
|
|
|
- publishContentExample.createCriteria().andStatusIn(Arrays.asList(1, 2)).andCreateTimeGreaterThan(DateUtil.getThatDayDate());
|
|
|
- long sendCount = publishContentMapper.countByExample(publishContentExample);
|
|
|
- if (planAccount.getPublishPreNum() <= (planAccount.getPublishNum() - sendCount)) {
|
|
|
- articleSortRequest.setPublishNum(planAccount.getPublishPreNum());
|
|
|
- } else {
|
|
|
- articleSortRequest.setPublishNum((int) (planAccount.getPublishNum() - sendCount));
|
|
|
- }
|
|
|
- }
|
|
|
+ articleSortRequest.setPublishNum(planAccount.getPublishPreNum());
|
|
|
if (Objects.equals(PublishGzhPushTypeEnum.auto_group_publish.getVal(), planAccount.getPushType())) {
|
|
|
articleSortRequest.setPublishNum(planAccount.getPublishNum());
|
|
|
}
|