Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -306,7 +306,7 @@ public class BuyOrderController {
|
||||
addEbookToUser(buyOrderProductList, buyOrder, 0);
|
||||
addCourseToUser(buyOrder);
|
||||
} else {
|
||||
return R.error(500, "花生币余额不足!");
|
||||
return R.error(500, "天医币余额不足!");
|
||||
}
|
||||
}
|
||||
// 2. 微信支付,需要预支付
|
||||
|
||||
@@ -2,16 +2,16 @@ package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ClassEntity;
|
||||
import com.peanut.modules.common.entity.ClassModel;
|
||||
import com.peanut.modules.common.entity.ClassTask;
|
||||
import com.peanut.modules.common.entity.ClassTaskAndQuesReply;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.ClassEntityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -33,6 +33,15 @@ public class ClassController {
|
||||
//新增班级模型
|
||||
@RequestMapping("/addClassModel")
|
||||
public R addClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
@@ -50,11 +59,7 @@ public class ClassController {
|
||||
score += classModel.getExamScore();
|
||||
}
|
||||
if (score==100){
|
||||
if (classEntityService.addClassModel(classModel)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("保存出错");
|
||||
}
|
||||
return classEntityService.addClassModel(classModel);
|
||||
}else {
|
||||
return R.error("请设置各模块占比总和为100");
|
||||
}
|
||||
@@ -63,6 +68,15 @@ public class ClassController {
|
||||
//修改班级模型
|
||||
@RequestMapping("/editClassModel")
|
||||
public R editClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
@@ -86,6 +100,13 @@ public class ClassController {
|
||||
}
|
||||
}
|
||||
|
||||
//获取模型可选课程
|
||||
@RequestMapping("/getClassModelCourseList")
|
||||
public R getClassModelCourseList(@RequestBody Map<String,Object> params){
|
||||
List<CourseEntity> courseList = classEntityService.getClassModelCourseList(params);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
//获取主任下的班级模型
|
||||
@RequestMapping("/getClassModelByUserid")
|
||||
public R getClassModelByUserid(@RequestBody Map<String,Object> params){
|
||||
@@ -318,4 +339,10 @@ public class ClassController {
|
||||
return R.ok().put("result",classEntityService.getUserScore(params));
|
||||
}
|
||||
|
||||
//学员成绩列表
|
||||
@RequestMapping("/userScoreList")
|
||||
public R userScoreList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.userScoreList(params));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,13 +39,12 @@ public class ClassExamController {
|
||||
public R importSubject(@RequestParam("file") MultipartFile file, @RequestParam("courseId") int courseId) {
|
||||
int num = 0;
|
||||
try (InputStream fis = file.getInputStream()) {
|
||||
List<ClassExamOption> optionList = new ArrayList<>();
|
||||
Long time = System.currentTimeMillis();
|
||||
//解析数据
|
||||
ExcelUtil example = new ExcelUtil();
|
||||
example.processOneSheet(fis);
|
||||
Long endtime = System.currentTimeMillis();
|
||||
LinkedHashMap<String, String> map = example.getRowContents();
|
||||
Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
|
||||
//处理数据
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
@@ -54,20 +53,54 @@ public class ClassExamController {
|
||||
count = Integer.parseInt(rowNo);
|
||||
// System.out.println(pos + ";" + entry.getValue());
|
||||
}
|
||||
List<ClassExamOption> optionList = new ArrayList<>();
|
||||
//先校验数据
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i=2;i<=count;i++){
|
||||
//类型
|
||||
String type = map.containsKey("A"+i)?map.get("A"+i):"";
|
||||
if (type.contains("单选")||type.contains("多选")){
|
||||
}else {
|
||||
sb.append("第"+i+"行题目类型出错\n");
|
||||
}
|
||||
String option1 = map.containsKey("C"+i)?map.get("C"+i):"";
|
||||
if (StringUtils.isBlank(option1)){
|
||||
sb.append("第"+i+"行无选项1\n");
|
||||
}
|
||||
String option2 = map.containsKey("D"+i)?map.get("D"+i):"";
|
||||
if (StringUtils.isBlank(option2)){
|
||||
sb.append("第"+i+"行无选项2\n");
|
||||
}
|
||||
String option3 = map.containsKey("E"+i)?map.get("E"+i):"";
|
||||
if (StringUtils.isBlank(option3)){
|
||||
sb.append("第"+i+"行无选项3\n");
|
||||
}
|
||||
String option4 = map.containsKey("F"+i)?map.get("F"+i):"";
|
||||
if (StringUtils.isBlank(option4)){
|
||||
sb.append("第"+i+"行无选项4\n");
|
||||
}
|
||||
String answer = map.containsKey("I"+i)?map.get("I"+i):"";
|
||||
if (StringUtils.isBlank(answer)){
|
||||
sb.append("第"+i+"行无答案\n");
|
||||
}
|
||||
//题目
|
||||
String content = map.containsKey("B"+i)?map.get("B"+i):"";
|
||||
if (StringUtils.isBlank(content)) {
|
||||
sb.append("第"+i+"行无题目\n");
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0){
|
||||
throw new Exception(sb.toString());
|
||||
}
|
||||
for (int i=2;i<=count;i++){
|
||||
ClassExamSubject subject = new ClassExamSubject();
|
||||
subject.setCourseId(courseId);
|
||||
//类型
|
||||
String type = map.containsKey("A"+i)?map.get("A"+i):"";
|
||||
if (type.contains("单选")){
|
||||
if (map.get("A"+i).contains("单选")){
|
||||
subject.setType(0);
|
||||
}else if (type.contains("多选")){
|
||||
}else if (map.get("A"+i).contains("多选")){
|
||||
subject.setType(1);
|
||||
}else {
|
||||
throw new Exception("第"+i+"题无题目类型");
|
||||
}
|
||||
//题目
|
||||
subject.setContent(map.containsKey("B"+i)?map.get("B"+i):"");
|
||||
subject.setContent(map.get("B"+i));
|
||||
//所属章节
|
||||
subject.setChapter(map.containsKey("N"+i)?map.get("N"+i):"");
|
||||
//音视频序号
|
||||
@@ -78,15 +111,15 @@ public class ClassExamController {
|
||||
subject.setCreateUser(map.containsKey("Q"+i)?map.get("Q"+i):"");
|
||||
classExamSubjectService.save(subject);
|
||||
num++;
|
||||
insertOption(optionList,subject.getId(),map.containsKey("C"+i)?map.get("C"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
insertOption(optionList,subject.getId(),map.containsKey("D"+i)?map.get("D"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
insertOption(optionList,subject.getId(),map.containsKey("E"+i)?map.get("E"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
insertOption(optionList,subject.getId(),map.containsKey("F"+i)?map.get("F"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
insertOption(optionList,subject.getId(),map.containsKey("G"+i)?map.get("G"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
insertOption(optionList,subject.getId(),map.containsKey("H"+i)?map.get("H"+i):"",map.containsKey("I"+i)?map.get("I"+i):"");
|
||||
//插入选项
|
||||
insertOption(optionList,subject.getId(),map.get("C"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("D"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("E"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("F"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.containsKey("G"+i)?map.get("G"+i):"",map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.containsKey("H"+i)?map.get("H"+i):"",map.get("I"+i));
|
||||
}
|
||||
classExamOptionService.saveBatch(optionList);
|
||||
System.out.println("解析数据" + count + "条;耗时" + (endtime - time) / 1000 + "秒");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
@@ -127,20 +160,26 @@ public class ClassExamController {
|
||||
return R.ok().put("page",classExamSubjectList);
|
||||
}
|
||||
|
||||
//考试题目列表
|
||||
//生成试卷
|
||||
@RequestMapping("/generateExamPaper")
|
||||
public R generateExamPaper(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.generateExamPaper(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
return classExamService.generateExamPaper(params);
|
||||
}
|
||||
|
||||
//提交考卷
|
||||
//提交试卷
|
||||
@RequestMapping("/submitExamPaper")
|
||||
public R submitExamPaper(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.submitExamPaper(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
}
|
||||
|
||||
//试卷详情
|
||||
@RequestMapping("/getExamPaperInfo")
|
||||
public R getExamPaperInfo(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.getExamPaperInfo(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ClassExamUser {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer examId;
|
||||
private Integer classId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
Page getClassModelList(Map<String ,Object> params);
|
||||
|
||||
boolean addClassModel(ClassModel classModel);
|
||||
R addClassModel(ClassModel classModel);
|
||||
|
||||
R editClassModel(ClassModel classModel);
|
||||
|
||||
List<CourseEntity> getClassModelCourseList(Map<String, Object> params);
|
||||
|
||||
List<ClassModel> getClassModelByUserid(Map<String ,Object> params);
|
||||
|
||||
List<Map<String, Object>> getClassByDirectorid(Map<String,Object> params);
|
||||
@@ -85,4 +87,6 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
Map<String,Object> getUserScore(Map<String,Object> params);
|
||||
|
||||
List userScoreList(Map<String,Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ClassExam;
|
||||
import com.peanut.modules.common.entity.ClassExamOption;
|
||||
import com.peanut.modules.common.entity.ClassExamSubject;
|
||||
@@ -25,8 +26,10 @@ public interface ClassExamService extends IService<ClassExam> {
|
||||
|
||||
Page getClassExamSubjectList(Map<String,Object> params);
|
||||
|
||||
Object generateExamPaper(Map<String,Object> params);
|
||||
R generateExamPaper(Map<String,Object> params);
|
||||
|
||||
Object submitExamPaper(Map<String,Object> params);
|
||||
|
||||
Object getExamPaperInfo(Map<String,Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@@ -43,6 +45,10 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
@Autowired
|
||||
private ClassExamUserDao classExamUserDao;
|
||||
@Autowired
|
||||
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
||||
|
||||
@Override
|
||||
public Page getClassModelList(Map<String, Object> params) {
|
||||
@@ -62,7 +68,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addClassModel(ClassModel classModel) {
|
||||
@Transactional
|
||||
public R addClassModel(ClassModel classModel) {
|
||||
classModelDao.insert(classModel);
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
@@ -73,7 +80,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
classCourseDao.insert(classCourse);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,6 +109,17 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseEntity> getClassModelCourseList(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.exists("select * from course_to_medicine where del_flag = 0 and course_id = t.id");
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
wrapper.selectAs(CourseEntity::getId,"id");
|
||||
wrapper.selectAs(CourseEntity::getTitle,"title");
|
||||
List<CourseEntity> list = courseDao.selectList(wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassModel> getClassModelByUserid(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<ClassModel> wrapper = new LambdaQueryWrapper<>();
|
||||
@@ -530,6 +548,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
public List<ClassEntity> getClassNoUser() {
|
||||
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(ClassEntity.class);
|
||||
wrapper.eq(ClassEntity::getState,"0");
|
||||
String classSql = "select 1 from ( select c.id from class c left join class_course cc on cc.model_id = c.model_id left join class_user cu on cu.class_id = c.id where c.del_flag = 0 and cc.del_flag = 0 and cu.del_flag = 0 and cu.user_id = "+ShiroUtils.getUId()+" ) s where s.id = t.id";
|
||||
String courseSql = "select 1 from (select cc.model_id from class_course cc where cc.del_flag = 0 and cc.course_id in (select cc.course_id from class_course cc left join class_model cm on cm.id = cc.model_id left join class c on c.model_id = cm.id left join class_user cu on cu.class_id = c.id where cc.del_flag = 0 and cm.del_flag = 0 and c.del_flag = 0 and cu.del_flag = 0 and cu.user_id = "+ShiroUtils.getUId()+")) q where q.model_id = t.model_id";
|
||||
wrapper.notExists(classSql);
|
||||
@@ -968,9 +987,13 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
questionWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
questionWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
questionWrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
questionWrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
questionWrapper.eq(ClassEntity::getId,classEntity.getId());
|
||||
if (params.containsKey("userId")){
|
||||
questionWrapper.eq(ClassTaskAndQuesReply::getUserId,params.get("userId"));
|
||||
}else {
|
||||
questionWrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
questionWrapper.eq(ClassTaskAndQuesReply::getClassId,params.get("classId"));
|
||||
}
|
||||
questionWrapper.eq(ClassTaskAndQuesReply::getClassId,classEntity.getId());
|
||||
List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper);
|
||||
if (questionReplys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : questionReplys) {
|
||||
@@ -986,7 +1009,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> task0wrapper = new MPJLambdaWrapper<>();
|
||||
task0wrapper.leftJoin(ClassTask.class,ClassTask::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
task0wrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
task0wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
task0wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
task0wrapper.eq(ClassTask::getType,"0");
|
||||
task0wrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper);
|
||||
@@ -1004,7 +1027,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> task1wrapper = new MPJLambdaWrapper<>();
|
||||
task1wrapper.leftJoin(ClassTask.class,ClassTask::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
task1wrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
task1wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
task1wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
task1wrapper.eq(ClassTask::getType,"1");
|
||||
task1wrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper);
|
||||
@@ -1021,7 +1044,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
double experienceScore = 0;
|
||||
MPJLambdaWrapper<ClassTask> experiencewrapper = new MPJLambdaWrapper<>();
|
||||
experiencewrapper.eq(ClassTask::getUserId,ShiroUtils.getUId());
|
||||
experiencewrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
experiencewrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
experiencewrapper.eq(ClassTask::getType,"2");
|
||||
List<ClassTask> experiences = classTaskDao.selectList(experiencewrapper);
|
||||
if (experiences.size() > 0) {
|
||||
@@ -1036,5 +1059,106 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List userScoreList(Map<String, Object> params) {
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
List<ClassUser> classUsers = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
List<Map<String,Object>> resultList = new ArrayList<>();
|
||||
if (classUsers.size() > 0){
|
||||
for (ClassUser classUser:classUsers){
|
||||
params.put("userId",classUser.getUserId());
|
||||
Map<String,Object> map = getUserScore(params);
|
||||
map.put("user",myUserDao.selectById(classUser.getUserId()));
|
||||
if (classModel.getIsExam()==1){
|
||||
List<ClassExamUser> classExamUsers = classExamUserDao.selectList(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getUserId,classUser.getUserId())
|
||||
.eq(ClassExamUser::getClassId,classEntity.getId()));
|
||||
int examScore = 0;
|
||||
for (ClassExamUser classExamUser:classExamUsers){
|
||||
if (classExamUser.getScore()>examScore){
|
||||
examScore = classExamUser.getScore();
|
||||
}
|
||||
}
|
||||
map.put("examScore",examScore);
|
||||
}
|
||||
//处理分数占比
|
||||
BigDecimal userScore = new BigDecimal(0);;
|
||||
double staticScore = 2.5;
|
||||
if(classModel.getIsExam()==1){
|
||||
BigDecimal examScore = new BigDecimal(map.get("examScore").toString());
|
||||
examScore.divide(new BigDecimal(100));
|
||||
examScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
||||
examScore = examScore.setScale(2,RoundingMode.HALF_UP);
|
||||
map.put("examScore",examScore);
|
||||
userScore.add(examScore);
|
||||
}
|
||||
if(classModel.getIsQuestion()==1){
|
||||
BigDecimal questionScore = new BigDecimal(map.get("questionScore").toString());
|
||||
MPJLambdaWrapper<CourseCatalogueChapterEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.eq(ClassModel::getId,classModel.getId());
|
||||
wrapper.ne(CourseCatalogueChapterEntity::getQuestions,"");
|
||||
int count = courseCatalogueChapterDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
questionScore.divide(totalScore);
|
||||
questionScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
||||
questionScore = questionScore.setScale(2,RoundingMode.HALF_UP);
|
||||
map.put("questionScore",questionScore);
|
||||
userScore.add(questionScore);
|
||||
}
|
||||
if(classModel.getIsTask()==1){
|
||||
BigDecimal task0Score = new BigDecimal(map.get("task0Score").toString());
|
||||
MPJLambdaWrapper<ClassTask> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
wrapper.eq(ClassTask::getType,"0");
|
||||
int count = classTaskDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
task0Score.divide(totalScore);
|
||||
task0Score.multiply(new BigDecimal(classModel.getTaskScore()));
|
||||
task0Score = task0Score.setScale(2,RoundingMode.HALF_UP);
|
||||
map.put("task0Score",task0Score);
|
||||
userScore.add(task0Score);
|
||||
}
|
||||
if(classModel.getIsMedicalcase()==1){
|
||||
BigDecimal task1Score = new BigDecimal(map.get("task1Score").toString());
|
||||
MPJLambdaWrapper<ClassTask> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
wrapper.eq(ClassTask::getType,"1");
|
||||
int count = classTaskDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
task1Score.divide(totalScore);
|
||||
task1Score.multiply(new BigDecimal(classModel.getMedicalcaseScore()));
|
||||
task1Score = task1Score.setScale(2,RoundingMode.HALF_UP);
|
||||
map.put("task1Score",task1Score);
|
||||
userScore.add(task1Score);
|
||||
}
|
||||
if(classModel.getIsExperience()==1){
|
||||
BigDecimal experienceScore = new BigDecimal(map.get("experienceScore").toString());
|
||||
if (experienceScore.compareTo(new BigDecimal(classModel.getExperienceScore()))>-1){
|
||||
experienceScore = new BigDecimal(classModel.getExperienceScore());
|
||||
}
|
||||
map.put("experienceScore",experienceScore);
|
||||
userScore.add(experienceScore);
|
||||
}
|
||||
map.put("userScore",userScore);
|
||||
resultList.add(map);
|
||||
}
|
||||
Collections.sort(resultList, new Comparator<Map<String,Object>>() {
|
||||
@Override
|
||||
public int compare(Map<String,Object> m1, Map<String,Object> m2) {
|
||||
if((double)(m2.get("userScore")) > (double)(m1.get("userScore"))){
|
||||
return 1;
|
||||
}else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
@@ -27,6 +28,8 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
private ClassCourseDao classCourseDao;
|
||||
@Autowired
|
||||
private ClassExamUserDao classExamUserDao;
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
|
||||
@Override
|
||||
public void addClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
@@ -104,61 +107,80 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object generateExamPaper(Map<String, Object> params) {
|
||||
public R generateExamPaper(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ClassCourse> courseWrapper = new MPJLambdaWrapper<>();
|
||||
courseWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
courseWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
courseWrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
courseWrapper.selectAll(ClassCourse.class);
|
||||
List<ClassCourse> courseList = classCourseDao.selectList(courseWrapper);
|
||||
List<ClassExamSubject> resultList = new ArrayList<>();
|
||||
List<ClassExamSubject> sList = new ArrayList<>();
|
||||
List<ClassExamSubject> mList = new ArrayList<>();
|
||||
List<Map<String,Object>> resultList = new ArrayList<>();
|
||||
List<Map<String,Object>> sList = new ArrayList<>();
|
||||
List<Map<String,Object>> mList = new ArrayList<>();
|
||||
if (courseList.size() > 0) {
|
||||
int stotal = 50;//单选题总数
|
||||
int mtotal = 50;//多选题总数
|
||||
int stotal = 5;//单选题总数
|
||||
int mtotal = 5;//多选题总数
|
||||
int snum = (int)Math.floor(stotal/courseList.size());
|
||||
int mnum = (int)Math.floor(mtotal/courseList.size());
|
||||
for (ClassCourse course:courseList){
|
||||
for (ClassCourse classCourse:courseList){
|
||||
CourseEntity course = courseDao.selectById(classCourse.getCourseId());
|
||||
//单选
|
||||
List<ClassExamSubject> singleList = classExamSubjectDao.selectList(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,course.getCourseId())
|
||||
List<Map<String,Object>> singleList = classExamSubjectDao.selectMaps(new MPJLambdaWrapper<ClassExamSubject>()
|
||||
.selectAs(ClassExamSubject::getId,"id")
|
||||
.selectAs(ClassExamSubject::getType,"type")
|
||||
.selectAs(ClassExamSubject::getContent,"content")
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId())
|
||||
.eq(ClassExamSubject::getType,0));
|
||||
Collections.shuffle(singleList);//打乱顺序
|
||||
try {
|
||||
if (sList.size()+snum>stotal){
|
||||
sList.addAll(singleList.subList(0,stotal-sList.size()));
|
||||
}else {
|
||||
sList.addAll(singleList.subList(0,snum));
|
||||
}
|
||||
}catch (Exception e) {
|
||||
return R.error(course.getTitle()+"-单选题数量不足");
|
||||
}
|
||||
//多选
|
||||
List<ClassExamSubject> mulList = classExamSubjectDao.selectList(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,course.getCourseId())
|
||||
List<Map<String,Object>> mulList = classExamSubjectDao.selectMaps(new MPJLambdaWrapper<ClassExamSubject>()
|
||||
.selectAs(ClassExamSubject::getId,"id")
|
||||
.selectAs(ClassExamSubject::getType,"type")
|
||||
.selectAs(ClassExamSubject::getContent,"content")
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId())
|
||||
.eq(ClassExamSubject::getType,1));
|
||||
Collections.shuffle(mulList);//打乱顺序
|
||||
try {
|
||||
if (mList.size()+mnum>mtotal){
|
||||
mList.addAll(mulList.subList(0,mtotal-mList.size()));
|
||||
}else {
|
||||
mList.addAll(mulList.subList(0,mnum));
|
||||
}
|
||||
}catch (Exception e) {
|
||||
return R.error(course.getTitle()+"-多选题数量不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
resultList.addAll(sList);
|
||||
resultList.addAll(mList);
|
||||
//拼装选项
|
||||
if (resultList.size()>0){
|
||||
for (ClassExamSubject subject:resultList) {
|
||||
List<ClassExamOption> options = classExamOptionDao.selectList(
|
||||
new LambdaQueryWrapper<ClassExamOption>().eq(ClassExamOption::getSubjectId,subject.getId()));
|
||||
for (Map<String,Object> subject:resultList) {
|
||||
List<Map<String,Object>> options = classExamOptionDao.selectMaps(new MPJLambdaWrapper<ClassExamOption>()
|
||||
.selectAs(ClassExamOption::getId,"id")
|
||||
.selectAs(ClassExamOption::getContent,"content")
|
||||
.selectAs(ClassExamOption::getRightWrong,"rightWrong")
|
||||
.eq(ClassExamOption::getSubjectId,subject.get("id")));
|
||||
Collections.shuffle(options);//打乱顺序
|
||||
subject.setOptions(options);
|
||||
subject.put("options",options);
|
||||
}
|
||||
}
|
||||
ClassExamUser classExamUser = new ClassExamUser();
|
||||
classExamUser.setExamId(this.getBaseMapper().selectOne(new LambdaQueryWrapper<ClassExam>().eq(ClassExam::getClassId,params.get("classId"))).getId());
|
||||
classExamUser.setClassId(Integer.parseInt(params.get("classId").toString()));
|
||||
classExamUser.setSubject(JSONUtil.toJsonStr(resultList));
|
||||
classExamUser.setUserId(ShiroUtils.getUId());
|
||||
classExamUserDao.insert(classExamUser);
|
||||
return resultList;
|
||||
return R.ok().put("examPaper",resultList).put("id",classExamUser.getId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,4 +226,13 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
return classExamUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getExamPaperInfo(Map<String, Object> params) {
|
||||
List<ClassExamUser> classExamUserList = classExamUserDao.selectList(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getClassId,params.get("classId"))
|
||||
.eq(ClassExamUser::getUserId,params.get("userId"))
|
||||
.orderByDesc(ClassExamUser::getScore));
|
||||
return classExamUserList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class UserVipController {
|
||||
return R.error("积分不足");
|
||||
}
|
||||
}else {
|
||||
return R.error("花生币不足");
|
||||
return R.error("天医币不足");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class UserVipController {
|
||||
return R.error("积分不足");
|
||||
}
|
||||
}else {
|
||||
return R.error("花生币不足");
|
||||
return R.error("天医币不足");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user