소스 검색

食堂考核,调整新增编辑的相关逻辑

dzx 1 년 전
부모
커밋
b04a19e93b

+ 6 - 0
src/main/java/com/xjrsoft/module/assessment/controller/AssessmentTemplatePlanController.java

@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -117,6 +118,11 @@ public class AssessmentTemplatePlanController {
         if(templatePlan == null){
             throw new MyException("未能找到场所信息");
         }
+        if(dto.getStatus() == 1){
+            templatePlan.setStartTime(new Date());
+        }else if(dto.getStatus() == 2){
+            templatePlan.setEndTime(new Date());
+        }
         templatePlan.setStatus(dto.getStatus());
         planService.updateById(templatePlan);
         return RT.ok(true);

+ 54 - 46
src/main/java/com/xjrsoft/module/assessment/service/impl/AssessmentTemplatePlanServiceImpl.java

@@ -47,6 +47,8 @@ import com.xjrsoft.module.assessment.vo.AssessmentQuestionResultVo;
 import com.xjrsoft.module.assessment.vo.AssessmentQuestionVo;
 import com.xjrsoft.module.assessment.vo.AssessmentTemplatePlanPageVo;
 import com.xjrsoft.module.assessment.vo.AssessmentTemplatePlanQuestionVo;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.mapper.BaseClassMapper;
 import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
 import com.xjrsoft.module.organization.service.IWeChatService;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
@@ -84,6 +86,7 @@ public class AssessmentTemplatePlanServiceImpl extends MPJBaseServiceImpl<Assess
     private final XjrUserMapper xjrUserMapper;
     private final IWeChatService weChatService;
     private final CommonPropertiesConfig commonPropertiesConfig;
+    private final BaseClassMapper baseClassMapper;
 
 
     @Override
@@ -111,6 +114,30 @@ public class AssessmentTemplatePlanServiceImpl extends MPJBaseServiceImpl<Assess
             planQuestion.setAssessmentTemplatePlanId(assessmentTemplatePlan.getId());
             planQuestionMapper.insert(planQuestion);
         }
