考试修改

This commit is contained in:
pengjie 2024-06-04 17:40:10 +08:00
parent ad2e38738c
commit aff7659b9a
8 changed files with 56 additions and 1 deletions

View File

@ -438,6 +438,13 @@ public class ExamQuestionBankController {
return Result.ok("文件导入失败!");
}
@ApiOperation(value = "导入模板下载", notes = "导入模板下载", httpMethod = "GET")
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String")
@GetMapping(value = "/exporExcelTemplate")
public void exporExcelTemplate(HttpServletResponse response, String projectSn) {
examQuestionBankService.exporExcelTemplate(response, projectSn);
}
private String getType(int type) {
String typeName = null;
switch (type) {

View File

@ -69,7 +69,8 @@ public class ExamWorkerController {
String workerId = MapUtils.getString(map, "workerId");
List<ExamTrainRecordVo> list = examTrainRecordService.pageList(new Page(1, -1), Wrappers.<ExamTrainRecord>lambdaQuery()
.eq(ExamTrainRecord::getWorkerId, workerId)
.eq(ExamTrainRecord::getIsPass, 0)).getRecords();
.eq(ExamTrainRecord::getIsPass, 0)
.gt(ExamTrainRecord::getExamCount, 0)).getRecords();
return Result.success(list);
}
@ -122,6 +123,7 @@ public class ExamWorkerController {
result.error500("未找到对应实体");
} else {
examTrainRecordEntity.setStartExamTime(new Date());
examTrainRecordEntity.setExamNum(examTrainRecordEntity.getExamCount() - 1);
result.setResult(examTrainRecordService.updateById(examTrainRecordEntity));
result.setSuccess(true);
}

View File

@ -92,6 +92,12 @@ public class ExamTrainRecord implements Serializable {
*/
@Excel(name = "考试次数", width = 15)
@ApiModelProperty(value = "考试次数")
private Integer examCount;
/**
* 考试次数
*/
@Excel(name = "考试次数", width = 15)
@ApiModelProperty(value = "考试次数")
private Integer examNum;
/**
* 是否签到

View File

@ -4,6 +4,7 @@ import com.zhgd.xmgl.modules.exam.entity.ExamQuestionBank;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -23,4 +24,6 @@ public interface IExamQuestionBankService extends IService<ExamQuestionBank> {
ExamQuestionBankVo queryById(Long id);
List<ExamQuestionBankVo> queryByBatchId(List<Long> ids);
void exporExcelTemplate(HttpServletResponse response, String projectSn);
}

View File

@ -1,14 +1,18 @@
package com.zhgd.xmgl.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.exam.entity.ExamQuestionBank;
import com.zhgd.xmgl.modules.exam.entity.ExamQuestionOption;
import com.zhgd.xmgl.modules.exam.entity.ExamSubject;
import com.zhgd.xmgl.modules.exam.mapper.ExamQuestionBankMapper;
import com.zhgd.xmgl.modules.exam.service.IExamQuestionBankService;
import com.zhgd.xmgl.modules.exam.service.IExamQuestionOptionService;
import com.zhgd.xmgl.modules.exam.service.IExamSubjectService;
import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.ExcelUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -16,6 +20,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -33,6 +38,9 @@ public class ExamQuestionBankServiceImpl extends ServiceImpl<ExamQuestionBankMap
@Autowired
private IExamQuestionOptionService examQuestionOptionService;
@Autowired
private IExamSubjectService examSubjectService;
@Override
public boolean saveInfo(ExamQuestionBankVo examQuestionBankVo) {
UserInfo user = SecurityUtils.getUser();
@ -92,4 +100,10 @@ public class ExamQuestionBankServiceImpl extends ServiceImpl<ExamQuestionBankMap
}
return examQuestionBankVoList;
}
@Override
public void exporExcelTemplate(HttpServletResponse response, String projectSn) {
List<ExamSubject> subjectList = examSubjectService.list(Wrappers.<ExamSubject>lambdaQuery().eq(ExamSubject::getProjectSn, projectSn));
ExcelUtils.exporExcelExamQuestionBankTemplate(response, subjectList);
}
}

View File

@ -100,6 +100,7 @@ public class ExamTrainServiceImpl extends ServiceImpl<ExamTrainMapper, ExamTrain
recordList.forEach(r -> {
r.setIsPass(0);
r.setExamNum(0);
r.setExamCount(examTrain.getExamNum());
r.setProjectSn(examTrain.getProjectSn());
r.setCreateBy(examTrain.getCreateBy());
r.setTrainId(examTrain.getId());

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.util;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.exam.entity.ExamSubject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -250,6 +251,27 @@ public class ExcelUtils {
}
}
public static void exporExcelExamQuestionBankTemplate(HttpServletResponse response, List<ExamSubject> subjectList) {
try {
ClassPathResource classPathResource = new ClassPathResource("excel/题库导入模板.xlsx");
InputStream inputStream = classPathResource.getInputStream();
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
//部门/班组下拉列
XSSFSheet sheet2 = workbook.getSheet("科目名称");
if (subjectList.size() > 0) {
for (int i = 0; i < subjectList.size(); i++) {
XSSFRow row1 = sheet2.createRow(i);
XSSFCell cell1 = row1.createCell(0);
cell1.setCellType(CellType.STRING);
cell1.setCellValue(subjectList.get(i).getName());
}
}
downLoadExcel("题库导入模板.xlsx", response, workbook);
} catch (IOException e) {
log.error("error", e);
}
}
/*public static void main(String[] args) {
try {
InputStream instream = new FileInputStream("D:/qqq.xlsx");

Binary file not shown.