修改部分成绩和导出相关接口

master
xiaoCJ 2 months ago
parent d1b0807e0c
commit 9abf4d343d

@ -37,7 +37,7 @@ public class Constant {
public static final String SHIZHAN = "实战考核模块"; public static final String SHIZHAN = "实战考核模块";
public static final String THEORY = "理论考试模块"; public static final String THEORY = "理论考试模块";
public static final String RESOURCE = "资源中心模块"; public static final String RESOURCE = "资源中心模块";
public static final String API_URL = "http://120.79.54.255:8889"; // public static final String API_URL = "http://120.79.54.255:8889";
// public static final String API_URL = "http://192.168.2.19:8889"; public static final String API_URL = "http://192.168.2.19:8889";
} }

@ -4,10 +4,13 @@ import cn.hutool.core.util.IdUtil;
import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.annotation.AnonymousAccess;
import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.*;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog; import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog;
import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper; import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper;
import com.sztzjy.financial_bigdata.mapper.StuTrainingStepRecordMapper;
import com.sztzjy.financial_bigdata.mapper.SysWeightMapper; import com.sztzjy.financial_bigdata.mapper.SysWeightMapper;
import com.sztzjy.financial_bigdata.mapper.TrainingReportMapper; import com.sztzjy.financial_bigdata.mapper.TrainingReportMapper;
import com.sztzjy.financial_bigdata.resourceCenterAPI.CaseApi;
import com.sztzjy.financial_bigdata.resourceCenterAPI.CourseAPI; import com.sztzjy.financial_bigdata.resourceCenterAPI.CourseAPI;
import com.sztzjy.financial_bigdata.service.stu.StuScoreService; import com.sztzjy.financial_bigdata.service.stu.StuScoreService;
import com.sztzjy.financial_bigdata.service.tea.ITeaGradeManageService; import com.sztzjy.financial_bigdata.service.tea.ITeaGradeManageService;
@ -26,8 +29,12 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* @Author xcj * @Author xcj
@ -49,7 +56,8 @@ public class StuScoreController {
private ITeaGradeManageService gradeManageService; private ITeaGradeManageService gradeManageService;
@Autowired @Autowired
private StuScoreService stuScoreService; private StuScoreService stuScoreService;
@Autowired
private StuTrainingStepRecordMapper trainingStepRecordMapper;
@AnonymousAccess @AnonymousAccess
@ApiOperation("***得分情况展示") @ApiOperation("***得分情况展示")
@ -57,7 +65,7 @@ public class StuScoreController {
public ResultEntity<StuTrainingDto> getScoreInfo(@RequestParam String userId, public ResultEntity<StuTrainingDto> getScoreInfo(@RequestParam String userId,
@RequestParam String chapterId, @RequestParam String chapterId,
@RequestParam String schoolId, @RequestParam String schoolId,
@RequestParam String systemOwner){ @RequestParam String systemOwner) throws IOException {
StuTrainingDto stuTrainingDto = new StuTrainingDto(); StuTrainingDto stuTrainingDto = new StuTrainingDto();
StuTrainingExample stuTrainingExample = new StuTrainingExample(); StuTrainingExample stuTrainingExample = new StuTrainingExample();
@ -70,9 +78,44 @@ public class StuScoreController {
} catch (IOException e) { } catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败");
} }
List<String> reportIds = stuTrainings.stream().map(StuTraining::getReportId).collect(Collectors.toList());
TrainingReportExample trainingReportExample =new TrainingReportExample();
trainingReportExample.createCriteria().andReportIdIn(reportIds);
List<TrainingReport> trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample);
//提前查出所有report对象
Map<String, TrainingReport> trainingReportMap = trainingReports.stream()
.collect(Collectors.toMap(TrainingReport::getReportId, Function.identity()));
//提前查出权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andCourseIdEqualTo(sysCourseChapter.getTwoId())
.andSchoolIdEqualTo(schoolId)
.andSystemOwnerEqualTo(systemOwner);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
Map<String, SysWeight> weightMap = sysWeights.stream().collect(Collectors.toMap(SysWeight::getCourseId, Function.identity()));
//查步骤集合
List<String>ids =new ArrayList<>();
ids.add(chapterId);
List<TestTestSysCaseQuestionStepWithBLOBs> list = CaseApi.selectCaseStepByThreeIds(ids);
Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds = list.stream()
.filter(step -> step.getThreeId() != null) // 过滤掉 threeId 为 null 的对象
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId)); // 按 threeId 分组
//一次查出所有的记录表
StuTrainingStepRecordExample example = new StuTrainingStepRecordExample();
example.createCriteria().andUserIdEqualTo(userId); // 批量查询用户记录
List<StuTrainingStepRecord> allRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
Map<String, List<StuTrainingStepRecord>> allRecordsMap = allRecords.stream()
.collect(Collectors.groupingBy(StuTrainingStepRecord::getUserId)); // 按 threeId 分组
if (!stuTrainings.isEmpty()) { if (!stuTrainings.isEmpty()) {
StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainings.get(0); StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainings.get(0);
stuTrainingDto = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTrainingWithBLOBs, stuTrainingDto, sysCourseChapter); stuTrainingDto = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTrainingWithBLOBs, stuTrainingDto,
sysCourseChapter,trainingReportMap,weightMap,groupedIds,allRecordsMap);
} }
return new ResultEntity<StuTrainingDto>(stuTrainingDto); return new ResultEntity<StuTrainingDto>(stuTrainingDto);
} }

