Procházet zdrojové kódy

add:评卷参数结构保存

caozixuan před 3 roky
rodič
revize
d8f8158e0b

+ 10 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPaperGroupMarkerService.java

@@ -1,8 +1,10 @@
 package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.bean.marking.Marker;
 import com.qmth.distributed.print.business.entity.ExamPaperGroupMarker;
 
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -11,9 +13,17 @@ import java.util.Set;
  * @Date: 2022-04-13
  */
 public interface ExamPaperGroupMarkerService extends IService<ExamPaperGroupMarker> {
+    /**
+     * 根据分组id和评卷员集合新增分组和评卷员关系
+     *
+     * @param examPaperGroupId 分组id
+     * @param markerList       评卷员集合
+     */
+    void saveExamPaperGroupMarkerByGroupId(Long examPaperGroupId, List<Marker> markerList);
 
     /**
      * 根据分组idSet删除评卷员分组关系
+     *
      * @param groupIdSet 分组idSet
      */
     void deleteExamPaperGroupMarkerService(Set<Long> groupIdSet);

+ 1 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPaperGroupService.java

@@ -18,9 +18,8 @@ public interface ExamPaperGroupService extends IService<ExamPaperGroup> {
      *
      * @param examPaperStructureId 试卷结构id
      * @param groupInfo            分组信息
-     * @return 分组id
      */
-    Long saveExamPaperGroupInfo(Long examPaperStructureId, List<GroupInfo> groupInfo);
+    void saveExamPaperGroupInfo(Long examPaperStructureId, List<GroupInfo> groupInfo);
 
     /**
      * 删除考试试卷分组信息

+ 18 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperGroupMarkerServiceImpl.java

@@ -2,13 +2,17 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.bean.marking.Marker;
 import com.qmth.distributed.print.business.entity.ExamPaperGroupMarker;
 import com.qmth.distributed.print.business.mapper.ExamPaperGroupMarkerMapper;
 import com.qmth.distributed.print.business.service.ExamPaperGroupMarkerService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @Description: 评卷员-分组关系服务实现类
@@ -18,11 +22,23 @@ import java.util.Set;
 @Service
 public class ExamPaperGroupMarkerServiceImpl extends ServiceImpl<ExamPaperGroupMarkerMapper,ExamPaperGroupMarker> implements ExamPaperGroupMarkerService {
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void saveExamPaperGroupMarkerByGroupId(Long examPaperGroupId, List<Marker> markerList) {
+        Set<ExamPaperGroupMarker> examPaperGroupMarkerSet = markerList.stream().flatMap(e -> {
+            ExamPaperGroupMarker marker = new ExamPaperGroupMarker();
+            marker.setGroupId(examPaperGroupId);
+            marker.setMarkerId(e.getId());
+            return Stream.of(marker);
+        }).collect(Collectors.toSet());
+        this.saveBatch(examPaperGroupMarkerSet);
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void deleteExamPaperGroupMarkerService(Set<Long> groupIdSet) {
-        if (groupIdSet.size() > 0){
-            this.remove(new QueryWrapper<ExamPaperGroupMarker>().lambda().in(ExamPaperGroupMarker::getGroupId,groupIdSet));
+        if (groupIdSet.size() > 0) {
+            this.remove(new QueryWrapper<ExamPaperGroupMarker>().lambda().in(ExamPaperGroupMarker::getGroupId, groupIdSet));
         }
     }
 }

+ 2 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperGroupServiceImpl.java

@@ -33,7 +33,7 @@ public class ExamPaperGroupServiceImpl extends ServiceImpl<ExamPaperGroupMapper,
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public Long saveExamPaperGroupInfo(Long examPaperStructureId, List<GroupInfo> groupInfo) {
+    public void saveExamPaperGroupInfo(Long examPaperStructureId, List<GroupInfo> groupInfo) {
         // 1.删除原有分组
         this.deleteExamPaperGroupInfo(examPaperStructureId);
         // 2.新增新的试卷结构分组
@@ -60,10 +60,8 @@ public class ExamPaperGroupServiceImpl extends ServiceImpl<ExamPaperGroupMapper,
             this.save(examPaperGroup);
             // 新增后的分组id
             Long groupId = examPaperGroup.getId();
-
-
+            examPaperGroupMarkerService.saveExamPaperGroupMarkerByGroupId(groupId,markerList);
         }
-        return null;
     }
 
     @Transactional(rollbackFor = Exception.class)

+ 3 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java

@@ -286,12 +286,10 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
     @Transactional(rollbackFor = Exception.class)
     @Override
     public ExamPaperStructure submitExamPaperParams(EvaluationParameters evaluationParameters, SysUser requestUser) {
-        // TODO: 2022/4/13 1.保存试卷结构
+        // 1.保存试卷结构
         ExamPaperStructure examPaperStructure = this.saveExamPaperStructure(evaluationParameters, requestUser);
-        // TODO: 2022/4/13 2.保存分组信息
-        Long examPaperGroupId = examPaperGroupService.saveExamPaperGroupInfo(examPaperStructure.getId(), evaluationParameters.getGroupInfo());
-        // TODO: 2022/4/13 3.保存分组和评卷员的关系
-
+        // 2.保存分组和分组关系信息
+        examPaperGroupService.saveExamPaperGroupInfo(examPaperStructure.getId(), evaluationParameters.getGroupInfo());
         // 返回试卷结构信息
         return examPaperStructure;
     }