|
@@ -1,32 +1,20 @@
|
|
package cn.com.qmth.scancentral.controller.admin;
|
|
package cn.com.qmth.scancentral.controller.admin;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
|
-
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
-import com.qmth.boot.core.collection.PageResult;
|
|
|
|
|
|
+import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
|
|
-import cn.com.qmth.scancentral.bean.User;
|
|
|
|
import cn.com.qmth.scancentral.controller.BaseController;
|
|
import cn.com.qmth.scancentral.controller.BaseController;
|
|
-import cn.com.qmth.scancentral.entity.ExamEntity;
|
|
|
|
-import cn.com.qmth.scancentral.exception.ParameterExceptions;
|
|
|
|
-import cn.com.qmth.scancentral.service.ExamService;
|
|
|
|
-import cn.com.qmth.scancentral.vo.ExamConfigVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.ExamVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.ResultVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.UpdateTimeVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.examinfo.ExamEdit;
|
|
|
|
-import cn.com.qmth.scancentral.vo.examinfo.ExamOverview;
|
|
|
|
-import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
|
|
|
|
|
|
+import cn.com.qmth.scancentral.service.AsyncTaskService;
|
|
|
|
+import cn.com.qmth.scancentral.util.Calculator;
|
|
|
|
+import cn.com.qmth.scancentral.vo.asynctask.AsyncTaskVo;
|
|
|
|
+import cn.com.qmth.scancentral.vo.subject.DataExportTaskVo;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
@@ -37,111 +25,17 @@ import io.swagger.annotations.ApiOperation;
|
|
public class AsyncTaskController extends BaseController {
|
|
public class AsyncTaskController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private ExamService examService;
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "扫描点代码获取")
|
|
|
|
- @PostMapping(value = "scan-site")
|
|
|
|
- public String getScanSite(@RequestParam Long examId) {
|
|
|
|
- return examService.getScanSite(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "扫描点代码设置")
|
|
|
|
- @PostMapping(value = "scan-site/save")
|
|
|
|
- public UpdateTimeVo scanSiteSave(@RequestParam Long examId, @RequestParam String scanSite) {
|
|
|
|
- examService.scanSiteSave(examId, scanSite);
|
|
|
|
- return UpdateTimeVo.create();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "考试概览数据")
|
|
|
|
- @RequestMapping(value = "/overview", method = RequestMethod.POST)
|
|
|
|
- public ExamOverview overview(@RequestParam Long examId) {
|
|
|
|
- User user = getAccessUser();
|
|
|
|
- return examService.getExamOverview(examId, user);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "获取考试列表")
|
|
|
|
- @RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
|
- public PageResult<ExamVo> list(ExamQuery query) {
|
|
|
|
- User user = getAccessUser();
|
|
|
|
- return examService.pageQuery(query, user);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "新建、修改考试")
|
|
|
|
- @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
|
- public ResultVo save(ExamEdit exam) {
|
|
|
|
- exam.setOperateUserId(getAccessUser().getId());
|
|
|
|
- examService.save(exam);
|
|
|
|
- return new ResultVo(System.currentTimeMillis());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "获取基础数据配置")
|
|
|
|
- @RequestMapping(value = "/config/info", method = RequestMethod.POST)
|
|
|
|
- public ExamConfigVo getConfigInfo(@RequestParam Long examId) {
|
|
|
|
- return examService.getConfigInfo(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "保存基础数据配置")
|
|
|
|
- @RequestMapping(value = "/config/save", method = RequestMethod.POST)
|
|
|
|
- public ResultVo saveConfig(@Valid @RequestBody ExamConfigVo config) {
|
|
|
|
- User user = getAccessUser();
|
|
|
|
- examService.saveConfig(config, user);
|
|
|
|
- return new ResultVo(System.currentTimeMillis());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "启用、禁用考试")
|
|
|
|
- @RequestMapping(value = "/toggle", method = RequestMethod.POST)
|
|
|
|
- public ResultVo updateEnable(@RequestParam Long examId, @RequestParam Boolean enable) {
|
|
|
|
- User user = getAccessUser();
|
|
|
|
- ExamEntity exam = examService.getById(examId);
|
|
|
|
- if (exam == null) {
|
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
|
|
|
+ private AsyncTaskService asyncTaskService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "异步任务进度查询")
|
|
|
|
+ @PostMapping("progress")
|
|
|
|
+ public AsyncTaskVo progress(@RequestParam String taskId) {
|
|
|
|
+ DataExportTaskVo vo = asyncTaskService.getDataExportTask(taskId);
|
|
|
|
+ if (vo == null) {
|
|
|
|
+ throw new ParameterException("未找到导出任务");
|
|
}
|
|
}
|
|
-
|
|
|
|
- LambdaUpdateWrapper<ExamEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
- updateWrapper.set(ExamEntity::getEnable, enable);
|
|
|
|
- updateWrapper.set(ExamEntity::getUpdateTime, System.currentTimeMillis());
|
|
|
|
- updateWrapper.set(ExamEntity::getUpdaterId, user.getId());
|
|
|
|
- updateWrapper.eq(ExamEntity::getId, exam.getId());
|
|
|
|
- examService.update(updateWrapper);
|
|
|
|
-
|
|
|
|
- return new ResultVo(System.currentTimeMillis());
|
|
|
|
|
|
+ vo.setProgress(Calculator.percentageDouble(vo.getProgressCount(), vo.getTotalCount()));
|
|
|
|
+ return vo;
|
|
}
|
|
}
|
|
|
|
|
|
- // @ApiOperation(value = "修改考试上传状态")
|
|
|
|
- // @RequestMapping(value = "/upload", method = RequestMethod.POST)
|
|
|
|
- // public ExamUploadVo upload(@RequestParam Long id, @RequestParam Boolean
|
|
|
|
- // enable) {
|
|
|
|
- // User user = getAccessUser();
|
|
|
|
- // ExamUploadVo vo = new ExamUploadVo();
|
|
|
|
- // ExamEntity exam = examService.getById(id);
|
|
|
|
- // if (exam == null) {
|
|
|
|
- // throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // exam.setEnableUpload(enable);
|
|
|
|
- // examService.saveOrUpdate(exam);
|
|
|
|
- // vo.setEnable(exam.getEnableUpload());
|
|
|
|
- // vo.setUpdateTime(exam.getUpdateTime());
|
|
|
|
- // vo.setProgress(studentService.getUploadProgress(id));
|
|
|
|
- // return vo;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // @ApiOperation(value = "修改考试科目参数")
|
|
|
|
- // @RequestMapping(value = "/subject/config", method = RequestMethod.POST)
|
|
|
|
- // public SubjectConfigVo subjectConfig(@Validated SubjectConfigDomain
|
|
|
|
- // domain) {
|
|
|
|
- // User user = getAccessUser();
|
|
|
|
- // return subjectService.config(user, domain);
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // @ApiOperation(value = "修改考试实时审核状态")
|
|
|
|
- // @RequestMapping(value = "/syncVerify", method = RequestMethod.POST)
|
|
|
|
- // public ResultVo syncVerify(@RequestParam Long examId, @RequestParam
|
|
|
|
- // Boolean enable) {
|
|
|
|
- // User user = getAccessUser();
|
|
|
|
- // ExamEntity exam = examService.updateEnableSyncVerify(user, examId,
|
|
|
|
- // enable);
|
|
|
|
- // return new ResultVo(System.currentTimeMillis());
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
}
|
|
}
|