Compare commits

...

6 Commits

Author SHA1 Message Date
yang
4205912db5 定时任务测试 2024-11-30 12:08:11 +08:00
nisen
423b658e04 Merge branch 'yx1107-bug-l' into 104-master 2024-11-18 20:08:14 +08:00
Wangxxz
acc62c85e0 优化 2024-11-18 20:07:36 +08:00
nisen
795966d944 Merge branch 'yx1107-bug-l' into 104-master 2024-11-18 15:46:23 +08:00
Wangxxz
ec00f55606 频繁调用finishCheck100进度更新 2024-11-18 15:43:01 +08:00
Wangxxz
fc94e4aedd 受众加判空 2024-11-08 10:42:05 +08:00
7 changed files with 88 additions and 4 deletions

View File

@@ -232,6 +232,13 @@
<artifactId>spring-retry</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<resources>

View File

@@ -0,0 +1,40 @@
package com.xboe;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class XxlJobConfig {
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
// 创建 XxlJobSpringExecutor 执行器
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
// 返回
return xxlJobSpringExecutor;
}
}

View File

@@ -1,6 +1,7 @@
package com.xboe.module.boecase.api;
import com.xboe.module.boecase.service.ICasesService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -16,6 +17,7 @@ public class CaseScheduledTasks {
* 每月的第一天的1:00执行
*/
// @Scheduled(cron = "0 0 1 1 * ?")
@XxlJob("refreshViewsRankOfMajor")
public void refreshViewsRankOfMajor() {
casesService.refreshViewsRankOfMajor();
}
@@ -23,7 +25,8 @@ public class CaseScheduledTasks {
/**
* 季初第一天两点执行cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月
*/
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
// @Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
@XxlJob("refreshLastQuarterStatistics")
public void refreshLastQuarterStatistics() {
casesService.refreshLastQuarterStatistics();
}

View File

@@ -177,7 +177,7 @@ public class StudyCourseApi extends ApiBaseController{
if (!Objects.isNull(studyCourse)){
pass = true;
}
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
log.error("---------------参数------------ audienceList = " + audienceList);
for (CourseCrowd c : courseCrowdList) {

View File

@@ -2,10 +2,14 @@ package com.xboe.school.study.dao;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;
import com.xboe.core.orm.BaseDao;
@@ -26,6 +30,9 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
@Autowired
StudyCourseItemDao scItemDao;
@Autowired
StringRedisTemplate redisTemplate;
@Resource
private ThirdApi thirdApi;
@@ -36,6 +43,11 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
* @param total
*/
public void finishCheck(String studyId,String courseId,Integer total,String token){
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
return ;
}
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
LocalDateTime now=LocalDateTime.now();
//已完成的内容
@@ -50,7 +62,9 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
}
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
//以下注意float类型是否等于100对应
float percent=n*100/total;
float percent=n*100/total;
if(n>=total) {
//自主报名的课程,代表学习完成
super.updateMultiFieldById(studyId,
@@ -58,11 +72,13 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
UpdateBuilder.create("lastTime",now),
UpdateBuilder.create("finishTime",now),
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
}else {
super.updateMultiFieldById(studyId,
UpdateBuilder.create("progress",percent),
UpdateBuilder.create("lastTime",LocalDateTime.now()),
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
// redisTemplate.opsForValue().set(studyId, String.valueOf(percent), 10, TimeUnit.SECONDS);
}
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);

View File

@@ -74,3 +74,12 @@ xboe.email.url=https://u.boe.com/api/b1/email/send
xboe.email.from=boeu_learning@boe.com.cn
xboe.email.user=
xboe.email.security=
xxl.job.admin.addresses=http://u.boe.com/jobAdmin
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
xxl.job.executor.appname=java-servers-job-api
xxl.job.executor.port=9995
xxl.job.executor.address=
xxl.job.executor.ip=
xxl.job.executor.logpath=/var/log/xxl-job/dw/
xxl.job.executor.logretentiondays=30

View File

@@ -80,4 +80,13 @@ xboe.email.from=boeu_learning@boe.com.cn
xboe.email.user=
xboe.email.security=
boe.domain=https://u-pre.boe.com
boe.domain=https://u-pre.boe.com
xxl.job.admin.addresses=http://u-pre.boe.com/jobAdmin
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
xxl.job.executor.appname=java-servers-job-api
xxl.job.executor.port=9995
xxl.job.executor.address=
xxl.job.executor.ip=
xxl.job.executor.logpath=/var/log/xxl-job/dw/
xxl.job.executor.logretentiondays=30