瀏覽代碼

增加抽取规避时间

(cherry picked from commit d15bf3f473)
tags/24080901
WendyYang 10 月之前
父節點
當前提交
8152e6092b
共有 2 個文件被更改,包括 20 次插入14 次删除
  1. +16
    -14
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertRandomInviteTask.java
  2. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java

+ 16
- 14
hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertRandomInviteTask.java 查看文件

@@ -4,10 +4,6 @@ import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.SpringUtils;
import com.ningdatech.cache.model.cache.CacheHashKey;
import com.ningdatech.cache.repository.CachePlusOps;
import com.hz.pm.api.common.util.SpringContextHolder;
import com.hz.pm.api.meeting.builder.ExpertInviteBuilder;
import com.hz.pm.api.meeting.entity.domain.Meeting;
@@ -25,11 +21,14 @@ import com.hz.pm.api.meeting.service.IExpertInviteAvoidRuleService;
import com.hz.pm.api.meeting.service.IExpertInviteRuleService;
import com.hz.pm.api.meeting.service.IMeetingExpertService;
import com.hz.pm.api.meeting.service.IMeetingService;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.SpringUtils;
import com.ningdatech.cache.model.cache.CacheHashKey;
import com.ningdatech.cache.repository.CachePlusOps;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -37,10 +36,7 @@ import org.springframework.util.Assert;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -83,18 +79,20 @@ public class ExpertRandomInviteTask {
*/
private static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_TASK_MAP = new ConcurrentHashMap<>();

private ExpertRandomInviteTask currProxy() {
return (ExpertRandomInviteTask) AopContext.currentProxy();
}

private CacheHashKey getCacheKey(Long meetingId) {
String field = meetingId == null ? null : meetingId.toString();
return new CacheHashKey(MEETING_ID_INVITE_RANDOM, field, EXPIRE_TIME);
}

private boolean inInviteTimeRange() {
int currHour = LocalTime.now().getHour();
return currHour >= properties.getInviteStartHour()
&& currHour < properties.getInviteEndHour();
}

@PostConstruct
public void initTask() {
if (!properties.getEnable()) {
if (Boolean.FALSE.equals(properties.getEnable())) {
log.warn("随机邀请已关闭……");
return;
}
@@ -227,6 +225,10 @@ public class ExpertRandomInviteTask {
@Transactional(rollbackFor = Exception.class)
public void invite(Long meetingId, Boolean reInvite, LocalDateTime tsTime) {
log.info("开始进行专家后台抽取:{}", meetingId);
if (!inInviteTimeRange()) {
log.warn("不在会议抽取执行时间:{}",meetingId);
return;
}
Meeting meeting = meetingService.getById(meetingId);
if (meeting.getInviteStatus() || meeting.getStartTime().isBefore(LocalDateTime.now())) {
log.info("会议已开始停止抽取:{}", meeting);


+ 4
- 0
hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java 查看文件

@@ -48,4 +48,8 @@ public class RandomInviteProperties {
*/
private Integer recentDays = 7;

private Integer inviteStartHour = 8;

private Integer inviteEndHour = 20;

}

Loading…
取消
儲存