|
|
@@ -33,10 +33,7 @@ import com.zhongzheng.modules.exam.bo.ExamKnowledgeAddBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamKnowledgeBusinessAddBo;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
|
import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
|
|
|
-import com.zhongzheng.modules.goods.bo.BankGoodsExamAddBo;
|
|
|
-import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
-import com.zhongzheng.modules.goods.bo.TodayExamTobVo;
|
|
|
-import com.zhongzheng.modules.goods.bo.TodayExamWeekRecordDetailVo;
|
|
|
+import com.zhongzheng.modules.goods.bo.*;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsExamTime;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsExamTimeService;
|
|
|
@@ -73,9 +70,15 @@ import org.w3c.dom.NamedNodeMap;
|
|
|
import org.w3c.dom.Node;
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import javax.xml.bind.DatatypeConverter;
|
|
|
+import java.awt.*;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
+import java.net.URL;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -1892,22 +1895,107 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
vo.setUserId(k);
|
|
|
vo.setRecordCount(v.size());
|
|
|
User user = iUserService.getById(k);
|
|
|
- vo.setUserName(user.getNickname());
|
|
|
+ vo.setUserName(user.getRealname());
|
|
|
+ vo.setAvatar(user.getAvatar());
|
|
|
+ voList.add(vo);
|
|
|
});
|
|
|
return voList.stream().sorted(Comparator.comparing(TodayExamTobVo::getRecordCount).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public TodayExamWeekRecordDetailVo getTodayExamWeekRecord(Long goodsId, Long userId) {
|
|
|
- //获取每日一练的打卡记录
|
|
|
+ //获取每日一练的打卡记录
|
|
|
List<UserSpecialExamRecord> recordList = userSpecialExamRecordService
|
|
|
.list(new LambdaQueryWrapper<UserSpecialExamRecord>()
|
|
|
.eq(UserSpecialExamRecord::getUserId, userId)
|
|
|
.eq(UserSpecialExamRecord::getGoodsId, goodsId));
|
|
|
-
|
|
|
- return null;
|
|
|
+ if (CollectionUtils.isEmpty(recordList)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<UserExamRecord> userExamRecordList = new ArrayList<>();
|
|
|
+ //做题记录
|
|
|
+ recordList.forEach(item -> {
|
|
|
+ List<UserExamRecord> list = iUserExamRecordService.list(new LambdaQueryWrapper<UserExamRecord>()
|
|
|
+ .eq(UserExamRecord::getGoodsId, goodsId)
|
|
|
+ .eq(UserExamRecord::getUserId, userId)
|
|
|
+ .eq(ObjectUtils.isNotNull(item.getModuleExamId()) && item.getModuleExamId() != 0, UserExamRecord::getModuleExamId, item.getModuleExamId())
|
|
|
+ .eq(ObjectUtils.isNotNull(item.getChapterExamId()) && item.getChapterExamId() != 0, UserExamRecord::getChapterExamId, item.getChapterExamId())
|
|
|
+ .eq(UserExamRecord::getExamId, item.getExamId())
|
|
|
+ .ge(UserExamRecord::getCreateTime,item.getRecordTime())
|
|
|
+ .le(UserExamRecord::getChapterExamId,item.getRecordTime() + (24*60*60))
|
|
|
+ .eq(UserExamRecord::getStatus,1));
|
|
|
+ userExamRecordList.addAll(list);
|
|
|
+ });
|
|
|
+ //做题数和正确率
|
|
|
+ Long doNum = 0L;
|
|
|
+ Long rightNum = 0L;
|
|
|
+ List<UserExamRecord> weekRecord = new ArrayList<>();
|
|
|
+ List<UserExamRecord> lastWeekRecord = new ArrayList<>();
|
|
|
+ //本周和上周的时间
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
|
|
+ Long time = 24*60*60L;
|
|
|
+ Map<String, Long> timeInterval = DateUtils.getTimeInterval(cal.getTime());
|
|
|
+ Long start = timeInterval.get("start");
|
|
|
+ Long end = timeInterval.get("end") + time;
|
|
|
+ Map<String, Long> lastTimeInterval = DateUtils.getLastTimeInterval(cal.getTime());
|
|
|
+ Long laststart = lastTimeInterval.get("laststart");
|
|
|
+ Long lastEnd = lastTimeInterval.get("lastend")+ time;
|
|
|
+ for (UserExamRecord record : userExamRecordList) {
|
|
|
+ doNum += record.getAllQuestionNum();
|
|
|
+ rightNum += record.getRightQuestionNum();
|
|
|
+ //本周记录
|
|
|
+ if (record.getCreateTime() > start && record.getCreateTime() < end){
|
|
|
+ weekRecord.add(record);
|
|
|
+ }else if (record.getCreateTime() > laststart && record.getCreateTime() < lastEnd){
|
|
|
+ //上周记录
|
|
|
+ lastWeekRecord.add(record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TodayExamWeekRecordDetailVo result = new TodayExamWeekRecordDetailVo();
|
|
|
+ result.setDoNum(doNum);
|
|
|
+ result.setAccuracyAvg(getPercent(rightNum.intValue(),doNum.intValue()));
|
|
|
+ //本周
|
|
|
+ if (CollectionUtils.isNotEmpty(weekRecord)){
|
|
|
+ List<TodayExamWeekRecordVo> voList = new ArrayList<>();
|
|
|
+ Long todayTime = DateUtils.getTodayZeroTime() + time;
|
|
|
+ Long startTime = start;
|
|
|
+ while ( startTime < todayTime){
|
|
|
+ Long endTime = startTime + time;
|
|
|
+ List<UserExamRecord> records = new ArrayList<>();
|
|
|
+ for (UserExamRecord record : weekRecord) {
|
|
|
+ if (record.getCreateTime() >= startTime && record.getCreateTime() <= endTime){
|
|
|
+ records.add(record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(records)){
|
|
|
+ TodayExamWeekRecordVo vo = new TodayExamWeekRecordVo();
|
|
|
+ vo.setExamCount(records.size());
|
|
|
+ Exam exam = iExamService.getById(records.get(0).getExamId());
|
|
|
+ vo.setExamId(exam.getExamId());
|
|
|
+ vo.setExamName(exam.getExamName());
|
|
|
+ vo.setExamTime(startTime);
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ startTime += time;
|
|
|
+ }
|
|
|
+ result.setResultList(voList);
|
|
|
+ Long doSum = weekRecord.stream().mapToLong(UserExamRecord::getAllQuestionNum).sum();
|
|
|
+ Long rightSum = weekRecord.stream().mapToLong(UserExamRecord::getRightQuestionNum).sum();
|
|
|
+ result.setWeekAccuracyDoNum(doSum);
|
|
|
+ result.setWeekAccuracyAvg(getPercent(rightSum.intValue(),doSum.intValue()));
|
|
|
+ }
|
|
|
+ //上周
|
|
|
+ if (CollectionUtils.isNotEmpty(lastWeekRecord)){
|
|
|
+ Long lastSum = lastWeekRecord.stream().mapToLong(UserExamRecord::getAllQuestionNum).sum();
|
|
|
+ Long lastRigheSum = lastWeekRecord.stream().mapToLong(UserExamRecord::getRightQuestionNum).sum();
|
|
|
+ result.setLastWeekAccuracyDoNum(lastSum);
|
|
|
+ result.setLastWeekAccuracyAvg(getPercent(lastRigheSum.intValue(),lastSum.intValue()));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private String getPercent(Integer x,Integer y){
|
|
|
Double d1 = x * 1.0;
|
|
|
Double d2 = y * 1.0;
|