+        List<BaseClass> classList = baseClassMapper.selectList(
+            new QueryWrapper<BaseClass>().lambda()
+            .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+            .eq(BaseClass::getIsGraduate, 1)
+        );
+        List<Long> classIds = new ArrayList<>();
+        if("all".equals(dto.getType())){
+            for (BaseClass baseClass : classList) {
+                classIds.add(baseClass.getId());
+            }
+        }else if("random".equals(dto.getType())){
+            List<Integer> randomList = new ArrayList<>();
+            Random random = new Random();
+            while(randomList.size() < dto.getRandomNumber()){
+                int nextInt = random.nextInt(classList.size());
+                if(!randomList.contains(nextInt) && nextInt >= 0){
+                    randomList.add(nextInt);
+
+                }
+            }
+            for (Integer i : randomList) {
+                classIds.add(classList.get(i).getId());
+            }
+        }
 
         //存入班级,并根据选人方式存入答题学生
         for (Long classId : dto.getClassIds()) {
@@ -123,29 +150,7 @@ public class AssessmentTemplatePlanServiceImpl extends MPJBaseServiceImpl<Assess
             query.leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
             .eq(BaseStudentSchoolRoll::getClassId, classId);
             List<XjrUser> studentList = xjrUserMapper.selectJoinList(XjrUser.class, query);
-            List<XjrUser> needStudentList = new ArrayList<>();
-            if("all".equals(dto.getType())){
-                needStudentList.addAll(studentList);
-            }else if("random".equals(dto.getType())){
-                int maxCount = studentList.size();//班级最大人数
-                if(dto.getRandomNumber() > maxCount){
-                    needStudentList.addAll(studentList);
-                }else{
-                    List<Integer> randomList = new ArrayList<>();
-                    Random random = new Random();
-                    while(randomList.size() < dto.getRandomNumber()){
-                        int nextInt = random.nextInt(studentList.size());
-                        if(!randomList.contains(nextInt) && nextInt >= 0){
-                            randomList.add(nextInt);
-
-                        }
-                    }
-                    for (Integer i : randomList) {
-                        needStudentList.add(studentList.get(i));
-                    }
-                }
-            }
-            for (XjrUser xjrUser : needStudentList) {
+            for (XjrUser xjrUser : studentList) {
                 AssessmentPlanAnswerStudent answer = new AssessmentPlanAnswerStudent();
                 answer.setAssessmentTemplatePlanId(assessmentTemplatePlan.getId());
                 answer.setStudentUserId(xjrUser.getId());
@@ -187,6 +192,31 @@ public class AssessmentTemplatePlanServiceImpl extends MPJBaseServiceImpl<Assess
         //删除班级和学生
         answerClassMapper.deleteByPlanId(assessmentTemplatePlan.getId(), StpUtil.getLoginIdAsLong());
         studentMapper.deleteByPlanId(assessmentTemplatePlan.getId(), StpUtil.getLoginIdAsLong());
+        List<BaseClass> classList = baseClassMapper.selectList(
+            new QueryWrapper<BaseClass>().lambda()
+            .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+            .eq(BaseClass::getIsGraduate, 1)
+        );
+        List<Long> classIds = new ArrayList<>();
+        if("all".equals(dto.getType())){
+            for (BaseClass baseClass : classList) {
+                classIds.add(baseClass.getId());
+            }
+        }else if("random".equals(dto.getType())){
+            List<Integer> randomList = new ArrayList<>();
+            Random random = new Random();
+            while(randomList.size() < dto.getRandomNumber()){
+                int nextInt = random.nextInt(classList.size());
+                if(!randomList.contains(nextInt) && nextInt >= 0){
+                    randomList.add(nextInt);
+
+                }
+            }
+            for (Integer i : randomList) {
+                classIds.add(classList.get(i).getId());
+            }
+        }
+
         //存入班级,并根据选人方式存入答题学生
         for (Long classId : dto.getClassIds()) {
             AssessmentPlanAnswerClass answerClass = new AssessmentPlanAnswerClass();
@@ -198,29 +228,7 @@ public class AssessmentTemplatePlanServiceImpl extends MPJBaseServiceImpl<Assess
             query.leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
                     .eq(BaseStudentSchoolRoll::getClassId, classId);
             List<XjrUser> studentList = xjrUserMapper.selectJoinList(XjrUser.class, query);
-            List<XjrUser> needStudentList = new ArrayList<>();
-            if("all".equals(dto.getType())){
-                needStudentList.addAll(studentList);
-            }else if("random".equals(dto.getType())){
-                int maxCount = studentList.size();//班级最大人数
-                if(dto.getRandomNumber() > maxCount){
-                    needStudentList.addAll(studentList);
-                }else{
-                    List<Integer> randomList = new ArrayList<>();
-                    Random random = new Random();
-                    while(randomList.size() < dto.getRandomNumber()){
-                        int nextInt = random.nextInt(studentList.size());
-                        if(!randomList.contains(nextInt) && nextInt >= 0){
-                            randomList.add(nextInt);
-
-                        }
-                    }
-                    for (Integer i : randomList) {
-                        needStudentList.add(studentList.get(i));
-                    }
-                }
-            }
-            for (XjrUser xjrUser : needStudentList) {
+            for (XjrUser xjrUser : studentList) {
                 AssessmentPlanAnswerStudent answer = new AssessmentPlanAnswerStudent();
                 answer.setAssessmentTemplatePlanId(assessmentTemplatePlan.getId());
                 answer.setStudentUserId(xjrUser.getId());

+ 45 - 0
src/main/java/com/xjrsoft/module/assessment/vo/AssessmentQuestionResultDetailVo.java

@@ -0,0 +1,45 @@
+package com.xjrsoft.module.assessment.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @title: 考核题目答案出参
+* @Author dzx
+* @Date: 2024-03-29
+* @Version 1.0
+*/
+@Data
+public class AssessmentQuestionResultDetailVo implements Serializable {
+
+    @ApiModelProperty("")
+    private Long id;
+
+    @ApiModelProperty("题目题干")
+    private String name;
+
+    @ApiModelProperty("分数")
+    private Long score;
+
+    @ApiModelProperty("题目类型")
+    private String type;
+
+    @ApiModelProperty("类别(1:大题 2:小题 3:选项)")
+    private Integer category;
+
+    @ApiModelProperty("父级id")
+    private Long parentId;
+
+    @ApiModelProperty("小题是否必填(1:是 0:否)")
+    private Short required;
+
+    @ApiModelProperty("数量")
+    private Integer count;
+
+    @ApiModelProperty("子集")
+    private List<AssessmentQuestionResultDetailVo> children;
+
+}