|
@@ -1,7 +1,9 @@
|
|
|
package cn.com.qmth.examcloud.tool.service.query_paper_struct;
|
|
|
|
|
|
import cn.com.qmth.examcloud.tool.config.SysProperty;
|
|
|
+import cn.com.qmth.examcloud.tool.entity.TaskEntity;
|
|
|
import cn.com.qmth.examcloud.tool.service.CommonService;
|
|
|
+import cn.com.qmth.examcloud.tool.service.TaskService;
|
|
|
import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.CourseVO;
|
|
|
import cn.com.qmth.examcloud.tool.service.query_paper_struct.vo.ExamPaperVO;
|
|
|
import cn.com.qmth.examcloud.tool.service.query_paper_struct.vo.ExtractConfigVO;
|
|
@@ -30,7 +32,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
-public class QueryPaperStructTask {
|
|
|
+public class QueryPaperStructTask implements TaskService {
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(QueryPaperStructTask.class);
|
|
|
|
|
@@ -40,21 +42,22 @@ public class QueryPaperStructTask {
|
|
|
@Autowired
|
|
|
private CommonService commonService;
|
|
|
|
|
|
- public void start(User user, Long examId) {
|
|
|
- this.execute(user, examId);
|
|
|
+ @Override
|
|
|
+ public void start(TaskEntity task) {
|
|
|
+ // this.execute(loginUser, task);
|
|
|
}
|
|
|
|
|
|
- private void execute(User user, Long examId) {
|
|
|
+ public void execute(User loginUser, Long examId, String exportDir) {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("key", user.getKey());
|
|
|
- headers.put("token", user.getToken());
|
|
|
+ headers.put("key", loginUser.getKey());
|
|
|
+ headers.put("token", loginUser.getToken());
|
|
|
|
|
|
- List<CourseVO> courses = commonService.getExamCourseList(user, examId);
|
|
|
+ List<CourseVO> courses = commonService.getExamCourseList(loginUser, examId);
|
|
|
log.info("考试Id:{}, 课程数为:{}", examId, courses.size());
|
|
|
|
|
|
List<List<String>> excelRows = new ArrayList<>();
|
|
|
for (CourseVO course : courses) {
|
|
|
- List<ExtractConfigVO> extractConfigs = this.getExtractConfig(user, examId, course.getCourseCode());
|
|
|
+ List<ExtractConfigVO> extractConfigs = this.getExtractConfig(loginUser, examId, course.getCourseCode());
|
|
|
if (CollectionUtils.isEmpty(extractConfigs)) {
|
|
|
// 若当前账号未配相关数据权限,则会取不到调卷规则数据,请更换账号!!
|
|
|
log.info("考试Id:{}, 课程Id:{}, 课程代码:{}, 未配置调卷规则!", examId, course.getCourseId(),
|
|
@@ -80,7 +83,7 @@ public class QueryPaperStructTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- final String filePath = "D:/result_" + examId + ".xlsx";
|
|
|
+ final String filePath = exportDir + "result_" + examId + ".xlsx";
|
|
|
List<String> excelHeaders = Lists.newArrayList("考试Id", "课程代码", "课程名称", "抽题模式", "权重比例", "试卷类型", "试卷Id", "试卷名称");
|
|
|
EasyExcel.write(filePath).head(ExcelHelper.buildHeaders(excelHeaders))
|
|
|
.registerWriteHandler(ExcelHelper.sheetStrategy()).registerWriteHandler(ExcelHelper.styleStrategy())
|
|
@@ -113,16 +116,16 @@ public class QueryPaperStructTask {
|
|
|
/**
|
|
|
* 查询某个考试课程的调卷规则配置
|
|
|
*/
|
|
|
- private List<ExtractConfigVO> getExtractConfig(User user, Long examId, String courseCode) {
|
|
|
+ private List<ExtractConfigVO> getExtractConfig(User loginUser, Long examId, String courseCode) {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("key", user.getKey());
|
|
|
- headers.put("token", user.getToken());
|
|
|
+ headers.put("key", loginUser.getKey());
|
|
|
+ headers.put("token", loginUser.getToken());
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("examId", String.valueOf(examId));
|
|
|
params.put("courseNo", courseCode);
|
|
|
|
|
|
- String url = user.getServerUrl() + "/api/ecs_ques/findPageExtractConfig/1/10";
|
|
|
+ String url = loginUser.getServerUrl() + "/api/ecs_ques/findPageExtractConfig/1/10";
|
|
|
String json = HttpHelper.get(url, headers, params);
|
|
|
|
|
|
Pager<ExtractConfigVO> page = new JsonMapper().parseJson(json, new TypeReference<Pager<ExtractConfigVO>>() {
|