派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.qxueyou.scc.exercise.service.impl;
 
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.qxueyou.scc.base.service.ICacheService;
import com.qxueyou.scc.exercise.service.IExerciseVerService;
 
/**
 * 班级正确率处理service
 * @author zhiyong
 *
 */    
@Service("ExerciseGroupAccuracyDealService")
public class ExerciseGroupAccuracyDealService  {
    
    /** 缓存service  */
    @Autowired
    ICacheService cache;
    
    /** 练习接口service  */
    @Autowired
    IExerciseVerService exerciseVerService;
    
    /** 配置service  */
    /*@Autowired
    IConfigService config;*/
    
    /**
     * 排名更新时间,默认60秒  半小时更新一次
     */
    //private int updateRankMinutes = 60;
    
    @SuppressWarnings("unused")
    private static Logger log = LogManager.getLogger("ExerciseGroupAccuracyDealService");
 
    /*@PostConstruct
    void init() {
 
        CommonONSConsumer.registerHandler("EXER_GROUP_ACCURACY", "ExerciseGroupAccuracyDealService");
            
        //updateRankMinutes = Integer.parseInt(config.getConfigByEnv("ons-classAccuracy-update-minutes"));
    }
 
    
    @Override
    public void doHandle(Message msg, ConsumeContext context) {
        try {
            
            String groupId = msg.getUserProperties("groupId");
            String doCount = msg.getUserProperties("doCount");
            String correctCount = msg.getUserProperties("correctCount");
            
            if(cache.get(getCacheIdFromRank(groupId), Integer.class) != null){// 缓存不为空 说明已经处理过
                return;
            }
            
            updateUpdateTime(groupId);
            
            // 更新字段值到exercise_group_extend表
            exerciseVerService.doUpdateExerGroupClsAccuracy(groupId,doCount,correctCount);
            
            
        } catch (Exception e) {
 
            log.error("更新练习组班级正确率失败:" + e, e);
 
            throw e;
 
        }
    }*/
 
    /**
     * 插入缓存记录,标记本次更新排名时间    半小时更新一次
     * 
     * @param rank
    private void updateUpdateTime(String groupId) {
        cache.set(getCacheIdFromRank(groupId), 30 * updateRankMinutes, 1);
    }
 
    /**
     * 获取cacheId
     * 
     * @param rank
     * @return
    private String getCacheIdFromRank(String groupId) {
        return Constants.EXER_GROUP_ACCURACY_CACHE_KEY + groupId;
    }*/
    
}