|
@@ -388,33 +388,61 @@ public class MarkGroupServiceImpl extends MppServiceImpl<MarkGroupMapper, MarkGr
|
|
// 更新MarkPaper中groupStatus
|
|
// 更新MarkPaper中groupStatus
|
|
markService.updateMarkGroupStatus(examId, paperNumber);
|
|
markService.updateMarkGroupStatus(examId, paperNumber);
|
|
|
|
|
|
-// List<MarkUserGroup>
|
|
|
|
-
|
|
|
|
- List<MarkUserGroup> markUserGroupList = markUserGroupService.listByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, markGroupDto.getGroupNumber());
|
|
|
|
- if (CollectionUtils.isNotEmpty(markUserGroupList)) {
|
|
|
|
- List<Long> userIds = markUserGroupList.stream().map(MarkUserGroup::getUserId).collect(Collectors.toList());
|
|
|
|
- List<MarkUserGroup> markUserGroups = new ArrayList<>();
|
|
|
|
- for (MarkUser marker : markGroupDto.getMarkers()) {
|
|
|
|
- if (userIds.contains(marker.getUserId())) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- markUserGroups.add(new MarkUserGroup(examId, paperNumber, markGroupDto.getGroupNumber(), marker.getUserId()));
|
|
|
|
- }
|
|
|
|
- if (CollectionUtils.isNotEmpty(markUserGroups)) {
|
|
|
|
- markUserGroupService.saveBatch(markUserGroups);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ boolean isClear = isEqual || !doubleEnable.equals(markGroupDto.getDoubleEnable()) || (markGroupDto.getDoubleEnable() && (doubleRate == null || markGroupDto.getDoubleRate().doubleValue() != markGroup.getDoubleRate().doubleValue()));
|
|
|
|
+ updateMarkUserGroup(isClear, examId, paperNumber, markGroupDto);
|
|
|
|
|
|
// 增加或减少分组内题目数量和题目变动、单双评切换、开启双评且双评比例值修改过。则删除任务
|
|
// 增加或减少分组内题目数量和题目变动、单双评切换、开启双评且双评比例值修改过。则删除任务
|
|
- if (isEqual ||
|
|
|
|
- !doubleEnable.equals(markGroupDto.getDoubleEnable())
|
|
|
|
- || (markGroupDto.getDoubleEnable() && (doubleRate == null || markGroupDto.getDoubleRate().doubleValue() != markGroup.getDoubleRate().doubleValue()))) {
|
|
|
|
|
|
+ if (isClear) {
|
|
if (lockService.trylock(LockType.GROUP_DELETE, examId, paperNumber, markGroupDto.getGroupNumber())) {
|
|
if (lockService.trylock(LockType.GROUP_DELETE, examId, paperNumber, markGroupDto.getGroupNumber())) {
|
|
markSyncService.deleteMarkGroup(markGroup, false);
|
|
markSyncService.deleteMarkGroup(markGroup, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void updateMarkUserGroup(boolean isClear, Long examId, String paperNumber, MarkGroupDto markGroupDto) {
|
|
|
|
+ List<MarkUser> markUserList = markGroupDto.getMarkers();
|
|
|
|
+ if (CollectionUtils.isEmpty(markUserList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择评卷员");
|
|
|
|
+ }
|
|
|
|
+ List<MarkUserGroup> markUserGroupList = markUserGroupService.listByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, markGroupDto.getGroupNumber());
|
|
|
|
+ if (CollectionUtils.isEmpty(markUserGroupList)) {
|
|
|
|
+ markUserGroupList = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ List<Long> oldUserIds = markUserGroupList.stream().map(MarkUserGroup::getUserId).collect(Collectors.toList());
|
|
|
|
+ List<Long> userIds = markUserList.stream().map(MarkUser::getUserId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 需要删除的用户
|
|
|
|
+ Collection<Long> deleteUserIds = CollectionUtils.subtract(oldUserIds, userIds);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(deleteUserIds)) {
|
|
|
|
+ markUserGroupList.stream().filter(m -> deleteUserIds.contains(m.getUserId())).forEach(m -> {
|
|
|
|
+ markUserGroupService.deleteMarker(m.getId());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 需要新增的用户
|
|
|
|
+ List<MarkUserGroup> markUserGroups = new ArrayList<>();
|
|
|
|
+ Collection<Long> addUserIds = CollectionUtils.subtract(userIds, oldUserIds);
|
|
|
|
+ for (Long addUserId : addUserIds) {
|
|
|
|
+ markUserGroups.add(new MarkUserGroup(examId, paperNumber, markGroupDto.getGroupNumber(), addUserId));
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(markUserGroups)) {
|
|
|
|
+ markUserGroupService.saveBatch(markUserGroups);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isClear) {
|
|
|
|
+ // 需要修改的用户
|
|
|
|
+ Collection<Long> updateUserIds = CollectionUtils.intersection(oldUserIds, userIds);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(updateUserIds)) {
|
|
|
|
+ markUserGroupList.stream().filter(m -> updateUserIds.contains(m.getUserId())).forEach(m -> {
|
|
|
|
+ markUserGroupService.resetById(m.getId());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.updateMarkedCount(examId, paperNumber, markGroupDto.getGroupNumber(), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 校验修改前后分组内题目是否一致
|
|
* 校验修改前后分组内题目是否一致
|
|
*
|
|
*
|