|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.util.DateUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
+import com.ruoyi.common.utils.NumberUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.learn.domain.LearnStudent;
|
|
|
import com.ruoyi.learn.mapper.LearnAnswerMapper;
|
|
|
@@ -12,10 +13,7 @@ import com.ruoyi.learn.service.ILearnStudentService;
|
|
|
import com.ruoyi.mingxue.mapper.CustomerVideoWatchesMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class LearnStatService {
|
|
|
@@ -33,7 +31,8 @@ public class LearnStatService {
|
|
|
|
|
|
public List<JSONObject> getRecordKnowledge(Long studentId) {
|
|
|
LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(studentId);
|
|
|
- Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(new Long[] { learnStudent.getMajorPlanId() }) : Sets.newHashSet(0L);
|
|
|
+ Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(new Long[] { learnStudent.getMajorPlanId() }) : Sets.newHashSet();
|
|
|
+ knowledgeIdSet.add(0L);
|
|
|
List<JSONObject> list = answerMapper.selectKnowledgeStats(Dict.create().set("studentId", studentId).set("knowIds", knowledgeIdSet));
|
|
|
list.forEach(o -> {
|
|
|
o.put("directed", "1".equals(o.get("directed")));
|
|
|
@@ -56,13 +55,30 @@ public class LearnStatService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public JSONObject getRecordPlanStudy(Long studentId, Date date) {
|
|
|
- Map cond = Dict.create().set("studentId", studentId).set("date", date);
|
|
|
+ public JSONObject getRecordPlanStudy(Long studentId, Integer year, Long month) {
|
|
|
+ Date beginDate, endDate;
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ if(NumberUtils.isPositive(month)) {
|
|
|
+ cal.set(year, month.intValue() - 1, 1);
|
|
|
+ beginDate = cal.getTime();
|
|
|
+ cal.add(Calendar.MONTH, 1);
|
|
|
+ endDate = cal.getTime();
|
|
|
+ } else {
|
|
|
+ cal.set(year, 0, 1);
|
|
|
+ beginDate = cal.getTime();
|
|
|
+ cal.add(Calendar.YEAR, 1);
|
|
|
+ endDate = cal.getTime();
|
|
|
+ }
|
|
|
+
|
|
|
+ Map cond = Dict.create().set("studentId", studentId).set("beginDate", beginDate).set("endDate", endDate);
|
|
|
JSONObject header = answerMapper.selectQuestionStatsHeader(cond);
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("total", header.getIntValue("total"));
|
|
|
result.put("rate", header.getIntValue("rate"));
|
|
|
result.put("studyDays", header.getIntValue("time"));
|
|
|
+ if(null == month || month.equals(0)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
List<JSONObject> list = Lists.newArrayList();
|
|
|
answerMapper.selectQuestionStatsDetail(cond).stream().forEach(s -> {
|
|
|
JSONObject data = JSONObject.of("date", DateUtils.format(s.getDate("time"), "yyyy-MM-dd"), "study", s.getString("value"), "rate", s.getString("rate"));
|