Commit 3afc38e7 by 阳浪

试题导出

parent 93193d6a
...@@ -3,13 +3,17 @@ package com.yizhi.application.exam.controller; ...@@ -3,13 +3,17 @@ package com.yizhi.application.exam.controller;
import com.yizhi.core.application.context.ContextHolder; import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext; import com.yizhi.core.application.context.RequestContext;
import com.yizhi.exam.application.feign.QuestionLibraryClient;
import com.yizhi.exam.application.vo.QuestionLibraryVO;
import com.yizhi.util.application.domain.Response; import com.yizhi.util.application.domain.Response;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -23,6 +27,12 @@ public class ExamExportController { ...@@ -23,6 +27,12 @@ public class ExamExportController {
private LibrarySubjectExport li; private LibrarySubjectExport li;
@Autowired @Autowired
private LibrarySubjectXmlExport lxml; private LibrarySubjectXmlExport lxml;
@Autowired
QuestionLibraryClient questionLibraryClient;
@Value("${pc.host.url}")
String pcHostUrl;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
@ApiOperation("题库试题导出") @ApiOperation("题库试题导出")
@GetMapping("/question/subject/export") @GetMapping("/question/subject/export")
...@@ -52,7 +62,10 @@ public class ExamExportController { ...@@ -52,7 +62,10 @@ public class ExamExportController {
map.put("pageSize", pageSize); map.put("pageSize", pageSize);
} }
li.execute(map, true); li.execute(map, true);
return Response.ok("任务编号:" + taskId + ",请前往系统管理的任务管理进行查看!"); String libraryName = questionLibraryClient.selectQuestionLibraryById(libraryId).getName();
StringBuffer fileName = new StringBuffer().append(libraryName).append("--").append(taskId).append(".xls");
String fileUril = pcHostUrl+"/api/v1/buckets/upload/objects/download/?preview=true&prefix="+fileName.toString();
return Response.ok(fileUril);
} }
@ApiOperation("题库试题导出_xml") @ApiOperation("题库试题导出_xml")
...@@ -89,8 +102,11 @@ public class ExamExportController { ...@@ -89,8 +102,11 @@ public class ExamExportController {
map.put("pageNo", pageNo); map.put("pageNo", pageNo);
map.put("pageSize", pageSize); map.put("pageSize", pageSize);
lxml.execute(map, true); lxml.execute(map, true);
QuestionLibraryVO questionLibraryVO = questionLibraryClient.selectQuestionLibraryById(libraryId);
return Response.ok("任务编号:" + serialNo + "。任务名称:" + taskName + "请到任务管理中查看!"); String sheetName = questionLibraryVO.getName();
String fileName = sheetName + "_" + simpleDateFormat.format(submitTime) + ".xml";
String fileUril = pcHostUrl+"/api/v1/buckets/upload/objects/download/?preview=true&prefix="+fileName;
return Response.ok(fileUril);
} }
} }
...@@ -83,7 +83,7 @@ public class LibrarySubjectExport extends AbstractDefaultTask<String, Map<String ...@@ -83,7 +83,7 @@ public class LibrarySubjectExport extends AbstractDefaultTask<String, Map<String
//给excel表取个名称 //给excel表取个名称
if (!StringUtils.isBlank(sheetName)) { if (!StringUtils.isBlank(sheetName)) {
fileName = new StringBuffer().append(sheetName).append("--").append(System.currentTimeMillis()).append(".xls"); fileName = new StringBuffer().append(sheetName).append("--").append(taskId).append(".xls");
sheet = workBook.createSheet(fileName.toString()); sheet = workBook.createSheet(fileName.toString());
} }
//设置标题行 题型 题干 标签 题目解析 正确答案 因为选项个数不固定 所以在下面代码中动态生成 //设置标题行 题型 题干 标签 题目解析 正确答案 因为选项个数不固定 所以在下面代码中动态生成
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment