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;
|
}*/
|
|
}
|