multi-admin/src/main/java/com/gkhy/exam/admin/controller/app/AppPaperStudentController.java
@@ -1,8 +1,12 @@ package com.gkhy.exam.admin.controller.app; import com.gkhy.exam.common.annotation.Log; import com.gkhy.exam.common.annotation.RepeatSubmit; import com.gkhy.exam.common.api.CommonResult; import com.gkhy.exam.common.enums.BusinessType; import com.gkhy.exam.system.domain.ExPaperStudent; import com.gkhy.exam.system.domain.vo.BatchPaperStudentVO; import com.gkhy.exam.system.service.ExPaperStudentService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -68,4 +72,15 @@ paperStudentService.endExam(paperStudent); return CommonResult.success(); } @RepeatSubmit @ApiOperation(value = "重新考试") @PostMapping("/againExam") public CommonResult againExam(@RequestBody ExPaperStudent exPaperStudent) { paperStudentService.againExam(exPaperStudent); return CommonResult.success(); } } multi-system/src/main/java/com/gkhy/exam/system/domain/ExExamRecord.java
@@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; import java.time.LocalDateTime; import java.util.List; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; @@ -112,4 +113,8 @@ private ExStudent student; @ApiModelProperty("培训记录文件") @TableField(exist = false) private List<RecordFile> files; } multi-system/src/main/java/com/gkhy/exam/system/domain/RecordFile.java
对比新文件 @@ -0,0 +1,22 @@ package com.gkhy.exam.system.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @Data public class RecordFile implements Serializable { @ApiModelProperty("主键") @TableId(value = "id", type = IdType.AUTO) private Integer id; @TableField("record_id") private Integer recordId; @TableField("file_name") private String fileName; @TableField("file_path") private String filePath; } multi-system/src/main/java/com/gkhy/exam/system/mapper/ExExamRecordMapper.java
@@ -2,7 +2,9 @@ import com.gkhy.exam.system.domain.ExExamRecord; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.gkhy.exam.system.domain.RecordFile; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -29,4 +31,10 @@ * @return */ ExExamRecord selectExamRecordById(Long recordId); void insertFile(@Param("files") List<RecordFile> files, @Param("recordId") Long recordId); void deletedFile(@Param("id") Long id); List<RecordFile> selectFiles(@Param("id") Long id); } multi-system/src/main/java/com/gkhy/exam/system/mapper/ExPaperStudentMapper.java
@@ -90,5 +90,5 @@ void batchUpdateComplete(@Param("paperStudentIds") List<Long> paperStudentIds,@Param("completed") Integer completed); void deleteByPaperStudentId(@Param("paperId") Long paperId, @Param("studentId") Long studentId); } multi-system/src/main/java/com/gkhy/exam/system/mapper/ExStudentAnswerMapper.java
@@ -33,4 +33,6 @@ * @return */ ExStudentAnswer getStudentAnswer(ExStudentAnswer studentAnswer); void deletedByPaperStudentId(@Param("paperId") Long paperId, @Param("studentId") Long studentId); } multi-system/src/main/java/com/gkhy/exam/system/service/ExPaperStudentService.java
@@ -102,4 +102,5 @@ */ public void handlePaperData(ExPaperStudent paperStudent); void againExam(ExPaperStudent exPaperStudent); } multi-system/src/main/java/com/gkhy/exam/system/service/impl/ExExamRecordServiceImpl.java
@@ -8,8 +8,10 @@ import com.gkhy.exam.common.utils.PageUtils; import com.gkhy.exam.common.utils.SecurityUtils; import com.gkhy.exam.system.domain.ExExamRecord; import com.gkhy.exam.system.domain.RecordFile; import com.gkhy.exam.system.mapper.ExExamRecordMapper; import com.gkhy.exam.system.service.ExExamRecordService; import org.ehcache.core.util.CollectionUtil; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -35,20 +37,31 @@ } PageUtils.startPage(); List<ExExamRecord> recordList=baseMapper.selectExamRecordList(examRecord); for (ExExamRecord exExamRecord : recordList) { List<RecordFile> recordFiles = baseMapper.selectFiles(exExamRecord.getId()); exExamRecord.setFiles(recordFiles); } return CommonPage.restPage(recordList); } @Override public ExExamRecord selectExamRecordById(Long recordId) { return baseMapper.selectExamRecordById(recordId); ExExamRecord exExamRecord = baseMapper.selectExamRecordById(recordId); List<RecordFile> recordFiles = baseMapper.selectFiles(exExamRecord.getId()); exExamRecord.setFiles(recordFiles); return exExamRecord; } @Override public int insertExamRecord(ExExamRecord examRecord) { checkUserAllowed(examRecord); examRecord.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId()); // examRecord.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId()); examRecord.setCreateBy(SecurityUtils.getUsername()); int row=baseMapper.insert(examRecord); List<RecordFile> files = examRecord.getFiles(); if (!files.isEmpty()){ baseMapper.insertFile(files,examRecord.getId()); } if(row<1){ throw new ApiException("新增登记记录失败"); } @@ -60,6 +73,11 @@ checkUserAllowed(examRecord); examRecord.setUpdateBy(SecurityUtils.getUsername()); int row=baseMapper.updateById(examRecord); List<RecordFile> files = examRecord.getFiles(); baseMapper.deletedFile(examRecord.getId()); if (!files.isEmpty()){ baseMapper.insertFile(files, examRecord.getId()); } if(row<1){ throw new ApiException("更新登记记录失败"); } @@ -69,13 +87,14 @@ @Override public int deleteExamRecordById(Long recordId) { checkUserAllowed(baseMapper.selectById(recordId)); baseMapper.deletedFile(recordId); return baseMapper.deleteById(recordId); } public void checkUserAllowed(ExExamRecord examRecord) { SysUser currentUser= SecurityUtils.getLoginUser().getUser(); if(currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){ throw new ApiException("管理员没有权限操作"); return; } if(currentUser.getUserType().equals(UserTypeEnum.STUDENT.getCode())){ throw new ApiException("没有权限操作"); multi-system/src/main/java/com/gkhy/exam/system/service/impl/ExPaperStudentServiceImpl.java
@@ -322,6 +322,19 @@ } } @Override @Transactional public void againExam(ExPaperStudent exPaperStudent) { baseMapper.deleteByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId()); studentAnswerMapper.deletedByPaperStudentId(exPaperStudent.getPaperId(),exPaperStudent.getStudentId()); BatchPaperStudentVO batchPaperStudentVO = new BatchPaperStudentVO(); batchPaperStudentVO.setPaperId(exPaperStudent.getPaperId()); List<Long> longs = new ArrayList<>(); longs.add(exPaperStudent.getStudentId()); batchPaperStudentVO.setStudentIds(longs); batchAddPaperStudent(batchPaperStudentVO); } private Integer getScore(ExExamPaper examPaper,Integer questionType){ if(questionType.equals(QuestionTypeEnum.SINGLE.getCode())){ return examPaper.getSingleScore(); multi-system/src/main/resources/mapper/system/ExExamRecordMapper.xml
@@ -31,21 +31,35 @@ <sql id="selectExamRecordVo"> select a.id, a.company_id, a.student_id, a.plan_name, a.course_name,a.level,a.period,a.actual_period,a.score, a.company_id,a.passed, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name, a.passed, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name, c.name as student_name,c.id_no as student_idno,c.phone as student_phone from ex_exam_record a left join sys_company b on b.id=a.company_id left join ex_student c on c.id=a.student_id </sql> <insert id="insertFile"> INSERT INTO `record_file` (`record_id`, `file_name`, `file_path`) VALUES <foreach collection="files" separator="," item="item"> ( #{recordId},#{item.fileName}, #{item.filePath}) </foreach> </insert> <delete id="deletedFile"> delete from record_file where record_id = #{id} </delete> <select id="selectExamRecordList" resultMap="ExamRecordResult"> <include refid="selectExamRecordVo"/> <where> <if test="planName != null and planName != ''"> AND a.plan_name like concat('%', #{planName}, '%') <if test="courseName != null and courseName != ''"> AND a.course_name like concat('%', #{courseName}, '%') </if> <if test="companyId != null "> AND a.company_id =#{companyId} <if test="companyName != null "> AND b.name like concat('%',#{companyName},'%') </if> <if test="companyId!=null"> and a.company_id = #{companyId} </if> </where> order by a.id desc @@ -55,4 +69,13 @@ <include refid="selectExamRecordVo"/> where a.id=#{recordId} </select> <select id="selectFiles" resultType="com.gkhy.exam.system.domain.RecordFile"> select id, record_id, file_name, file_path from record_file where record_id = #{id} </select> </mapper> multi-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml
@@ -107,6 +107,9 @@ #{item} </foreach> </update> <delete id="deleteByPaperStudentId"> delete from ex_paper_student where paper_id =#{paperId} and student_id = #{studentId} </delete> <select id="countByPaperId" resultType="java.lang.Integer"> select count(1) from ex_paper_student where paper_id=#{paperId} multi-system/src/main/resources/mapper/system/ExStudentAnswerMapper.xml
@@ -1,6 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.gkhy.exam.system.mapper.ExStudentAnswerMapper"> <delete id="deletedByPaperStudentId"> DELETE FROM ex_student_answer WHERE paper_id = #{paperId} AND student_id = #{studentId} </delete> <select id="countByPaperId" resultType="java.lang.Integer"> select count(1) from ex_student_answer where paper_id=#{paperId} and student_id=#{studentId}