安全教育和红外对射修改

This commit is contained in:
pengjie 2024-05-21 20:19:15 +08:00
parent a9f475fcff
commit dfbc7c85d1
4 changed files with 43 additions and 20 deletions

View File

@ -211,27 +211,16 @@ public class ExamCourseRecordController {
*/ */
@ApiOperation(value = "导出excel学习情况信息", notes = "导出excel学习情况信息", httpMethod = "POST") @ApiOperation(value = "导出excel学习情况信息", notes = "导出excel学习情况信息", httpMethod = "POST")
@RequestMapping(value = "/exportXls") @RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) { public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> map) {
// Step.1 组装查询条件 // Step.1 组装查询条件
QueryWrapper<ExamCourseRecord> queryWrapper = null; QueryWrapper<ExamCourseRecord> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamCourseRecord.class, map);
try { List<ExamCourseRecord> pageList = examCourseRecordService.page(new Page<>(-1 , -1), queryWrapper).getRecords();
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
ExamCourseRecord examCourseRecord = JSON.parseObject(deString, ExamCourseRecord.class);
queryWrapper = QueryGenerator.initQueryWrapper(examCourseRecord, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Step.2 AutoPoi 导出Excel //Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<ExamCourseRecord> pageList = examCourseRecordService.list(queryWrapper);
//导出文件名称 //导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "学习情况列表"); mv.addObject(NormalExcelConstants.FILE_NAME, "学习情况列表");
mv.addObject(NormalExcelConstants.CLASS, ExamCourseRecord.class); mv.addObject(NormalExcelConstants.CLASS, ExamCourseRecord.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("学习情况列表数据", "导出人:Jeecg", "导出信息")); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("学习情况列表数据", "导出人:" + SecurityUtils.getUser().getRealName(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList); mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv; return mv;
} }

View File

@ -111,24 +111,28 @@ public class ExamQuestionBankController {
@OperLog(operModul = "题目管理管理", operType = "列表查询", operDesc = "随机获取题目") @OperLog(operModul = "题目管理管理", operType = "列表查询", operDesc = "随机获取题目")
@ApiOperation(value = " 随机获取题目", notes = "随机获取题目", httpMethod = "POST") @ApiOperation(value = " 随机获取题目", notes = "随机获取题目", httpMethod = "POST")
@PostMapping(value = "/random") @PostMapping(value = "/random")
public Result<HashSet<Long>> random(@RequestBody List<RandomQuery> randomQueryList) { public Result<List<ExamQuestionBank>> random(@RequestBody List<RandomQuery> randomQueryList) {
LambdaQueryWrapper<ExamQuestionBank> queryWrapper = Wrappers.<ExamQuestionBank>lambdaQuery(); LambdaQueryWrapper<ExamQuestionBank> queryWrapper = Wrappers.<ExamQuestionBank>lambdaQuery();
if (randomQueryList.get(0).getSubjectId() != null) {
queryWrapper.eq(ExamQuestionBank::getSubjectId, randomQueryList.get(0).getSubjectId());
}
List<ExamQuestionBank> list = examQuestionBankService.list(queryWrapper); List<ExamQuestionBank> list = examQuestionBankService.list(queryWrapper);
HashSet<Long> resultList = new HashSet<>(); HashSet<Long> resultList = new HashSet<>();
Random random = new Random(); Random random = new Random();
for (int i = 0; i < randomQueryList.size(); i++) { for (int i = 0; i < randomQueryList.size(); i++) {
int finalI = i; int finalI = i;
List<ExamQuestionBank> radioList = list.stream().filter(l -> l.getType() == finalI + 1 && List<ExamQuestionBank> radioList = list.stream()
l.getDifficulty() == randomQueryList.get(finalI).getDifficulty()).collect(Collectors.toList()); .filter(l -> l.getType() == randomQueryList.get(finalI).getType()
&& l.getDifficulty() == randomQueryList.get(finalI).getDifficulty()).collect(Collectors.toList());
for (int j = 0; j < randomQueryList.get(i).getNumber();) { for (int j = 0; j < randomQueryList.get(i).getNumber();) {
int index = random.nextInt(radioList.size()); int index = random.nextInt(radioList.size());
boolean add = resultList.add(radioList.get(index).getId()); boolean add = resultList.add(radioList.get(index).getId());
if (add) { if (add) {
i++; j++;
} }
} }
} }
return Result.success(resultList); return Result.success(examQuestionBankService.listByIds(resultList));
} }

View File

@ -2,6 +2,8 @@ package com.zhgd.xmgl.modules.exam.controller;
import com.zhgd.annotation.OperLog; import com.zhgd.annotation.OperLog;
import com.zhgd.xmgl.modules.exam.entity.ExamAnswerQuestion; import com.zhgd.xmgl.modules.exam.entity.ExamAnswerQuestion;
import com.zhgd.xmgl.modules.exam.entity.ExamCourseRecord;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.PageUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -233,4 +235,26 @@ public class ExamTrainRecordController {
public Result<Object> submit(@RequestBody List<ExamAnswerQuestion> examAnswerQuestionList) { public Result<Object> submit(@RequestBody List<ExamAnswerQuestion> examAnswerQuestionList) {
return Result.success(examTrainRecordService.submit(examAnswerQuestionList)); return Result.success(examTrainRecordService.submit(examAnswerQuestionList));
} }
/**
* 导出excel
*
* @param request
* @param response
*/
@ApiOperation(value = "导出excel学习情况信息", notes = "导出excel学习情况信息", httpMethod = "POST")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> map) {
// Step.1 组装查询条件
QueryWrapper<ExamTrainRecord> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamTrainRecord.class, map);
IPage<ExamTrainRecord> pageList = examTrainRecordService.page(new Page<>(-1, -1), queryWrapper);
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "教育培训情况列表");
mv.addObject(NormalExcelConstants.CLASS, ExamTrainRecord.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("教育培训情况列表数据", "导出人:" + SecurityUtils.getUser().getRealName(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
} }

View File

@ -6,6 +6,12 @@ import lombok.Data;
@Data @Data
public class RandomQuery { public class RandomQuery {
@ApiModelProperty(value = "科目ID")
private Long subjectId;
@ApiModelProperty(value = "试题类型(1单选题2多选题3填空题)")
private Integer type;
@ApiModelProperty(value = "难易程度") @ApiModelProperty(value = "难易程度")
private Integer difficulty; private Integer difficulty;