@ -80,6 +80,10 @@ public class TeaGradeManageController {
StuScoreService stuScoreService; StuScoreService stuScoreService;
@Value("${file.path}") @Value("${file.path}")
private String filePath; private String filePath;
@Autowired
private TrainingReportMapper trainingReportMapper;
@Autowired
private StuTrainingStepRecordMapper trainingStepRecordMapper;
@AnonymousAccess @AnonymousAccess
@ -191,7 +195,6 @@ public class TeaGradeManageController {
} }
@AnonymousAccess @AnonymousAccess
@PostMapping("/getCountChart") @PostMapping("/getCountChart")
@ApiOperation("考试模式--图表统计接口") @ApiOperation("考试模式--图表统计接口")
@ -654,7 +657,6 @@ public class TeaGradeManageController {
} }
@AnonymousAccess @AnonymousAccess
@ApiOperation("老师端/练习模式得分详情展示") @ApiOperation("老师端/练习模式得分详情展示")
@PostMapping("getScoreInfo") @PostMapping("getScoreInfo")
@ -663,30 +665,61 @@ public class TeaGradeManageController {
@RequestParam String systemOwner) throws IOException { @RequestParam String systemOwner) throws IOException {
List<StuTrainingDto> list = new ArrayList<>(); List<StuTrainingDto> list = new ArrayList<>();
List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner,schoolId); List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
List<String> twoIds = sysTwoCatalogs.stream().map(SysTwoCatalog::getTwoId).collect(Collectors.toList());
List<SysThreeCatalog>allChapterId =new ArrayList<>(); List<SysThreeCatalog> allChapterId = CourseAPI.callSelectThreeCatalogList(twoIds, schoolId);
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { List<String> ids = allChapterId.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
allChapterId.addAll(sysThreeCatalogs);
}
StuTrainingExample stuTrainingExample = new StuTrainingExample(); StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdEqualTo(userId); stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
List<String> reportIds = stuTrainings.stream().map(StuTraining::getReportId).collect(Collectors.toList());
TrainingReportExample trainingReportExample = new TrainingReportExample();
trainingReportExample.createCriteria().andReportIdIn(reportIds);
List<TrainingReport> trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample);
//提前查出所有report对象
Map<String, TrainingReport> trainingReportMap = trainingReports.stream()
.collect(Collectors.toMap(TrainingReport::getReportId, Function.identity()));
Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog)); Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog));
//提前查出权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andCourseIdIn(twoIds)
.andSchoolIdEqualTo(schoolId)
.andSystemOwnerEqualTo(systemOwner);
//一次查出所有章节下的案例步骤
List<TestTestSysCaseQuestionStepWithBLOBs> lists = CaseApi.selectCaseStepByThreeIds(ids);
Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds = lists.stream()
.filter(step -> step.getThreeId() != null) // 过滤掉 threeId 为 null 的对象
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId)); // 按 threeId 分组
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
Map<String, SysWeight> weightMap = sysWeights.stream().collect(Collectors.toMap(SysWeight::getCourseId, Function.identity()));
//一次查出所有的记录表
StuTrainingStepRecordExample example = new StuTrainingStepRecordExample();
example.createCriteria().andUserIdEqualTo(userId); // 批量查询用户记录
List<StuTrainingStepRecord> allRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
Map<String, List<StuTrainingStepRecord>> allRecordsMap = allRecords.stream()
.collect(Collectors.groupingBy(StuTrainingStepRecord::getUserId)); // 按 threeId 分组
try { try {
for (StuTrainingWithBLOBs stuTraining : stuTrainings) { for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
String chapterId = stuTraining.getChapterId(); String chapterId = stuTraining.getChapterId();
SysThreeCatalog sysCourseChapter = chapterIds.get(chapterId); SysThreeCatalog sysCourseChapter = chapterIds.get(chapterId);
if (sysCourseChapter==null){ if (sysCourseChapter == null) {
continue; continue;
} }
StuTrainingDto stuTrainingDto = new StuTrainingDto(); StuTrainingDto stuTrainingDto = new StuTrainingDto();
stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName());
list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter)); list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto,
sysCourseChapter, trainingReportMap, weightMap, groupedIds,allRecordsMap));
} }
} catch (Exception e) { } catch (Exception e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败");

@ -12,6 +12,8 @@ import com.sztzjy.financial_bigdata.entity.tea_dto.TrainingDto;
import com.sztzjy.financial_bigdata.util.HttpUtils; import com.sztzjy.financial_bigdata.util.HttpUtils;
import com.sztzjy.financial_bigdata.util.ResultEntity; import com.sztzjy.financial_bigdata.util.ResultEntity;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException; import java.io.IOException;
@ -37,6 +39,7 @@ public class CaseApi {
private final static String deleteCaseStep = Constant.API_URL + "/api/tea/CaseApi/deleteCaseStep"; private final static String deleteCaseStep = Constant.API_URL + "/api/tea/CaseApi/deleteCaseStep";
private final static String selectCaseStepDetails = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepDetails"; private final static String selectCaseStepDetails = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepDetails";
private final static String selectCaseStepListBatchByIdListAndSort = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdListAndSort"; private final static String selectCaseStepListBatchByIdListAndSort = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdListAndSort";
private final static String selectCaseStepByThreeIds = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepByThreeIds";
private final static String selectCaseStepListBatchByIdList = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdList"; private final static String selectCaseStepListBatchByIdList = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdList";
private final static String selectAllStepBySystemOwner = Constant.API_URL + "/api/tea/CaseApi/selectAllStepBySystemOwner"; private final static String selectAllStepBySystemOwner = Constant.API_URL + "/api/tea/CaseApi/selectAllStepBySystemOwner";
@ -301,6 +304,24 @@ public class CaseApi {
return list; return list;
} }
public static List<TestTestSysCaseQuestionStepWithBLOBs> selectCaseStepByThreeIds(List<String> chapterIds) throws IOException {
// 使用 Gson 将 List 转换为 JSON 字符串
String requestBody = new Gson().toJson(chapterIds);
JSONObject object = HttpUtils.sendPostNew(
selectCaseStepByThreeIds,
requestBody);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<List<TestTestSysCaseQuestionStepWithBLOBs>>() {}.getType(); // 正确的解析类型
List<TestTestSysCaseQuestionStepWithBLOBs> steps = gson.fromJson(object.get("respString").toString(), listType);
return steps;
}
public static List<TestTestSysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdList(List<String> list) throws IOException { public static List<TestTestSysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdList(List<String> list) throws IOException {
Gson gson = new Gson(); Gson gson = new Gson();
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(

@ -2,26 +2,31 @@ package com.sztzjy.financial_bigdata.resourceCenterAPI;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.sztzjy.financial_bigdata.config.Constant; import com.sztzjy.financial_bigdata.config.Constant;
import com.sztzjy.financial_bigdata.entity.SysCourseChapter;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog; import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysTwoCatalog; import com.sztzjy.financial_bigdata.entity.resource_entity.SysTwoCatalog;
import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs; import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs;
import com.sztzjy.financial_bigdata.util.HttpUtils; import com.sztzjy.financial_bigdata.util.HttpUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
public class CourseAPI { public class CourseAPI {
private final static String getAllTwoCatalogList = Constant.API_URL + "/api/sys/courseApi/getAllTwoCatalogList"; private final static String getAllTwoCatalogList = Constant.API_URL + "/api/sys/courseApi/getAllTwoCatalogList";
private final static String selectThreeCatalogListByTwoId = Constant.API_URL + "/api/sys/courseApi/selectThreeCatalogListByTwoId"; private final static String selectThreeCatalogListByTwoId = Constant.API_URL + "/api/sys/courseApi/selectThreeCatalogListByTwoId";
private final static String selectThreeCatalogListByTwoIdList = Constant.API_URL + "/api/sys/courseApi/selectThreeCatalogListByTwoIdList";
private final static String insertSysTwoCatalog = Constant.API_URL + "/api/sys/courseApi/insertSysTwoCatalog"; private final static String insertSysTwoCatalog = Constant.API_URL + "/api/sys/courseApi/insertSysTwoCatalog";
private final static String deleteTwoCatalog = Constant.API_URL + "/api/sys/courseApi/deleteTwoCatalog"; private final static String deleteTwoCatalog = Constant.API_URL + "/api/sys/courseApi/deleteTwoCatalog";
private final static String insertSysThreeCatalog = Constant.API_URL + "/api/sys/courseApi/insertSysThreeCatalog"; private final static String insertSysThreeCatalog = Constant.API_URL + "/api/sys/courseApi/insertSysThreeCatalog";
@ -32,21 +37,23 @@ public class CourseAPI {
private final static String selectChapterByChapterId = Constant.API_URL + "/api/sys/courseApi/selectChapterByChapterId"; private final static String selectChapterByChapterId = Constant.API_URL + "/api/sys/courseApi/selectChapterByChapterId";
private final static String selectNameByCourseID = Constant.API_URL + "/api/sys/courseApi/selectNameByCourseID"; private final static String selectNameByCourseID = Constant.API_URL + "/api/sys/courseApi/selectNameByCourseID";
private final static String getModuleBySchoolId = Constant.API_URL + "/api/sys/courseApi/getModuleBySchoolId"; private final static String getModuleBySchoolId = Constant.API_URL + "/api/sys/courseApi/getModuleBySchoolId";
private final static String selectChapterByIdList = Constant.API_URL + "/api/sys/courseApi/selectChapterByIdList";
/** /**
* local: * local:
* rsapi: * rsapi:
*/ */
public static List<SysTwoCatalog> selectCourseList(String systemOwner,String schoolId) throws IOException { public static List<SysTwoCatalog> selectCourseList(String systemOwner, String schoolId) throws IOException {
String requestBody="systemOwner="+systemOwner+"&schoolId="+schoolId; String requestBody = "systemOwner=" + systemOwner + "&schoolId=" + schoolId;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
getAllTwoCatalogList, getAllTwoCatalogList,
requestBody); requestBody);
Gson gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter()) .registerTypeAdapter(Date.class, new DateTypeAdapter())
.create(); .create();
Type listType = new TypeToken<List<SysTwoCatalog>>() {}.getType(); Type listType = new TypeToken<List<SysTwoCatalog>>() {
}.getType();
List<SysTwoCatalog> twoCatalogList = gson.fromJson(object.get("respString").toString(), listType); List<SysTwoCatalog> twoCatalogList = gson.fromJson(object.get("respString").toString(), listType);
return twoCatalogList; return twoCatalogList;
} }
@ -55,34 +62,56 @@ public class CourseAPI {
* local: * local:
* rsapi:ID * rsapi:ID
*/ */
public static List<SysThreeCatalog> selectThreeCatalogListByTwoId(String twoId,String schoolId) throws IOException { public static List<SysThreeCatalog> selectThreeCatalogListByTwoId(String twoId, String schoolId) throws IOException {
String requestBody="twoId="+twoId+"&schoolId="+schoolId; String requestBody = "twoId=" + twoId + "&schoolId=" + schoolId;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
selectThreeCatalogListByTwoId, selectThreeCatalogListByTwoId,
requestBody); requestBody);
Gson gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter()) .registerTypeAdapter(Date.class, new DateTypeAdapter())
.create(); .create();
Type listType = new TypeToken<List<SysThreeCatalog>>() {}.getType(); Type listType = new TypeToken<List<SysThreeCatalog>>() {
}.getType();
List<SysThreeCatalog> threeCatalogList = gson.fromJson(object.get("respString").toString(), listType); List<SysThreeCatalog> threeCatalogList = gson.fromJson(object.get("respString").toString(), listType);
return threeCatalogList; return threeCatalogList;
} }
public static List<SysThreeCatalog> callSelectThreeCatalogList(List<String> twoIds, String schoolId) throws IOException {
// 使用 Gson 将 List 转换为 JSON 字符串
String requestBody = new Gson().toJson(twoIds);
// 构建URL
String url = selectThreeCatalogListByTwoIdList + "?schoolId=" + schoolId;
JSONObject object = HttpUtils.sendPostNew(
url,
requestBody);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<List<SysThreeCatalog>>() {
}.getType(); // 正确的解析类型
List<SysThreeCatalog> sysThreeCatalogs = gson.fromJson(object.get("respString").toString(), listType);
return sysThreeCatalogs;
}
/** /**
* local: * local:
* rsapi: * rsapi:
*/ */
public static Boolean insertSysTwoCatalog(SysTwoCatalog twoCatalog,String systemOwner,String schoolId) throws IOException { public static Boolean insertSysTwoCatalog(SysTwoCatalog twoCatalog, String systemOwner, String schoolId) throws IOException {
twoCatalog.setOneId(systemOwner); twoCatalog.setOneId(systemOwner);
twoCatalog.setCreator(schoolId); twoCatalog.setCreator(schoolId);
Gson gson = new Gson(); Gson gson = new Gson();
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
insertSysTwoCatalog, insertSysTwoCatalog,
gson.toJson(twoCatalog),"application/json",null); gson.toJson(twoCatalog), "application/json", null);
String respString = object.get("respString").toString(); String respString = object.get("respString").toString();
if("true".equals(respString)){ if ("true".equals(respString)) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
@ -92,14 +121,14 @@ public class CourseAPI {
* rsapi: * rsapi:
*/ */
public static Boolean deleteTwoCatalog(String courseId) throws IOException { public static Boolean deleteTwoCatalog(String courseId) throws IOException {
String requestBody="twoId="+courseId; String requestBody = "twoId=" + courseId;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
deleteTwoCatalog, deleteTwoCatalog,
requestBody); requestBody);
String respString = object.get("respString").toString(); String respString = object.get("respString").toString();
if("true".equals(respString)){ if ("true".equals(respString)) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
@ -115,11 +144,11 @@ public class CourseAPI {
Gson gson = new Gson(); Gson gson = new Gson();
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
insertSysThreeCatalog, insertSysThreeCatalog,
gson.toJson(threeCatalog),"application/json",null); gson.toJson(threeCatalog), "application/json", null);
String respString = object.get("respString").toString(); String respString = object.get("respString").toString();
if("true".equals(respString)){ if ("true".equals(respString)) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
@ -129,14 +158,14 @@ public class CourseAPI {
* rsapi: * rsapi:
*/ */
public static Boolean deleteThreeCatalog(String threeId) throws IOException { public static Boolean deleteThreeCatalog(String threeId) throws IOException {
String requestBody="threeId="+threeId; String requestBody = "threeId=" + threeId;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
deleteThreeCatalog, deleteThreeCatalog,
requestBody); requestBody);
String respString = object.get("respString").toString(); String respString = object.get("respString").toString();
if("true".equals(respString)){ if ("true".equals(respString)) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
@ -145,14 +174,15 @@ public class CourseAPI {
* ASC * ASC
*/ */
public static List<SysTwoCatalog> selectTwoCataLogByInnerAndAsc(String systemOwner) throws IOException { public static List<SysTwoCatalog> selectTwoCataLogByInnerAndAsc(String systemOwner) throws IOException {
String requestBody="systemOwner="+systemOwner; String requestBody = "systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
selectTwoCataLogByInnerAndAsc, selectTwoCataLogByInnerAndAsc,
requestBody); requestBody);
Gson gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter()) .registerTypeAdapter(Date.class, new DateTypeAdapter())
.create(); .create();
Type listType = new TypeToken<List<SysTwoCatalog>>() {}.getType(); Type listType = new TypeToken<List<SysTwoCatalog>>() {
}.getType();
List<SysTwoCatalog> twoCatalogList = gson.fromJson(object.get("respString").toString(), listType); List<SysTwoCatalog> twoCatalogList = gson.fromJson(object.get("respString").toString(), listType);
return twoCatalogList; return twoCatalogList;
} }
@ -169,7 +199,7 @@ public class CourseAPI {
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
urlWithParams, urlWithParams,
gson.toJson(courseIds), "application/json", null); gson.toJson(courseIds), "application/json", null);
if(object==null){ if (object == null) {
return null; return null;
} }
Type listType = new TypeToken<List<SysThreeCatalog>>() { Type listType = new TypeToken<List<SysThreeCatalog>>() {
@ -182,7 +212,7 @@ public class CourseAPI {
* *
*/ */
public static Integer getTotalChapterCount(String systemOwner) throws IOException { public static Integer getTotalChapterCount(String systemOwner) throws IOException {
String requestBody="systemOwner="+systemOwner; String requestBody = "systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
getTotalChapterCount, getTotalChapterCount,
requestBody); requestBody);
@ -195,7 +225,7 @@ public class CourseAPI {
* ID * ID
*/ */
public static SysThreeCatalog selectChapterByChapterId(String chapterId) throws IOException { public static SysThreeCatalog selectChapterByChapterId(String chapterId) throws IOException {
String requestBody = "chapterId="+chapterId; String requestBody = "chapterId=" + chapterId;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
selectChapterByChapterId, selectChapterByChapterId,
requestBody); requestBody);
@ -208,13 +238,35 @@ public class CourseAPI {
return step; return step;
} }
/**
* ID
*/
public static List<SysThreeCatalog> selectChapterByIdList(List<String> chapterIds) throws IOException {
// 使用 Gson 将 List 转换为 JSON 字符串
String requestBody = new Gson().toJson(chapterIds);
JSONObject object = HttpUtils.sendPostNew(
selectChapterByIdList,
requestBody);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
Type listType = new TypeToken<List<SysThreeCatalog>>() {
}.getType(); // 正确的解析类型
List<SysThreeCatalog> steps = gson.fromJson(object.get("respString").toString(), listType);
return steps;
}
/** /**
* *
* *
*/ */
public static List<String> selectNameByCourseID(String schoolId,String systemOwner) throws IOException { public static List<String> selectNameByCourseID(String schoolId, String systemOwner) throws IOException {
String requestBody = "schoolId="+schoolId+"&systemOwner="+systemOwner; String requestBody = "schoolId=" + schoolId + "&systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost( JSONObject object = HttpUtils.sendPost(
selectNameByCourseID, selectNameByCourseID,
requestBody); requestBody);

@ -1,16 +1,25 @@
package com.sztzjy.financial_bigdata.service.stu; package com.sztzjy.financial_bigdata.service.stu;
import com.sztzjy.financial_bigdata.entity.StuTrainingStepRecord;
import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs; import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs;
import com.sztzjy.financial_bigdata.entity.SysWeight;
import com.sztzjy.financial_bigdata.entity.TrainingReport;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog; import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog;
import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author xcj * @Author xcj
* @Date 2024/11/22 * @Date 2024/11/22
*/ */
public interface StuScoreService { public interface StuScoreService {
StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner,StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter); StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner, StuTrainingWithBLOBs stuTrainingWithBLOBs,
StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter,
Map<String, TrainingReport> trainingReportMap,Map<String, SysWeight> weightMap,
Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds,
Map<String, List<StuTrainingStepRecord>> allRecordsMap);
} }

@ -21,7 +21,9 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @Author xcj * @Author xcj
@ -125,15 +127,12 @@ public class StuScoreServiceImpl implements StuScoreService {
@Override @Override
public StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner, StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter){ public StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner, StuTrainingWithBLOBs stuTrainingWithBLOBs,
SysWeightExample sysWeightExample = new SysWeightExample(); StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter, Map<String, TrainingReport> trainingReportMap,
sysWeightExample.createCriteria().andCourseIdEqualTo(sysCourseChapter.getTwoId()) Map<String, SysWeight> weightMap, Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds,
.andSchoolIdEqualTo(schoolId) Map<String, List<StuTrainingStepRecord>> allRecordsMap) {
.andSystemOwnerEqualTo(systemOwner); SysWeight sysWeight = weightMap.get(sysCourseChapter.getTwoId());
if (sysWeight!=null) {
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
if (!sysWeights.isEmpty()) {
SysWeight sysWeight = sysWeights.get(0);
BeanUtils.copyProperties(sysWeight, stuTrainingDto); // 提取权重数据 BeanUtils.copyProperties(sysWeight, stuTrainingDto); // 提取权重数据
} else { } else {
setDefaultWeights(stuTrainingDto); setDefaultWeights(stuTrainingDto);
@ -147,25 +146,19 @@ public class StuScoreServiceImpl implements StuScoreService {
if (stuTrainingDto.getCaseStuScore() == null) { if (stuTrainingDto.getCaseStuScore() == null) {
stuTrainingDto.setCaseStuScore(BigDecimal.ZERO); stuTrainingDto.setCaseStuScore(BigDecimal.ZERO);
} else { } else {
//1.取出章节下的有所案例ID //1.取出章节下的有所案例ID
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = null; List<TestTestSysCaseQuestionStepWithBLOBs> stepList = groupedIds.get(sysCourseChapter.getThreeId());
try { List<String> stepIdList = stepList.stream().map(TestTestSysCaseQuestionStepWithBLOBs::getCaseStepId).collect(Collectors.toList());
stepList = CaseApi.selectCaseStepListBatchByIdListAndSort(sysCourseChapter.getThreeId());
} catch (IOException e) {
throw new RuntimeException("资源中心根据根据案例题IDS批量查询失败");
}
List<String> stepIdList = stepList.stream().map(TestSysCaseQuestionStep::getCaseStepId).collect(Collectors.toList());
//2.步骤表中所有得分之和 //2.步骤表中所有得分之和
BigDecimal rightTotalScore = stepList.stream() BigDecimal rightTotalScore = stepList.stream()
.map(TestTestSysCaseQuestionStepWithBLOBs::getScore) .map(TestTestSysCaseQuestionStepWithBLOBs::getScore)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
//3.记录表中所有ID得分之和 // 3.根据 stepIdList 筛选记录
StuTrainingStepRecordExample example =new StuTrainingStepRecordExample(); List<StuTrainingStepRecord> stuTrainingStepRecords = allRecordsMap.get(stuTrainingWithBLOBs.getUserId())
example.createCriteria().andCaseStepIdIn(stepIdList).andUserIdEqualTo(stuTrainingWithBLOBs.getUserId()); .stream().filter(record -> stepIdList.contains(record.getCaseStepId())).collect(Collectors.toList());
List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
double stuTotalScore = stuTrainingStepRecords.stream() //学生总共得分 double stuTotalScore = stuTrainingStepRecords.stream() //学生总共得分
.map(StuTrainingStepRecord::getScore) .map(StuTrainingStepRecord::getScore)
@ -174,8 +167,8 @@ public class StuScoreServiceImpl implements StuScoreService {
BigDecimal expTrainingWeight = stuTrainingDto.getExpTrainingWeight(); //实验实训权重 BigDecimal expTrainingWeight = stuTrainingDto.getExpTrainingWeight(); //实验实训权重
BigDecimal accuracy = BigDecimal.valueOf(stuTotalScore).divide(rightTotalScore,2,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).multiply(expTrainingWeight.divide(BigDecimal.valueOf(100))); BigDecimal accuracy = BigDecimal.valueOf(stuTotalScore).divide(rightTotalScore, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).multiply(expTrainingWeight.divide(BigDecimal.valueOf(100)));
if (accuracy.compareTo(expTrainingWeight)>0){ if (accuracy.compareTo(expTrainingWeight) > 0) {
accuracy = expTrainingWeight; accuracy = expTrainingWeight;
} }
//这里返回正确率 模块得分/模块案例满分*100*权重 //这里返回正确率 模块得分/模块案例满分*100*权重
@ -189,7 +182,7 @@ public class StuScoreServiceImpl implements StuScoreService {
BigDecimal learningEvalScore = stuTrainingDto.getLearningEvalScore(); BigDecimal learningEvalScore = stuTrainingDto.getLearningEvalScore();
BigDecimal learningEvalWeight = stuTrainingDto.getLearningEvalWeight(); BigDecimal learningEvalWeight = stuTrainingDto.getLearningEvalWeight();
BigDecimal weightLearningEvalScore = learningEvalWeight.multiply(learningEvalScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); BigDecimal weightLearningEvalScore = learningEvalWeight.multiply(learningEvalScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
if (weightLearningEvalScore.compareTo(learningEvalWeight)>0){ if (weightLearningEvalScore.compareTo(learningEvalWeight) > 0) {
weightLearningEvalScore = learningEvalWeight; weightLearningEvalScore = learningEvalWeight;
} }
stuTrainingDto.setLearningEvalScore(weightLearningEvalScore); stuTrainingDto.setLearningEvalScore(weightLearningEvalScore);
@ -197,13 +190,13 @@ public class StuScoreServiceImpl implements StuScoreService {
//学习资源 //学习资源
if (stuTrainingDto.getResourceLearningScore()==null){ if (stuTrainingDto.getResourceLearningScore() == null) {
stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO); stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO);
}else { } else {
BigDecimal resourceLearningScore = stuTrainingDto.getResourceLearningScore(); BigDecimal resourceLearningScore = stuTrainingDto.getResourceLearningScore();
BigDecimal resourceLearningWeight = stuTrainingDto.getResourceLearningWeight(); BigDecimal resourceLearningWeight = stuTrainingDto.getResourceLearningWeight();
BigDecimal weightresourceLearningScore = resourceLearningWeight.multiply(resourceLearningScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); BigDecimal weightresourceLearningScore = resourceLearningWeight.multiply(resourceLearningScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
if (weightresourceLearningScore.compareTo(resourceLearningWeight)>0){ if (weightresourceLearningScore.compareTo(resourceLearningWeight) > 0) {
weightresourceLearningScore = resourceLearningWeight; weightresourceLearningScore = resourceLearningWeight;
} }
stuTrainingDto.setResourceLearningScore(weightresourceLearningScore); stuTrainingDto.setResourceLearningScore(weightresourceLearningScore);
@ -216,7 +209,7 @@ public class StuScoreServiceImpl implements StuScoreService {
BigDecimal knowledgeSummaryScore = stuTrainingDto.getKnowledgeSummaryScore(); BigDecimal knowledgeSummaryScore = stuTrainingDto.getKnowledgeSummaryScore();
BigDecimal knowledgeSummaryWeight = stuTrainingDto.getKnowledgeSummaryWeight(); BigDecimal knowledgeSummaryWeight = stuTrainingDto.getKnowledgeSummaryWeight();
BigDecimal weightKnowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); BigDecimal weightKnowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
if (weightKnowledgeSummaryScore.compareTo(knowledgeSummaryWeight)>0){ if (weightKnowledgeSummaryScore.compareTo(knowledgeSummaryWeight) > 0) {
weightKnowledgeSummaryScore = knowledgeSummaryWeight; weightKnowledgeSummaryScore = knowledgeSummaryWeight;
} }
stuTrainingDto.setKnowledgeSummaryScore(weightKnowledgeSummaryScore); stuTrainingDto.setKnowledgeSummaryScore(weightKnowledgeSummaryScore);
@ -224,7 +217,7 @@ public class StuScoreServiceImpl implements StuScoreService {
// 设置报告相关数据 // 设置报告相关数据
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOBs.getReportId()); TrainingReport trainingReport = trainingReportMap.get(stuTrainingWithBLOBs.getReportId());
if (trainingReport == null) { if (trainingReport == null) {
stuTrainingDto.setReportCompleteStatus("未提交"); stuTrainingDto.setReportCompleteStatus("未提交");
stuTrainingDto.setReportScore(BigDecimal.ZERO); stuTrainingDto.setReportScore(BigDecimal.ZERO);
@ -232,7 +225,7 @@ public class StuScoreServiceImpl implements StuScoreService {
BigDecimal reportScore = trainingReport.getTeacherScore(); BigDecimal reportScore = trainingReport.getTeacherScore();
BigDecimal reportWeight = stuTrainingDto.getReportWeight(); BigDecimal reportWeight = stuTrainingDto.getReportWeight();
BigDecimal weightReportScore = reportScore.multiply(reportWeight).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); BigDecimal weightReportScore = reportScore.multiply(reportWeight).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
if (weightReportScore.compareTo(reportWeight)>0){ if (weightReportScore.compareTo(reportWeight) > 0) {
weightReportScore = reportWeight; weightReportScore = reportWeight;
} }
stuTrainingDto.setReportScore(weightReportScore); stuTrainingDto.setReportScore(weightReportScore);

@ -30,6 +30,7 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -80,7 +81,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
return list; return list;
} }
private List<TeaTrainingInfoDTO> getTrainingInfoDTOSNew(String schoolId, String systemOwner) { private List<TeaTrainingInfoDTO> getTrainingInfoDTOSNew(String schoolId, String systemOwner) throws IOException {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOSNew(schoolId, systemOwner); List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOSNew(schoolId, systemOwner);
assert !Objects.requireNonNull(list).isEmpty(); assert !Objects.requireNonNull(list).isEmpty();
list.sort(new TotalScoreComparator()); list.sort(new TotalScoreComparator());
@ -93,7 +94,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} }
private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOSNew(String schoolId, String systemOwner) { private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOSNew(String schoolId, String systemOwner) throws IOException {
StuUserExample example1 = new StuUserExample(); StuUserExample example1 = new StuUserExample();
example1.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOnwerEqualTo(systemOwner).andRoleIdEqualTo(4); example1.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOnwerEqualTo(systemOwner).andRoleIdEqualTo(4);
List<StuUser> stuUsers = userMapper.selectByExample(example1); List<StuUser> stuUsers = userMapper.selectByExample(example1);
@ -124,8 +125,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} }
// 实训记录按用户ID分组 // 实训记录按用户ID分组
Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId)); Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
List<String> chapterIdList = new ArrayList<>();
List<SysTwoCatalog> sysTwoCatalogs = new ArrayList<>(); List<SysTwoCatalog> sysTwoCatalogs = new ArrayList<>();
try { try {
@ -134,15 +133,9 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
e.printStackTrace(); e.printStackTrace();
} }
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { List<String> towIds = sysTwoCatalogs.stream().map(SysTwoCatalog::getTwoId).collect(Collectors.toList());
try { List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.callSelectThreeCatalogList(towIds, schoolId);
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId); List<String> chapterIdList = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
List<String> threeCatalogs = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
chapterIdList.addAll(threeCatalogs);
} catch (IOException e) {
e.printStackTrace();
}
}
//一次性取到所有案例题步骤,给实验实训算分用 //一次性取到所有案例题步骤,给实验实训算分用
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = new ArrayList<>(); List<TestTestSysCaseQuestionStepWithBLOBs> stepList = new ArrayList<>();
@ -215,7 +208,10 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId); sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample); List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0); SysWeight sysWeight = sysWeights.get(0);
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight();
// 遍历用户计算分数并封装DTO // 遍历用户计算分数并封装DTO
List<TeaTrainingInfoDTO> list = new ArrayList<>(); List<TeaTrainingInfoDTO> list = new ArrayList<>();
for (StuUser stuUser : stuUsers) { for (StuUser stuUser : stuUsers) {
@ -241,7 +237,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
totalScore = totalScore.add(reportScore); totalScore = totalScore.add(reportScore);
} }
} }
BigDecimal moduleScore = getModuleScore(training, sysWeight, map, map1, resultMap); BigDecimal moduleScore = getModuleScore(training, knowledgeSummaryWeight, resourceLearningWeight, learningEvalWeight, expTrainingWeight, map, map1, resultMap);
totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP); totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP);
} }
//综合得分 //综合得分
@ -393,15 +389,57 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
@Override @Override
public List<StuTrainingDto> getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) { public List<StuTrainingDto> getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) throws IOException {
List<StuTrainingDto> list = new ArrayList<>(); List<StuTrainingDto> list = new ArrayList<>();
List<SysTwoCatalog> sysTwoCatalogs = null;
try {
sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
} catch (IOException e) {
e.printStackTrace();
}
StuTrainingExample stuTrainingExample = new StuTrainingExample(); StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdEqualTo(userId); stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
Map<String, SysThreeCatalog> chapterMap = new HashMap<>(); Map<String, SysThreeCatalog> chapterMap = new HashMap<>();
List<String> reportIds = stuTrainings.stream().map(StuTraining::getReportId).collect(Collectors.toList());
TrainingReportExample trainingReportExample = new TrainingReportExample();
trainingReportExample.createCriteria().andReportIdIn(reportIds);
List<TrainingReport> trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample);
//提前查出所有report对象
Map<String, TrainingReport> trainingReportMap = trainingReports.stream()
.collect(Collectors.toMap(TrainingReport::getReportId, Function.identity()));
List<String> twoIds = sysTwoCatalogs.stream().map(SysTwoCatalog::getTwoId).collect(Collectors.toList());
//提前查出权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andCourseIdIn(twoIds)
.andSchoolIdEqualTo(schoolId)
.andSystemOwnerEqualTo(systemOwner);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
Map<String, SysWeight> weightMap = sysWeights.stream().collect(Collectors.toMap(SysWeight::getCourseId, Function.identity()));
//一次查出所有章节下的案例步骤
List<SysThreeCatalog> allChapterId = CourseAPI.callSelectThreeCatalogList(twoIds, schoolId);
List<String> ids = allChapterId.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = CaseApi.selectCaseStepByThreeIds(ids);
Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds = stepList.stream()
.filter(step -> step.getThreeId() != null) // 过滤掉 threeId 为 null 的对象
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId)); // 按 threeId 分组
//一次查出所有的记录表
StuTrainingStepRecordExample example = new StuTrainingStepRecordExample();
example.createCriteria().andUserIdEqualTo(userId); // 批量查询用户记录
List<StuTrainingStepRecord> allRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
Map<String, List<StuTrainingStepRecord>> allRecordsMap = allRecords.stream()
.collect(Collectors.groupingBy(StuTrainingStepRecord::getUserId)); // 按 threeId 分组
try { try {
for (StuTrainingWithBLOBs stuTraining : stuTrainings) { for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
String chapterId = stuTraining.getChapterId(); String chapterId = stuTraining.getChapterId();
@ -412,7 +450,8 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} }
StuTrainingDto stuTrainingDto = new StuTrainingDto(); StuTrainingDto stuTrainingDto = new StuTrainingDto();
stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName());
list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter)); list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter,
trainingReportMap, weightMap, groupedIds, allRecordsMap));
} }
return list; return list;
} catch (Exception e) { } catch (Exception e) {
@ -421,13 +460,9 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} }
//计算模块得分 章节下所有的案例步骤得分之和 / 章节下所有的案例步骤满分 //计算模块得分 章节下所有的案例步骤得分之和 / 章节下所有的案例步骤满分
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight, private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, BigDecimal knowledgeSummaryWeight, BigDecimal resourceLearningWeight,
BigDecimal learningEvalWeight, BigDecimal expTrainingWeight,
Map<String, List<String>> map, Map<String, List<BigDecimal>> map1, Map<String, Map<String, BigDecimal>> resultMap) { Map<String, List<String>> map, Map<String, List<BigDecimal>> map1, Map<String, Map<String, BigDecimal>> resultMap) {
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight();
BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO); BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO);
BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO); BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO);
BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO); BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO);
@ -585,14 +620,72 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
public void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException { public void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException {
List<TeaTrainingInfoDTO> trainingInfoDTOSNew = getTrainingInfoDTOSNew(schoolId, systemOwner); List<TeaTrainingInfoDTO> trainingInfoDTOSNew = getTrainingInfoDTOSNew(schoolId, systemOwner);
List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId); List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
List<SysThreeCatalog> allChapterId = new ArrayList<>(); List<String> twoIds = sysTwoCatalogs.stream().map(SysTwoCatalog::getTwoId).collect(Collectors.toList());
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { List<SysThreeCatalog> allChapterId = CourseAPI.callSelectThreeCatalogList(twoIds, schoolId);
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
allChapterId.addAll(sysThreeCatalogs);
}
Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog)); Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog));
List<ExcelDto> excelDtos = new ArrayList<>(); List<ExcelDto> excelDtos = new ArrayList<>();
// 1. 提取所有的 userId
Set<String> userIds = trainingInfoDTOSNew.stream()
.map(TeaTrainingInfoDTO::getUserId)
.collect(Collectors.toSet());
// 2. 基于 userId 查询所有的 StuTrainingWithBLOBs
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds));
List<StuTrainingWithBLOBs> stuTrainingsByUser = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
// 3. 将 stuTrainings 按照 userId 分组
Map<String, List<StuTrainingWithBLOBs>> trainingsByUserId = stuTrainingsByUser.stream()
.collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
//提前查出权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andCourseIdIn(twoIds)
.andSchoolIdEqualTo(schoolId)
.andSystemOwnerEqualTo(systemOwner);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
Map<String, SysWeight> weightMap = sysWeights.stream().collect(Collectors.toMap(SysWeight::getCourseId, Function.identity()));
// 4. 提前收集所有的 reportId
Set<String> allReportIds = new HashSet<>();
for (List<StuTrainingWithBLOBs> stuTrainings : trainingsByUserId.values()) {
List<String> reportIds = stuTrainings.stream().map(StuTraining::getReportId).collect(Collectors.toList());
allReportIds.addAll(reportIds);
}
// 5. 基于 reportId 查询所有的 TrainingReport
TrainingReportExample trainingReportExample = new TrainingReportExample();
trainingReportExample.createCriteria().andReportIdIn(new ArrayList<>(allReportIds));
List<TrainingReport> trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample);
// 6. 将 trainingReports 按照 reportId 分组
Map<String, TrainingReport> trainingReportMap = trainingReports.stream()
.collect(Collectors.toMap(TrainingReport::getReportId, Function.identity()));
//一次查出所有三级目录
List<String> ids = allChapterId.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectChapterByIdList(ids);
Map<String, SysThreeCatalog> sysThreeCatalogsMap = sysThreeCatalogs.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, Function.identity()));
//一次查出所有章节下的案例步骤
List<TestTestSysCaseQuestionStepWithBLOBs> list = CaseApi.selectCaseStepByThreeIds(ids);
Map<String, List<TestTestSysCaseQuestionStepWithBLOBs>> groupedIds = list.stream()
.filter(step -> step.getThreeId() != null) // 过滤掉 threeId 为 null 的对象
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId)); // 按 threeId 分组
//一次查出所有的记录表
StuTrainingStepRecordExample example = new StuTrainingStepRecordExample();
example.createCriteria().andUserIdIn(new ArrayList<>(userIds)); // 批量查询用户记录
List<StuTrainingStepRecord> allRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
Map<String, List<StuTrainingStepRecord>> allRecordsMap = allRecords.stream()
.collect(Collectors.groupingBy(StuTrainingStepRecord::getUserId)); // 按 threeId 分组
for (TeaTrainingInfoDTO teaTrainingInfoDTO : trainingInfoDTOSNew) { for (TeaTrainingInfoDTO teaTrainingInfoDTO : trainingInfoDTOSNew) {
ExcelDto excelDto = new ExcelDto(); ExcelDto excelDto = new ExcelDto();
excelDto.setProgress(teaTrainingInfoDTO.getProgress()); excelDto.setProgress(teaTrainingInfoDTO.getProgress());
@ -602,25 +695,19 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
excelDto.setTotalScore(teaTrainingInfoDTO.getTotalScore()); excelDto.setTotalScore(teaTrainingInfoDTO.getTotalScore());
String userId = teaTrainingInfoDTO.getUserId(); String userId = teaTrainingInfoDTO.getUserId();
StuTrainingExample stuTrainingExample = new StuTrainingExample(); // 根据 userId 获取对应的 StuTrainingWithBLOBs 列表
stuTrainingExample.createCriteria().andUserIdEqualTo(userId); List<StuTrainingWithBLOBs> stuTrainings = trainingsByUserId.get(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
LinkedHashMap<String, BigDecimal> map = new LinkedHashMap<>(); LinkedHashMap<String, BigDecimal> map = new LinkedHashMap<>();
LinkedHashMap<String, SysThreeCatalog> chapterMap = new LinkedHashMap<>();
for (StuTrainingWithBLOBs stuTraining : stuTrainings) { for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
String chapterId = stuTraining.getChapterId(); String chapterId = stuTraining.getChapterId();
SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId); SysThreeCatalog sysThreeCatalog = sysThreeCatalogsMap.get(chapterId);
if (sysCourseChapter == null) {
sysCourseChapter = CourseAPI.selectChapterByChapterId(chapterId);
chapterMap.put(chapterId, sysCourseChapter);
}
StuTrainingDto stuTrainingDto = new StuTrainingDto(); StuTrainingDto stuTrainingDto = new StuTrainingDto();
stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); stuTrainingDto.setTaskModule(sysThreeCatalog.getThreeName());
StuTrainingDto scoreByChapterId = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter); StuTrainingDto scoreByChapterId = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining,
stuTrainingDto, sysThreeCatalog, trainingReportMap, weightMap, groupedIds, allRecordsMap);
BigDecimal moduleScore = scoreByChapterId.getModuleScore(); BigDecimal moduleScore = scoreByChapterId.getModuleScore();
String taskModule = scoreByChapterId.getTaskModule(); String taskModule = scoreByChapterId.getTaskModule();
@ -693,14 +780,13 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
e.printStackTrace(); e.printStackTrace();
} }
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { List<String> twoIds = sysTwoCatalogs.stream().map(SysTwoCatalog::getTwoId).collect(Collectors.toList());
try {
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId); try {
List<String> threeCatalogs = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList()); List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.callSelectThreeCatalogList(twoIds, schoolId);
chapterIdList.addAll(threeCatalogs); chapterIdList = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}
} }
//一次性取到所有案例题步骤,给实验实训算分用 //一次性取到所有案例题步骤,给实验实训算分用
@ -775,6 +861,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample); List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0); SysWeight sysWeight = sysWeights.get(0);
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight();
// 遍历用户计算分数并封装DTO // 遍历用户计算分数并封装DTO
List<TeaTrainingInfoDTO> list = new ArrayList<>(); List<TeaTrainingInfoDTO> list = new ArrayList<>();
for (StuUser stuUser : stuUsers) { for (StuUser stuUser : stuUsers) {
@ -800,7 +891,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
totalScore = totalScore.add(reportScore); totalScore = totalScore.add(reportScore);
} }
} }
BigDecimal moduleScore = getModuleScore(training, sysWeight, map, map1, resultMap); BigDecimal moduleScore = getModuleScore(training, knowledgeSummaryWeight, resourceLearningWeight, learningEvalWeight, expTrainingWeight, map, map1, resultMap);
totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP); totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP);
} }
//综合得分 //综合得分

