|
|
@@ -4,21 +4,37 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
+import com.xjrsoft.common.enums.CourseTimeTypeEnum;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.module.classtime.dto.AddClassTimeStatisticsDto;
|
|
|
+import com.xjrsoft.module.classtime.entity.ClassTimeDelete;
|
|
|
import com.xjrsoft.module.classtime.entity.ClassTimeStatistics;
|
|
|
import com.xjrsoft.module.classtime.entity.ClassTimeStatisticsRecord;
|
|
|
import com.xjrsoft.module.classtime.entity.ClassTimeStatisticsSet;
|
|
|
import com.xjrsoft.module.classtime.mapper.ClassTimeStatisticsMapper;
|
|
|
import com.xjrsoft.module.classtime.mapper.ClassTimeStatisticsRecordMapper;
|
|
|
+import com.xjrsoft.module.classtime.service.IClassTimeDeleteService;
|
|
|
import com.xjrsoft.module.classtime.service.IClassTimeStatisticsService;
|
|
|
import com.xjrsoft.module.classtime.service.IClassTimeStatisticsSetService;
|
|
|
+import com.xjrsoft.module.classtime.vo.CourseListVo;
|
|
|
+import com.xjrsoft.module.classtime.vo.TeacherListVo;
|
|
|
+import com.xjrsoft.module.oa.entity.WfTeacherCourseTime;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 课时统计
|
|
|
@@ -34,6 +50,9 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
private final ClassTimeStatisticsRecordMapper recordMapper;
|
|
|
|
|
|
private final IClassTimeStatisticsSetService statisticsSetService;
|
|
|
+
|
|
|
+ private final IClassTimeDeleteService deleteService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean add(ClassTimeStatistics classTimeStatistics) {
|
|
|
@@ -94,10 +113,98 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 1、通过xjr_user和base_teacher查询所有教师,查询聘用类型为:正式聘用和外聘的
|
|
|
+ * 2、根据统计的开始日期和结束日期查询课时补充(wf_teacher_course_time)中的教研会、督导听课、临近三年退休政策、出题、阅卷、周末培优
|
|
|
+ * 3、根绝统计的开始日期和结束日期查询课程表(course_table)中的所有课程数据
|
|
|
+ *
|
|
|
+ * @param statistics
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean refreshRecord(ClassTimeStatistics statistics) {
|
|
|
+ // 1、查询教师
|
|
|
+ List<TeacherListVo> teacherList = this.baseMapper.getTeacherList();
|
|
|
+ // 2、查询补课课时
|
|
|
+ List<WfTeacherCourseTime> courseTimeList = this.baseMapper.getWfTeacherCourseTimeList();
|
|
|
+ //按照课时补充类型分类统计
|
|
|
+ Map<String, List<WfTeacherCourseTime>> courseTimeMap = courseTimeList.stream().collect(Collectors.groupingBy(WfTeacherCourseTime::getCourseTimeType));
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+
|
|
|
+ //费用设置jsonArray
|
|
|
+ JsonArray costSetArray = parser.parse(statistics.getCostSetJson()).getAsJsonArray();
|
|
|
+ //权重设置jsonArray
|
|
|
+ JsonArray weightSetArray = parser.parse(statistics.getWeightSetJson()).getAsJsonArray();
|
|
|
+
|
|
|
+ //查询课程数据
|
|
|
+ List<CourseListVo> allCourseList = this.baseMapper.getCourseList(statistics);
|
|
|
+
|
|
|
+ //查询删除课时的数据,将每个班删除的具体日期统计出来
|
|
|
+ List<ClassTimeDelete> deleteList = deleteService.list(
|
|
|
+ new QueryWrapper<ClassTimeDelete>().lambda()
|
|
|
+ .ne(ClassTimeDelete::getEnabledMark, EnabledMark.DISABLED)
|
|
|
+ );
|
|
|
+ Map<Long, List<ClassTimeDelete>> deleteDataMap = deleteList.stream().collect(Collectors.groupingBy(ClassTimeDelete::getClassId));
|
|
|
+ Map<Long, Set<LocalDate>> deleteMap = new HashMap<>();//将每个班级计算出来所有被删除的日期存入map
|
|
|
+ for (Long classId : deleteDataMap.keySet()) {
|
|
|
+ List<LocalDate> dateList = new ArrayList<>();
|
|
|
+ for (ClassTimeDelete classTimeDelete : deleteDataMap.get(classId)) {
|
|
|
+ LocalDate currentDate = classTimeDelete.getStartDate();
|
|
|
+ while (!currentDate.isAfter(classTimeDelete.getEndDate())) {
|
|
|
+ dateList.add(currentDate);
|
|
|
+ currentDate = currentDate.plusDays(1); // 增加一天
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //去重并存到map中
|
|
|
+ deleteMap.put(classId, new HashSet<>(dateList));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ //循环教师,准备开始计算
|
|
|
+ for (TeacherListVo teacher : teacherList) {
|
|
|
+ ClassTimeStatisticsRecord record = new ClassTimeStatisticsRecord();
|
|
|
+ record.setUserId(teacher.getId());
|
|
|
+ record.setEmployType(teacher.getEmployType());
|
|
|
+
|
|
|
+ Double allClassTime = 0D;
|
|
|
+ //计算补充课时,算作正课课时,但是计算超出课时时不计算这部分
|
|
|
+ for (String courseTimeType : courseTimeMap.keySet()) {
|
|
|
+ List<WfTeacherCourseTime> courseTimes = courseTimeMap.get(courseTimeType);
|
|
|
+ double sum = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ allClassTime = allClassTime + sum;
|
|
|
+ if(CourseTimeTypeEnum.CTT001.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime1(sum);
|
|
|
+ }else if(CourseTimeTypeEnum.CTT002.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime2(sum);
|
|
|
+ }else if(CourseTimeTypeEnum.CTT003.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime3(sum);
|
|
|
+ }else if(CourseTimeTypeEnum.CTT004.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime4(sum);
|
|
|
+ }else if(CourseTimeTypeEnum.CTT005.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime5(sum);
|
|
|
+ }else if(CourseTimeTypeEnum.CTT006.getCode().equals(courseTimeType)){
|
|
|
+ record.setClassTime6(sum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询出老师的课程
|
|
|
+ List<CourseListVo> courseList = allCourseList.stream()
|
|
|
+ .filter(x -> x.getTeacherId().contains(teacher.getId().toString()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //循环,统计出各项数据
|
|
|
+ for (CourseListVo courseListVo : courseList) {
|
|
|
+ //如果这个课程数据包含在被删除的课时中,跳过不计算
|
|
|
+ Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
+ if(deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setAllClassTime(allClassTime);
|
|
|
+
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|