feat: 新增被评价学生总数与补充评价对象的班级名

11111
winter 1 year ago
parent 79db32c215
commit 7918786641

@ -66,6 +66,7 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
int totalCount = 0;
int criticalCount = 0;
Set<String> creatorIdSet = new HashSet<>();
Set<String> studentSet = new HashSet<>();
User loginUser = SecurityUtil.getLoginUser();
String schoolId = loginUser.getSchoolId();
@ -103,6 +104,10 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
}
// 处理已评价老师总数
creatorIdSet.add(item.getCreatorId());
// 处理被评价的学生数
if ("student".equals(item.getTargetType())) {
studentSet.add(item.getTargetId());
}
}
if (slice.hasNext()) {
@ -116,6 +121,7 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
indexData.setCriticalCount(criticalCount);
indexData.setPraiseCount(totalCount - criticalCount);
indexData.setTeacherCount(creatorIdSet.size());
indexData.setStudentCount(studentSet.size());
return indexData;
}

@ -60,7 +60,7 @@ public interface AppraiseRecordRepository extends CosmosRepository<AppraiseRecor
int countRecords(Boolean praise, String academicYearId, String code);
@Query("select n.createTime, n.appraiseNode.isPraise, n.creatorId from Student as c join n in c.nodes where c.code = @code and c.academicYearId = @academicYearId")
@Query("select c.targetId, c.targetType, n.createTime, n.appraiseNode.isPraise, n.creatorId from Student as c join n in c.nodes where c.code = @code and c.academicYearId = @academicYearId")
Slice<RecordVo> findAllByAcademicYearId(String code, String academicYearId, Pageable pageable);
/**

@ -14,7 +14,7 @@ import java.util.List;
*/
@Repository
public interface ClassRepository extends CosmosRepository<ClassInfo, String> {
ClassInfo findClassByIdAndCode(String targetId, String format);
ClassInfo findClassByIdAndCode(String targetId, String code);
@Query("select c.id, c.name from School as c where c.code = @code and c.id in (@ids)")
List<ClassInfo> findAllByCodeAndIdIn(String code, Collection<String> ids);

@ -27,6 +27,7 @@ public class AppraiseRecord extends BaseItem {
* id
*/
private String classId;
private String className;
/**
* ( id: -semesterId -> 2023-{semesterId})
*/

@ -14,5 +14,6 @@ public class IndexData {
private Integer praiseCount;
private Integer criticalCount;
private Integer teacherCount;
private Integer studentCount;
private Map<Long, Integer> countByWeek;
}

@ -241,6 +241,7 @@ public class EvaluationServiceImpl implements EvaluationService {
User loginUser = SecurityUtil.getLoginUser();
String schoolId = loginUser.getSchoolId();
String classId;
String className;
String periodId;
String name;
String avatar = null;
@ -255,6 +256,10 @@ public class EvaluationServiceImpl implements EvaluationService {
name = student.getName();
avatar = student.getPicture();
gender = student.getGender();
// 获取班级信息
ClassInfo classInfo = classRepository.findClassByIdAndCode(classId, String.format(PK.CLASS, schoolId));
className = classInfo.getName();
} else if (targetType.equals(TARGET_CLASS)){
ClassInfo classInfo = classRepository.findClassByIdAndCode(targetId, String.format(PK.CLASS, schoolId));
if (classInfo == null) {
@ -263,6 +268,7 @@ public class EvaluationServiceImpl implements EvaluationService {
classId = targetId;
periodId = classInfo.getPeriodId();
name = classInfo.getName();
className = classInfo.getName();
} else {
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不受支持的评价对象");
}
@ -309,6 +315,7 @@ public class EvaluationServiceImpl implements EvaluationService {
record.setTargetId(targetId);
record.setTargetType(targetType);
record.setClassId(classId);
record.setClassName(className);
record.setName(name);
record.setAvatar(avatar);
record.setGender(gender);
@ -319,7 +326,6 @@ public class EvaluationServiceImpl implements EvaluationService {
record.setCode(String.format(PK.PK_APPRAISE_RECORD, schoolId));
appraiseRecordRepository.save(record);
} else {
CosmosPatchOperations operations = CosmosPatchOperations.create();
operations.add("/nodes/0", item);
// 表扬

@ -6,11 +6,9 @@ import cn.teammodel.model.entity.school.School;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@ -105,7 +103,12 @@ public class SchoolDateUtil {
if (timeStamp == null) {
return ChronoUnit.WEEKS.between(startDateTime, endDateTime) + 1;
} else {
LocalDateTime curDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStamp), ZoneOffset.UTC);
LocalDateTime curDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStamp), ZoneOffset.of("+08:00"));
startDateTime = startDateTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0);
// 如果传参没在学期范围内, 返回 -1
if (curDateTime.isBefore(startDateTime) || curDateTime.isAfter(endDateTime)) {
return -1;

@ -157,9 +157,19 @@ public class TestWithoutSpring {
@Test
public void testWeek() {
LocalDateTime start = LocalDateTime.ofInstant(Instant.ofEpochSecond(1690819200L), ZoneOffset.UTC);
LocalDateTime end = LocalDateTime.ofInstant(Instant.ofEpochSecond(1708099200L), ZoneOffset.UTC);
long l = SchoolDateUtil.calculateWeekNum(start, end, null);
LocalDateTime start = LocalDateTime.ofInstant(Instant.ofEpochMilli(1690819200000L), ZoneOffset.of("+08:00"));
LocalDateTime end = LocalDateTime.ofInstant(Instant.ofEpochMilli(1708099200000L),ZoneOffset.of("+08:00"));
long l = SchoolDateUtil.calculateWeekNum(start, end, 1702025230000L);
System.out.println(l);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime time = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
// .withHour(0)
// .withMinute(0)
// .withSecond(0)
// .withNano(0);
//
// LocalDateTime time1 = LocalDateTime.of(2023, 12, 18, 0, 0);
// System.out.println(ChronoUnit.WEEKS.between(time, time1) + 1);
}
}

Loading…
Cancel
Save