考试修改
This commit is contained in:
parent
ad2e38738c
commit
aff7659b9a
@ -438,6 +438,13 @@ public class ExamQuestionBankController {
|
|||||||
return Result.ok("文件导入失败!");
|
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) {
|
private String getType(int type) {
|
||||||
String typeName = null;
|
String typeName = null;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@ -69,7 +69,8 @@ public class ExamWorkerController {
|
|||||||
String workerId = MapUtils.getString(map, "workerId");
|
String workerId = MapUtils.getString(map, "workerId");
|
||||||
List<ExamTrainRecordVo> list = examTrainRecordService.pageList(new Page(1, -1), Wrappers.<ExamTrainRecord>lambdaQuery()
|
List<ExamTrainRecordVo> list = examTrainRecordService.pageList(new Page(1, -1), Wrappers.<ExamTrainRecord>lambdaQuery()
|
||||||
.eq(ExamTrainRecord::getWorkerId, workerId)
|
.eq(ExamTrainRecord::getWorkerId, workerId)
|
||||||
.eq(ExamTrainRecord::getIsPass, 0)).getRecords();
|
.eq(ExamTrainRecord::getIsPass, 0)
|
||||||
|
.gt(ExamTrainRecord::getExamCount, 0)).getRecords();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,7 @@ public class ExamWorkerController {
|
|||||||
result.error500("未找到对应实体");
|
result.error500("未找到对应实体");
|
||||||
} else {
|
} else {
|
||||||
examTrainRecordEntity.setStartExamTime(new Date());
|
examTrainRecordEntity.setStartExamTime(new Date());
|
||||||
|
examTrainRecordEntity.setExamNum(examTrainRecordEntity.getExamCount() - 1);
|
||||||
result.setResult(examTrainRecordService.updateById(examTrainRecordEntity));
|
result.setResult(examTrainRecordService.updateById(examTrainRecordEntity));
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,12 @@ public class ExamTrainRecord implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@Excel(name = "考试次数", width = 15)
|
@Excel(name = "考试次数", width = 15)
|
||||||
@ApiModelProperty(value = "考试次数")
|
@ApiModelProperty(value = "考试次数")
|
||||||
|
private Integer examCount;
|
||||||
|
/**
|
||||||
|
* 考试次数
|
||||||
|
*/
|
||||||
|
@Excel(name = "考试次数", width = 15)
|
||||||
|
@ApiModelProperty(value = "考试次数")
|
||||||
private Integer examNum;
|
private Integer examNum;
|
||||||
/**
|
/**
|
||||||
* 是否签到
|
* 是否签到
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.zhgd.xmgl.modules.exam.entity.ExamQuestionBank;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
|
import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,4 +24,6 @@ public interface IExamQuestionBankService extends IService<ExamQuestionBank> {
|
|||||||
ExamQuestionBankVo queryById(Long id);
|
ExamQuestionBankVo queryById(Long id);
|
||||||
|
|
||||||
List<ExamQuestionBankVo> queryByBatchId(List<Long> ids);
|
List<ExamQuestionBankVo> queryByBatchId(List<Long> ids);
|
||||||
|
|
||||||
|
void exporExcelTemplate(HttpServletResponse response, String projectSn);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,18 @@
|
|||||||
package com.zhgd.xmgl.modules.exam.service.impl;
|
package com.zhgd.xmgl.modules.exam.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
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.ExamQuestionBank;
|
||||||
import com.zhgd.xmgl.modules.exam.entity.ExamQuestionOption;
|
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.mapper.ExamQuestionBankMapper;
|
||||||
import com.zhgd.xmgl.modules.exam.service.IExamQuestionBankService;
|
import com.zhgd.xmgl.modules.exam.service.IExamQuestionBankService;
|
||||||
import com.zhgd.xmgl.modules.exam.service.IExamQuestionOptionService;
|
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.modules.exam.vo.ExamQuestionBankVo;
|
||||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||||
|
import com.zhgd.xmgl.util.ExcelUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -16,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -33,6 +38,9 @@ public class ExamQuestionBankServiceImpl extends ServiceImpl<ExamQuestionBankMap
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IExamQuestionOptionService examQuestionOptionService;
|
private IExamQuestionOptionService examQuestionOptionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExamSubjectService examSubjectService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveInfo(ExamQuestionBankVo examQuestionBankVo) {
|
public boolean saveInfo(ExamQuestionBankVo examQuestionBankVo) {
|
||||||
UserInfo user = SecurityUtils.getUser();
|
UserInfo user = SecurityUtils.getUser();
|
||||||
@ -92,4 +100,10 @@ public class ExamQuestionBankServiceImpl extends ServiceImpl<ExamQuestionBankMap
|
|||||||
}
|
}
|
||||||
return examQuestionBankVoList;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,6 +100,7 @@ public class ExamTrainServiceImpl extends ServiceImpl<ExamTrainMapper, ExamTrain
|
|||||||
recordList.forEach(r -> {
|
recordList.forEach(r -> {
|
||||||
r.setIsPass(0);
|
r.setIsPass(0);
|
||||||
r.setExamNum(0);
|
r.setExamNum(0);
|
||||||
|
r.setExamCount(examTrain.getExamNum());
|
||||||
r.setProjectSn(examTrain.getProjectSn());
|
r.setProjectSn(examTrain.getProjectSn());
|
||||||
r.setCreateBy(examTrain.getCreateBy());
|
r.setCreateBy(examTrain.getCreateBy());
|
||||||
r.setTrainId(examTrain.getId());
|
r.setTrainId(examTrain.getId());
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.zhgd.xmgl.util;
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||||
|
import com.zhgd.xmgl.modules.exam.entity.ExamSubject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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) {
|
/*public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
InputStream instream = new FileInputStream("D:/qqq.xlsx");
|
InputStream instream = new FileInputStream("D:/qqq.xlsx");
|
||||||
|
|||||||
BIN
src/main/resources/excel/题库导入模版.xlsx
Normal file
BIN
src/main/resources/excel/题库导入模版.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user