src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java
@@ -4,16 +4,25 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.excel.ExamScoreExcel; import org.springblade.modules.exam.excel.ExamScoreImporter; import org.springblade.modules.exam.excel.ExamSubjectExcel; import org.springblade.modules.exam.excel.ExamSubjectImporter; import org.springblade.modules.exam.service.ExamSubjectChoicesService; import org.springblade.modules.exam.vo.ExamSubjectChoicesVO; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @author zhongrj @@ -153,4 +162,27 @@ return R.status(examSubjectChoicesService.updateChoicesValue(id,value)); } /** * 导入题库 * @param isCovered 1 覆盖 0不覆盖 * @return */ @PostMapping("import-examSubject") @ApiOperation(value = "导入题库", notes = "传入excel") public R importExamScore(MultipartFile file, Integer isCovered) { ExamSubjectImporter examSubjectImporter = new ExamSubjectImporter(examSubjectChoicesService, false); ExcelUtil.save(file, examSubjectImporter, ExamSubjectExcel.class); return R.success("操作成功"); } /** * 导出模板 */ @GetMapping("export-template") @ApiOperation(value = "导出模板") public void exportUser(HttpServletResponse response) { List<ExamSubjectExcel> list = new ArrayList<>(); ExcelUtil.export(response, "题库导入数据模板", "题库导入数据表", list, ExamSubjectExcel.class); } } src/main/java/org/springblade/modules/exam/excel/ExamSubjectExcel.java
New file @@ -0,0 +1,84 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.exam.excel; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; import lombok.Data; import java.io.Serializable; /** * 题目导入 * @author zhongrj * @since 2021-08-05 */ @Data @ColumnWidth(25) @HeadRowHeight(20) @ContentRowHeight(18) public class ExamSubjectExcel implements Serializable { private static final long serialVersionUID = 1L; @ColumnWidth(25) @ExcelProperty("题目名称") private String subjectName; @ColumnWidth(15) @ExcelProperty("题目类型(0:单选题 1:多选题 2:判断题 3:实操题)") private Integer choicesType; @ColumnWidth(20) @ExcelProperty("题库类型 A为简易题库,B为复杂题库,C为模拟题库") private String tktype; @ColumnWidth(25) @ExcelProperty("A项内容,选项内容判断题不需要填写") private String optionContentA; @ColumnWidth(25) @ExcelProperty("B项内容") private String optionContentB; @ColumnWidth(25) @ExcelProperty("C项内容") private String optionContentC; @ColumnWidth(25) @ExcelProperty("D项内容") private String optionContentD; @ColumnWidth(25) @ExcelProperty("E项内容(单选,多选,判断题不需填写,实操题ABCDE分别对应12345)") private String optionContentE; @ColumnWidth(15) @ExcelProperty("答案,多选和实操答案以英文逗号隔开,如A,B") private String answer; @ColumnWidth(15) @ExcelProperty("分值") private Integer score; @ColumnWidth(20) @ExcelProperty("解析") private String analysis; } src/main/java/org/springblade/modules/exam/excel/ExamSubjectImporter.java
New file @@ -0,0 +1,41 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.exam.excel; import lombok.RequiredArgsConstructor; import org.springblade.core.excel.support.ExcelImporter; import org.springblade.modules.exam.service.ExamSubjectChoicesService; import java.util.List; /** * 题目成绩导入类 * * @author zhongrj * @since 2021-08-05 */ @RequiredArgsConstructor public class ExamSubjectImporter implements ExcelImporter<ExamSubjectExcel> { private final ExamSubjectChoicesService service; private final Boolean isCovered; @Override public void save(List<ExamSubjectExcel> data) { service.importSubject(data, isCovered); } } src/main/java/org/springblade/modules/exam/service/ExamSubjectChoicesService.java
@@ -3,7 +3,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.excel.ExamSubjectExcel; import org.springblade.modules.exam.vo.ExamSubjectChoicesVO; import java.util.List; /** * 选择题服务类 @@ -44,4 +47,11 @@ * @return */ boolean saveSubjectChoicesAndOption(ExamSubjectChoicesVO examSubjectChoices); /** * 题库导入 * @param data 导入数据 * @param isCovered */ void importSubject(List<ExamSubjectExcel> data, Boolean isCovered); } src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
@@ -7,6 +7,7 @@ import org.springblade.common.utils.arg; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.entity.ExamSubjectOption; import org.springblade.modules.exam.excel.ExamSubjectExcel; import org.springblade.modules.exam.mapper.ExamSubjectChoicesMapper; import org.springblade.modules.exam.service.ExamSubjectChoicesService; import org.springblade.modules.exam.service.ExamSubjectOptionService; @@ -14,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -148,4 +150,156 @@ } return status; } /** * 题库导入 * @param data 导入数据 * @param isCovered */ @Override public void importSubject(List<ExamSubjectExcel> data, Boolean isCovered) { data.forEach(examSubjectExcel -> { //题目对象 ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); subjectChoices.setCreateDate(new Date()); subjectChoices.setDelFlag(0); subjectChoices.setAnswer(examSubjectExcel.getAnswer()); if (null != examSubjectExcel.getAnalysis() && examSubjectExcel.getAnalysis() != "") { subjectChoices.setAnalysis(examSubjectExcel.getAnalysis()); } subjectChoices.setChoicesType(examSubjectExcel.getChoicesType()); subjectChoices.setSubjectName(examSubjectExcel.getSubjectName()); subjectChoices.setScore(examSubjectExcel.getScore()); subjectChoices.setTktype(examSubjectExcel.getTktype()); //题目新增 this.save(subjectChoices); //判断类型,单选,多选选项新增 if (examSubjectExcel.getChoicesType() == 0 || examSubjectExcel.getChoicesType() == 1) { //A选项新增 ExamSubjectOption examSubjectOption = new ExamSubjectOption(); //选项新增 examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption.setCreateDate(new Date()); examSubjectOption.setDelFlag(0); examSubjectOption.setOptionName("A"); examSubjectOption.setOptionContent(examSubjectExcel.getOptionContentA()); //新增 examSubjectOptionService.save(examSubjectOption); //B选项新增 ExamSubjectOption examSubjectOption1 = new ExamSubjectOption(); //选项新增 examSubjectOption1.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption1.setCreateDate(new Date()); examSubjectOption1.setDelFlag(0); examSubjectOption1.setOptionName("B"); examSubjectOption1.setOptionContent(examSubjectExcel.getOptionContentB()); //新增 examSubjectOptionService.save(examSubjectOption1); //C选项新增 ExamSubjectOption examSubjectOption2 = new ExamSubjectOption(); //选项新增 examSubjectOption2.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption2.setCreateDate(new Date()); examSubjectOption2.setDelFlag(0); examSubjectOption2.setOptionName("C"); examSubjectOption2.setOptionContent(examSubjectExcel.getOptionContentC()); //新增 examSubjectOptionService.save(examSubjectOption2); //D选项新增 ExamSubjectOption examSubjectOption3 = new ExamSubjectOption(); //选项新增 examSubjectOption3.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption3.setCreateDate(new Date()); examSubjectOption3.setDelFlag(0); examSubjectOption3.setOptionName("D"); examSubjectOption3.setOptionContent(examSubjectExcel.getOptionContentD()); //新增 examSubjectOptionService.save(examSubjectOption3); } //多选选项新增 if (examSubjectExcel.getChoicesType() == 3) { //1选项新增 if (null!=examSubjectExcel.getOptionContentA() && examSubjectExcel.getOptionContentA()!="") { ExamSubjectOption examSubjectOption = new ExamSubjectOption(); //选项新增 examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption.setCreateDate(new Date()); examSubjectOption.setDelFlag(0); examSubjectOption.setOptionName("1"); examSubjectOption.setOptionContent(examSubjectExcel.getOptionContentA()); //新增 examSubjectOptionService.save(examSubjectOption); } //2选项新增 if (null!=examSubjectExcel.getOptionContentB() && examSubjectExcel.getOptionContentB()!="") { ExamSubjectOption examSubjectOption1 = new ExamSubjectOption(); //选项新增 examSubjectOption1.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption1.setCreateDate(new Date()); examSubjectOption1.setDelFlag(0); examSubjectOption1.setOptionName("2"); examSubjectOption1.setOptionContent(examSubjectExcel.getOptionContentB()); //新增 examSubjectOptionService.save(examSubjectOption1); } //3选项新增 if (null!=examSubjectExcel.getOptionContentC() && examSubjectExcel.getOptionContentC()!="") { ExamSubjectOption examSubjectOption2 = new ExamSubjectOption(); //选项新增 examSubjectOption2.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption2.setCreateDate(new Date()); examSubjectOption2.setDelFlag(0); examSubjectOption2.setOptionName("3"); examSubjectOption2.setOptionContent(examSubjectExcel.getOptionContentC()); //新增 examSubjectOptionService.save(examSubjectOption2); } //4选项新增 if (null!=examSubjectExcel.getOptionContentD() && examSubjectExcel.getOptionContentD()!="") { ExamSubjectOption examSubjectOption3 = new ExamSubjectOption(); //选项新增 examSubjectOption3.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption3.setCreateDate(new Date()); examSubjectOption3.setDelFlag(0); examSubjectOption3.setOptionName("4"); examSubjectOption3.setOptionContent(examSubjectExcel.getOptionContentD()); //新增 examSubjectOptionService.save(examSubjectOption3); } //5选项新增 if (null!=examSubjectExcel.getOptionContentE() && examSubjectExcel.getOptionContentE()!="") { ExamSubjectOption examSubjectOption4 = new ExamSubjectOption(); //选项新增 examSubjectOption4.setSubjectChoicesId(subjectChoices.getId()); examSubjectOption4.setCreateDate(new Date()); examSubjectOption4.setDelFlag(0); examSubjectOption4.setOptionName("5"); examSubjectOption4.setOptionContent(examSubjectExcel.getOptionContentE()); //新增 examSubjectOptionService.save(examSubjectOption4); } } //内网数据同步 try { // arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices); } catch (Exception e) { e.printStackTrace(); } }); } } src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -166,6 +166,7 @@ dept.dept_name AS label, dept.id AS "key", dept.id AS "value", 1 as idCardNo, ( SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END @@ -205,6 +206,7 @@ bu.real_name AS label, bu.id AS "key", bu.id AS "value", bu.cardid as idCardNo, 0 as "has_children" from blade_user bu left join src/main/java/org/springblade/modules/system/vo/DeptAndUserVO.java
@@ -20,4 +20,9 @@ using = ToStringSerializer.class ) private Long value; /** * 身份证号 */ private String idCardNo; } src/main/java/org/springblade/modules/training/controller/TrainExamController.java
@@ -146,9 +146,8 @@ * @return */ @GetMapping("/page-tree") public R pageTree(TrainExam trainExam) { List<TrainExam> pages = trainExamService.selectTrainExamPageTree(trainExam); return R.data(pages); public List<TrainExam> pageTree(TrainExam trainExam) { return trainExamService.selectTrainExamPageTree(trainExam); } } src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java
@@ -92,6 +92,11 @@ @PostMapping("/submit") public R submit(@RequestBody TrainingRegistration trainingRegistration) throws Exception { if (null==trainingRegistration.getId()){ //查询是否已报名 Integer registration = trainingRegistrationService.getTrainingRegistrationInfo(trainingRegistration); if (null==registration){ return R.data(201,"已报名,不能重复报名"); } trainingRegistration.setTrainingTime(new Date()); trainingRegistration.setCancel(1); //默认报名未考试状态 @@ -102,7 +107,11 @@ // trainingRegistration.setApplyCode(getApplyCode(trainingRegistration)); } // arg.test01(arg.url+"/trainingRegistration/submit",trainingRegistration); return R.status(trainingRegistrationService.saveOrUpdate(trainingRegistration)); boolean status = trainingRegistrationService.saveOrUpdate(trainingRegistration); if (status){ return R.data(200,"报名成功"); } return R.data(202,"报名失败"); } /** src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.java
@@ -45,4 +45,11 @@ * @return */ int getCandidateNoCount(@Param("result")String result); /** * 查询培训报名信息 * @param trainingRegistration 培训报名对象信息 * @return */ Integer getTrainingRegistrationInfo(@Param("trainingRegistration")TrainingRegistration trainingRegistration); } src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml
@@ -126,4 +126,19 @@ and candidate_no like concat('%', #{result},'%') </if> </select> <!--查询培训报名信息--> <select id="getTrainingRegistrationInfo" resultType="java.lang.Integer"> select 1 from sys_training_registration where 1=1 and cancel = 1 and is_exam = 1 <if test="trainingRegistration.userId!=null and trainingRegistration.userId!=''"> and user_id = #{trainingRegistration.userId} </if> <if test="trainingRegistration.trainExamId!=null and trainingRegistration.trainExamId!=''"> and train_exam_id = #{trainingRegistration.trainExamId} </if> limit 1 </select> </mapper> src/main/java/org/springblade/modules/training/service/TrainingRegistrationService.java
@@ -48,4 +48,11 @@ * @return */ int getCandidateNoCount(String result); /** * 查询培训报名信息 * @param trainingRegistration 培训报名对象信息 * @return */ Integer getTrainingRegistrationInfo(TrainingRegistration trainingRegistration); } src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
@@ -87,4 +87,14 @@ public int getCandidateNoCount(String result) { return baseMapper.getCandidateNoCount(result); } /** * 查询培训报名信息 * @param trainingRegistration 培训报名对象信息 * @return */ @Override public Integer getTrainingRegistrationInfo(TrainingRegistration trainingRegistration) { return baseMapper.getTrainingRegistrationInfo(trainingRegistration); } } src/main/resources/application.yml
@@ -1,6 +1,6 @@ #服务器配置 server: port: 82 port: 81 undertow: # 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程 io-threads: 16