|
@@ -49,27 +49,29 @@ public class MarkerGroupLeaderService {
|
|
|
}
|
|
|
Set<MarkUser> groupMarkers = markerGroup.getMarkers();
|
|
|
List<MarkUser> markLeaders = groupMarkers.stream().filter(m -> Role.MARK_LEADER.equals(m.getRole())).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(markLeaders)) {
|
|
|
+ throw new RuntimeException("每个分组至少有一个科组长");
|
|
|
+ }
|
|
|
MarkerGroup group = markerGroupRepo.save(markerGroup);
|
|
|
- if (!CollectionUtils.isEmpty(markLeaders)) {
|
|
|
- List<MarkUser> markers = groupMarkers.stream().filter(m -> Role.MARKER.equals(m.getRole())).collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(markers)) {
|
|
|
- List<MarkerGroupLeader> leaderList = new ArrayList<>();
|
|
|
- for (MarkUser markLeader : markLeaders) {
|
|
|
- for (MarkUser marker : markers) {
|
|
|
- MarkerGroupLeader markerGroupLeader = new MarkerGroupLeader();
|
|
|
- markerGroupLeader.setWorkId(markerGroup.getWorkId());
|
|
|
- markerGroupLeader.setSubject(markerGroup.getSubject());
|
|
|
- markerGroupLeader.setStage(stage);
|
|
|
- markerGroupLeader.setGroupId(group.getId());
|
|
|
- markerGroupLeader.setGroupName(group.getName());
|
|
|
- markerGroupLeader.setMarkLeaderId(markLeader.getId());
|
|
|
- markerGroupLeader.setMarkerId(marker.getId());
|
|
|
- leaderList.add(markerGroupLeader);
|
|
|
- }
|
|
|
+ List<MarkUser> markers = groupMarkers.stream().filter(m -> Role.MARKER.equals(m.getRole())).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(markers)) {
|
|
|
+ List<MarkerGroupLeader> leaderList = new ArrayList<>();
|
|
|
+ for (MarkUser markLeader : markLeaders) {
|
|
|
+ for (MarkUser marker : markers) {
|
|
|
+ MarkerGroupLeader markerGroupLeader = new MarkerGroupLeader();
|
|
|
+ markerGroupLeader.setWorkId(markerGroup.getWorkId());
|
|
|
+ markerGroupLeader.setSubject(markerGroup.getSubject());
|
|
|
+ markerGroupLeader.setStage(stage);
|
|
|
+ markerGroupLeader.setGroupId(group.getId());
|
|
|
+ markerGroupLeader.setGroupName(group.getName());
|
|
|
+ markerGroupLeader.setMarkLeaderId(markLeader.getId());
|
|
|
+ markerGroupLeader.setMarkerId(marker.getId());
|
|
|
+ leaderList.add(markerGroupLeader);
|
|
|
}
|
|
|
- markerGroupLeaderRepo.save(leaderList);
|
|
|
}
|
|
|
+ markerGroupLeaderRepo.save(leaderList);
|
|
|
}
|
|
|
+
|
|
|
return group;
|
|
|
}
|
|
|
|
|
@@ -140,7 +142,7 @@ public class MarkerGroupLeaderService {
|
|
|
public List<Long> listPaperIdsByWorkIdAndSubjectAndStage(Long workId, Subject subject, MarkStage stage, List<Long> markers) {
|
|
|
List<Object[]> papers = markTaskRepo.findByWorkIdAndSubjectAndStage(workId, subject.name(), stage.ordinal());
|
|
|
if (!CollectionUtils.isEmpty(papers)) {
|
|
|
- List<Long> paperIds = papers.stream().filter(m->markers.contains(Long.valueOf(m[1].toString()))).map(m -> Long.valueOf(m[0].toString())).distinct().collect(Collectors.toList());
|
|
|
+ List<Long> paperIds = papers.stream().filter(m -> markers.contains(Long.valueOf(m[1].toString()))).map(m -> Long.valueOf(m[0].toString())).distinct().collect(Collectors.toList());
|
|
|
return paperIds;
|
|
|
}
|
|
|
return null;
|
|
@@ -166,15 +168,14 @@ public class MarkerGroupLeaderService {
|
|
|
* @param stage
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map<String, Object>> listGroupByWorkIdAndSubjectAndStage(Long workId, Subject subject, MarkStage stage) {
|
|
|
+ public Set<Map<String, Object>> listGroupByWorkIdAndSubjectAndStage(Long workId, Subject subject, MarkStage stage) {
|
|
|
stage = Objects.isNull(stage) ? MarkStage.LEVEL : stage;
|
|
|
List<MarkerGroupLeader> markerGroupLeaders = markerGroupLeaderRepo.findByWorkIdAndSubjectAndStage(workId, subject, stage);
|
|
|
- Map<Long, String> map = markerGroupLeaders.stream().collect(Collectors.toMap(m -> m.getGroupId(), m -> m.getGroupName()));
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- for (Map.Entry<Long, String> entry : map.entrySet()) {
|
|
|
+ Set<Map<String, Object>> list = new HashSet<>();
|
|
|
+ for (MarkerGroupLeader markerGroupLeader : markerGroupLeaders) {
|
|
|
Map<String, Object> stringMap = new HashMap<>();
|
|
|
- stringMap.computeIfAbsent("groupId", v -> entry.getKey());
|
|
|
- stringMap.computeIfAbsent("groupName", v -> entry.getValue());
|
|
|
+ stringMap.computeIfAbsent("groupId", v -> markerGroupLeader.getGroupId());
|
|
|
+ stringMap.computeIfAbsent("groupName", v -> markerGroupLeader.getGroupName());
|
|
|
list.add(stringMap);
|
|
|
}
|
|
|
return list;
|
|
@@ -182,6 +183,7 @@ public class MarkerGroupLeaderService {
|
|
|
|
|
|
/**
|
|
|
* 根据分组查询组内评卷员
|
|
|
+ *
|
|
|
* @param workId
|
|
|
* @param subject
|
|
|
* @param level
|
|
@@ -189,13 +191,13 @@ public class MarkerGroupLeaderService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Long> listByWorkIdAndSubjectAndStageAndGroupId(Long workId, Subject subject, MarkStage level, Long groupId) {
|
|
|
- if(Objects.isNull(groupId)){
|
|
|
+ if (Objects.isNull(groupId)) {
|
|
|
return null;
|
|
|
}
|
|
|
List<MarkerGroupLeader> markerGroupLeaders = markerGroupLeaderRepo.findByWorkIdAndSubjectAndStageAndGroupId(workId, subject, level, groupId);
|
|
|
List<Long> markerIds = null;
|
|
|
- if(!CollectionUtils.isEmpty(markerGroupLeaders)){
|
|
|
- markerIds = markerGroupLeaders.stream().map(m->m.getMarkerId()).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(markerGroupLeaders)) {
|
|
|
+ markerIds = markerGroupLeaders.stream().map(m -> m.getMarkerId()).distinct().collect(Collectors.toList());
|
|
|
}
|
|
|
return markerIds;
|
|
|
}
|