diff --git a/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentExamRecordController.java b/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentExamRecordController.java new file mode 100644 index 0000000..121c56b --- /dev/null +++ b/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentExamRecordController.java @@ -0,0 +1,51 @@ +package com.zcloud.edu.app.study; + + +import com.alibaba.cola.dto.MultiResponse; +import com.alibaba.cola.dto.PageResponse; +import com.alibaba.cola.dto.Response; +import com.alibaba.cola.dto.SingleResponse; +import com.jjb.saas.framework.auth.model.SSOUser; +import com.jjb.saas.framework.auth.utils.AuthContext; +import com.zcloud.edu.api.study.StudentExamRecordServiceI; +import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO; +import com.zcloud.edu.dto.clientobject.study.StudentSignCO; +import com.zcloud.edu.dto.study.StudentExamRecordAddCmd; +import com.zcloud.edu.dto.study.StudentExamRecordPageQry; +import com.zcloud.edu.dto.study.StudentExamRecordUpdateCmd; +import com.zcloud.edu.dto.study.StudentSignPageQry; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; + +/** + * web-adapter + * + * @Author zhangyue + * @Date 2026-01-13 14:18:16 + */ +@Api(tags = "考试信息") +@RequestMapping("/${application.gateway}/app/studentExamRecord") +@RestController +@AllArgsConstructor +public class AppStudentExamRecordController { + private final StudentExamRecordServiceI studentExamRecordService; + + @ApiOperation("提交试卷") + @PostMapping("/submit") + public SingleResponse submit(@Validated @RequestBody StudentExamRecordAddCmd cmd) { + SSOUser ssoUser = AuthContext.getCurrentUser(); + return studentExamRecordService.add(cmd); + } + + @ApiOperation("分页") + @PostMapping("/list") + public PageResponse page(@RequestBody StudentExamRecordPageQry qry) { + return studentExamRecordService.listPage(qry); + } +} + diff --git a/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentSignController.java b/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentSignController.java index 0ae036c..0dcf77e 100644 --- a/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentSignController.java +++ b/web-adapter/src/main/java/com/zcloud/edu/app/study/AppStudentSignController.java @@ -74,8 +74,8 @@ public class AppStudentSignController { return SingleResponse.buildSuccess(); } - @ApiOperation("修改") - @PutMapping("/edit") + @ApiOperation("上传签到签字") + @PostMapping("/uploadSignUrl") public SingleResponse edit(@Validated @RequestBody StudentSignUpdateCmd studentSignUpdateCmd) { studentSignService.edit(studentSignUpdateCmd); return SingleResponse.buildSuccess(); diff --git a/web-adapter/src/main/java/com/zcloud/edu/web/study/StudentController.java b/web-adapter/src/main/java/com/zcloud/edu/web/study/StudentController.java index 81a1e7f..38f8657 100644 --- a/web-adapter/src/main/java/com/zcloud/edu/web/study/StudentController.java +++ b/web-adapter/src/main/java/com/zcloud/edu/web/study/StudentController.java @@ -10,6 +10,7 @@ import com.jjb.saas.framework.auth.utils.AuthContext; import com.zcloud.edu.api.study.StudentServiceI; import com.zcloud.edu.dto.clientobject.study.StudentCO; import com.zcloud.edu.dto.study.StudentAddCmd; +import com.zcloud.edu.dto.study.StudentCountQry; import com.zcloud.edu.dto.study.StudentPageQry; import com.zcloud.edu.dto.study.StudentUpdateCmd; import io.swagger.annotations.Api; @@ -65,6 +66,12 @@ public class StudentController { return SingleResponse.of(studentService.countStudent(classId)); } + @ApiOperation("班级内学员数") + @PostMapping("/countStudentByCorpId") + public MultiResponse countStudentByCorpId(@RequestBody StudentCountQry qry) { + return studentService.countStudentByCorpId(qry); + } + @ApiOperation("删除") @PostMapping("/{id}") public Response remove(@PathVariable("id") Long id) { diff --git a/web-app/src/main/java/com/zcloud/edu/command/query/study/StudentQueryExe.java b/web-app/src/main/java/com/zcloud/edu/command/query/study/StudentQueryExe.java index b404a3a..28fbd96 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/query/study/StudentQueryExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/query/study/StudentQueryExe.java @@ -1,6 +1,7 @@ package com.zcloud.edu.command.query.study; import cn.hutool.core.bean.BeanUtil; +import com.alibaba.cola.dto.MultiResponse; import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.dto.SingleResponse; import com.zcloud.edu.command.convertor.study.StudentCoConvertor; @@ -12,6 +13,7 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO; import com.zcloud.edu.dto.clientobject.study.StudentSignCO; import com.zcloud.edu.dto.data.archives.ClassArchivesDTO; import com.zcloud.edu.dto.data.archives.PersonArchivesDTO; +import com.zcloud.edu.dto.study.StudentCountQry; import com.zcloud.edu.dto.study.StudentPageQry; import com.zcloud.edu.persistence.dataobject.study.*; import com.zcloud.edu.persistence.repository.study.*; @@ -204,5 +206,16 @@ public class StudentQueryExe { classArchivesDTO.setFailStudentList(failStudentList); return SingleResponse.of(classArchivesDTO); } + + + + + public MultiResponse executeCountStudentByCorpId(StudentCountQry qry){ + Map params = PageQueryHelper.toHashMap(qry); + List studentDOList = studentRepository.countStudentByCorpId(params); + List studentCOList = BeanUtil.copyToList(studentDOList, StudentCO.class); + return MultiResponse.of(studentCOList); + } + } diff --git a/web-app/src/main/java/com/zcloud/edu/command/study/StudentExamRecordAddExe.java b/web-app/src/main/java/com/zcloud/edu/command/study/StudentExamRecordAddExe.java index b0c3a70..f46d011 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/study/StudentExamRecordAddExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/study/StudentExamRecordAddExe.java @@ -1,14 +1,33 @@ package com.zcloud.edu.command.study; +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.cola.dto.Response; +import com.alibaba.cola.dto.SingleResponse; import com.alibaba.cola.exception.BizException; import com.zcloud.edu.domain.gateway.study.StudentExamRecordGateway; +import com.zcloud.edu.domain.model.study.ClassExamPaperE; import com.zcloud.edu.domain.model.study.StudentExamRecordE; +import com.zcloud.edu.domain.model.study.StudentExamRecordItemE; +import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO; import com.zcloud.edu.dto.study.StudentExamRecordAddCmd; +import com.zcloud.edu.dto.study.StudentExamRecordItemAddCmd; +import com.zcloud.edu.persistence.dataobject.study.ClassDO; +import com.zcloud.edu.persistence.dataobject.study.ClassExamPaperDO; +import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO; +import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordItemDO; +import com.zcloud.edu.persistence.repository.study.ClassExamPaperRepository; +import com.zcloud.edu.persistence.repository.study.ClassRepository; +import com.zcloud.edu.persistence.repository.study.StudentExamRecordItemRepository; +import com.zcloud.edu.persistence.repository.study.StudentExamRecordRepository; +import io.swagger.models.auth.In; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.List; + /** * web-app @@ -20,21 +39,41 @@ import org.springframework.transaction.annotation.Transactional; @AllArgsConstructor public class StudentExamRecordAddExe { private final StudentExamRecordGateway studentExamRecordGateway; - + private final ClassExamPaperRepository classExamPaperRepository; + private final StudentExamRecordItemRepository studentExamRecordItemRepository; + private final StudentExamRecordRepository studentExamRecordRepository; + private final ClassRepository classRepository; @Transactional(rollbackFor = Exception.class) - public boolean execute(StudentExamRecordAddCmd cmd) { + public SingleResponse execute(StudentExamRecordAddCmd cmd) { + ClassDO classDO = classRepository.getByClassId(cmd.getClassId()); + Integer count = studentExamRecordRepository.countByStudentId(cmd.getStudentId()); + if (count >= classDO.getNumberofexams()) { + throw new BizException("您已经没有考试次数"); + } + + StudentExamRecordE studentExamRecordE = new StudentExamRecordE(); + ClassExamPaperDO classExamPaper = classExamPaperRepository.findByClassId(cmd.getClassId()); + List questionList = cmd.getQuestionList(); + List queList = BeanUtil.copyToList(questionList, StudentExamRecordItemE.class); BeanUtils.copyProperties(cmd, studentExamRecordE); + studentExamRecordE.submit(classExamPaper.getPassScore(), queList); + boolean res = false; try { res = studentExamRecordGateway.add(studentExamRecordE); + studentExamRecordItemRepository.saveBatch(BeanUtil.copyToList(queList, StudentExamRecordItemDO.class)); } catch (Exception e) { throw new RuntimeException(e); } if (!res) { throw new BizException("保存失败"); } - return true; + + StudentExamRecordCO studentExamRecordCO = new StudentExamRecordCO(); + BeanUtils.copyProperties(studentExamRecordE, studentExamRecordCO); + studentExamRecordCO.setSurplusExamNum(classDO.getNumberofexams() - count - 1); + return SingleResponse.of(studentExamRecordCO); } } diff --git a/web-app/src/main/java/com/zcloud/edu/command/study/StudentSignUpdateExe.java b/web-app/src/main/java/com/zcloud/edu/command/study/StudentSignUpdateExe.java index 0d71678..eb056f7 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/study/StudentSignUpdateExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/study/StudentSignUpdateExe.java @@ -4,11 +4,16 @@ import com.alibaba.cola.exception.BizException; import com.zcloud.edu.domain.gateway.study.StudentSignGateway; import com.zcloud.edu.domain.model.study.StudentSignE; import com.zcloud.edu.dto.study.StudentSignUpdateCmd; +import com.zcloud.edu.persistence.dataobject.study.StudentDO; +import com.zcloud.edu.persistence.repository.study.StudentRepository; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.util.HashMap; +import java.util.Map; + /** * web-app @@ -20,12 +25,22 @@ import org.springframework.transaction.annotation.Transactional; @AllArgsConstructor public class StudentSignUpdateExe { private final StudentSignGateway studentSignGateway; + private final StudentRepository studentRepository; @Transactional(rollbackFor = Exception.class) public void execute(StudentSignUpdateCmd studentSignUpdateCmd) { StudentSignE studentSignE = new StudentSignE(); BeanUtils.copyProperties(studentSignUpdateCmd, studentSignE); boolean res = studentSignGateway.update(studentSignE); + + Map params = new HashMap<>(); + if (studentSignUpdateCmd.getType() == 1){ + params.put("signFlag",1); + } else if (studentSignUpdateCmd.getType() == 2){ + params.put("examSignFlag",1); + } + params.put("studentId", studentSignUpdateCmd.getStudentId()); + studentRepository.updateStudent(params); if (!res) { throw new BizException("修改失败"); } diff --git a/web-app/src/main/java/com/zcloud/edu/service/study/StudentExamRecordServiceImpl.java b/web-app/src/main/java/com/zcloud/edu/service/study/StudentExamRecordServiceImpl.java index 0fa3bd3..4ba2de2 100644 --- a/web-app/src/main/java/com/zcloud/edu/service/study/StudentExamRecordServiceImpl.java +++ b/web-app/src/main/java/com/zcloud/edu/service/study/StudentExamRecordServiceImpl.java @@ -1,6 +1,7 @@ package com.zcloud.edu.service.study; import com.alibaba.cola.dto.PageResponse; +import com.alibaba.cola.dto.Response; import com.alibaba.cola.dto.SingleResponse; import com.zcloud.edu.api.study.StudentExamRecordServiceI; import com.zcloud.edu.command.query.study.StudentExamRecordQueryExe; @@ -14,6 +15,8 @@ import com.zcloud.edu.dto.study.StudentExamRecordUpdateCmd; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.math.BigDecimal; + /** * web-app * @@ -35,10 +38,8 @@ public class StudentExamRecordServiceImpl implements StudentExamRecordServiceI { } @Override - public SingleResponse add(StudentExamRecordAddCmd cmd) { - - studentExamRecordAddExe.execute(cmd); - return SingleResponse.buildSuccess(); + public SingleResponse add(StudentExamRecordAddCmd cmd) { + return studentExamRecordAddExe.execute(cmd); } @Override diff --git a/web-app/src/main/java/com/zcloud/edu/service/study/StudentServiceImpl.java b/web-app/src/main/java/com/zcloud/edu/service/study/StudentServiceImpl.java index 1696e15..545bce1 100644 --- a/web-app/src/main/java/com/zcloud/edu/service/study/StudentServiceImpl.java +++ b/web-app/src/main/java/com/zcloud/edu/service/study/StudentServiceImpl.java @@ -1,5 +1,6 @@ package com.zcloud.edu.service.study; +import com.alibaba.cola.dto.MultiResponse; import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.dto.SingleResponse; import com.zcloud.edu.api.study.StudentServiceI; @@ -12,10 +13,12 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO; import com.zcloud.edu.dto.data.archives.ClassArchivesDTO; import com.zcloud.edu.dto.data.archives.PersonArchivesDTO; import com.zcloud.edu.dto.study.StudentAddCmd; +import com.zcloud.edu.dto.study.StudentCountQry; import com.zcloud.edu.dto.study.StudentPageQry; import com.zcloud.edu.dto.study.StudentUpdateCmd; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -89,5 +92,10 @@ public class StudentServiceImpl implements StudentServiceI { public SingleResponse getClassExamResult(ClassArchivesQry qry) { return studentQueryExe.executeGetClassExamResult(qry); } + + @Override + public MultiResponse countStudentByCorpId(StudentCountQry qry) { + return studentQueryExe.executeCountStudentByCorpId(qry); + } } diff --git a/web-client/src/main/java/com/zcloud/edu/api/study/StudentServiceI.java b/web-client/src/main/java/com/zcloud/edu/api/study/StudentServiceI.java index 6c79e28..727eb42 100644 --- a/web-client/src/main/java/com/zcloud/edu/api/study/StudentServiceI.java +++ b/web-client/src/main/java/com/zcloud/edu/api/study/StudentServiceI.java @@ -1,5 +1,6 @@ package com.zcloud.edu.api.study; +import com.alibaba.cola.dto.MultiResponse; import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.dto.SingleResponse; import com.zcloud.edu.dto.archives.ClassArchivesQry; @@ -7,8 +8,10 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO; import com.zcloud.edu.dto.data.archives.ClassArchivesDTO; import com.zcloud.edu.dto.data.archives.PersonArchivesDTO; import com.zcloud.edu.dto.study.StudentAddCmd; +import com.zcloud.edu.dto.study.StudentCountQry; import com.zcloud.edu.dto.study.StudentPageQry; import com.zcloud.edu.dto.study.StudentUpdateCmd; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -40,5 +43,7 @@ public interface StudentServiceI { Long countStudent(String classId); SingleResponse getClassExamResult(ClassArchivesQry qry); + + MultiResponse countStudentByCorpId(StudentCountQry qry); } diff --git a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java index cec38c3..7221659 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java @@ -175,6 +175,10 @@ public class StudentCO extends ClientObject { private Integer numberofexams; + // 学员统计数量 + @ApiModelProperty(value = "学员统计数量") + @TableField(exist = false) + private Integer studentCount; diff --git a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordCO.java b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordCO.java index 5d48ccf..3c47f70 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordCO.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordCO.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -56,7 +57,7 @@ public class StudentExamRecordCO extends ClientObject { private Integer examQuestionWrong; //考试得分 @ApiModelProperty(value = "考试得分") - private Object examScore; + private BigDecimal examScore; //考试结果 0 -不通过 1-通过 @ApiModelProperty(value = "考试结果 0 -不通过 1-通过") private Integer result; @@ -67,6 +68,9 @@ public class StudentExamRecordCO extends ClientObject { @ApiModelProperty(value = "试题集合") private List examRecordItemList; + @ApiModelProperty(value = "剩余考试次数") + private Integer surplusExamNum; + //环境 @ApiModelProperty(value = "环境") private String env; diff --git a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordItemCO.java b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordItemCO.java index 3327a5d..f485789 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordItemCO.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentExamRecordItemCO.java @@ -28,15 +28,19 @@ public class StudentExamRecordItemCO extends ClientObject { //学员id @ApiModelProperty(value = "学员id") private String studentId; + + //班级id + @ApiModelProperty(value = "班级id") + private String classId; //习题ID @ApiModelProperty(value = "习题ID") private String questionId; //学员答案 - @ApiModelProperty(value = "学员答案") + @ApiModelProperty(value = "正确答案") private String answer; //正确答案 - @ApiModelProperty(value = "正确答案") - private String answerRight; + @ApiModelProperty(value = "学员答案") + private String choiceAnswer; //删除标识true false @ApiModelProperty(value = "删除标识true false") private String deleteEnum; diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentCountQry.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentCountQry.java new file mode 100644 index 0000000..a843c77 --- /dev/null +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentCountQry.java @@ -0,0 +1,36 @@ +package com.zcloud.edu.dto.study; + +import com.alibaba.cola.dto.PageQuery; +import lombok.Data; + +import java.util.List; + + +/** + * web-client + * + * @Author zhangyue + * @Date 2026-01-13 14:18:15 + */ +@Data +public class StudentCountQry { + + /** + * 查询条件操作前缀,支持以下几种数据库查询操作: + * - `like`: 模糊匹配查询,对应SQL的LIKE操作符 + * - `eq`: 等值查询,对应SQL的=操作符 + * - `gt`: 大于比较查询 + * - `lt`: 小于比较查询 + * - `ge`: 大于等于比较查询 + * - `le`: 小于等于比较查询 + * - `ne`: 不等比较查询,对应SQL的!=操作符 + */ + private String eqStudentId; + private String eqClassId; + private String likeProjectNames; + private String likeName; + private String likeInterestedIds; + private List corpinfoIds; + +} + diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordAddCmd.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordAddCmd.java index 0aa2111..45115c1 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordAddCmd.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordAddCmd.java @@ -9,6 +9,8 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.List; /** * web-client @@ -22,60 +24,50 @@ import javax.validation.constraints.NotNull; @AllArgsConstructor public class StudentExamRecordAddCmd extends Command { @ApiModelProperty(value = "业务id", name = "studentExamRecordId", required = true) - @NotEmpty(message = "业务id不能为空") private String studentExamRecordId; @ApiModelProperty(value = "用户id", name = "userId", required = true) - @NotNull(message = "用户id不能为空") private Long userId; @ApiModelProperty(value = "学员id", name = "studentId", required = true) - @NotEmpty(message = "学员id不能为空") private String studentId; @ApiModelProperty(value = "班级id", name = "classId", required = true) - @NotEmpty(message = "班级id不能为空") private String classId; @ApiModelProperty(value = "企业id", name = "corpinfoId", required = true) - @NotNull(message = "企业id不能为空") private Long corpinfoId; @ApiModelProperty(value = "班级-试卷 表ID", name = "classExamPaperId", required = true) - @NotEmpty(message = "班级-试卷 表ID不能为空") private String classExamPaperId; @ApiModelProperty(value = "试卷id", name = "examPaperId", required = true) - @NotEmpty(message = "试卷id不能为空") private String examPaperId; @ApiModelProperty(value = "考试时间", name = "examTimeBegin", required = true) - @NotEmpty(message = "考试时间不能为空") private String examTimeBegin; @ApiModelProperty(value = "考试交卷时间", name = "examTimeEnd", required = true) - @NotEmpty(message = "考试交卷时间不能为空") private String examTimeEnd; @ApiModelProperty(value = "考试总题数", name = "examQuestionNum", required = true) - @NotNull(message = "考试总题数不能为空") private Integer examQuestionNum; @ApiModelProperty(value = "考试对题数", name = "examQuestionRight", required = true) - @NotNull(message = "考试对题数不能为空") private Integer examQuestionRight; @ApiModelProperty(value = "考试错题数", name = "examQuestionWrong", required = true) - @NotNull(message = "考试错题数不能为空") private Integer examQuestionWrong; @ApiModelProperty(value = "考试得分", name = "examScore", required = true) - @NotEmpty(message = "考试得分不能为空") - private Object examScore; + private BigDecimal examScore; @ApiModelProperty(value = "考试结果 0 -不通过 1-通过", name = "result", required = true) - @NotNull(message = "考试结果 0 -不通过 1-通过不能为空") private Integer result; + @ApiModelProperty(value = "选项", name = "questionList", required = true) + @NotNull(message = "选项不能为空") + private List questionList; + } diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemAddCmd.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemAddCmd.java index 57cee40..1d69a2c 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemAddCmd.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemAddCmd.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import javax.validation.constraints.NotEmpty; +import java.math.BigDecimal; /** * web-client @@ -21,28 +22,24 @@ import javax.validation.constraints.NotEmpty; @AllArgsConstructor public class StudentExamRecordItemAddCmd extends Command { @ApiModelProperty(value = "业务id", name = "studentExamRecordItemId", required = true) - @NotEmpty(message = "业务id不能为空") private String studentExamRecordItemId; @ApiModelProperty(value = "考试记录id", name = "studentExamRecordId", required = true) - @NotEmpty(message = "考试记录id不能为空") private String studentExamRecordId; @ApiModelProperty(value = "学员id", name = "studentId", required = true) - @NotEmpty(message = "学员id不能为空") private String studentId; @ApiModelProperty(value = "习题ID", name = "questionId", required = true) - @NotEmpty(message = "习题ID不能为空") private String questionId; - @ApiModelProperty(value = "学员答案", name = "answer", required = true) - @NotEmpty(message = "学员答案不能为空") + @ApiModelProperty(value = "正确答案", name = "answer", required = true) private String answer; - @ApiModelProperty(value = "正确答案", name = "answerRight", required = true) - @NotEmpty(message = "正确答案不能为空") - private String answerRight; + @ApiModelProperty(value = "学员答案", name = "choiceAnswer", required = true) + private String choiceAnswer; + @ApiModelProperty(value = "分值", name = "score", required = true) + private BigDecimal score; } diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemUpdateCmd.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemUpdateCmd.java index ff90164..901d08b 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemUpdateCmd.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordItemUpdateCmd.java @@ -36,11 +36,11 @@ public class StudentExamRecordItemUpdateCmd extends Command { @ApiModelProperty(value = "习题ID", name = "questionId", required = true) @NotEmpty(message = "习题ID不能为空") private String questionId; - @ApiModelProperty(value = "学员答案", name = "answer", required = true) - @NotEmpty(message = "学员答案不能为空") - private String answer; - @ApiModelProperty(value = "正确答案", name = "answerRight", required = true) + @ApiModelProperty(value = "正确答案", name = "answer", required = true) @NotEmpty(message = "正确答案不能为空") - private String answerRight; + private String answer; + @ApiModelProperty(value = "学员答案", name = "choiceAnswer", required = true) + @NotEmpty(message = "学员答案不能为空") + private String choiceAnswer; } diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordPageQry.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordPageQry.java index 61e10ea..5de7d54 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordPageQry.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordPageQry.java @@ -24,5 +24,6 @@ public class StudentExamRecordPageQry extends PageQuery { * - `ne`: 不等比较查询,对应SQL的!=操作符 */ private String likeStudentExamRecordId; + private String likeStudentId; } diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordUpdateCmd.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordUpdateCmd.java index 74f4127..52980cd 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordUpdateCmd.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentExamRecordUpdateCmd.java @@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; /** * web-client @@ -62,7 +63,7 @@ public class StudentExamRecordUpdateCmd extends Command { private Integer examQuestionWrong; @ApiModelProperty(value = "考试得分", name = "examScore", required = true) @NotEmpty(message = "考试得分不能为空") - private Object examScore; + private BigDecimal examScore; @ApiModelProperty(value = "考试结果 0 -不通过 1-通过", name = "result", required = true) @NotNull(message = "考试结果 0 -不通过 1-通过不能为空") private Integer result; diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentSignUpdateCmd.java b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentSignUpdateCmd.java index 6b11567..ceb49f2 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/StudentSignUpdateCmd.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/StudentSignUpdateCmd.java @@ -21,29 +21,25 @@ import javax.validation.constraints.NotNull; @NoArgsConstructor @AllArgsConstructor public class StudentSignUpdateCmd extends Command { - @ApiModelProperty(value = "${column.comment}", name = "id", required = true) - @NotNull(message = "${column.comment}不能为空") + @ApiModelProperty(value = "id", name = "id", required = true) + @NotNull(message = "id不能为空") private Long id; @ApiModelProperty(value = "学员id", name = "studentId", required = true) - @NotEmpty(message = "学员id不能为空") private String studentId; @ApiModelProperty(value = "业务id", name = "studentSignId", required = true) - @NotEmpty(message = "业务id不能为空") private String studentSignId; @ApiModelProperty(value = "班级id", name = "classId", required = true) - @NotEmpty(message = "班级id不能为空") private String classId; @ApiModelProperty(value = "用户id", name = "userId", required = true) - @NotNull(message = "用户id不能为空") private Long userId; @ApiModelProperty(value = "企业id", name = "corpinfoId", required = true) - @NotNull(message = "企业id不能为空") private Long corpinfoId; @ApiModelProperty(value = "签到人脸路径", name = "faceUrl", required = true) - @NotEmpty(message = "签到人脸路径不能为空") private String faceUrl; + @ApiModelProperty(value = "签字路径", name = "signUrl", required = true) + private String signUrl; @ApiModelProperty(value = "签到类型 1-打卡签到 2-人脸签到", name = "type", required = true) - @NotNull(message = "签到类型 1-打卡签到 2-人脸签到不能为空") private Integer type; + } diff --git a/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordE.java b/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordE.java index ba50c48..a9124e6 100644 --- a/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordE.java +++ b/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordE.java @@ -1,9 +1,14 @@ package com.zcloud.edu.domain.model.study; import com.jjb.saas.framework.domain.model.BaseE; +import com.zcloud.gbscommon.utils.Tools; import lombok.Data; +import org.springframework.util.ObjectUtils; +import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; /** * web-domain @@ -39,7 +44,7 @@ public class StudentExamRecordE extends BaseE { //考试错题数 private Integer examQuestionWrong; //考试得分 - private Object examScore; + private BigDecimal examScore; //考试结果 0 -不通过 1-通过 private Integer result; //环境 @@ -66,5 +71,38 @@ public class StudentExamRecordE extends BaseE { private Long createId; //修改人id private Long updateId; + // 构造函数 + + public void submit(BigDecimal passScore, List queList){ + + examScore = BigDecimal.ZERO; + examQuestionRight = 0; + examQuestionWrong = 0; + examQuestionNum = 0; + this.setStudentExamRecordId(Tools.get32UUID()); + this.setExamQuestionNum(queList.size()); + for (StudentExamRecordItemE que : queList) { + que.setStudentExamRecordId(this.getStudentExamRecordId()); + que.setStudentExamRecordItemId(Tools.get32UUID()); + que.setStudentId(this.getStudentId()); + que.setClassId(this.getClassId()); + if (!ObjectUtils.isEmpty(que.getChoiceAnswer())){ + String choiceAnswer = que.getChoiceAnswer().chars() + .sorted() + .mapToObj(c -> String.valueOf((char) c)) + .collect(Collectors.joining()); + if (choiceAnswer.equals(que.getAnswer())){ + examScore = examScore.add(que.getScore()); + examQuestionRight++; + } + } + } + this.setExamQuestionWrong(examQuestionNum - examQuestionRight); + if (examScore.compareTo(passScore) >= 0){ + result = 1; + } else { + result = 0; + } + } } diff --git a/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordItemE.java b/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordItemE.java index edaf276..17151cc 100644 --- a/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordItemE.java +++ b/web-domain/src/main/java/com/zcloud/edu/domain/model/study/StudentExamRecordItemE.java @@ -3,6 +3,7 @@ package com.zcloud.edu.domain.model.study; import com.jjb.saas.framework.domain.model.BaseE; import lombok.Data; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -20,12 +21,16 @@ public class StudentExamRecordItemE extends BaseE { private String studentExamRecordId; //学员id private String studentId; + //班级id + private String classId; //习题ID private String questionId; - //学员答案 + // private String answer; - //正确答案 - private String answerRight; + // 分数 + private BigDecimal score; + // 学员选择答案 + private String choiceAnswer; //删除标识true false private String deleteEnum; //备注 diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java index d8d1845..026fbb4 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java @@ -101,6 +101,12 @@ public class StudentDO extends BaseDO { @TableField(exist = false) private Integer classCount; + // 学员统计数量 + @ApiModelProperty(value = "学员统计数量") + @TableField(exist = false) + private Integer studentCount; + + @ApiModelProperty(value = "完成班级数") @TableField(exist = false) private Integer completeClassCount; diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordDO.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordDO.java index c5e7b6e..4ef8b96 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordDO.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordDO.java @@ -8,6 +8,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.math.BigDecimal; + /** * web-infrastructure * @@ -57,7 +59,7 @@ public class StudentExamRecordDO extends BaseDO { private Integer examQuestionWrong; //考试得分 @ApiModelProperty(value = "考试得分") - private Object examScore; + private BigDecimal examScore; //考试结果 0 -不通过 1-通过 @ApiModelProperty(value = "考试结果 0 -不通过 1-通过") private Integer result; @@ -70,5 +72,22 @@ public class StudentExamRecordDO extends BaseDO { private String signUrl; + //试卷名称 + @ApiModelProperty(value = "试卷名称") + @TableField(exist = false) + private String examName; + //试卷总分数 + @ApiModelProperty(value = "试卷总分数") + @TableField(exist = false) + private BigDecimal paperExamScore; + //合格分数 + @ApiModelProperty(value = "合格分数") + @TableField(exist = false) + private BigDecimal passScore; + //考试时长(分钟) + @ApiModelProperty(value = "考试时长(分钟)") + @TableField(exist = false) + private Integer examTime; + } diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordItemDO.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordItemDO.java index a2d523b..3ae9df0 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordItemDO.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentExamRecordItemDO.java @@ -37,11 +37,11 @@ public class StudentExamRecordItemDO extends BaseDO { @ApiModelProperty(value = "习题ID") private String questionId; //学员答案 - @ApiModelProperty(value = "学员答案") + @ApiModelProperty(value = "正确答案") private String answer; //正确答案 - @ApiModelProperty(value = "正确答案") - private String answerRight; + @ApiModelProperty(value = "学员答案") + private String choiceAnswer; @ApiModelProperty(value = "试题类型(1单选题、2多选题、3判断题)") diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentExamRecordMapper.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentExamRecordMapper.java index 8cad650..3e7eb4a 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentExamRecordMapper.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentExamRecordMapper.java @@ -1,6 +1,9 @@ package com.zcloud.edu.persistence.mapper.study; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.zcloud.edu.persistence.dataobject.study.ClassDO; import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -15,5 +18,9 @@ import org.apache.ibatis.annotations.Param; public interface StudentExamRecordMapper extends BaseMapper { StudentExamRecordDO getInfoByStudentId(@Param("studentId") String studentId); + Integer countByStudentId(@Param("studentId") String studentId); + + IPage listPage(IPage page, @Param("ew") QueryWrapper queryWrapper, String menuPerms); + } diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentMapper.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentMapper.java index 2e1d598..3395f77 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentMapper.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/mapper/study/StudentMapper.java @@ -29,6 +29,10 @@ public interface StudentMapper extends BaseMapper { List listAll(@Param("params") Map params); + void updateStudent(@Param("params") Map params); + + List countStudentByCorpId(@Param("params") Map params); + } diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/impl/study/StudentExamRecordRepositoryImpl.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/impl/study/StudentExamRecordRepositoryImpl.java index a228568..077915b 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/impl/study/StudentExamRecordRepositoryImpl.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/impl/study/StudentExamRecordRepositoryImpl.java @@ -68,5 +68,10 @@ public class StudentExamRecordRepositoryImpl extends BaseRepositoryImpl params) { + studentMapper.updateStudent(params); + } + + @Override + public List countStudentByCorpId(Map params) { + return studentMapper.countStudentByCorpId(params); + } + } diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentExamRecordRepository.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentExamRecordRepository.java index 10a3bd1..133d9c1 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentExamRecordRepository.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentExamRecordRepository.java @@ -23,5 +23,7 @@ public interface StudentExamRecordRepository extends BaseRepository listAllByStudentId(String studentId); StudentExamRecordDO getInfoByStudentId(String studentId); + + Integer countByStudentId(String studentId); } diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentRepository.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentRepository.java index 4239eec..437b699 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentRepository.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/repository/study/StudentRepository.java @@ -31,12 +31,14 @@ public interface StudentRepository extends BaseRepository { StudentDO findFaceUrlByPhone(String phone); - List countStuClass(Map params); + List countStuClass(Map params); StudentDO findInfoByStudentId(String studentId); List listAll(Map params); + void updateStudent(Map params); + List countStudentByCorpId(Map params); } diff --git a/web-infrastructure/src/main/resources/mapper/study/StudentExamRecordMapper.xml b/web-infrastructure/src/main/resources/mapper/study/StudentExamRecordMapper.xml index 2184085..14e1057 100644 --- a/web-infrastructure/src/main/resources/mapper/study/StudentExamRecordMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/study/StudentExamRecordMapper.xml @@ -33,5 +33,30 @@ er.result desc, er.exam_score desc, er.create_time desc limit 1 + + + + diff --git a/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml b/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml index 7343559..cf3aebf 100644 --- a/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml @@ -103,5 +103,37 @@ + + update + student + + + ,sign_flag = #{params.signFlag} + + + ,exam_sign_flag = #{params.examSignFlag} + + + where + student_id = #{params.studentId} + + + + +