|
@@ -1,38 +1,11 @@
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.qmth.distributed.print.business.bean.dto.ExamPaperStructurePageDto;
|
|
|
|
-import com.qmth.distributed.print.business.bean.marking.Question;
|
|
|
|
import com.qmth.distributed.print.business.entity.ExamPaperStructure;
|
|
import com.qmth.distributed.print.business.entity.ExamPaperStructure;
|
|
-import com.qmth.distributed.print.business.entity.ExamTaskDetail;
|
|
|
|
-import com.qmth.distributed.print.business.entity.TBSyncTask;
|
|
|
|
-import com.qmth.distributed.print.business.enums.ExamTaskSyncStatusEnum;
|
|
|
|
import com.qmth.distributed.print.business.mapper.ExamPaperStructureMapper;
|
|
import com.qmth.distributed.print.business.mapper.ExamPaperStructureMapper;
|
|
import com.qmth.distributed.print.business.service.ExamPaperStructureService;
|
|
import com.qmth.distributed.print.business.service.ExamPaperStructureService;
|
|
-import com.qmth.distributed.print.business.service.ExamTaskDetailService;
|
|
|
|
-import com.qmth.distributed.print.business.service.TBSyncTaskService;
|
|
|
|
-import com.qmth.teachcloud.common.bean.auth.AuthBean;
|
|
|
|
-import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
|
-import com.qmth.teachcloud.common.bean.dto.stmms.ExamCloudPaperStructDto;
|
|
|
|
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
|
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
|
-import com.qmth.teachcloud.common.enums.PushTypeEnum;
|
|
|
|
-import com.qmth.teachcloud.common.enums.QuestionType;
|
|
|
|
-import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
|
|
|
|
-import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
|
-import com.qmth.teachcloud.common.util.ExamTaskUtil;
|
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.*;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 试卷结构 服务实现类
|
|
* 试卷结构 服务实现类
|
|
@@ -41,94 +14,5 @@ import java.util.*;
|
|
@Service
|
|
@Service
|
|
public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructureMapper, ExamPaperStructure> implements ExamPaperStructureService {
|
|
public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructureMapper, ExamPaperStructure> implements ExamPaperStructureService {
|
|
|
|
|
|
- @Resource
|
|
|
|
- ExamTaskDetailService examTaskDetailService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- TBSyncTaskService tbSyncTaskService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private BasicRoleDataPermissionService basicRoleDataPermissionService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- CommonCacheService commonCacheService;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public IPage<ExamPaperStructurePageDto> listByPropositionTeacherId(Long semesterId, Long examId, Integer pageNumber, Integer pageSize, Boolean ready) {
|
|
|
|
- Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- String url = "/api/admin/exam/structure/list";
|
|
|
|
- DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, sysUser.getId(), url);
|
|
|
|
- Page<ExamPaperStructure> page = new Page<>(pageNumber, pageSize);
|
|
|
|
- String syncStatus = ExamTaskSyncStatusEnum.FINISH.name();
|
|
|
|
- // 查看是否有评卷参数管理权限
|
|
|
|
- AuthBean authBean = commonCacheService.userAuthCache(sysUser.getId());
|
|
|
|
- Set<String> urls = authBean.getUrls();
|
|
|
|
- int privilegeCount = Objects.nonNull(urls) ? (int) urls.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
|
|
|
|
- if (privilegeCount == 0) {
|
|
|
|
- syncStatus = null;
|
|
|
|
- }
|
|
|
|
- IPage<ExamPaperStructurePageDto> examPaperStructureIPage = this.baseMapper.listByPropositionTeacherId(page, schoolId, semesterId, examId, syncStatus, ready, dpr);
|
|
|
|
- examPaperStructureIPage.getRecords().forEach(m -> {
|
|
|
|
- // 试卷结构同步任务状态
|
|
|
|
- if (m.getId() != null) {
|
|
|
|
- QueryWrapper<TBSyncTask> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(TBSyncTask::getObjectId, m.getId()).eq(TBSyncTask::getType, PushTypeEnum.STRUCTURE_GROUP_PUSH);
|
|
|
|
- TBSyncTask tbSyncTask = tbSyncTaskService.getOne(queryWrapper);
|
|
|
|
- m.setTaskStatus(tbSyncTask == null ? null : tbSyncTask.getStatus().name());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
|
|
|
|
- .eq(ExamTaskDetail::getExamTaskId, m.getExamTaskId()));
|
|
|
|
- if (examTaskDetail != null && StringUtils.isNotBlank(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
|
- List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), m.getPaperType());
|
|
|
|
- if (CollectionUtils.isNotEmpty(paperInfoVoList)) {
|
|
|
|
- m.setCardId(String.valueOf(paperInfoVoList.get(0).getCardId()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- return examPaperStructureIPage;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Map<QuestionType, List<Question>> parseExamCloudPaperStruct(List<ExamCloudPaperStructDto> examCloudPaperStructDtoList) {
|
|
|
|
- Map<QuestionType, List<Question>> result = new HashMap<>();
|
|
|
|
- List<Question> objList = new ArrayList<>();
|
|
|
|
- List<Question> subList = new ArrayList<>();
|
|
|
|
- for (ExamCloudPaperStructDto examCloudPaperStructDto : examCloudPaperStructDtoList) {
|
|
|
|
- boolean objective = examCloudPaperStructDto.getObjective();
|
|
|
|
- String mainTitle = examCloudPaperStructDto.getMainTitle();
|
|
|
|
- Integer mainNumber = examCloudPaperStructDto.getMainNumber();
|
|
|
|
- Integer subNumber = examCloudPaperStructDto.getSubNumber();
|
|
|
|
- double totalScore = examCloudPaperStructDto.getTotalScore();
|
|
|
|
- String answer = examCloudPaperStructDto.getAnswer();
|
|
|
|
-
|
|
|
|
- Question question = new Question();
|
|
|
|
- question.setMainTitle(mainTitle);
|
|
|
|
- question.setMainNumber(mainNumber);
|
|
|
|
- question.setSubNumber(String.valueOf(subNumber));
|
|
|
|
- question.setTotalScore(BigDecimal.valueOf(totalScore));
|
|
|
|
- question.setAnswer(answer);
|
|
|
|
- if (objective) {
|
|
|
|
- objList.add(question);
|
|
|
|
- } else {
|
|
|
|
- subList.add(question);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- result.put(QuestionType.OBJECTIVE, objList);
|
|
|
|
- result.put(QuestionType.SUBJECTIVE, subList);
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public long countByPropositionTeacherId(Boolean ready) {
|
|
|
|
- Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, sysUser.getId(), "/api/admin/exam/structure/list");
|
|
|
|
- List<ExamPaperStructure> examPaperStructureList = this.baseMapper.listByPropositionTeacherId(schoolId, null, null, sysUser.getId(), ExamTaskSyncStatusEnum.FINISH.name(), ready, dpr);
|
|
|
|
- return CollectionUtils.isEmpty(examPaperStructureList) ? 0 : examPaperStructureList.size();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|