update 五大维度算法调整及内容更新

develop
hhb@hotmail.com 1 week ago
parent 97806f846d
commit fe68059867

@ -20,6 +20,8 @@ import cn.teammodel.utils.GroupUtil;
import cn.teammodel.utils.SchoolDateUtil;
import com.azure.cosmos.CosmosException;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@ -792,7 +794,7 @@ public class TeacherServiceImpl implements TeacherService {
int count = paperTeacherRepository.getPaperCount(String.format(paperCode, teacherDto.getTmdId()));
List<SugVo> sugVos = sugVoList.stream().filter(sugVo -> sugVo.getHabook().equals(teacherDto.getTmdId())).collect(Collectors.toList());
LinkedHashMap<String,Object> mapTeach = new LinkedHashMap<>();
int[] scores = new int[10];
int[] scores = new int[11];
for (SugVo sugVo : sugVos) {
scores[0] += sugVo.getT_data();
scores[1] += sugVo.getT_green();
@ -804,6 +806,12 @@ public class TeacherServiceImpl implements TeacherService {
scores[7] += sugVo.getDouble_green_count();
scores[8] += sugVo.getMaterial_count();
scores[9] += sugVo.getTpcplan_count();
if (sugVo.getObserve_lessons() != null) {
Set<String> observeLessons = new HashSet<>((List<String>) sugVo.getObserve_lessons());
// 如果后续需要使用 observeLessons可以在此处添加逻辑
scores[10] += observeLessons.size();
}
}
//T(数据)
mapTeach.put("TData",scores[0]);
@ -821,6 +829,7 @@ public class TeacherServiceImpl implements TeacherService {
mapTeach.put("DoubleGreenCount",scores[7]);
mapTeach.put("MaterialCount",scores[8]);
mapTeach.put("TpcplanCount",scores[9]);
mapTeach.put("ObserveLessons",scores[10]);
mapTeach.put("Lessons",records.size());
//资源数量:试卷数量
mapTeach.put("paperCount",count);
@ -848,7 +857,7 @@ public class TeacherServiceImpl implements TeacherService {
.filter(sugVo -> teachers.contains(sugVo.getHabook()))
.collect(Collectors.toList());
LinkedHashMap<String,Object> mapTeach = new LinkedHashMap<>();
int[] scores = new int[10];
int[] scores = new int[11];
for (SugVo sugVo : filteredSugVoList) {
scores[0] += sugVo.getT_data();
scores[1] += sugVo.getT_green();
@ -860,6 +869,11 @@ public class TeacherServiceImpl implements TeacherService {
scores[7] += sugVo.getDouble_green_count();
scores[8] += sugVo.getMaterial_count();
scores[9] += sugVo.getTpcplan_count();
if (sugVo.getObserve_lessons() != null) {
Set<String> observeLessons = new HashSet<>((List<String>) sugVo.getObserve_lessons());
// 如果后续需要使用 observeLessons可以在此处添加逻辑
scores[10] += observeLessons.size();
}
}
//T(数据)
mapTeach.put("TData",scores[0]);
@ -876,6 +890,7 @@ public class TeacherServiceImpl implements TeacherService {
mapTeach.put("DoubleGreenCount",scores[7]);
mapTeach.put("MaterialCount",scores[8]);
mapTeach.put("TpcplanCount",scores[9]);
mapTeach.put("ObserveLessons",scores[10]);
mapTeach.put("Lessons",records.size());
//资源数量:试卷数量
mapTeach.put("paperCount",count);
@ -885,7 +900,7 @@ public class TeacherServiceImpl implements TeacherService {
//查询学校试卷 备注:若是后面影响速度,可以优化改代码
int count = paperSchoolRepository.getPaperCount(String.format(paperCode, teacherDto.getCode()),loginId,null,"school",teacherDto.getPeriodId());
LinkedHashMap<String, Object> mapTeach = new LinkedHashMap<>();
int[] scores = new int[10];
int[] scores = new int[11];
for (SugVo sugVo : sugVoList) {
scores[0] += sugVo.getT_data();
scores[1] += sugVo.getT_green();
@ -897,6 +912,11 @@ public class TeacherServiceImpl implements TeacherService {
scores[7] += sugVo.getDouble_green_count();
scores[8] += sugVo.getMaterial_count();
scores[9] += sugVo.getTpcplan_count();
if (sugVo.getObserve_lessons() != null) {
Set<String> observeLessons = new HashSet<>((List<String>) sugVo.getObserve_lessons());
// 如果后续需要使用 observeLessons可以在此处添加逻辑
scores[10] += observeLessons.size();
}
}
//T(数据)
mapTeach.put("TData", scores[0]);
@ -913,6 +933,7 @@ public class TeacherServiceImpl implements TeacherService {
mapTeach.put("DoubleGreenCount",scores[7]);
mapTeach.put("MaterialCount",scores[8]);
mapTeach.put("TpcplanCount",scores[9]);
mapTeach.put("ObserveLessons",scores[10]);
mapTeach.put("Lessons",records.size());
//资源数量:试卷数量
mapTeach.put("paperCount",count);
@ -1010,7 +1031,7 @@ public class TeacherServiceImpl implements TeacherService {
Map<String, Object> result = new HashMap<>();
try {
// 初始化四项数据
double TData = 0, TGreen = 0, Lessons = 0, paperCount = 0,LessonCount = 0,DoubleGreenCount = 0,MaterialCount = 0,PublicCount = 0;
double TData = 0, TGreen = 0, Lessons = 0, paperCount = 0,LessonCount = 0,DoubleGreenCount = 0,ObserveLessons = 0,PublicCount = 0;
// 获取原始数据集合
Map<String, Object> resMap = getTeachingAndResearch(teacherDto, request);
@ -1023,6 +1044,7 @@ public class TeacherServiceImpl implements TeacherService {
ownerIds.add(teacherDto.getTmdId());
gpTeacherDto.setOwnerIds(ownerIds);
gpTeacherDto.setIds(ownerIds);
gpTeacherDto.setSchoolId(teacherDto.getCode());
// 遍历并提取八项数据
@ -1037,7 +1059,7 @@ public class TeacherServiceImpl implements TeacherService {
case "paperCount": paperCount = (Integer) value; break;
case "LessonCount": LessonCount = (Integer) value; break;
case "DoubleGreenCount": DoubleGreenCount = (Integer) value; break;
case "MaterialCount": MaterialCount = (Integer) value; break;
case "ObserveLessons": ObserveLessons = (Integer) value; break;
case "PublicCount": PublicCount = (Integer) value; break;
}
}
@ -1052,7 +1074,7 @@ public class TeacherServiceImpl implements TeacherService {
paperCount = Math.round((paperCount / teachersList.size()) * 100.0) / 100.0;
LessonCount = Math.round((LessonCount / teachersList.size()) * 100.0) / 100.0;
DoubleGreenCount = Math.round((DoubleGreenCount / teachersList.size()) * 100.0) / 100.0;
MaterialCount = Math.round((MaterialCount / teachersList.size()) * 100.0) / 100.0;
ObserveLessons = Math.round((ObserveLessons / teachersList.size()) * 100.0) / 100.0;
PublicCount = Math.round((PublicCount / teachersList.size()) * 100.0) / 100.0;
List<String> ids = teachersList.stream()
.map(GpTeacherVo::getId)
@ -1097,12 +1119,15 @@ public class TeacherServiceImpl implements TeacherService {
paperCount = Math.round((paperCount / count) * 100.0) / 100.0;
LessonCount = Math.round((LessonCount / count) * 100.0) / 100.0;
DoubleGreenCount = Math.round((DoubleGreenCount / count) * 100.0) / 100.0;
MaterialCount = Math.round((MaterialCount / count) * 100.0) / 100.0;
ObserveLessons = Math.round((ObserveLessons / count) * 100.0) / 100.0;
PublicCount = Math.round((PublicCount / count) * 100.0) / 100.0;
}
gpTeacherDto.setOwnerIds(tmdIds);
gpTeacherDto.setIds(tmdIds);
gpTeacherDto.setGradeIds(new ArrayList<>(Collections.singletonList( String.valueOf(Integer.parseInt(teacherDto.getGrade()) + 1))));
}
DoubleGreenCount = DoubleGreenCount * 10;
/*if (!StringUtils.isNotEmpty(teacherDto.getGrade()) && StringUtils.isNotEmpty(teacherDto.getTmdId())) {
//获取该tmdId下的年级信息
@ -1167,23 +1192,34 @@ public class TeacherServiceImpl implements TeacherService {
//研修分数获取
double TrainingScore = 0;
Map<String, Object> training = getTeacherTraining(gpTeacherDto, request);
List<Map<String, Object>> trainings = (List<Map<String, Object>>) training.get("studyScores");
List<Map<String, Object>> trainings = (List<Map<String, Object>>) training.get("persons");
if (trainings != null) {
// 计算总分数
for (Map<String, Object> trainingMap : trainings) {
Object scoreObj = trainingMap.get("score");
Object scoreObj = trainingMap.get("studyHour");
Object isJoin = trainingMap.get("isJoin");
if(isJoin instanceof Boolean) {
if ((boolean) isJoin) {
double score = 60;
double hourScore = 0;
if (scoreObj instanceof Integer) {
int score = (int) scoreObj;
TrainingScore += score;
int hour = (int) scoreObj;
if (hour > 0) {
hourScore = 40 * (1 - Math.exp(-K * hour));
}
}
TrainingScore += (score + hourScore);
} else {
TrainingScore += 0;
}
}
}
}
if (TrainingScore > 0) {
TrainingScore = Math.round(TrainingScore / gpTeacherDto.getIds().size() * 100.0) / 100.0;
}
// 基础分计算
double honorScore = (honorScores > 0) ? 100.0 - 20.0 / honorScores : 60;
double honorScore = honorScores > 0 ? Math.round(100.0 - (165.0 / (honorScores + 4.5))) : 60;
// 计算各维度贡献值(使用指数衰减函数)
double tDataScore = 25 * (1 - Math.exp(-K * TData));
@ -1192,12 +1228,12 @@ public class TeacherServiceImpl implements TeacherService {
double paperScore = 10 * (1 - Math.exp(-K * paperCount));
//计算教学贡献值
// 基础分计算
double baseScore = (DoubleGreenCount > 0) ? 100.0 - 40.0 / DoubleGreenCount : 0;
double baseScore = 40 * (1 - Math.exp(-K * DoubleGreenCount));
// 附加分计算
double lessonScore = (LessonCount >= 1) ? (5.0 - 3.0 / LessonCount) : 0;
double materialScore = (MaterialCount >= 1) ? (3.0 - 1.0 / MaterialCount) : 0;
double publicScore = (PublicCount >= 1) ? (2.0 - 1.0 / PublicCount) : 0;
double lessonScore = 20 * (1 - Math.exp(-K * LessonCount));
double materialScore = 30 * (1 - Math.exp(-K * ObserveLessons));
double publicScore = 10 * (1 - Math.exp(-K * PublicCount));
// 总分计算不超过100
double totalTeachingScore = baseScore + lessonScore + materialScore + publicScore;
@ -1218,7 +1254,7 @@ public class TeacherServiceImpl implements TeacherService {
result.put("researchScore", totalTeachingScore);
result.put("honorScore", honorScore);
result.put("trainingScore", TrainingScore);
result.put("scientificScore", 0);
result.put("scientificScore", 60);
} catch (Exception ex) {
@ -1297,6 +1333,30 @@ public class TeacherServiceImpl implements TeacherService {
sugVo.setDouble_green_count(Integer.parseInt(dataMap.get("double_green_count").toString()));
sugVo.setMaterial_count(Integer.parseInt(dataMap.get("material_count").toString()));
sugVo.setTpcplan_count(Integer.parseInt(dataMap.get("tpcplan_count").toString()));
// 假设 dataMap.get("observe_lessons") 返回的是 JSON 字符串格式的数组
Object observeLessonsObj = dataMap.get("observe_lessons");
if (observeLessonsObj instanceof String) {
// 如果是字符串,尝试解析为 List<String>
try {
String observeLessonsStr = (String) observeLessonsObj;
List<String> observeLessonsList = new ObjectMapper().readValue(
observeLessonsStr, new TypeReference<List<String>>() {}
);
sugVo.setObserve_lessons(observeLessonsList);
} catch (Exception e) {
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误: observe_lessons");
}
} else if (observeLessonsObj instanceof List) {
// 如果已经是 List 类型,直接设置
@SuppressWarnings("unchecked")
List<String> observeLessonsList = (List<String>) observeLessonsObj;
sugVo.setObserve_lessons(observeLessonsList);
} else {
// 如果类型不匹配,抛出异常或记录日志
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "observe_lessons 数据类型不匹配");
}
return sugVo;
}
@ -1349,7 +1409,7 @@ public class TeacherServiceImpl implements TeacherService {
Map<String, Object> gradeMap;
try {
String url = "open_study/find";
gpTeacherDto.setGrant_type("study_average_score");
gpTeacherDto.setGrant_type("study_duration");
gradeMap = GroupUtil.getTeacherInfo(gpTeacherDto,new GroupUtil(env), request, url);
}catch (Exception e) {
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "国培数据转换错误");

@ -12,4 +12,6 @@ public class GpTeacherDto {
private List<String> mobiles;
private List<String> ownerIds;
private List<String> ids;
private String schoolId;
private List<String> gradeIds;
}

@ -2,6 +2,8 @@ package cn.teammodel.model.vo.admin;
import lombok.Data;
import java.util.List;
@Data
public class SugVo {
private String habook;
@ -24,4 +26,5 @@ public class SugVo {
private Integer material_count;
private Integer tpcplan_count;
private Integer star_level;
private List<String> observe_lessons;
}

@ -86,7 +86,7 @@ public class GroupUtil {
}else {
apiUrl = "https://gp.winteach.cn/"+url;
apiUrl = "https://gp-test.winteach.cn/"+url;
}
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {

Loading…
Cancel
Save