beetlsql3-dev
parent
8bebcff7e1
commit
273d4af046
@ -0,0 +1,20 @@
|
|||||||
|
package com.ibeetl.jlw.service.questionSettingQueue;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: <br>
|
||||||
|
*
|
||||||
|
* @author: mlx
|
||||||
|
* @description:
|
||||||
|
* @date: 2022/12/9 1:02
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QuestionSettingDelayed {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 题目配置ID
|
||||||
|
*/
|
||||||
|
private Long questionSettingId;
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.ibeetl.jlw.service.questionSettingQueue;
|
||||||
|
|
||||||
|
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao;
|
||||||
|
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog;
|
||||||
|
import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum;
|
||||||
|
import com.ibeetl.jlw.service.TeacherOpenCourseQuestionLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.PRE_SUBMIT;
|
||||||
|
import static com.ibeetl.jlw.service.questionSettingQueue.RedisDelayQueue.QuestionQueueTypeEnum.QUESTION_SETTING;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: <br>
|
||||||
|
*
|
||||||
|
* @author: mlx
|
||||||
|
* @description:
|
||||||
|
* @date: 2022/12/9 0:41
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class QuestionSettingRedisDelayQueueImpl extends RedisDelayQueue<QuestionSettingDelayed> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TeacherOpenCourseQuestionLogDao teacherOpenCourseQuestionLogDao;
|
||||||
|
@Autowired
|
||||||
|
private TeacherOpenCourseQuestionLogService teacherOpenCourseQuestionLogService;
|
||||||
|
@Autowired @Lazy
|
||||||
|
private QuestionSettingRedisDelayQueueImpl questionSettingRedisDelayQueue;
|
||||||
|
|
||||||
|
public QuestionSettingRedisDelayQueueImpl(RedisTemplate redisTemplate) {
|
||||||
|
super(redisTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMsg(QuestionSettingDelayed msg) {
|
||||||
|
final Long questionSettingId = msg.getQuestionSettingId();
|
||||||
|
// 查询需要更新状态的题目日志
|
||||||
|
List<TeacherOpenCourseQuestionLog> list = teacherOpenCourseQuestionLogDao.getByQuestionLogAddType(questionSettingId, PRE_SUBMIT.name(), null);
|
||||||
|
|
||||||
|
// 获取需要修改的日志IDs
|
||||||
|
List<TeacherOpenCourseQuestionLog> logList = list.stream().map(item -> {
|
||||||
|
TeacherOpenCourseQuestionLog questionLog = new TeacherOpenCourseQuestionLog();
|
||||||
|
questionLog.setTeacherOpenCourseQuestionLogId(item.getTeacherOpenCourseQuestionLogId());
|
||||||
|
// 更改为交卷状态
|
||||||
|
questionLog.setQuestionLogAddType(QuestionLogAddTypeEnum.FINALLY_SUBMIT);
|
||||||
|
return questionLog;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
// 逻辑提交试卷
|
||||||
|
teacherOpenCourseQuestionLogService.updateBatchTemplate(logList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void consumer() {
|
||||||
|
new Thread(() -> {
|
||||||
|
// 为了走异步
|
||||||
|
questionSettingRedisDelayQueue.loop(QUESTION_SETTING.name());
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue