From a0877d9c0e2cf8678c025ecd88a5045d6e581e56 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 29 十月 2024 14:19:31 +0800
Subject: [PATCH] 试卷标题不能为空
---
src/main/java/com/ycl/jxkg/job/StudyRecordJob.java | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/job/StudyRecordJob.java b/src/main/java/com/ycl/jxkg/job/StudyRecordJob.java
index 36eda18..c901abd 100644
--- a/src/main/java/com/ycl/jxkg/job/StudyRecordJob.java
+++ b/src/main/java/com/ycl/jxkg/job/StudyRecordJob.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.benmanes.caffeine.cache.Cache;
+import com.ycl.jxkg.constants.CaffeineConstant;
import com.ycl.jxkg.domain.entity.StudyRecord;
import com.ycl.jxkg.mapper.StudyRecordMapper;
import com.ycl.jxkg.service.StudyRecordService;
@@ -36,33 +37,32 @@
private void updateStudyRecord() {
log.info("寮�濮嬪瓨瀛︿範鏃堕暱");
List<StudyRecord> cacheList = new ArrayList<>();
- // 鍙栧嚭鎵�鏈夌紦瀛橀」
- ConcurrentMap<String, Object> map = caffeineCache.asMap();
- for (Map.Entry<String, Object> entry : map.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith("STUDENT_")) {
- StudyRecord studyRecord = (StudyRecord) entry.getValue();
- cacheList.add(studyRecord);
+ // 鍙栧嚭鎵�鏈夊涔犺褰曠紦瀛橀」
+ Map<String, StudyRecord> studyMap = (Map<String, StudyRecord>) caffeineCache.getIfPresent(CaffeineConstant.STUDY_RECORD);
+ if (!CollectionUtils.isEmpty(studyMap)) {
+ for (Map.Entry<String, StudyRecord> entry : studyMap.entrySet()) {
+ cacheList.add(entry.getValue());
}
- }
- List<Integer> studentIds = cacheList.stream().map(StudyRecord::getStudentId).collect(Collectors.toList());
- if (!CollectionUtils.isEmpty(studentIds)) {
- //鏁版嵁搴撲腑宸茬粡瀛樺湪鐨勫鐢熸暟鎹�
- QueryWrapper<StudyRecord> wrapper = new QueryWrapper<>();
- wrapper.in("student_id", studentIds);
- List<StudyRecord> studyRecords = studyRecordMapper.selectList(wrapper);
- for (StudyRecord record : studyRecords) {
- for (StudyRecord cacheRecord : cacheList) {
- if (record.getStudentId().equals(cacheRecord.getStudentId())) {
- cacheRecord.setId(record.getId());
- cacheRecord.setStudyTime(record.getStudyTime() + cacheRecord.getStudyTime());
- cacheRecord.setMeetCount(record.getMeetCount());
+
+ List<Integer> studentIds = cacheList.stream().map(StudyRecord::getStudentId).collect(Collectors.toList());
+ if (!CollectionUtils.isEmpty(studentIds)) {
+ //鏁版嵁搴撲腑宸茬粡瀛樺湪鐨勫鐢熸暟鎹�
+ QueryWrapper<StudyRecord> wrapper = new QueryWrapper<>();
+ wrapper.in("student_id", studentIds);
+ List<StudyRecord> studyRecords = studyRecordMapper.selectList(wrapper);
+ for (StudyRecord record : studyRecords) {
+ for (StudyRecord cacheRecord : cacheList) {
+ if (record.getStudentId().equals(cacheRecord.getStudentId())) {
+ cacheRecord.setId(record.getId());
+ cacheRecord.setStudyTime(record.getStudyTime() + cacheRecord.getStudyTime());
+ cacheRecord.setMeetCount(record.getMeetCount());
+ }
}
}
+ studyRecordService.saveOrUpdateBatch(cacheList);
}
- studyRecordService.saveOrUpdateBatch(cacheList);
+ caffeineCache.invalidate(CaffeineConstant.STUDY_RECORD);
}
- caffeineCache.invalidateAll(map.keySet());
log.info("缁撴潫瀛樺涔犳椂闀�");
}
}
--
Gitblit v1.8.0