|
@@ -1,5 +1,8 @@
|
|
|
package com.ruoyi.web.controller.front;
|
|
package com.ruoyi.web.controller.front;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
|
|
+import cn.hutool.core.lang.Dict;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
@@ -37,7 +40,6 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.validation.ValidationException;
|
|
import javax.validation.ValidationException;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -181,14 +183,14 @@ public class FrontStudentController extends BaseController {
|
|
|
@GetMapping("plan")
|
|
@GetMapping("plan")
|
|
|
public AjaxResult getPlan()
|
|
public AjaxResult getPlan()
|
|
|
{
|
|
{
|
|
|
- return AjaxResult.success(getCurrLearnPlan());
|
|
|
|
|
|
|
+ return AjaxResult.success(learnPlanService.getCurrLearnPlan());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("11 保存学习计划")
|
|
@ApiOperation("11 保存学习计划")
|
|
|
@PostMapping("plan")
|
|
@PostMapping("plan")
|
|
|
public AjaxResult savePlan(@RequestBody LearnPlan plan)
|
|
public AjaxResult savePlan(@RequestBody LearnPlan plan)
|
|
|
{
|
|
{
|
|
|
- LearnPlan curr = getCurrLearnPlan();
|
|
|
|
|
|
|
+ LearnPlan curr = learnPlanService.getCurrLearnPlan();
|
|
|
Date today = DateUtils.truncate(new Date(), Calendar.DATE);
|
|
Date today = DateUtils.truncate(new Date(), Calendar.DATE);
|
|
|
if(null != curr) {
|
|
if(null != curr) {
|
|
|
if(curr.getStatus().equals(1)) {
|
|
if(curr.getStatus().equals(1)) {
|
|
@@ -218,7 +220,10 @@ public class FrontStudentController extends BaseController {
|
|
|
@GetMapping("plan/stats")
|
|
@GetMapping("plan/stats")
|
|
|
public AjaxResult getPlanStats(@ApiParam String reportMonth)
|
|
public AjaxResult getPlanStats(@ApiParam String reportMonth)
|
|
|
{
|
|
{
|
|
|
- LearnPlan curr = getCurrLearnPlan();
|
|
|
|
|
|
|
+ LearnPlan curr = learnPlanService.getCurrLearnPlan();
|
|
|
|
|
+ if(null == curr) {
|
|
|
|
|
+ throw new RuntimeException("未配置学习计划");
|
|
|
|
|
+ }
|
|
|
// 统计每天的学习情况, 再汇总
|
|
// 统计每天的学习情况, 再汇总
|
|
|
LearnPlanStudy cond = new LearnPlanStudy();
|
|
LearnPlanStudy cond = new LearnPlanStudy();
|
|
|
cond.setStudentId(SecurityUtils.getLoginUser().getUserId());
|
|
cond.setStudentId(SecurityUtils.getLoginUser().getUserId());
|
|
@@ -227,48 +232,48 @@ public class FrontStudentController extends BaseController {
|
|
|
} catch (ParseException e) {
|
|
} catch (ParseException e) {
|
|
|
throw new ValidationException("日期格式错误");
|
|
throw new ValidationException("日期格式错误");
|
|
|
}
|
|
}
|
|
|
- List<LearnPlanStudy> studyList = learnPlanStudyService.selectLearnPlanStudyList(cond);
|
|
|
|
|
|
|
+ List<LearnPlanStudy> studyList = learnPlanStudyService.selectPlanStudyStats(cond);
|
|
|
Integer doneDay = 0;
|
|
Integer doneDay = 0;
|
|
|
Long videoTimes = 0L;
|
|
Long videoTimes = 0L;
|
|
|
Long questionCnt = 0L;
|
|
Long questionCnt = 0L;
|
|
|
- Date today = new Date();
|
|
|
|
|
- List<JSONObject> todayStudyList = Lists.newArrayList();
|
|
|
|
|
- JSONObject todayStudy = null;
|
|
|
|
|
|
|
+ List<Dict> monthStudyList = Lists.newArrayList();
|
|
|
|
|
+ Date firstDate = null;
|
|
|
for(LearnPlanStudy study : studyList) {
|
|
for(LearnPlanStudy study : studyList) {
|
|
|
JSONObject planStudy = toStudyStats(study);
|
|
JSONObject planStudy = toStudyStats(study);
|
|
|
- if(!study.getReportDate().before(today)) { // 今天
|
|
|
|
|
- doneDay++;
|
|
|
|
|
|
|
+ doneDay++;
|
|
|
|
|
+ if(null != study.getVideoTime()) {
|
|
|
videoTimes += study.getVideoTime();
|
|
videoTimes += study.getVideoTime();
|
|
|
- questionCnt = study.getQuestionCount();
|
|
|
|
|
- } else {
|
|
|
|
|
- todayStudy = planStudy;
|
|
|
|
|
}
|
|
}
|
|
|
- todayStudyList.add(planStudy);
|
|
|
|
|
|
|
+ if(null != study.getQuestionCount()) {
|
|
|
|
|
+ questionCnt += study.getQuestionCount();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(null == firstDate) {
|
|
|
|
|
+ firstDate = study.getReportDate();
|
|
|
|
|
+ }
|
|
|
|
|
+ monthStudyList.add(Dict.create().set("date", DateUtil.format(study.getReportDate(), "yyyy-MM-dd")).set("data", planStudy));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Integer preDay = 0;
|
|
|
|
|
- if(DateUtils.isSameDay(cond.getReportDate(), DateUtils.truncate(curr.getBeginTime(), Calendar.MONTH))) {
|
|
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
|
|
- cal.setTime(curr.getBeginTime());
|
|
|
|
|
- preDay = cal.get(Calendar.DAY_OF_MONTH) - 1;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Integer preDay = 0; // 同月的排队计划开始之前的 历史月不好计算,待定 TODO MF
|
|
|
|
|
+// if(DateUtils.isSameDay(DateUtils.truncate(cond.getReportDate(), Calendar.MONTH), DateUtils.truncate(curr.getBeginTime(), Calendar.MONTH))) {
|
|
|
|
|
+// Calendar cal = Calendar.getInstance();
|
|
|
|
|
+// cal.setTime(curr.getBeginTime());
|
|
|
|
|
+// preDay = cal.get(Calendar.DAY_OF_MONTH) - 1;
|
|
|
|
|
+// }
|
|
|
JSONObject stats = new JSONObject();
|
|
JSONObject stats = new JSONObject();
|
|
|
stats.put("doneDay", doneDay);
|
|
stats.put("doneDay", doneDay);
|
|
|
- stats.put("unDoneDay", LocalDate.now().getDayOfMonth() - doneDay - preDay);
|
|
|
|
|
|
|
+ stats.put("undoneDay", LocalDateTimeUtil.of(cond.getReportDate()).getDayOfMonth() - doneDay - preDay);
|
|
|
stats.put("videoTimes", videoTimes);
|
|
stats.put("videoTimes", videoTimes);
|
|
|
stats.put("questionCnt", questionCnt);
|
|
stats.put("questionCnt", questionCnt);
|
|
|
- stats.put("studyList", todayStudyList);
|
|
|
|
|
- stats.put("today", todayStudy);
|
|
|
|
|
- stats.put("plan", curr);
|
|
|
|
|
|
|
+ stats.put("studyList", monthStudyList);
|
|
|
return AjaxResult.success(stats);
|
|
return AjaxResult.success(stats);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private JSONObject toStudyStats(LearnPlanStudy todayStudy) {
|
|
private JSONObject toStudyStats(LearnPlanStudy todayStudy) {
|
|
|
JSONObject study = new JSONObject();
|
|
JSONObject study = new JSONObject();
|
|
|
study.put("questionCnt", todayStudy.getQuestionCount());
|
|
study.put("questionCnt", todayStudy.getQuestionCount());
|
|
|
- study.put("videoTime", todayStudy.getVideoTime());
|
|
|
|
|
|
|
+ study.put("videoTime", todayStudy.getVideoCount());
|
|
|
study.put("videoTimes", todayStudy.getVideoTime());
|
|
study.put("videoTimes", todayStudy.getVideoTime());
|
|
|
- study.put("rightRate", "0");
|
|
|
|
|
|
|
+ study.put("rightRate", Math.round((float)(todayStudy.getRightCount() * 100 / todayStudy.getQuestionCount())));
|
|
|
return study;
|
|
return study;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -339,16 +344,4 @@ public class FrontStudentController extends BaseController {
|
|
|
result.put("list", list);
|
|
result.put("list", list);
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private LearnPlan getCurrLearnPlan() {
|
|
|
|
|
- LearnPlan cond = new LearnPlan();
|
|
|
|
|
- cond.setStudentId(SecurityUtils.getLoginUser().getUserId());
|
|
|
|
|
- cond.setStatus(1);
|
|
|
|
|
- List<LearnPlan> planList = learnPlanService.selectLearnPlanList(cond);
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(planList)) {
|
|
|
|
|
- return planList.get(0);
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|