Commit 60e8951b authored by wujipeng's avatar wujipeng
Browse files

优化项

parent c185bde7
...@@ -9,9 +9,9 @@ public class CourseAdminScheduleSwapDTO { ...@@ -9,9 +9,9 @@ public class CourseAdminScheduleSwapDTO {
/** 目标排课组;必须与路径中的源排课组属于同一班级且不能相同。 */ /** 目标排课组;必须与路径中的源排课组属于同一班级且不能相同。 */
private String targetScheduleGroupId; private String targetScheduleGroupId;
/** 产品规定的必填调课原因。 */ /** 源排课组中要对调的半天:AM(上午)或PM(下午)。 */
private String reason; private String sourcePeriod;
/** 可选调课说明,不限制业务字符数。 */ /** 目标排课组中要对调的半天:AM(上午)或PM(下午)。 */
private String note; private String targetPeriod;
} }
...@@ -37,7 +37,7 @@ public interface CourseAdminService { ...@@ -37,7 +37,7 @@ public interface CourseAdminService {
CourseAdminScheduleGroupVO updateSchedule(String scheduleGroupId, CourseAdminScheduleGroupVO updateSchedule(String scheduleGroupId,
CourseAdminScheduleGroupSaveDTO request); CourseAdminScheduleGroupSaveDTO request);
/** 与同班另一课次交换日期、时段、课次和课时,课程内容及教师保持不变。 */ /** 与同班另一课次按上午或下午交换;全天记录无业务引用时由服务层安全拆分。 */
List<CourseAdminScheduleGroupVO> swapSchedule(String scheduleGroupId, List<CourseAdminScheduleGroupVO> swapSchedule(String scheduleGroupId,
CourseAdminScheduleSwapDTO request); CourseAdminScheduleSwapDTO request);
......
...@@ -62,6 +62,7 @@ import java.util.HashMap; ...@@ -62,6 +62,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -736,9 +737,8 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -736,9 +737,8 @@ public class CourseAdminServiceImpl implements CourseAdminService {
if (request == null) throw new BusinessException("调课信息不能为空"); if (request == null) throw new BusinessException("调课信息不能为空");
String targetGroupId = requireScheduleGroupId(request.getTargetScheduleGroupId()); String targetGroupId = requireScheduleGroupId(request.getTargetScheduleGroupId());
if (sourceGroupId.equals(targetGroupId)) throw new BusinessException("不能与当前课次对调"); if (sourceGroupId.equals(targetGroupId)) throw new BusinessException("不能与当前课次对调");
String reason = requireText(request.getReason(), "调课原因", 32); String sourcePeriod = requireSwapPeriod(request.getSourcePeriod(), "本节次时段");
// 调课说明按产品要求不限制业务字符数,仅清理首尾空白和纯空白输入。 String targetPeriod = requireSwapPeriod(request.getTargetPeriod(), "对调课次时段");
String note = trimToNull(request.getNote());
List<ClassSubjectEntity> sourceSnapshot = classSubjectMapper List<ClassSubjectEntity> sourceSnapshot = classSubjectMapper
.selectAdminCourseGroupEntities(sourceGroupId); .selectAdminCourseGroupEntities(sourceGroupId);
...@@ -768,24 +768,50 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -768,24 +768,50 @@ public class CourseAdminServiceImpl implements CourseAdminService {
lockTeachers(java.util.stream.Stream.concat(source.stream(), target.stream()) lockTeachers(java.util.stream.Stream.concat(source.stream(), target.stream())
.map(ClassSubjectEntity::getTeacherId).filter(Objects::nonNull) .map(ClassSubjectEntity::getTeacherId).filter(Objects::nonNull)
.distinct().sorted().collect(Collectors.toList())); .distinct().sorted().collect(Collectors.toList()));
TemporalPayload sourceTime = captureTemporalPayload(source);
TemporalPayload targetTime = captureTemporalPayload(target); /*
applyTemporalPayload(source, targetTime); * 调课以半天为最小单位。若历史课程把上午、下午保存在同一条记录中,先在事务内
applyTemporalPayload(target, sourceTime); * 拆出未参与对调的另一半;已有签到等下游数据时禁止拆分,避免改变历史业务引用。
*/
PeriodSwapSelection sourceSelection = selectSwapPeriod(
source, sourcePeriod, "本节次");
PeriodSwapSelection targetSelection = selectSwapPeriod(
target, targetPeriod, "对调课次");
Date now = new Date();
ClassSubjectEntity sourceRemainder = createPeriodRemainder(sourceSelection, now);
ClassSubjectEntity targetRemainder = createPeriodRemainder(targetSelection, now);
TemporalPayload sourceTime = sourceSelection.selectedPayload;
TemporalPayload targetTime = targetSelection.selectedPayload;
applyTemporalPart(sourceSelection.course, targetTime.date, targetTime.frames,
targetTime.subjectTimes, targetTime.hours);
sourceSelection.course.setScheduleGroupId(targetGroupId);
applyTemporalPart(targetSelection.course, sourceTime.date, sourceTime.frames,
sourceTime.subjectTimes, sourceTime.hours);
targetSelection.course.setScheduleGroupId(sourceGroupId);
List<Integer> excludedIds = java.util.stream.Stream.concat(source.stream(), target.stream()) List<Integer> excludedIds = java.util.stream.Stream.concat(source.stream(), target.stream())
.map(ClassSubjectEntity::getId).collect(Collectors.toList()); .map(ClassSubjectEntity::getId).collect(Collectors.toList());
Date now = new Date(); List<ClassSubjectEntity> changedCourses = java.util.stream.Stream
for (ClassSubjectEntity course : source) { .concat(source.stream(), target.stream()).collect(Collectors.toList());
markAdjustment(course, targetGroupId, reason, note, now); if (sourceRemainder != null) changedCourses.add(sourceRemainder);
if (targetRemainder != null) changedCourses.add(targetRemainder);
// 组级列表只有一个“已调课”标识,因此同组未参与交换的另一半也同步标记。
for (ClassSubjectEntity course : changedCourses) {
String counterpartGroupId = sourceGroupId.equals(course.getScheduleGroupId())
? targetGroupId : sourceGroupId;
markAdjustment(course, counterpartGroupId, now);
ensureNoConflict(course, normalizeStoredFrames(course.getTimeFrame()), excludedIds); ensureNoConflict(course, normalizeStoredFrames(course.getTimeFrame()), excludedIds);
} }
for (ClassSubjectEntity course : target) { for (ClassSubjectEntity course : changedCourses) {
markAdjustment(course, sourceGroupId, reason, note, now); if (course.getId() == null) {
ensureNoConflict(course, normalizeStoredFrames(course.getTimeFrame()), excludedIds); course.setCreateTime(now);
} if (classSubjectMapper.insert(course) != 1) {
for (ClassSubjectEntity course : java.util.stream.Stream.concat(source.stream(), target.stream()) throw new BusinessException("课次信息已发生变化,请刷新后重试");
.collect(Collectors.toList())) { }
continue;
}
if (classSubjectMapper.updateAdminCourse(course) != 1) { if (classSubjectMapper.updateAdminCourse(course) != 1) {
throw new BusinessException("课次信息已发生变化,请刷新后重试"); throw new BusinessException("课次信息已发生变化,请刷新后重试");
} }
...@@ -1255,6 +1281,15 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -1255,6 +1281,15 @@ public class CourseAdminServiceImpl implements CourseAdminService {
return normalized; return normalized;
} }
/** 调课仅接受明确的上午或下午,拒绝前端传入未定义的期间值。 */
private String requireSwapPeriod(String value, String fieldName) {
String period = requireText(value, fieldName, 2).toUpperCase(Locale.ROOT);
if (!PERIOD_AM.equals(period) && !PERIOD_PM.equals(period)) {
throw new BusinessException(fieldName + "只支持上午或下午");
}
return period;
}
private String resolveStoredGroupId(ClassSubjectEntity existing) { private String resolveStoredGroupId(ClassSubjectEntity existing) {
String groupId = trimToNull(existing.getScheduleGroupId()); String groupId = trimToNull(existing.getScheduleGroupId());
return groupId == null ? "legacy-" + existing.getId() : groupId; return groupId == null ? "legacy-" + existing.getId() : groupId;
...@@ -1268,53 +1303,107 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -1268,53 +1303,107 @@ public class CourseAdminServiceImpl implements CourseAdminService {
target.setAdjustmentNote(source.getAdjustmentNote()); target.setAdjustmentNote(source.getAdjustmentNote());
} }
/** 把一个排课组压缩为可交换的时间载荷,课程内容和教师不进入载荷。 */
private TemporalPayload captureTemporalPayload(List<ClassSubjectEntity> courses) {
List<String> frames = courses.stream()
.flatMap(course -> splitStoredFrames(course.getTimeFrame()).stream())
.distinct()
.sorted(Comparator.comparing(frame -> parseTimeRange(frame).start))
.collect(Collectors.toList());
if (frames.isEmpty()) throw new BusinessException("课次缺少有效时段,无法调课");
int subjectTimes = courses.stream().mapToInt(ClassSubjectEntity::getSubjectTimes).sum();
BigDecimal hours = courses.stream().map(ClassSubjectEntity::getSubjectHour)
.filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
return new TemporalPayload(courses.get(0).getDate(), frames, subjectTimes, hours);
}
/** /**
* 将来源课次的时间载荷应用到目标课程内容上。 * 从排课组中定位指定半天的唯一课程,并准备全天课程拆分后的两份时间载荷。
* * 当前编辑弹窗约束每个半天至多一条课程;遇到历史重复数据时拒绝猜测交换对象。
* <p>一条课程时直接接收整天时段;上午/下午两条课程时按中午分割,并按时段数
* 分摊课次和课时,确保组级总数与来源课次完全一致。</p>
*/ */
private void applyTemporalPayload(List<ClassSubjectEntity> destination, private PeriodSwapSelection selectSwapPeriod(
TemporalPayload payload) { List<ClassSubjectEntity> courses, String requestedPeriod, String label) {
if (destination.size() > 2) { List<PeriodSwapSelection> matches = new ArrayList<>();
throw new BusinessException("当前课次包含两条以上独立课程,暂不支持与其对调"); for (ClassSubjectEntity course : courses) {
} List<TimeRange> ranges = normalizeStoredFrames(course.getTimeFrame());
if (destination.size() == 1) { String storedPeriod = resolvePeriod(ranges);
applyTemporalPart(destination.get(0), payload.date, payload.frames, if (requestedPeriod.equals(storedPeriod)) {
payload.subjectTimes, payload.hours); matches.add(new PeriodSwapSelection(course,
return; temporalPayload(course, ranges), null));
continue;
}
if (!PERIOD_ALL_DAY.equals(storedPeriod)) continue;
List<TimeRange> morning = new ArrayList<>();
List<TimeRange> afternoon = new ArrayList<>();
for (TimeRange range : ranges) {
if (!range.end.isAfter(NOON)) {
morning.add(range);
} else if (!range.start.isBefore(NOON)) {
afternoon.add(range);
} else {
throw new BusinessException(label + "包含跨越中午的时段,无法按上午、下午调课");
}
}
if (morning.isEmpty() || afternoon.isEmpty()) {
throw new BusinessException(label + "缺少完整的上午或下午时段");
}
if (hasCourseDependencies(course.getId())) {
throw new BusinessException(label
+ "已产生签到、请假或评价数据,不能拆分上午、下午调课");
}
TemporalPayload morningPayload = proportionalPayload(course, morning, ranges.size());
TemporalPayload afternoonPayload = new TemporalPayload(
course.getDate(), toFrameTexts(afternoon),
course.getSubjectTimes() - morningPayload.subjectTimes,
course.getSubjectHour().subtract(morningPayload.hours));
matches.add(PERIOD_AM.equals(requestedPeriod)
? new PeriodSwapSelection(course, morningPayload, afternoonPayload)
: new PeriodSwapSelection(course, afternoonPayload, morningPayload));
} }
List<String> morning = payload.frames.stream() if (matches.isEmpty()) {
.filter(frame -> parseTimeRange(frame).start.isBefore(NOON)) throw new BusinessException(label + "没有可调换的"
.collect(Collectors.toList()); + (PERIOD_AM.equals(requestedPeriod) ? "上午" : "下午") + "课程");
List<String> afternoon = payload.frames.stream()
.filter(frame -> !parseTimeRange(frame).start.isBefore(NOON))
.collect(Collectors.toList());
if (morning.isEmpty() || afternoon.isEmpty()) {
throw new BusinessException("源课次没有完整的上午、下午时段,无法与双课程课次对调");
} }
int totalFrames = payload.frames.size(); if (matches.size() > 1) {
int morningTimes = payload.subjectTimes * morning.size() / totalFrames; throw new BusinessException(label + "同一时段包含多条课程,暂不支持直接对调");
int afternoonTimes = payload.subjectTimes - morningTimes; }
BigDecimal morningHours = payload.hours.multiply(BigDecimal.valueOf(morning.size())) return matches.get(0);
.divide(BigDecimal.valueOf(totalFrames), 1, java.math.RoundingMode.HALF_UP); }
BigDecimal afternoonHours = payload.hours.subtract(morningHours);
applyTemporalPart(destination.get(0), payload.date, morning, morningTimes, morningHours); /** 按时段数量同比例拆分课次和课时,与排课编辑的汇总口径保持一致。 */
applyTemporalPart(destination.get(1), payload.date, afternoon, afternoonTimes, afternoonHours); private TemporalPayload proportionalPayload(
ClassSubjectEntity course, List<TimeRange> selected, int totalFrameCount) {
int selectedTimes = course.getSubjectTimes() * selected.size() / totalFrameCount;
BigDecimal selectedHours = course.getSubjectHour()
.multiply(BigDecimal.valueOf(selected.size()))
.divide(BigDecimal.valueOf(totalFrameCount), 1, java.math.RoundingMode.HALF_UP);
return new TemporalPayload(course.getDate(), toFrameTexts(selected),
selectedTimes, selectedHours);
}
private TemporalPayload temporalPayload(
ClassSubjectEntity course, List<TimeRange> ranges) {
return new TemporalPayload(course.getDate(), toFrameTexts(ranges),
course.getSubjectTimes(), course.getSubjectHour());
}
private List<String> toFrameTexts(List<TimeRange> ranges) {
return ranges.stream().map(TimeRange::asText).collect(Collectors.toList());
}
/**
* 全天课程参与半天调课时,为未参与的一半创建同内容记录。
* 主键不复制,保证MyBatis执行新增;业务内容及原组标识完整保留。
*/
private ClassSubjectEntity createPeriodRemainder(
PeriodSwapSelection selection, Date now) {
if (selection.remainderPayload == null) return null;
ClassSubjectEntity source = selection.course;
ClassSubjectEntity remainder = new ClassSubjectEntity();
remainder.setClassId(source.getClassId());
remainder.setScheduleGroupId(source.getScheduleGroupId());
remainder.setDate(selection.remainderPayload.date);
remainder.setWeek(chineseWeekday(selection.remainderPayload.date));
remainder.setSubjectTimes(selection.remainderPayload.subjectTimes);
remainder.setTimeFrame(String.join(",", selection.remainderPayload.frames));
remainder.setSubjectHour(selection.remainderPayload.hours);
remainder.setSubjectName(source.getSubjectName());
remainder.setTeacherId(source.getTeacherId());
remainder.setRemark(source.getRemark());
remainder.setLocation(source.getLocation());
remainder.setType(source.getType());
copyAdjustmentMetadata(source, remainder);
remainder.setCreateTime(now);
remainder.setUpdateTime(now);
return remainder;
} }
private void applyTemporalPart(ClassSubjectEntity course, Date date, List<String> frames, private void applyTemporalPart(ClassSubjectEntity course, Date date, List<String> frames,
...@@ -1330,13 +1419,13 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -1330,13 +1419,13 @@ public class CourseAdminServiceImpl implements CourseAdminService {
return normalizeTimeFrames(splitStoredFrames(stored)); return normalizeTimeFrames(splitStoredFrames(stored));
} }
/** 两组均写入同一原因和说明,只把对方组ID分别保存。 */ /** 标记半天对调关系;新交互不再采集调课原因和说明。 */
private void markAdjustment(ClassSubjectEntity course, String counterpartGroupId, private void markAdjustment(ClassSubjectEntity course, String counterpartGroupId,
String reason, String note, Date now) { Date now) {
course.setAdjusted(Boolean.TRUE); course.setAdjusted(Boolean.TRUE);
course.setAdjustmentCounterpartGroupId(counterpartGroupId); course.setAdjustmentCounterpartGroupId(counterpartGroupId);
course.setAdjustmentReason(reason); course.setAdjustmentReason(null);
course.setAdjustmentNote(note); course.setAdjustmentNote(null);
course.setUpdateTime(now); course.setUpdateTime(now);
} }
...@@ -1566,6 +1655,22 @@ public class CourseAdminServiceImpl implements CourseAdminService { ...@@ -1566,6 +1655,22 @@ public class CourseAdminServiceImpl implements CourseAdminService {
} }
} }
/** 指定半天的课程实体、参与交换的时间载荷及全天拆分后需要保留的另一半。 */
private static final class PeriodSwapSelection {
private final ClassSubjectEntity course;
private final TemporalPayload selectedPayload;
private final TemporalPayload remainderPayload;
private PeriodSwapSelection(
ClassSubjectEntity course,
TemporalPayload selectedPayload,
TemporalPayload remainderPayload) {
this.course = course;
this.selectedPayload = selectedPayload;
this.remainderPayload = remainderPayload;
}
}
/** 单个半开时间区间[start, end),相邻课程因此不会被误判为冲突。 */ /** 单个半开时间区间[start, end),相邻课程因此不会被误判为冲突。 */
private static final class TimeRange { private static final class TimeRange {
private final LocalTime start; private final LocalTime start;
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
百分比字段以 `0~100` 的数值返回并最多保留两位小数,空值由页面展示为“—”。 百分比字段以 `0~100` 的数值返回并最多保留两位小数,空值由页面展示为“—”。
班级详情页的课程维护直接复用课程管理接口:查询、新增、Word导入、导出、整行调课和单节编辑 班级详情页的课程维护直接复用课程管理接口:查询、新增、Word导入、导出、按上午/下午调课和单节编辑
分别见`course-management-api.md`,提交的`classId`均取当前详情班级。 分别见`course-management-api.md`,提交的`classId`均取当前详情班级。
### 学员字段示例 ### 学员字段示例
......
...@@ -179,9 +179,11 @@ JWT解析当前用户并校验管理员角色,不接受客户端提交管理 ...@@ -179,9 +179,11 @@ JWT解析当前用户并校验管理员角色,不接受客户端提交管理
`POST /class/subject/admin/schedules/{scheduleGroupId}/swap` `POST /class/subject/admin/schedules/{scheduleGroupId}/swap`
请求提交 `targetScheduleGroupId`、必填 `reason` 和最多60字的可选 `note`。源、目标排课组必须属于 请求提交 `targetScheduleGroupId`、`sourcePeriod` 和 `targetPeriod`;两个期间只支持 `AM`(上午)或
同一班级。服务端只交换日期、星期、时段、课次和课时,课程名称、授课教师、地点、类型和备注 `PM`(下午)。源、目标排课组必须属于同一班级。服务端只对调选中的半天,课程名称、授课教师、
保持在原课程上;两组均记录“已调课”、对方组ID、原因和说明。成功后返回交换后的两个排课组。 地点、类型和备注随该半天课程移动;两组均记录“已调课”和对方组ID,不再采集原因与说明。
历史全天课程会在事务内拆为上午、下午两条后再对调;若该课程已有签到、请假或评价数据,服务端
拒绝拆分并返回明确提示,避免破坏既有业务引用。成功后返回交换后的两个排课组。
## 7. 兼容的单课程编辑与删除 ## 7. 兼容的单课程编辑与删除
......
...@@ -40,6 +40,7 @@ import java.util.Collections; ...@@ -40,6 +40,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
...@@ -421,22 +422,70 @@ class CourseAdminServiceImplTest { ...@@ -421,22 +422,70 @@ class CourseAdminServiceImplTest {
CourseAdminScheduleSwapDTO request = new CourseAdminScheduleSwapDTO(); CourseAdminScheduleSwapDTO request = new CourseAdminScheduleSwapDTO();
request.setTargetScheduleGroupId("group-2"); request.setTargetScheduleGroupId("group-2");
request.setReason("教师冲突"); request.setSourcePeriod("AM");
request.setNote("双方已确认"); request.setTargetPeriod("PM");
List<CourseAdminScheduleGroupVO> result = service.swapSchedule("group-1", request); List<CourseAdminScheduleGroupVO> result = service.swapSchedule("group-1", request);
assertEquals(2, result.size()); assertEquals(2, result.size());
assertEquals("目标课程", target.getSubjectName()); assertEquals("目标课程", target.getSubjectName());
assertEquals("09:00-10:20", target.getTimeFrame()); assertEquals("09:00-10:20", target.getTimeFrame());
assertEquals("group-1", target.getScheduleGroupId());
assertEquals("源课程", source.getSubjectName()); assertEquals("源课程", source.getSubjectName());
assertEquals("13:00-16:00", source.getTimeFrame()); assertEquals("13:00-16:00", source.getTimeFrame());
assertEquals("group-2", source.getScheduleGroupId());
assertTrue(Boolean.TRUE.equals(source.getAdjusted())); assertTrue(Boolean.TRUE.equals(source.getAdjusted()));
assertEquals("group-2", source.getAdjustmentCounterpartGroupId()); assertEquals("group-1", source.getAdjustmentCounterpartGroupId());
assertEquals("教师冲突", target.getAdjustmentReason()); assertEquals("group-2", target.getAdjustmentCounterpartGroupId());
assertNull(target.getAdjustmentReason());
verify(classSubjectMapper, org.mockito.Mockito.times(2)) verify(classSubjectMapper, org.mockito.Mockito.times(2))
.updateAdminCourse(any(ClassSubjectEntity.class)); .updateAdminCourse(any(ClassSubjectEntity.class));
} }
@Test
void swapScheduleShouldSplitAllDayCoursesAndExchangeOnlySelectedPeriod() {
ClassSubjectEntity source = existingCourse(11, "group-1",
"09:00-10:20,10:40-12:00,13:00-14:20,14:40-16:00");
source.setSubjectTimes(4);
source.setSubjectHour(new BigDecimal("4.0"));
source.setSubjectName("源课程");
ClassSubjectEntity target = existingCourse(22, "group-2",
"09:00-10:20,10:40-12:00,13:00-14:20,14:40-16:00");
target.setDate(Date.valueOf(testCourseDate().toLocalDate().plusDays(2)));
target.setWeek("周四");
target.setSubjectTimes(4);
target.setSubjectHour(new BigDecimal("4.0"));
target.setSubjectName("目标课程");
when(classSubjectMapper.selectAdminCourseGroupEntities("group-1"))
.thenReturn(Collections.singletonList(source));
when(classSubjectMapper.selectAdminCourseGroupEntities("group-2"))
.thenReturn(Collections.singletonList(target));
mockWritableClass();
when(classSubjectMapper.selectAdminConflictCandidates(any(), eq(1), any(), anyList()))
.thenReturn(Collections.emptyList());
when(classSubjectMapper.updateAdminCourse(any(ClassSubjectEntity.class))).thenReturn(1);
when(classSubjectMapper.insert(any(ClassSubjectEntity.class))).thenReturn(1);
mockEmptyDetail();
CourseAdminScheduleSwapDTO request = new CourseAdminScheduleSwapDTO();
request.setTargetScheduleGroupId("group-2");
request.setSourcePeriod("AM");
request.setTargetPeriod("AM");
service.swapSchedule("group-1", request);
assertEquals("group-2", source.getScheduleGroupId());
assertEquals("09:00-10:20,10:40-12:00", source.getTimeFrame());
assertEquals(new BigDecimal("2.0"), source.getSubjectHour());
assertEquals("group-1", target.getScheduleGroupId());
ArgumentCaptor<ClassSubjectEntity> inserted =
ArgumentCaptor.forClass(ClassSubjectEntity.class);
verify(classSubjectMapper, org.mockito.Mockito.times(2)).insert(inserted.capture());
assertTrue(inserted.getAllValues().stream().allMatch(course ->
"13:00-14:20,14:40-16:00".equals(course.getTimeFrame())));
assertTrue(inserted.getAllValues().stream().allMatch(course ->
course.getId() == null && new BigDecimal("2.0").equals(course.getSubjectHour())));
}
@Test @Test
void parseImportShouldSkipUnitTrainingAndSelectTargetClassShift() throws Exception { void parseImportShouldSkipUnitTrainingAndSelectTargetClassShift() throws Exception {
when(classSubjectMapper.selectAdminCourseTeacherOptions()).thenReturn(Arrays.asList( when(classSubjectMapper.selectAdminCourseTeacherOptions()).thenReturn(Arrays.asList(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment