|
@@ -17,6 +17,8 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.redisson.api.RAtomicLong;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -34,7 +36,7 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
@Autowired
|
|
|
private StudentBasicInfoDao studentBasicInfoDao;
|
|
|
@Autowired
|
|
|
- private RedisCache<String,Integer> redisCache;
|
|
|
+ private RedissonClient redissonClient;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, StudentStatistics> getDAO() {
|
|
@@ -48,54 +50,65 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
|
|
|
@Override
|
|
|
public void updateStudentStatistics() {
|
|
|
- //更新学员基本信息
|
|
|
+ // 更新学员基本信息
|
|
|
studentBasicInfoDao.updateStudentBasicInfo();
|
|
|
- RedisTemplate<String, Integer> redisTemplate = redisCache.getRedisTemplate();
|
|
|
- Integer num = redisTemplate.opsForValue().get("updateStudentStatisticsNum:");
|
|
|
- if(num == null || num == 1){
|
|
|
- if(num == null){
|
|
|
- num = 1;
|
|
|
- }
|
|
|
- //更新未排课总数
|
|
|
+
|
|
|
+ // 获取 Redis 中的 AtomicLong 对象,表示统计数字
|
|
|
+ RAtomicLong atomicLong = redissonClient.getAtomicLong("updateStudentStatisticsNum:");
|
|
|
+
|
|
|
+ // 获取当前计数值
|
|
|
+ long num = atomicLong.get();
|
|
|
+
|
|
|
+ if (num == 0) {
|
|
|
+ // 设置初始值为 1 如果 num 为空
|
|
|
+ atomicLong.set(1);
|
|
|
+ num = 1; // 初始值为 1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据 num 的值更新学员统计数据
|
|
|
+ if (num == 1) {
|
|
|
+ // 更新未排课总数
|
|
|
studentStatisticsDao.updateNoCourseNum();
|
|
|
- }else if (num == 2){
|
|
|
- //更新未开始价值总和
|
|
|
+ } else if (num == 2) {
|
|
|
+ // 更新未开始价值总和
|
|
|
studentStatisticsDao.updateNotStartCourseFee();
|
|
|
- }else if (num == 3){
|
|
|
- //更新未排课价值
|
|
|
+ } else if (num == 3) {
|
|
|
+ // 更新未排课价值
|
|
|
studentStatisticsDao.updateNoCourseFee();
|
|
|
- }else if (num == 4){
|
|
|
- //更新第一次课的时间\最近一次课时间
|
|
|
+ } else if (num == 4) {
|
|
|
+ // 更新第一次课的时间、最近一次课时间
|
|
|
studentStatisticsDao.updateFirstAndLastCourseTime();
|
|
|
- }else if (num == 5){
|
|
|
- //更新进行中课程组数量
|
|
|
+ } else if (num == 5) {
|
|
|
+ // 更新进行中课程组数量
|
|
|
studentStatisticsDao.updateNormalGroupNum();
|
|
|
- }else if (num == 6){
|
|
|
- //更新总课时数、已完成、剩余课时数、最近30天课耗、最近1年课耗
|
|
|
+ } else if (num == 6) {
|
|
|
+ // 更新总课时数、已完成、剩余课时数、最近30天课耗、最近1年课耗
|
|
|
studentStatisticsDao.updateCourseNum();
|
|
|
- }else if (num == 7){
|
|
|
- //更新声部班老师
|
|
|
+ } else if (num == 7) {
|
|
|
+ // 更新声部班老师
|
|
|
studentBasicInfoDao.updateSubjectTeacher();
|
|
|
- }else if (num == 8){
|
|
|
- //更新乐团主管、指导老师
|
|
|
+ } else if (num == 8) {
|
|
|
+ // 更新乐团主管、指导老师
|
|
|
studentStatisticsDao.updateTeacherAndEdu();
|
|
|
- }else if (num == 8){
|
|
|
- //更新学员合作单位
|
|
|
- studentStatisticsDao.updateCooperationOrgan();
|
|
|
} else if (num == 9) {
|
|
|
- //更新第一次付费时间
|
|
|
+ // 更新学员合作单位
|
|
|
+ studentStatisticsDao.updateCooperationOrgan();
|
|
|
+ } else if (num == 10) {
|
|
|
+ // 更新第一次付费时间
|
|
|
studentStatisticsDao.updateFirstOrderTime();
|
|
|
- num = 0;
|
|
|
+ // 重置 num 为 0 完成所有更新
|
|
|
+ atomicLong.set(0);
|
|
|
}
|
|
|
- num++;
|
|
|
- redisTemplate.opsForValue().set("updateStudentStatisticsNum:",num);
|
|
|
+
|
|
|
+ // 递增 num 的值,进入下一个步骤
|
|
|
+ atomicLong.incrementAndGet();
|
|
|
}
|
|
|
|
|
|
public int countStatistics(StudentStatisticsQueryInfo queryInfo){
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
if(StringUtils.isNotEmpty(queryInfo.getOrganId())){
|
|
|
- List<Integer> organIdList = Arrays.stream(queryInfo.getOrganId().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ List<Integer> organIdList = Arrays.stream(queryInfo.getOrganId().split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
params.put("organIdList",organIdList);
|
|
|
}
|
|
|
return studentStatisticsDao.countStatistics(params);
|
|
@@ -128,7 +141,7 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
public StudentStatisticsSumDto studentSmallClassStatisticsSum(String groupType,String organId) {
|
|
|
List<Integer> organIdList = new ArrayList<>();
|
|
|
if(StringUtils.isNotEmpty(organId)){
|
|
|
- organIdList = Arrays.stream(organId.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ organIdList = Arrays.stream(organId.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
}
|
|
|
StudentStatisticsSumDto dto = studentStatisticsDao.studentSmallClassStatisticsSum(groupType, organIdList);
|
|
|
//获取进行中的学员数量
|
|
@@ -144,7 +157,7 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
StudentStatisticsSumForDateDto sumForDateDto = new StudentStatisticsSumForDateDto();
|
|
|
List<Integer> organIdList = new ArrayList<>();
|
|
|
if(StringUtils.isNotEmpty(organId)){
|
|
|
- organIdList = Arrays.stream(organId.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ organIdList = Arrays.stream(organId.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
}
|
|
|
//获取流失人数
|
|
|
// sumForDateDto.setLostNum(studentStatisticsDao.countLostStudentNum(groupType,startDate,endDate,organIdList));
|