|
|
@ -27,10 +27,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -243,7 +240,7 @@ public class EvaluationServiceImpl implements EvaluationService {
|
|
|
|
String periodId;
|
|
|
|
String periodId;
|
|
|
|
String name;
|
|
|
|
String name;
|
|
|
|
String avatar = null;
|
|
|
|
String avatar = null;
|
|
|
|
// 判断评价对象是否合法
|
|
|
|
// 分别对班级和学生的关键信息取值
|
|
|
|
if (targetType.equals(TARGET_STUDENT)) {
|
|
|
|
if (targetType.equals(TARGET_STUDENT)) {
|
|
|
|
Student student = studentRepository.findStudentByIdAndCode(targetId, String.format(PK.STUDENT, schoolId));
|
|
|
|
Student student = studentRepository.findStudentByIdAndCode(targetId, String.format(PK.STUDENT, schoolId));
|
|
|
|
if (student == null) {
|
|
|
|
if (student == null) {
|
|
|
@ -280,8 +277,8 @@ public class EvaluationServiceImpl implements EvaluationService {
|
|
|
|
// 查询是否存在记录
|
|
|
|
// 查询是否存在记录
|
|
|
|
AppraiseRecord record = appraiseRecordRepository.findAppraiseRecordByTargetIdAndClassIdAndAcademicYearIdAndCode(
|
|
|
|
AppraiseRecord record = appraiseRecordRepository.findAppraiseRecordByTargetIdAndClassIdAndAcademicYearIdAndCode(
|
|
|
|
targetId,
|
|
|
|
targetId,
|
|
|
|
academicYearId,
|
|
|
|
|
|
|
|
classId,
|
|
|
|
classId,
|
|
|
|
|
|
|
|
academicYearId,
|
|
|
|
String.format(PK.PK_APPRAISE_RECORD,schoolId)
|
|
|
|
String.format(PK.PK_APPRAISE_RECORD,schoolId)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -350,6 +347,36 @@ public class EvaluationServiceImpl implements EvaluationService {
|
|
|
|
return appraiseRecordItems;
|
|
|
|
return appraiseRecordItems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void recallVote(RecallVoteDto recallVoteDto) {
|
|
|
|
|
|
|
|
String recordId = recallVoteDto.getRecordId();
|
|
|
|
|
|
|
|
String nodeId = recallVoteDto.getNodeId();
|
|
|
|
|
|
|
|
User loginUser = SecurityUtil.getLoginUser();
|
|
|
|
|
|
|
|
String schoolId = loginUser.getSchoolId();
|
|
|
|
|
|
|
|
String userId = loginUser.getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Optional<AppraiseRecord> optional = appraiseRecordRepository.findById(recordId, PK.buildOf(PK.PK_APPRAISE_RECORD, schoolId));
|
|
|
|
|
|
|
|
AppraiseRecord appraiseRecord = optional.orElseThrow(() -> new ServiceException("该记录不存在"));
|
|
|
|
|
|
|
|
AppraiseRecordItem record = appraiseRecord.getNodes()
|
|
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
|
|
.filter(item -> nodeId.equals(item.getId()))
|
|
|
|
|
|
|
|
.findFirst().orElseThrow(() -> new ServiceException("该记录节点不存在"));
|
|
|
|
|
|
|
|
// 鉴权(不是创建老师不能撤回)
|
|
|
|
|
|
|
|
if (!userId.equals(record.getCreatorId())) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.NO_AUTH_ERROR.getCode(), "您不是创建老师,不能撤回");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 删除评价项并且恢复评分
|
|
|
|
|
|
|
|
appraiseRecord.getNodes().removeIf(item -> nodeId.equals(item.getId()));
|
|
|
|
|
|
|
|
boolean praise = record.getAppraiseNode().isPraise();
|
|
|
|
|
|
|
|
Integer newPraiseCount = appraiseRecord.getPraiseCount() + (praise ? -1 : 1);
|
|
|
|
|
|
|
|
appraiseRecord.setPraiseCount(newPraiseCount);
|
|
|
|
|
|
|
|
int score = record.getAppraiseNode().getScore() == null ? 0 : record.getAppraiseNode().getScore();
|
|
|
|
|
|
|
|
Integer newScore = appraiseRecord.getScore() - score;
|
|
|
|
|
|
|
|
appraiseRecord.setScore(newScore);
|
|
|
|
|
|
|
|
// 保存
|
|
|
|
|
|
|
|
appraiseRecordRepository.save(appraiseRecord);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 递归收集 id 的节点及 id 节点的孩子节点 (迭代器删除居然也报错)
|
|
|
|
* 递归收集 id 的节点及 id 节点的孩子节点 (迭代器删除居然也报错)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|