|
|
@@ -0,0 +1,325 @@
|
|
|
+package com.zhongzheng.controller.bank;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.http.HttpStatus;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
+import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
+import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.poi.EasyPoiUtil;
|
|
|
+import com.zhongzheng.common.utils.poi.ExcelUtil;
|
|
|
+import com.zhongzheng.framework.web.service.TokenService;
|
|
|
+import com.zhongzheng.modules.bank.bo.*;
|
|
|
+import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
+import com.zhongzheng.modules.bank.domain.Question;
|
|
|
+import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
+import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
|
|
|
+import com.zhongzheng.modules.bank.service.IQuestionService;
|
|
|
+import com.zhongzheng.modules.bank.vo.*;
|
|
|
+import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseSectionImport;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
+import com.zhongzheng.modules.user.vo.UserSubscribeErrorImport;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.zhongzheng.common.annotation.Log;
|
|
|
+import com.zhongzheng.common.core.controller.BaseController;
|
|
|
+import com.zhongzheng.common.core.domain.AjaxResult;
|
|
|
+import com.zhongzheng.common.enums.BusinessType;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 题库题目Controller
|
|
|
+ *
|
|
|
+ * @author hjl
|
|
|
+ * @date 2021-10-21
|
|
|
+ */
|
|
|
+@Api(value = "题库题目控制器", tags = {"题库题目管理"})
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+@RestController
|
|
|
+@RequestMapping("/bank/question")
|
|
|
+public class QuestionController extends BaseController {
|
|
|
+
|
|
|
+ private final IQuestionService iQuestionService;
|
|
|
+
|
|
|
+ private final IQuestionBusinessService iQuestionBusinessService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询题库题目列表
|
|
|
+ */
|
|
|
+ @ApiOperation("查询题库题目列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo<QuestionVo> list(QuestionQueryBo bo) {
|
|
|
+ startPage();
|
|
|
+ // List<QuestionVo> list = ;
|
|
|
+ return iQuestionService.selectListByBo(bo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 题目批量删除
|
|
|
+ */
|
|
|
+ @ApiOperation("题目批量删除")
|
|
|
+ @PostMapping("/batch/del")
|
|
|
+ public AjaxResult<Void> batchDelQuestion(@RequestBody QuestionBatchDelBo bo) {
|
|
|
+ return toAjax(iQuestionService.batchDelQuestion(bo) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出题库题目列表
|
|
|
+ */
|
|
|
+ /* @ApiOperation("导出题库题目列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:export')")
|
|
|
+ @Log(title = "题库题目", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/export")
|
|
|
+ public AjaxResult<QuestionVo> export(QuestionQueryBo bo) {
|
|
|
+ List<QuestionVo> list = iQuestionService.queryList(bo);
|
|
|
+ ExcelUtil<QuestionVo> util = new ExcelUtil<QuestionVo>(QuestionVo.class);
|
|
|
+ return util.exportExcel(list, "题库题目");
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取题库题目详细信息
|
|
|
+ */
|
|
|
+ @ApiOperation("获取题库题目详细信息")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:query')")
|
|
|
+ @GetMapping("/{questionId}")
|
|
|
+ public AjaxResult<QuestionVo> getInfo(@PathVariable("questionId" ) Long questionId) {
|
|
|
+ return AjaxResult.success(iQuestionService.queryById(questionId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增题库题目
|
|
|
+ */
|
|
|
+ @ApiOperation("新增题库题目")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:add')")
|
|
|
+ @Log(title = "题库题目", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping()
|
|
|
+ public AjaxResult<Question> add(@RequestBody QuestionAddBo bo) {
|
|
|
+ return AjaxResult.success(iQuestionService.insertByAddBo(bo));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改题库题目
|
|
|
+ */
|
|
|
+ @ApiOperation("修改题库题目")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:edit')")
|
|
|
+ @Log(title = "题库题目", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public AjaxResult<Void> edit(@RequestBody QuestionEditBo bo) {
|
|
|
+ return toAjax(iQuestionService.updateByEditBo(bo) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除题库题目
|
|
|
+ */
|
|
|
+ /*@ApiOperation("删除题库题目")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:remove')")
|
|
|
+ @Log(title = "题库题目" , businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{questionIds}")
|
|
|
+ public AjaxResult<Void> remove(@PathVariable Long[] questionIds) {
|
|
|
+ return toAjax(iQuestionService.deleteWithValidByIds(Arrays.asList(questionIds), true) ? 1 : 0);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询题目业务层次关系列表
|
|
|
+ */
|
|
|
+ @ApiOperation("查询题目业务层次关系列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:business:list')")
|
|
|
+ @GetMapping("/business/list")
|
|
|
+ public TableDataInfo<QuestionBusiness> businessList(QuestionBusinessQueryBo bo) {
|
|
|
+ startPage();
|
|
|
+ bo.setType(QuestionBusiness.TYPE_QUESTION);
|
|
|
+ List<QuestionBusiness> list = iQuestionBusinessService.getListById(bo);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "题目管理", businessType = BusinessType.IMPORT)
|
|
|
+ @ApiOperation("导入题目模板")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importData")
|
|
|
+ public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
|
|
+ {
|
|
|
+ List<QuestionImportV2> questionList2 =EasyPoiUtil.importExcel(file,0,2,QuestionImportV2.class);
|
|
|
+ ExcelUtil<QuestionImportV2> util = new ExcelUtil<QuestionImportV2>(QuestionImportV2.class);
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String operName = loginUser.getUsername();
|
|
|
+ List<QuestionImport> questionList = new ArrayList<>();
|
|
|
+ List<QuestionImportV2> errorList = iQuestionService.importExcelQuestionV2(questionList2, updateSupport, operName);
|
|
|
+ if(Validator.isNotEmpty(errorList)&&errorList.size()>0){
|
|
|
+ List<QuestionImportV2> errorListExport = new ArrayList<>();
|
|
|
+ for(QuestionImportV2 qi : errorList){
|
|
|
+ QuestionImportV2 item = BeanUtil.toBean(qi, QuestionImportV2.class);
|
|
|
+ errorListExport.add(item);
|
|
|
+ }
|
|
|
+ ExcelUtil<QuestionImportV2> util1 = new ExcelUtil<QuestionImportV2>(QuestionImportV2.class);
|
|
|
+ String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ return util.exportEasyExcel(util1.exportEasyData(errorListExport), "导出错误数据"+timeStr);
|
|
|
+ }else{
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "题目管理", businessType = BusinessType.IMPORT)
|
|
|
+ @ApiOperation("导入题目模板返回数组")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importDataBackList")
|
|
|
+ public AjaxResult<Map<String, Object>> importDataBackList(MultipartFile file) throws Exception
|
|
|
+ {
|
|
|
+ List<QuestionImportV2> questionList2 =EasyPoiUtil.importExcel(file,0,2,QuestionImportV2.class);
|
|
|
+
|
|
|
+ ExcelUtil<QuestionImportV2> util = new ExcelUtil<QuestionImportV2>(QuestionImportV2.class);
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String operName = loginUser.getUsername();
|
|
|
+ //只返回数据不插入数据库
|
|
|
+ Map<String, Object> rs = iQuestionService.importExcelQuestionV2NotInBank(questionList2, false, operName);
|
|
|
+ List<QuestionImportV2> errorList = (List<QuestionImportV2>)rs.get("errorList");
|
|
|
+ List<QuestionAddBo> nqList = (List<QuestionAddBo>)rs.get("questionList");
|
|
|
+ if(Validator.isNotEmpty(errorList)&&errorList.size()>0){
|
|
|
+ List<QuestionImportV2> errorListExport = new ArrayList<>();
|
|
|
+ for(QuestionImportV2 qi : errorList){
|
|
|
+ QuestionImportV2 item = BeanUtil.toBean(qi, QuestionImportV2.class);
|
|
|
+ errorListExport.add(item);
|
|
|
+ }
|
|
|
+ ExcelUtil<QuestionImportV2> util1 = new ExcelUtil<QuestionImportV2>(QuestionImportV2.class);
|
|
|
+ String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ rs.put("errorExcel",util.exportEasyExcel(util1.exportEasyData(errorListExport), "导出错误数据"+timeStr));
|
|
|
+ rs.remove("errorList");
|
|
|
+ }
|
|
|
+ if(questionList2.size()>0&&questionList2.size()>nqList.size()&&nqList.size()>0){
|
|
|
+ rs.put("fullStatus","部分成功");
|
|
|
+ }
|
|
|
+ else if(questionList2.size()==nqList.size()){
|
|
|
+ rs.put("fullStatus","全部成功");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ rs.put("fullStatus","失败");
|
|
|
+ }
|
|
|
+ return AjaxResult.success(rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "题目管理", businessType = BusinessType.IMPORT)
|
|
|
+ @ApiOperation("导入旧系统题目模板返回数组")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importDataBackFromOldList")
|
|
|
+ public AjaxResult<Map<String, Object>> importDataBackFromOldList(MultipartFile file) throws Exception
|
|
|
+ {
|
|
|
+ List<QuestionImportV3> questionList2 =EasyPoiUtil.importExcel(file,0,1,QuestionImportV3.class);
|
|
|
+
|
|
|
+ ExcelUtil<QuestionImportV3> util = new ExcelUtil<QuestionImportV3>(QuestionImportV3.class);
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String operName = loginUser.getUsername();
|
|
|
+ //只返回数据不插入数据库
|
|
|
+ Map<String, Object> rs = iQuestionService.importExcelQuestionV3NotInBankFromOld(questionList2, false, operName);
|
|
|
+ List<QuestionImportV3> errorList = (List<QuestionImportV3>)rs.get("errorList");
|
|
|
+ List<QuestionAddBo> nqList = (List<QuestionAddBo>)rs.get("questionList");
|
|
|
+ if(Validator.isNotEmpty(errorList)&&errorList.size()>0){
|
|
|
+ List<QuestionImportV3> errorListExport = new ArrayList<>();
|
|
|
+ for(QuestionImportV3 qi : errorList){
|
|
|
+ QuestionImportV3 item = BeanUtil.toBean(qi, QuestionImportV3.class);
|
|
|
+ errorListExport.add(item);
|
|
|
+ }
|
|
|
+ ExcelUtil<QuestionImportV3> util1 = new ExcelUtil<QuestionImportV3>(QuestionImportV3.class);
|
|
|
+ String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ rs.put("errorExcel",util.exportEasyExcel(util1.exportEasyData(errorListExport), "导出错误数据"+timeStr));
|
|
|
+ rs.remove("errorList");
|
|
|
+ }
|
|
|
+ if(errorList.size()>0&&nqList.size()>0){
|
|
|
+ rs.put("fullStatus","部分成功");
|
|
|
+ }
|
|
|
+ else if(errorList.size()==0){
|
|
|
+ rs.put("fullStatus","全部成功");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ rs.put("fullStatus","失败");
|
|
|
+ }
|
|
|
+ return AjaxResult.success(rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "导入题目Word模板", businessType = BusinessType.IMPORT)
|
|
|
+ @ApiOperation("导入题目Word模板")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importWordData")
|
|
|
+ public AjaxResult importWordData(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
|
|
|
+ {
|
|
|
+ String errorLog = iQuestionService.importWordQuestion(file, eduId, projectId, businessId, subjectId);
|
|
|
+ return AjaxResult.success(errorLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "导入题目Word模板列表", businessType = BusinessType.IMPORT)
|
|
|
+ @ApiOperation("导入题目Word模板列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importWordQuestionList")
|
|
|
+ public AjaxResult<Map<String,Object>> importWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
|
|
|
+ {
|
|
|
+ Map<String,Object> result = iQuestionService.importWordQuestionList(file, eduId, projectId, businessId, subjectId);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("导入建匠题目Word模板列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importJJWordQuestionList")
|
|
|
+ public AjaxResult<Map<String,Object>> importJJWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
|
|
|
+ {
|
|
|
+ Map<String,Object> result = iQuestionService.importJJWordQuestionList(file, eduId, projectId, businessId, subjectId);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("导入学监题目Word模板列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:question:import')")
|
|
|
+ @PostMapping("/importXueJianWordQuestionList")
|
|
|
+ public AjaxResult<Map<String,Object>> importXueJianWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
|
|
|
+ {
|
|
|
+ Map<String,Object> result = iQuestionService.importXueJianWordQuestionList(file, eduId, projectId, businessId, subjectId);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("导入学监题目Word模板列表")
|
|
|
+ @PostMapping("/importXlsx")
|
|
|
+ public AjaxResult<Map<String,Object>> importXlsxQuestionList(MultipartFile file,String param) throws Exception
|
|
|
+ {
|
|
|
+ List<QuestionImportV4> questionList2 =EasyPoiUtil.importExcel(file,0,1,QuestionImportV4.class);
|
|
|
+ Map<String,Object> result = iQuestionService.importXlsxQuestionList(questionList2,param);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("补充题库图片")
|
|
|
+ @PostMapping("/importImage")
|
|
|
+ public AjaxResult<Map<String,Object>> importImage(MultipartFile file) throws Exception
|
|
|
+ {
|
|
|
+ List<QuestionImageVo> questionList2 =EasyPoiUtil.importExcel(file,0,1,QuestionImageVo.class);
|
|
|
+ Map<String,Object> result = iQuestionService.importImage(questionList2);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("识别图片文案2")
|
|
|
+ @PostMapping("/image/word/two")
|
|
|
+ public AjaxResult<Void> getImageWordTwo(MultipartFile file,String major,String exam) {
|
|
|
+ iQuestionService.getImageWordTwo(file,major,exam);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|