|
@@ -7,6 +7,7 @@ import com.ruoyi.common.constant.CacheConstants;
|
|
import com.ruoyi.common.core.domain.entity.FormalParentsStudent;
|
|
import com.ruoyi.common.core.domain.entity.FormalParentsStudent;
|
|
import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
|
|
import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
+import com.ruoyi.common.core.domain.model.LoginUser;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
@@ -60,17 +61,38 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
if (params != null && params.size() > 0) {
|
|
if (params != null && params.size() > 0) {
|
|
role = (String) params.get("role");
|
|
role = (String) params.get("role");
|
|
}
|
|
}
|
|
|
|
+ StringBuilder stdId = new StringBuilder("0,");
|
|
if ("parents".equals(role)) {
|
|
if ("parents".equals(role)) {
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
- //如果是家长要记录到redis中
|
|
|
|
- redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN + scoreId+":"+userId, userId);
|
|
|
|
|
|
+ //获取该家长的孩子id
|
|
|
|
+ LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
+ FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
|
|
|
|
+ formalParentsStudent.setParentsId(user.getUserId());
|
|
|
|
+ List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
|
|
|
|
+ for (FormalParentsStudent parentsStudent : formalParentsStudents) {
|
|
|
|
+ stdId.append(parentsStudent.getId()).append(",");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(stdId.toString())) {
|
|
|
|
+ stdId = new StringBuilder(stdId.substring(0, stdId.length() - 1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ map.put("stdId",stdId.toString());
|
|
|
|
+ scoreData.setParams(map);
|
|
//获取查看人数
|
|
//获取查看人数
|
|
- String chaKanCount = redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId);
|
|
|
|
- if (ObjectUtils.isEmpty(chaKanCount)){
|
|
|
|
- redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId,1);
|
|
|
|
- }else {
|
|
|
|
- redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId,Integer.parseInt(chaKanCount)+1);
|
|
|
|
|
|
+ Object chaKanCount = redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId);
|
|
|
|
+ if (ObjectUtils.isEmpty(chaKanCount)) {
|
|
|
|
+ redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId, 1);
|
|
|
|
+ } else {
|
|
|
|
+ //判断该家长是否查看过
|
|
|
|
+ Object cacheObject = redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN + scoreId + ":" + userId);
|
|
|
|
+ if (ObjectUtils.isEmpty(cacheObject)) {
|
|
|
|
+ redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId, Integer.parseInt(String.valueOf(chaKanCount)) + 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ //如果是家长要记录到redis中
|
|
|
|
+ redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN + scoreId + ":" + userId, userId);
|
|
|
|
+ return scoreDataMapper.selectScoreDataForParents(scoreData);
|
|
}
|
|
}
|
|
return scoreDataMapper.selectScoreDataByScoreId(scoreId);
|
|
return scoreDataMapper.selectScoreDataByScoreId(scoreId);
|
|
}
|
|
}
|
|
@@ -131,19 +153,21 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
//全部人数
|
|
//全部人数
|
|
double chaKanAll = 0D;
|
|
double chaKanAll = 0D;
|
|
double chaKanCount = 0D;
|
|
double chaKanCount = 0D;
|
|
- if (ObjectUtils.isNotEmpty(redisCache.getCacheObject(SCORE_PEOPLE_ALL + data.getScoreId()))&&ObjectUtils.isNotEmpty(redisCache.getCacheObject(SCORE_PEOPLE_ALL + data.getScoreId()))){
|
|
|
|
- chaKanAll = redisCache.getCacheObject(SCORE_PEOPLE_ALL + data.getScoreId());
|
|
|
|
- //已查看
|
|
|
|
- chaKanCount = redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + data.getScoreId());
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(redisCache.getCacheObject(SCORE_PEOPLE_ALL + data.getScoreId()))) {
|
|
|
|
+ chaKanAll = (int) redisCache.getCacheObject(SCORE_PEOPLE_ALL + data.getScoreId());
|
|
|
|
+ if (ObjectUtils.isNotEmpty(redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + data.getScoreId()))) {
|
|
|
|
+ //已查看
|
|
|
|
+ chaKanCount = (int) redisCache.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + data.getScoreId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
double weiChaKan = chaKanAll;
|
|
double weiChaKan = chaKanAll;
|
|
- if (chaKanAll > 0 && chaKanCount >= 0){
|
|
|
|
|
|
+ if (chaKanAll > 0 && chaKanCount >= 0) {
|
|
weiChaKan = chaKanAll - chaKanCount;
|
|
weiChaKan = chaKanAll - chaKanCount;
|
|
- }
|
|
|
|
- double z = chaKanCount / chaKanAll;
|
|
|
|
- //计算百分比
|
|
|
|
- if(Math.abs(z)>=0.1){
|
|
|
|
- percent = df.format(z);
|
|
|
|
|
|
+ double z = chaKanCount / chaKanAll;
|
|
|
|
+ if (Math.abs(z) >= 0.1) {
|
|
|
|
+ //计算百分比
|
|
|
|
+ percent = df.format(z);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
data.setChaKan(chaKanCount);
|
|
data.setChaKan(chaKanCount);
|
|
data.setWeiChaKan(weiChaKan);
|
|
data.setWeiChaKan(weiChaKan);
|
|
@@ -176,7 +200,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
//新增成绩的时候,往redis中放入该次考试总人数
|
|
//新增成绩的时候,往redis中放入该次考试总人数
|
|
int count = scoreDataMapper.selectDetailsCountByScoreId(scoreId);
|
|
int count = scoreDataMapper.selectDetailsCountByScoreId(scoreId);
|
|
redisCache.setCacheObject(SCORE_PEOPLE_ALL + scoreId, count);
|
|
redisCache.setCacheObject(SCORE_PEOPLE_ALL + scoreId, count);
|
|
- redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId,0);
|
|
|
|
|
|
+ redisCache.setCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId, 0);
|
|
return rows;
|
|
return rows;
|
|
}
|
|
}
|
|
|
|
|