|
|
@ -10,6 +10,7 @@ import cn.teammodel.model.entity.school.ClassInfo;
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDuty;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDuty;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDutyRecord;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDutyRecord;
|
|
|
|
|
|
|
|
import cn.teammodel.model.vo.weekDuty.DutyRecordVo;
|
|
|
|
import cn.teammodel.repository.ClassRepository;
|
|
|
|
import cn.teammodel.repository.ClassRepository;
|
|
|
|
import cn.teammodel.repository.DutyRecordRepository;
|
|
|
|
import cn.teammodel.repository.DutyRecordRepository;
|
|
|
|
import cn.teammodel.repository.DutyRepository;
|
|
|
|
import cn.teammodel.repository.DutyRepository;
|
|
|
@ -25,10 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.time.*;
|
|
|
|
import java.time.*;
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -158,6 +156,7 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
String newNodeName = updateDutyNodeDto.getName();
|
|
|
|
String newNodeName = updateDutyNodeDto.getName();
|
|
|
|
Integer newScore = updateDutyNodeDto.getScore();
|
|
|
|
Integer newScore = updateDutyNodeDto.getScore();
|
|
|
|
String desc = updateDutyNodeDto.getDesc();
|
|
|
|
String desc = updateDutyNodeDto.getDesc();
|
|
|
|
|
|
|
|
Boolean positive = updateDutyNodeDto.getPositive();
|
|
|
|
|
|
|
|
|
|
|
|
String schoolId = SecurityUtil.getLoginUser().getSchoolId();
|
|
|
|
String schoolId = SecurityUtil.getLoginUser().getSchoolId();
|
|
|
|
WeekDuty duty = dutyRepository.findBySchoolIdAndCode(schoolId, PK.WEEK_DUTY);
|
|
|
|
WeekDuty duty = dutyRepository.findBySchoolIdAndCode(schoolId, PK.WEEK_DUTY);
|
|
|
@ -173,7 +172,7 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
nodeToUpdate.setName(newNodeName);
|
|
|
|
nodeToUpdate.setName(newNodeName);
|
|
|
|
nodeToUpdate.setOrder(updateDutyNodeDto.getOrder());
|
|
|
|
nodeToUpdate.setOrder(updateDutyNodeDto.getOrder());
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是一级,二级需同步更新三级节点的 path
|
|
|
|
// 一级,二级需同步更新三级节点的 path
|
|
|
|
if (nodeToUpdate.getPath() == null || nodeToUpdate.getPath().length == 0) {
|
|
|
|
if (nodeToUpdate.getPath() == null || nodeToUpdate.getPath().length == 0) {
|
|
|
|
int index = StringUtils.isEmpty(nodeToUpdate.getPid()) ? 0 : 1;
|
|
|
|
int index = StringUtils.isEmpty(nodeToUpdate.getPid()) ? 0 : 1;
|
|
|
|
nodes.forEach(x -> {
|
|
|
|
nodes.forEach(x -> {
|
|
|
@ -188,9 +187,10 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
nodeToUpdate.setScore(newScore);
|
|
|
|
// 三级节点
|
|
|
|
|
|
|
|
nodeToUpdate.setScore(positive ? newScore : -newScore);
|
|
|
|
nodeToUpdate.setDesc(desc);
|
|
|
|
nodeToUpdate.setDesc(desc);
|
|
|
|
nodeToUpdate.setPositive(newScore >= 0);
|
|
|
|
nodeToUpdate.setPositive(newScore.equals(0) || positive);
|
|
|
|
nodeToUpdate.getPath()[2] = newNodeName;
|
|
|
|
nodeToUpdate.getPath()[2] = newNodeName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -312,7 +312,7 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<WeekDutyRecord.WeekDutyItem> findRecords(FindDutyRecordDto findDutyRecordDto) {
|
|
|
|
public List<DutyRecordVo> findRecords(FindDutyRecordDto findDutyRecordDto) {
|
|
|
|
String classId = StringUtils.isEmpty(findDutyRecordDto.getClassId()) ? null : findDutyRecordDto.getClassId();
|
|
|
|
String classId = StringUtils.isEmpty(findDutyRecordDto.getClassId()) ? null : findDutyRecordDto.getClassId();
|
|
|
|
String academicYearId = findDutyRecordDto.getAcademicYearId();
|
|
|
|
String academicYearId = findDutyRecordDto.getAcademicYearId();
|
|
|
|
Boolean positive = findDutyRecordDto.getPositive();
|
|
|
|
Boolean positive = findDutyRecordDto.getPositive();
|
|
|
@ -331,7 +331,7 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
startTime = mondayOfCurWeek.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli();
|
|
|
|
startTime = mondayOfCurWeek.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli();
|
|
|
|
endTime = Instant.now().toEpochMilli();
|
|
|
|
endTime = Instant.now().toEpochMilli();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<WeekDutyRecord.WeekDutyItem> records = dutyRecordRepository.findRecordsByConditions(
|
|
|
|
List<DutyRecordVo> records = dutyRecordRepository.findRecordsByConditions(
|
|
|
|
String.format(PK.WEEK_DUTY_RECORD, schoolId),
|
|
|
|
String.format(PK.WEEK_DUTY_RECORD, schoolId),
|
|
|
|
academicYearId,
|
|
|
|
academicYearId,
|
|
|
|
userId,
|
|
|
|
userId,
|
|
|
@ -339,9 +339,32 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
positive,
|
|
|
|
positive,
|
|
|
|
startTime,
|
|
|
|
startTime,
|
|
|
|
endTime);
|
|
|
|
endTime);
|
|
|
|
|
|
|
|
records = records.stream().sorted((o1, o2) -> o2.getInfo().getCreateTime().compareTo(o1.getInfo().getCreateTime())).collect(Collectors.toList());
|
|
|
|
return records;
|
|
|
|
return records;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void recallVote(RecallDutyVoteDto recallDutyVoteDto) {
|
|
|
|
|
|
|
|
String recordId = recallDutyVoteDto.getRecordId();
|
|
|
|
|
|
|
|
String nodeId = recallDutyVoteDto.getNodeId();
|
|
|
|
|
|
|
|
User user = SecurityUtil.getLoginUser();
|
|
|
|
|
|
|
|
String schoolId = user.getSchoolId();
|
|
|
|
|
|
|
|
String userId = user.getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Optional<WeekDutyRecord> optional = dutyRecordRepository.findById(recordId, PK.of(String.format(PK.WEEK_DUTY_RECORD, schoolId)));
|
|
|
|
|
|
|
|
WeekDutyRecord weekDutyRecord = optional.orElseThrow(() -> new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "评价记录不存在"));
|
|
|
|
|
|
|
|
WeekDutyRecord.WeekDutyItem item = weekDutyRecord.getNodes().stream()
|
|
|
|
|
|
|
|
.filter(x -> nodeId.equals(x.getDutyTreeNode().getId()))
|
|
|
|
|
|
|
|
.findFirst().
|
|
|
|
|
|
|
|
orElseThrow(() -> new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "评价记录不存在"));
|
|
|
|
|
|
|
|
if (!userId.equals(item.getCreatorId())) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "只能撤回自己的评价");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
weekDutyRecord.setScore(weekDutyRecord.getScore() - item.getDutyTreeNode().getScore());
|
|
|
|
|
|
|
|
weekDutyRecord.getNodes().remove(item);
|
|
|
|
|
|
|
|
dutyRecordRepository.save(weekDutyRecord);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 刷新值周树和 spots 的 id
|
|
|
|
* 刷新值周树和 spots 的 id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|