|
@@ -1,10 +1,30 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
+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.qmth.distributed.print.business.bean.params.analyze.GradeBatchPaperParam;
|
|
|
+import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchPaperResult;
|
|
|
import com.qmth.distributed.print.business.entity.GradeBatchPaper;
|
|
|
import com.qmth.distributed.print.business.mapper.GradeBatchPaperMapper;
|
|
|
import com.qmth.distributed.print.business.service.GradeBatchPaperService;
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.OrgTypeEnum;
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
+import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -16,5 +36,87 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMapper, GradeBatchPaper> implements GradeBatchPaperService {
|
|
|
+ @Resource
|
|
|
+ SysOrgService sysOrgService;
|
|
|
+ @Resource
|
|
|
+ TeachcloudCommonService teachcloudCommonService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<GradeBatchPaperResult> findGradeBatchPaperPage(Long semesterId, Long examId, Long basicCourseId, int pageNumber, int pageSize, SysUser requestUser) {
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+ IPage<GradeBatchPaperResult> datasource = this.baseMapper.findGradeBatchPaperPage(new Page<>(pageNumber, pageSize), semesterId, examId, basicCourseId, schoolId);
|
|
|
+ for (GradeBatchPaperResult record : datasource.getRecords()) {
|
|
|
+ Long teachingRoomId = record.getTeachingRoomId();
|
|
|
+ SysOrg teachCollege = this.findTeachCollegeByOrgId(teachingRoomId);
|
|
|
+ record.setTeachCollegeId(teachCollege.getId());
|
|
|
+ record.setTeachCollegeName(teachCollege.getName());
|
|
|
+ }
|
|
|
+ return datasource;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<GradeBatchPaperResult> findAbleAnalyzePaperList(Long semesterId, Long examId, Long collegeId, Long basicCourseId, String teacherName, SysUser requestUser) {
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+ Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
|
|
|
+ List<GradeBatchPaperResult> datasource = this.baseMapper.findAbleAnalyzePaper(semesterId, examId, collegeId, basicCourseId, teacherName, orgIds, schoolId);
|
|
|
+ List<GradeBatchPaperResult> needAddList = new ArrayList<>();
|
|
|
+ for (GradeBatchPaperResult gradeBatchPaperResult : datasource) {
|
|
|
+ // 额外处理开课学院
|
|
|
+ Long teachingRoomId = gradeBatchPaperResult.getTeachingRoomId();
|
|
|
+ SysOrg teachCollege = this.findTeachCollegeByOrgId(teachingRoomId);
|
|
|
+ if (SystemConstant.longNotNull(collegeId) && !collegeId.equals(teachCollege.getId())){
|
|
|
+ datasource.remove(gradeBatchPaperResult);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ gradeBatchPaperResult.setTeachCollegeId(teachCollege.getId());
|
|
|
+ gradeBatchPaperResult.setTeachCollegeName(teachCollege.getName());
|
|
|
+
|
|
|
+ // 需要拆分的试卷类型
|
|
|
+ String paperType = gradeBatchPaperResult.getPaperType();
|
|
|
+ for (String paperTypeCell : paperType.split(",")) {
|
|
|
+ GradeBatchPaperResult needAdd = new GradeBatchPaperResult();
|
|
|
+ BeanUtils.copyProperties(gradeBatchPaperResult,needAdd);
|
|
|
+ needAdd.setPaperType(paperTypeCell);
|
|
|
+ needAddList.add(needAdd);
|
|
|
+ }
|
|
|
+ datasource.remove(gradeBatchPaperResult);
|
|
|
+ }
|
|
|
+ datasource.addAll(needAddList);
|
|
|
+ return datasource.stream().sorted(Comparator.comparing(GradeBatchPaperResult::getSemesterName)
|
|
|
+ .thenComparing(GradeBatchPaperResult::getExamName)
|
|
|
+ .thenComparing(GradeBatchPaperResult::getTeachCollegeId)
|
|
|
+ .thenComparing(GradeBatchPaperResult::getCourseCode)
|
|
|
+ .thenComparing(GradeBatchPaperResult::getPaperNumber)
|
|
|
+ .thenComparing(GradeBatchPaperResult::getPaperType)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void saveGradeBatchPaper(List<GradeBatchPaperParam> gradeBatchPaperParamList, SysUser requestUser) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean deleteGradeBatchPaper(Long id) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据机构id查询开课学院
|
|
|
+ *
|
|
|
+ * @param orgId 机构id(课程所在教研室)
|
|
|
+ * @return 开课学院
|
|
|
+ */
|
|
|
+ private SysOrg findTeachCollegeByOrgId(Long orgId) {
|
|
|
+ if (!SystemConstant.longNotNull(orgId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("机构id不存在");
|
|
|
+ }
|
|
|
|
|
|
+ List<SysOrg> collegeList = sysOrgService.findParentsByOrgId(orgId).stream().filter(e -> OrgTypeEnum.COLLEGE.equals(e.getType())).distinct().collect(Collectors.toList());
|
|
|
+ if (collegeList.size() != 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到开课学院");
|
|
|
+ }
|
|
|
+ return collegeList.get(0);
|
|
|
+ }
|
|
|
}
|