|
@@ -7,14 +7,12 @@ import com.nuliji.tools.exception.ParameterException;
|
|
|
import com.nuliji.tools.exception.SystemException;
|
|
|
import com.qxgmat.data.constants.enums.QuestionType;
|
|
|
import com.qxgmat.data.constants.enums.SettingKey;
|
|
|
-import com.qxgmat.data.constants.enums.module.FeedbackModule;
|
|
|
import com.qxgmat.data.constants.enums.module.PaperModule;
|
|
|
import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
import com.qxgmat.data.constants.enums.status.DirectionStatus;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
-import com.qxgmat.data.relation.entity.UserCollectQuestionRelation;
|
|
|
-import com.qxgmat.data.relation.entity.UserNoteQuestionRelation;
|
|
|
-import com.qxgmat.dto.extend.UserReportExtendDto;
|
|
|
+import com.qxgmat.data.relation.entity.*;
|
|
|
+import com.qxgmat.dto.extend.*;
|
|
|
import com.qxgmat.dto.request.*;
|
|
|
import com.qxgmat.dto.request.UserNoteDto;
|
|
|
import com.qxgmat.dto.response.*;
|
|
@@ -60,6 +58,15 @@ public class MyController {
|
|
|
private ShiroHelp shiroHelp;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ExerciseStructService exerciseStructService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassCourseService classCourseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassCourseNoService classCourseNoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private UsersService usersService;
|
|
|
|
|
|
@Autowired
|
|
@@ -69,7 +76,10 @@ public class MyController {
|
|
|
private SettingService settingService;
|
|
|
|
|
|
@Autowired
|
|
|
- private StatDayService statDayService;
|
|
|
+ private UserCourseRecordService userCourseRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserSentenceRecordService userSentenceRecordService;
|
|
|
|
|
|
@Autowired
|
|
|
private QuestionNoService questionNoService;
|
|
@@ -208,20 +218,91 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/study", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取学习记录", notes = "获取选择那天的做题信息", httpMethod = "GET")
|
|
|
- public Response<JSONObject> studyTime(
|
|
|
+ public Response<UserStudyDayDto> studyTime(
|
|
|
@RequestParam(required = false) String date
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ Date day;
|
|
|
try {
|
|
|
- Date day = DateFormat.getDateInstance().parse(date);
|
|
|
+ day = DateFormat.getDateInstance().parse(date);
|
|
|
} catch (ParseException e) {
|
|
|
throw new ParameterException("日期格式错误");
|
|
|
}
|
|
|
- UserStudyDetailDto dto = new UserStudyDetailDto();
|
|
|
+ Date endDay = Tools.addDate(day, 1);
|
|
|
+ String startTime = day.toString();
|
|
|
+ String endTime = endDay.toString();
|
|
|
+ UserStudyDayDto dto = new UserStudyDayDto();
|
|
|
+
|
|
|
+ List<ExerciseStruct> p = exerciseStructService.main();
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
+ for (ExerciseStruct struct : p){
|
|
|
+ if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
|
|
|
+ m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
|
|
|
+ }
|
|
|
|
|
|
- // todo 获取学习统计
|
|
|
+ // 获取练习统计 - 按题型进行分组统计
|
|
|
+ Integer exerciseTime = 0;
|
|
|
+ Integer exerciseQuestion = 0;
|
|
|
+ List<UserExerciseExtendDto> exerciseList = new ArrayList<>();
|
|
|
+ List<UserStudyStatRelation> typeList = userReportService.statGroupExerciseType(user.getId(), startTime, endTime);
|
|
|
+ for(UserStudyStatRelation type:typeList){
|
|
|
+ exerciseTime += type.getUserTime();
|
|
|
+ exerciseQuestion += type.getUserNumber();
|
|
|
+ exerciseList.add(new UserExerciseExtendDto(m.get(type.getModule()), type.getUserNumber(), type.getUserTime(), type.getUserCorrect()));
|
|
|
+ }
|
|
|
+ // todo 练习统计排行
|
|
|
+
|
|
|
+ dto.setExerciseTime(exerciseTime);
|
|
|
+ dto.setExerciseQuestion(exerciseQuestion);
|
|
|
+ dto.setExerciseList(exerciseList);
|
|
|
+
|
|
|
+ // 获取模考统计 - 按卷子
|
|
|
+ Integer examinationTime = 0;
|
|
|
+ Integer examinationPaper = 0;
|
|
|
+ List<UserReport> userReportList = userReportService.getByModule(user.getId(), PaperModule.EXAMINATION, startTime, endTime);
|
|
|
+ Collection paperIds = Transform.getIds(userReportList, UserReport.class, "paperId");
|
|
|
+ List<UserPaper> userPaperList = userPaperService.select(paperIds);
|
|
|
+ Map userPaper = Transform.getMap(userPaperList, UserPaper.class, "id");
|
|
|
+ List<UserPaperBaseExtendDto> examinationPaperList = new ArrayList<>(userReportList.size());
|
|
|
+ for(UserReport report: userReportList){
|
|
|
+ examinationTime += report.getUserTime();
|
|
|
+ examinationPaper += 1;
|
|
|
+ UserPaperBaseExtendDto d = Transform.convert(userPaper.get(report.getPaperId()), UserPaperBaseExtendDto.class);
|
|
|
+ d.setReport(Transform.convert(report, UserReportExtendDto.class));
|
|
|
+ examinationPaperList.add(d);
|
|
|
+ }
|
|
|
+ // todo 模考统计排行
|
|
|
+
|
|
|
+ dto.setExaminationTime(examinationTime);
|
|
|
+ dto.setExaminationPaper(examinationPaper);
|
|
|
+ dto.setExaminationList(examinationPaperList);
|
|
|
+
|
|
|
+ // 获取课程访问记录 - 按课时
|
|
|
+ Integer classTime = 0;
|
|
|
+ Integer classCourse = 0;
|
|
|
+ List<UserCourseRecord> userCourseRecordList = userCourseRecordService.getByTime(user.getId(), startTime, endTime);
|
|
|
+ Collection courseIds = Transform.getIds(userCourseRecordList, UserCourseRecord.class, "courseId");
|
|
|
+ Collection courseNoIds = Transform.getIds(userCourseRecordList, UserCourseRecord.class, "noId");
|
|
|
+ List<ClassCourse> classCourseList = classCourseService.select(courseIds);
|
|
|
+ Map classCourseMap = Transform.getMap(classCourseList, ClassCourse.class, "id", "title");
|
|
|
+ List<ClassCourseNo> classCourseNoList = classCourseNoService.select(courseNoIds);
|
|
|
+ Map classCourseNoMap = Transform.getMap(classCourseNoList, ClassCourseNo.class, "id", "content");
|
|
|
+ List<UserCourseResultExtendDto> courseResultList = new ArrayList<>(userCourseRecordList.size());
|
|
|
+ for(UserCourseRecord record:userCourseRecordList){
|
|
|
+ classTime += record.getUserTime();
|
|
|
+ classCourse += 1;
|
|
|
+ UserCourseResultExtendDto d = Transform.convert(record, UserCourseResultExtendDto.class);
|
|
|
+ d.setTitle((String)classCourseMap.get(record.getCourseId()));
|
|
|
+ d.setContent((String)classCourseNoMap.get(record.getCourseNoId()));
|
|
|
+ courseResultList.add(d);
|
|
|
+ }
|
|
|
+ // todo 听课统计排行
|
|
|
+
|
|
|
+ dto.setClassTime(classTime);
|
|
|
+ dto.setClassCourse(classCourse);
|
|
|
+ dto.setClassList(courseResultList);
|
|
|
|
|
|
- return ResponseHelp.success(null);
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/study/total", method = RequestMethod.GET)
|
|
@@ -232,24 +313,109 @@ public class MyController {
|
|
|
dto.setCreateTime(user.getCreateTime());
|
|
|
dto.setDays((int)((user.getCreateTime().getTime() - new Date().getTime()) / (1000*3600*24)));
|
|
|
Integer totalTime = 0;
|
|
|
- // todo 获取学习统计 - 按练习学科(第2层)统计
|
|
|
- userReportService.statByModule(user.getId(), PaperModule.EXAMINATION.key, "","");
|
|
|
+ Map<String, Integer> categoryMap = new HashMap<>();
|
|
|
+ // 按模块类型分组查询: module=> sentence, examination, collect+error, 忽略exercise
|
|
|
+ List<UserStudyStatRelation> moduleList = userReportService.statGroupModule(user.getId());
|
|
|
+ for(UserStudyStatRelation module:moduleList){
|
|
|
+ // 练习时间过滤
|
|
|
+ if (module.getModule().equals(PaperModule.EXERCISE.key)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Integer time = module.getUserTime();
|
|
|
+ String key = module.getModule();
|
|
|
+ totalTime += time;
|
|
|
+ // 收藏及错误组卷合并
|
|
|
+ if (module.getModule().equals(PaperModule.COLLECT.key)
|
|
|
+ || module.getModule().equals(PaperModule.ERROR.key)){
|
|
|
+ key = "freedom";
|
|
|
+ time += categoryMap.getOrDefault(key, 0);
|
|
|
+ }
|
|
|
+ categoryMap.put(key, time);
|
|
|
+ }
|
|
|
+ // 按题型统计练习
|
|
|
+ List<UserStudyStatRelation> typeList = userReportService.statGroupExerciseType(user.getId(), null, null);
|
|
|
+ for(UserStudyStatRelation type:typeList){
|
|
|
+ totalTime += type.getUserTime();
|
|
|
+ categoryMap.put(type.getModule(), type.getUserTime());
|
|
|
+ }
|
|
|
+ // 按题型统计课程
|
|
|
+ List<UserCourseStatRelation> recordList = userCourseRecordService.statGroupType(user.getId(), null, null);
|
|
|
+ for (UserCourseStatRelation record : recordList){
|
|
|
+ totalTime += record.getUserTime();
|
|
|
+ // 累加同类型时间
|
|
|
+ Integer time = categoryMap.getOrDefault(record.getModule(), 0);
|
|
|
+ categoryMap.put(record.getModule(), time);
|
|
|
+ }
|
|
|
+ // 获取长难句阅读统计
|
|
|
+ UserSentenceStatRelation sentenceStatRelation = userSentenceRecordService.stat(user.getId(), null, null);
|
|
|
+ if (sentenceStatRelation != null){
|
|
|
+ Integer sentenceTime = categoryMap.getOrDefault(PaperModule.SENTENCE.key, 0);
|
|
|
+ categoryMap.put(PaperModule.SENTENCE.key, sentenceTime + sentenceStatRelation.getUserTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExerciseStruct> p = exerciseStructService.main();
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
+ for (ExerciseStruct struct : p){
|
|
|
+ if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
|
|
|
+ m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装数据
|
|
|
+ List<UserStudyExtendDto> categorys = new ArrayList<>();
|
|
|
+ if (categoryMap.containsKey(PaperModule.SENTENCE.key)) categorys.add(new UserStudyExtendDto(m.get(PaperModule.SENTENCE.key), categoryMap.get(PaperModule.SENTENCE.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.SC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.SC.key), categoryMap.get(QuestionType.SC.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.RC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.RC.key), categoryMap.get(QuestionType.RC.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.CR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.CR.key), categoryMap.get(QuestionType.CR.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.PS.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.PS.key), categoryMap.get(QuestionType.PS.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.DS.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.DS.key), categoryMap.get(QuestionType.DS.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.IR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.IR.key), categoryMap.get(QuestionType.IR.key)));
|
|
|
+ if (categoryMap.containsKey(QuestionType.AWA.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.AWA.key), categoryMap.get(QuestionType.AWA.key)));
|
|
|
+ if (categoryMap.containsKey(PaperModule.EXAMINATION.key)) categorys.add(new UserStudyExtendDto("模考", categoryMap.get(PaperModule.EXAMINATION.key)));
|
|
|
+ if (categoryMap.containsKey("freedom")) categorys.add(new UserStudyExtendDto("自由组卷", categoryMap.get("freedom")));
|
|
|
|
|
|
dto.setTime(totalTime);
|
|
|
+ dto.setCategorys(categorys);
|
|
|
return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/data", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取做题数据", notes = "获取做题数据", httpMethod = "GET")
|
|
|
- public Response<JSONObject> questionData(
|
|
|
+ public Response<UserStudyDayDto> questionData(
|
|
|
@RequestParam(required = false) String startTime,
|
|
|
@RequestParam(required = false) String endTime
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserStudyDayDto dto = new UserStudyDayDto();
|
|
|
|
|
|
- // todo 获取学习统计 - 按题型进行分组统计
|
|
|
+ List<ExerciseStruct> p = exerciseStructService.main();
|
|
|
+ Map<String, String> m = new HashMap<>();
|
|
|
+ for (ExerciseStruct struct : p){
|
|
|
+ if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
|
|
|
+ m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取练习统计 - 按题型进行分组统计
|
|
|
+ Integer exerciseTime = 0;
|
|
|
+ Integer exerciseQuestion = 0;
|
|
|
+ List<UserExerciseExtendDto> exerciseList = new ArrayList<>();
|
|
|
+ List<UserStudyStatRelation> typeList = userReportService.statGroupExerciseType(user.getId(), startTime, endTime);
|
|
|
+ for(UserStudyStatRelation type:typeList){
|
|
|
+ exerciseTime += type.getUserTime();
|
|
|
+ exerciseQuestion += type.getUserNumber();
|
|
|
+ exerciseList.add(new UserExerciseExtendDto(m.get(type.getModule()), type.getUserNumber(), type.getUserTime(), type.getUserCorrect()));
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setExerciseTime(exerciseTime);
|
|
|
+ dto.setExerciseQuestion(exerciseQuestion);
|
|
|
+ dto.setExerciseList(exerciseList);
|
|
|
|
|
|
- return ResponseHelp.success(null);
|
|
|
+ // 获取模考统计 - 按卷子
|
|
|
+
|
|
|
+ // 获取课程访问记录 - 按课时
|
|
|
+ Integer classTime = 0;
|
|
|
+ Integer classCourse = 0;
|
|
|
+
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/collect", method = RequestMethod.PUT)
|