|
@@ -1,11 +1,26 @@
|
|
|
package com.xjrsoft.module.schedule.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.xjrsoft.common.enums.CourseAdjustTypeEnum;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
+import com.xjrsoft.module.courseTable.entity.CourseTable;
|
|
|
+import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
|
+import com.xjrsoft.module.schedule.dto.WfCourseAdjustDto;
|
|
|
+import com.xjrsoft.module.schedule.entity.CourseTableBak;
|
|
|
import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
|
|
|
import com.xjrsoft.module.schedule.mapper.WfCourseAdjustMapper;
|
|
|
+import com.xjrsoft.module.schedule.service.ICourseTableBakService;
|
|
|
import com.xjrsoft.module.schedule.service.IWfCourseAdjustService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* @Author dzx
|
|
@@ -15,4 +30,55 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class WfCourseAdjustServiceImpl extends MPJBaseServiceImpl<WfCourseAdjustMapper, WfCourseAdjust> implements IWfCourseAdjustService {
|
|
|
+
|
|
|
+ private final ICourseTableBakService courseTableBakService;
|
|
|
+ private final ICourseTableService courseTableService;
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean cancel(WfCourseAdjustDto dto) {
|
|
|
+ WfCourseAdjust courseAdjust = this.getById(dto.getId());
|
|
|
+
|
|
|
+
|
|
|
+ List<CourseTableBak> bakList = courseTableBakService.list(
|
|
|
+ new QueryWrapper<CourseTableBak>().lambda()
|
|
|
+ .eq(CourseTableBak::getWfCourseAdjustId, dto.getId())
|
|
|
+ );
|
|
|
+ Map<Long, CourseTableBak> bakMap = new HashMap<>();
|
|
|
+ for (CourseTableBak courseTableBak : bakList) {
|
|
|
+ bakMap.put(courseTableBak.getId(), courseTableBak);
|
|
|
+ }
|
|
|
+ List<Long> courseIds = bakList.stream().map(CourseTableBak::getId).collect(Collectors.toList());
|
|
|
+ List<CourseTable> list = courseTableService.listByIds(courseIds);
|
|
|
+ if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseAdjust.getAdjustType())){
|
|
|
+ for (CourseTable courseTable : list) {
|
|
|
+ CourseTableBak tableBak = bakMap.get(courseTable.getId());
|
|
|
+ if(tableBak == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ courseTable.setTeacherId(tableBak.getTeacherId());
|
|
|
+ courseTable.setTeacherName(tableBak.getTeacherName());
|
|
|
+ courseTableService.updateById(courseTable);
|
|
|
+ }
|
|
|
+ }else if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseAdjust.getAdjustType())){
|
|
|
+ for (CourseTable courseTable : list) {
|
|
|
+ CourseTableBak tableBak = bakMap.get(courseTable.getId());
|
|
|
+ if(tableBak == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ courseTable.setTeacherId(tableBak.getTeacherId());
|
|
|
+ courseTable.setTeacherName(tableBak.getTeacherName());
|
|
|
+ courseTable.setScheduleDate(tableBak.getScheduleDate());
|
|
|
+ courseTable.setTimePeriod(tableBak.getTimePeriod());
|
|
|
+ courseTable.setTimeNumber(tableBak.getTimeNumber());
|
|
|
+ courseTable.setWeek(tableBak.getWeek());
|
|
|
+ courseTable.setWeeks(tableBak.getWeeks());
|
|
|
+ courseTable.setWeeksCn(tableBak.getWeeksCn());
|
|
|
+ courseTableService.updateById(courseTable);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ courseAdjust.setEnabledMark(EnabledMark.DISABLED.getCode());
|
|
|
+ courseAdjust.setModifyDate(new Date());
|
|
|
+ this.updateById(courseAdjust);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|