Merge remote-tracking branch 'origin/guoshengxiong' into guoshengxiong
This commit is contained in:
commit
bbe711972d
@ -5,6 +5,7 @@ import com.zhgd.xmgl.modules.bigdevice.service.ITowerAlarmService;
|
|||||||
import com.zhgd.xmgl.modules.bigdevice.service.ITowerCurrentDataService;
|
import com.zhgd.xmgl.modules.bigdevice.service.ITowerCurrentDataService;
|
||||||
import com.zhgd.xmgl.modules.bigdevice.service.ITowerWorkCycleService;
|
import com.zhgd.xmgl.modules.bigdevice.service.ITowerWorkCycleService;
|
||||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||||
|
import com.zhgd.xmgl.modules.exam.service.IExamQuestionBankService;
|
||||||
import com.zhgd.xmgl.modules.massrebound.service.IMassReboundSurveyAreaService;
|
import com.zhgd.xmgl.modules.massrebound.service.IMassReboundSurveyAreaService;
|
||||||
import com.zhgd.xmgl.modules.quality.service.IQualityInspectionRecordService;
|
import com.zhgd.xmgl.modules.quality.service.IQualityInspectionRecordService;
|
||||||
import com.zhgd.xmgl.modules.standard.service.IStandardAlarmService;
|
import com.zhgd.xmgl.modules.standard.service.IStandardAlarmService;
|
||||||
@ -44,6 +45,8 @@ public class DownloadController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IWorkerInfoService workerInfoService;
|
private IWorkerInfoService workerInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private IExamQuestionBankService examQuestionBankService;
|
||||||
|
@Autowired
|
||||||
private IWorkerMonthAttendanceStatisticsService workerMonthAttendanceStatisticsService;
|
private IWorkerMonthAttendanceStatisticsService workerMonthAttendanceStatisticsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMassReboundSurveyAreaService massReboundSurveyAreaService;
|
private IMassReboundSurveyAreaService massReboundSurveyAreaService;
|
||||||
@ -311,6 +314,15 @@ public class DownloadController {
|
|||||||
workerInfoService.exporExcelWorkerTemplate(response, projectSn);
|
workerInfoService.exporExcelWorkerTemplate(response, projectSn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "题库导入模板下载", notes = "题库导入模板下载", httpMethod = "GET")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/exporExcelExamQuestionTemplate")
|
||||||
|
public void exporExcelExamQuestionTemplate(HttpServletResponse response, String projectSn) {
|
||||||
|
examQuestionBankService.exporExcelTemplate(response, projectSn);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "列表查询隐患检查记录信息下载", notes = "列表查询隐患检查记录信息下载", httpMethod = "GET")
|
@ApiOperation(value = "列表查询隐患检查记录信息下载", notes = "列表查询隐患检查记录信息下载", httpMethod = "GET")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
|
|||||||
import com.zhgd.xmgl.modules.exam.vo.RandomQuery;
|
import com.zhgd.xmgl.modules.exam.vo.RandomQuery;
|
||||||
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 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;
|
||||||
@ -323,28 +324,25 @@ public class ExamQuestionBankController {
|
|||||||
List<ExamQuestionBank> pageList = examQuestionBankService.list(queryWrapper);
|
List<ExamQuestionBank> pageList = examQuestionBankService.list(queryWrapper);
|
||||||
List<ExamSubject> subList = examSubjectService.list();
|
List<ExamSubject> subList = examSubjectService.list();
|
||||||
List<ExamQuestionBankImport> resultList = new ArrayList<>();
|
List<ExamQuestionBankImport> resultList = new ArrayList<>();
|
||||||
int index = 1;
|
|
||||||
for (ExamQuestionBank examQuestionBank : pageList) {
|
for (ExamQuestionBank examQuestionBank : pageList) {
|
||||||
ExamSubject examSubject = subList.stream().filter(s -> s.getId().toString().equals(examQuestionBank.getSubjectId().toString()))
|
ExamSubject examSubject = subList.stream().filter(s -> s.getId().toString().equals(examQuestionBank.getSubjectId().toString()))
|
||||||
.collect(Collectors.toList()).get(0);
|
.collect(Collectors.toList()).get(0);
|
||||||
ExamQuestionBankImport examQuestionBankImport = new ExamQuestionBankImport();
|
ExamQuestionBankImport examQuestionBankImport = new ExamQuestionBankImport();
|
||||||
examQuestionBankImport.setIndex(index + "、");
|
|
||||||
examQuestionBankImport.setSubjectName(examSubject.getName());
|
examQuestionBankImport.setSubjectName(examSubject.getName());
|
||||||
examQuestionBankImport.setQuestionName(examQuestionBank.getQuestionName());
|
examQuestionBankImport.setQuestionName(examQuestionBank.getQuestionName());
|
||||||
examQuestionBankImport.setTypeName(getType(examQuestionBank.getType()));
|
examQuestionBankImport.setTypeName(getType(examQuestionBank.getType()));
|
||||||
examQuestionBankImport.setDifficulty(getDifficulty(examQuestionBank.getDifficulty()));
|
examQuestionBankImport.setDifficulty(getDifficulty(examQuestionBank.getDifficulty()));
|
||||||
examQuestionBankImport.setOptions(examQuestionBank.getOptions());
|
examQuestionBankImport.setOptions(examQuestionBank.getOptions());
|
||||||
examQuestionBankImport.setIsEnable(examQuestionBank.getIsEnable() == 1 ? "是" : "否");
|
examQuestionBankImport.setIsEnable(examQuestionBank.getIsEnable() == 1 ? "是" : "否");
|
||||||
examQuestionBankImport.setScore(examQuestionBank.getScore());
|
examQuestionBankImport.setScore(examQuestionBank.getScore().toString());
|
||||||
resultList.add(examQuestionBankImport);
|
resultList.add(examQuestionBankImport);
|
||||||
List<ExamQuestionOption> questionOptions = examQuestionOptionService.list(Wrappers.<ExamQuestionOption>lambdaQuery().eq(ExamQuestionOption::getQuestionId, examQuestionBank.getId()));
|
List<ExamQuestionOption> questionOptions = examQuestionOptionService.list(Wrappers.<ExamQuestionOption>lambdaQuery().eq(ExamQuestionOption::getQuestionId, examQuestionBank.getId()));
|
||||||
for (ExamQuestionOption questionOption : questionOptions) {
|
for (ExamQuestionOption questionOption : questionOptions) {
|
||||||
ExamQuestionBankImport examQuestionBankImport1 = new ExamQuestionBankImport();
|
ExamQuestionBankImport examQuestionBankImport1 = new ExamQuestionBankImport();
|
||||||
examQuestionBankImport1.setSubjectName(questionOption.getOptionCode());
|
examQuestionBankImport1.setOptionCode(questionOption.getOptionCode());
|
||||||
examQuestionBankImport1.setQuestionName(questionOption.getOptionDesc());
|
examQuestionBankImport1.setOptionDesc(questionOption.getOptionDesc());
|
||||||
resultList.add(examQuestionBankImport1);
|
resultList.add(examQuestionBankImport1);
|
||||||
}
|
}
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
//导出文件名称
|
//导出文件名称
|
||||||
mv.addObject(NormalExcelConstants.FILE_NAME, "题目管理列表");
|
mv.addObject(NormalExcelConstants.FILE_NAME, "题目管理列表");
|
||||||
@ -376,40 +374,42 @@ public class ExamQuestionBankController {
|
|||||||
params.setHeadRows(1);
|
params.setHeadRows(1);
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
try {
|
try {
|
||||||
List<ExamQuestionBankImport> examQuestionBankImports = ExcelImportUtil.importExcel(file.getInputStream(), ExamQuestionBankImport.class, params);
|
List<Map<String, String>> examQuestionBankImports = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
|
||||||
List<ExamQuestionBank> examQuestionBankList = new ArrayList<>();
|
List<ExamQuestionBank> examQuestionBankList = new ArrayList<>();
|
||||||
List<ExamQuestionOption> examQuestionOptionList = new ArrayList<>();
|
List<ExamQuestionOption> examQuestionOptionList = new ArrayList<>();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (ExamQuestionBankImport examQuestionBankImport : examQuestionBankImports) {
|
for (Map<String, String> examQuestionBankImport : examQuestionBankImports) {
|
||||||
if (StringUtils.isNotBlank(examQuestionBankImport.getQuestionName())) {
|
if (StringUtils.isNotBlank(examQuestionBankImport.get("*科目名称").trim())) {
|
||||||
if (StringUtils.isNotBlank(examQuestionBankImport.getIndex())) {
|
index++;
|
||||||
index++;
|
List<ExamSubject> subjects = subList.stream().filter(s -> s.getName().equals(examQuestionBankImport.get("*科目名称").trim())).collect(Collectors.toList());
|
||||||
List<ExamSubject> subjects = subList.stream().filter(s -> s.getName().equals(examQuestionBankImport.getSubjectName())).collect(Collectors.toList());
|
if (subjects == null || subjects.size() == 0) {
|
||||||
if (subjects == null || subjects.size() == 0) {
|
throw new CustomException("没有对应的科目名称,请检查", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
throw new CustomException("没有对应的科目名称,请检查", HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
ExamQuestionBank examQuestionBank = new ExamQuestionBank();
|
|
||||||
examQuestionBank.setId((long) index);
|
|
||||||
examQuestionBank.setSubjectId(subjects.get(0).getId());
|
|
||||||
examQuestionBank.setQuestionName(examQuestionBankImport.getQuestionName());
|
|
||||||
examQuestionBank.setType(getType(examQuestionBankImport.getTypeName()));
|
|
||||||
examQuestionBank.setDifficulty(getDifficulty(examQuestionBankImport.getDifficulty()));
|
|
||||||
examQuestionBank.setOptions(examQuestionBankImport.getOptions());
|
|
||||||
examQuestionBank.setIsEnable(examQuestionBankImport.getIsEnable().equals("是") ? 1 : 0);
|
|
||||||
examQuestionBank.setScore(examQuestionBankImport.getScore());
|
|
||||||
examQuestionBank.setProjectSn(systemUser.getSn());
|
|
||||||
examQuestionBank.setCreateBy(systemUser.getUserId().toString());
|
|
||||||
examQuestionBank.setCreateTime(new Date());
|
|
||||||
examQuestionBank.setUpdateBy(systemUser.getUserId().toString());
|
|
||||||
examQuestionBank.setUpdateTime(examQuestionBank.getCreateTime());
|
|
||||||
examQuestionBankList.add(examQuestionBank);
|
|
||||||
} else {
|
|
||||||
ExamQuestionOption examQuestionOption = new ExamQuestionOption();
|
|
||||||
examQuestionOption.setQuestionId((long) index);
|
|
||||||
examQuestionOption.setOptionCode(examQuestionBankImport.getSubjectName());
|
|
||||||
examQuestionOption.setOptionDesc(examQuestionBankImport.getQuestionName());
|
|
||||||
examQuestionOptionList.add(examQuestionOption);
|
|
||||||
}
|
}
|
||||||
|
ExamQuestionBank examQuestionBank = new ExamQuestionBank();
|
||||||
|
examQuestionBank.setId((long) index);
|
||||||
|
examQuestionBank.setSubjectId(subjects.get(0).getId());
|
||||||
|
examQuestionBank.setQuestionName(examQuestionBankImport.get("*试题名称").trim());
|
||||||
|
examQuestionBank.setType(getType(examQuestionBankImport.get("*试题类型").trim()));
|
||||||
|
examQuestionBank.setDifficulty(getDifficulty(examQuestionBankImport.get("*难易程度").trim()));
|
||||||
|
examQuestionBank.setOptions(examQuestionBankImport.get("*试题答案").trim());
|
||||||
|
examQuestionBank.setIsEnable(examQuestionBankImport.get("*是否应用").trim().equals("是") ? 1 : 0);
|
||||||
|
try {
|
||||||
|
examQuestionBank.setScore(Integer.parseInt(examQuestionBankImport.get("*作答正确得分").trim()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomException("分数格式错误,请填写正确的分数", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
examQuestionBank.setProjectSn(systemUser.getSn());
|
||||||
|
examQuestionBank.setCreateBy(systemUser.getUserId().toString());
|
||||||
|
examQuestionBank.setCreateTime(new Date());
|
||||||
|
examQuestionBank.setUpdateBy(systemUser.getUserId().toString());
|
||||||
|
examQuestionBank.setUpdateTime(examQuestionBank.getCreateTime());
|
||||||
|
examQuestionBankList.add(examQuestionBank);
|
||||||
|
} else if(StringUtils.isNotBlank(examQuestionBankImport.get("*选项代码").trim())) {
|
||||||
|
ExamQuestionOption examQuestionOption = new ExamQuestionOption();
|
||||||
|
examQuestionOption.setQuestionId((long) index);
|
||||||
|
examQuestionOption.setOptionCode(examQuestionBankImport.get("*选项代码").trim());
|
||||||
|
examQuestionOption.setOptionDesc(examQuestionBankImport.get("*选项描述").trim());
|
||||||
|
examQuestionOptionList.add(examQuestionOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ExamQuestionBank examQuestionBank : examQuestionBankList) {
|
for (ExamQuestionBank examQuestionBank : examQuestionBankList) {
|
||||||
@ -438,13 +438,6 @@ 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) {
|
||||||
|
|||||||
@ -9,35 +9,41 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
|||||||
@ApiModel(value = "试题导入(VO)", description = "ExamQuestionBankImport")
|
@ApiModel(value = "试题导入(VO)", description = "ExamQuestionBankImport")
|
||||||
public class ExamQuestionBankImport {
|
public class ExamQuestionBankImport {
|
||||||
|
|
||||||
@Excel(name = "试题序号", width = 15)
|
|
||||||
@ApiModelProperty(value = "试题序号")
|
|
||||||
private String index;
|
private String index;
|
||||||
|
|
||||||
@Excel(name = "科目名称/选项代码", width = 15)
|
@Excel(name = "*科目名称", width = 15)
|
||||||
@ApiModelProperty(value = "科目名称/选项代码")
|
@ApiModelProperty(value = "科目名称")
|
||||||
private String subjectName;
|
private String subjectName;
|
||||||
|
|
||||||
@Excel(name = "试题名称/选项描述", width = 15)
|
@Excel(name = "*试题名称", width = 15)
|
||||||
@ApiModelProperty(value = "试题名称/选项描述")
|
@ApiModelProperty(value = "试题名称")
|
||||||
private String questionName;
|
private String questionName;
|
||||||
|
|
||||||
@Excel(name = "试题类型(单选题;多选题;)", width = 15)
|
@Excel(name = "*试题类型", width = 15)
|
||||||
@ApiModelProperty(value = "试题类型(单选题;多选题;)")
|
@ApiModelProperty(value = "试题类型")
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
@Excel(name = "难易程度", width = 15)
|
@Excel(name = "*难易程度", width = 15)
|
||||||
@ApiModelProperty(value = "难易程度")
|
@ApiModelProperty(value = "难易程度")
|
||||||
private String difficulty;
|
private String difficulty;
|
||||||
|
|
||||||
@Excel(name = "试题答案", width = 15)
|
@Excel(name = "*试题答案", width = 15)
|
||||||
@ApiModelProperty(value = "试题答案")
|
@ApiModelProperty(value = "试题答案")
|
||||||
private String options;
|
private String options;
|
||||||
|
|
||||||
@Excel(name = "是否应用(否;是)", width = 15)
|
@Excel(name = "*是否应用(否;是)", width = 15)
|
||||||
@ApiModelProperty(value = "是否应用(否;是)")
|
@ApiModelProperty(value = "是否应用(否;是)")
|
||||||
private String isEnable;
|
private String isEnable;
|
||||||
|
|
||||||
@Excel(name = "作答正确得分", width = 15)
|
@Excel(name = "*作答正确得分", width = 15)
|
||||||
@ApiModelProperty(value = "作答正确得分")
|
@ApiModelProperty(value = "作答正确得分")
|
||||||
private Integer score;
|
private String score;
|
||||||
|
|
||||||
|
@Excel(name = "*选项代码", width = 15)
|
||||||
|
@ApiModelProperty(value = "选项代码")
|
||||||
|
private String optionCode;
|
||||||
|
|
||||||
|
@Excel(name = "*选项描述", width = 15)
|
||||||
|
@ApiModelProperty(value = "选项描述")
|
||||||
|
private String optionDesc;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,7 +253,7 @@ public class ExcelUtils {
|
|||||||
|
|
||||||
public static void exporExcelExamQuestionBankTemplate(HttpServletResponse response, List<ExamSubject> subjectList) {
|
public static void exporExcelExamQuestionBankTemplate(HttpServletResponse response, List<ExamSubject> subjectList) {
|
||||||
try {
|
try {
|
||||||
ClassPathResource classPathResource = new ClassPathResource("excel/题库导入模板.xlsx");
|
ClassPathResource classPathResource = new ClassPathResource("excel/题库导入模版.xlsx");
|
||||||
InputStream inputStream = classPathResource.getInputStream();
|
InputStream inputStream = classPathResource.getInputStream();
|
||||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||||
//部门/班组下拉列
|
//部门/班组下拉列
|
||||||
@ -266,7 +266,7 @@ public class ExcelUtils {
|
|||||||
cell1.setCellValue(subjectList.get(i).getName());
|
cell1.setCellValue(subjectList.get(i).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLoadExcel("题库导入模板.xlsx", response, workbook);
|
downLoadExcel("题库导入模版.xlsx", response, workbook);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("error:", e);
|
log.error("error:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user