@ -60,6 +60,54 @@ public class HttpUtils {
return response.toString(); return response.toString();
} }
public static JSONObject sendPostNew(String url, String paramStr) throws IOException {
try {
JSONObject ret = new JSONObject();
HttpPost method = new HttpPost(url);
// 使用 UTF-8 编码
StringEntity entity = new StringEntity(paramStr, "utf-8");
entity.setContentType("application/json"); // 直接设置为 JSON 类型
method.setEntity(entity);
// 设置请求超时
int timeout = 60000;
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.build();
method.setConfig(requestConfig);
// 创建 HttpClient
HttpClient client = HttpClients.createDefault();
HttpResponse resp = client.execute(method);
int statusCode = resp.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
log.info("接口请求失败,返回码:" + statusCode + ",失败原因:" + resp.getStatusLine().getReasonPhrase());
return null;
}
// 读取响应内容
String respString = EntityUtils.toString(resp.getEntity(), "UTF-8");
ret.put("statusCode", statusCode);
if (StringUtils.isNotEmpty(respString)) {
ret.put("respString", respString);
}
return ret;
} catch (Exception e) {
e.printStackTrace();
log.info("接口请求失败,失败原因:" + e.getMessage());
}
return null;
}
// 发送POST请求 // 发送POST请求
public static JSONObject sendPost(String url, String paramStr) throws IOException { public static JSONObject sendPost(String url, String paramStr) throws IOException {
try { try {

Loading…
Cancel
Save