|
|
@ -23,8 +23,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.time.Instant;
|
|
|
|
import java.time.*;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.Comparator;
|
|
|
@ -205,8 +205,9 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
String note = dutyVoteDto.getNote();
|
|
|
|
String note = dutyVoteDto.getNote();
|
|
|
|
boolean spread = dutyVoteDto.getSpread();
|
|
|
|
boolean spread = dutyVoteDto.getSpread();
|
|
|
|
List<String> attachments = dutyVoteDto.getAttachments();
|
|
|
|
List<String> attachments = dutyVoteDto.getAttachments();
|
|
|
|
|
|
|
|
User user = SecurityUtil.getLoginUser();
|
|
|
|
|
|
|
|
String schoolId = user.getSchoolId();
|
|
|
|
|
|
|
|
|
|
|
|
String schoolId = SecurityUtil.getLoginUser().getSchoolId();
|
|
|
|
|
|
|
|
ClassInfo classInfo = classRepository.findClassByIdAndCode(classId, String.format(PK.CLASS, schoolId));
|
|
|
|
ClassInfo classInfo = classRepository.findClassByIdAndCode(classId, String.format(PK.CLASS, schoolId));
|
|
|
|
if (classInfo == null) {
|
|
|
|
if (classInfo == null) {
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "目标班级不存在");
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "目标班级不存在");
|
|
|
@ -227,6 +228,11 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
if (dutyNode.getPath() == null || dutyNode.getPath().length == 0) {
|
|
|
|
if (dutyNode.getPath() == null || dutyNode.getPath().length == 0) {
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "只能评价三级节点");
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "只能评价三级节点");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// dutynode 剪枝
|
|
|
|
|
|
|
|
dutyNode.setCreator(null);
|
|
|
|
|
|
|
|
dutyNode.setCreatorId(null);
|
|
|
|
|
|
|
|
dutyNode.setCreateTime(null);
|
|
|
|
|
|
|
|
|
|
|
|
WeekDuty.DutySpot spot = duty.getSpots().stream()
|
|
|
|
WeekDuty.DutySpot spot = duty.getSpots().stream()
|
|
|
|
.filter(x -> spotId.equals(x.getId()))
|
|
|
|
.filter(x -> spotId.equals(x.getId()))
|
|
|
|
.findFirst()
|
|
|
|
.findFirst()
|
|
|
@ -246,6 +252,8 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
newItem.setAttachments(attachments);
|
|
|
|
newItem.setAttachments(attachments);
|
|
|
|
newItem.setNote(note);
|
|
|
|
newItem.setNote(note);
|
|
|
|
newItem.setCreateTime(Instant.now().toEpochMilli());
|
|
|
|
newItem.setCreateTime(Instant.now().toEpochMilli());
|
|
|
|
|
|
|
|
newItem.setCreator(user.getName());
|
|
|
|
|
|
|
|
newItem.setCreatorId(user.getId());
|
|
|
|
// 不存在则创建
|
|
|
|
// 不存在则创建
|
|
|
|
if (weekDutyRecord == null) {
|
|
|
|
if (weekDutyRecord == null) {
|
|
|
|
List<WeekDutyRecord.WeekDutyItem> nodes = Collections.singletonList(newItem);
|
|
|
|
List<WeekDutyRecord.WeekDutyItem> nodes = Collections.singletonList(newItem);
|
|
|
@ -303,6 +311,37 @@ public class DutyServiceImpl implements DutyService {
|
|
|
|
return duty.getSpots();
|
|
|
|
return duty.getSpots();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<WeekDutyRecord.WeekDutyItem> findRecords(FindDutyRecordDto findDutyRecordDto) {
|
|
|
|
|
|
|
|
String classId = StringUtils.isEmpty(findDutyRecordDto.getClassId()) ? null : findDutyRecordDto.getClassId();
|
|
|
|
|
|
|
|
String academicYearId = findDutyRecordDto.getAcademicYearId();
|
|
|
|
|
|
|
|
Boolean positive = findDutyRecordDto.getPositive();
|
|
|
|
|
|
|
|
Long startTime = findDutyRecordDto.getStartTime();
|
|
|
|
|
|
|
|
Long endTime = findDutyRecordDto.getEndTime();
|
|
|
|
|
|
|
|
User user = SecurityUtil.getLoginUser();
|
|
|
|
|
|
|
|
String schoolId = user.getSchoolId();
|
|
|
|
|
|
|
|
String userId = user.getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (startTime == null || endTime == null) {
|
|
|
|
|
|
|
|
LocalDateTime mondayOfCurWeek = LocalDateTime.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
|
|
|
|
|
|
|
.withHour(0)
|
|
|
|
|
|
|
|
.withMinute(0)
|
|
|
|
|
|
|
|
.withSecond(0)
|
|
|
|
|
|
|
|
.withNano(0);
|
|
|
|
|
|
|
|
startTime = mondayOfCurWeek.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli();
|
|
|
|
|
|
|
|
endTime = Instant.now().toEpochMilli();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<WeekDutyRecord.WeekDutyItem> records = dutyRecordRepository.findRecordsByConditions(
|
|
|
|
|
|
|
|
String.format(PK.WEEK_DUTY_RECORD, schoolId),
|
|
|
|
|
|
|
|
academicYearId,
|
|
|
|
|
|
|
|
userId,
|
|
|
|
|
|
|
|
classId,
|
|
|
|
|
|
|
|
positive,
|
|
|
|
|
|
|
|
startTime,
|
|
|
|
|
|
|
|
endTime);
|
|
|
|
|
|
|
|
return records;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 刷新值周树和 spots 的 id
|
|
|
|
* 刷新值周树和 spots 的 id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|