|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.google.gson.JsonArray;
|
|
import com.google.gson.JsonArray;
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
@@ -23,12 +24,14 @@ import com.xjrsoft.module.classtime.service.IClassTimeStatisticsService;
|
|
|
import com.xjrsoft.module.classtime.service.IClassTimeStatisticsSetService;
|
|
import com.xjrsoft.module.classtime.service.IClassTimeStatisticsSetService;
|
|
|
import com.xjrsoft.module.classtime.vo.CourseListVo;
|
|
import com.xjrsoft.module.classtime.vo.CourseListVo;
|
|
|
import com.xjrsoft.module.classtime.vo.TeacherListVo;
|
|
import com.xjrsoft.module.classtime.vo.TeacherListVo;
|
|
|
|
|
+import com.xjrsoft.module.classtime.vo.WeekTimeRangeVo;
|
|
|
import com.xjrsoft.module.oa.entity.WfTeacherCourseTime;
|
|
import com.xjrsoft.module.oa.entity.WfTeacherCourseTime;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -145,7 +148,6 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
costSetMap.put(object.get("field").getAsString(), object.get("value").getAsDouble());
|
|
costSetMap.put(object.get("field").getAsString(), object.get("value").getAsDouble());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//权重设置jsonArray
|
|
//权重设置jsonArray
|
|
|
JsonArray weightSetArray = parser.parse(statistics.getWeightSetJson()).getAsJsonArray();
|
|
JsonArray weightSetArray = parser.parse(statistics.getWeightSetJson()).getAsJsonArray();
|
|
|
Map<String, Double> weightSetMap = new HashMap<>();
|
|
Map<String, Double> weightSetMap = new HashMap<>();
|
|
@@ -153,6 +155,9 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
JsonObject object = jsonElement.getAsJsonObject();
|
|
JsonObject object = jsonElement.getAsJsonObject();
|
|
|
weightSetMap.put(object.get("label").getAsString(), object.get("value").getAsDouble());
|
|
weightSetMap.put(object.get("label").getAsString(), object.get("value").getAsDouble());
|
|
|
}
|
|
}
|
|
|
|
|
+ //计算出这个时间段内一共多少周
|
|
|
|
|
+ List<WeekTimeRangeVo> weekTimeRangeVos = calculateNaturalWeeks(statistics.getStartDate(), statistics.getEndDate());
|
|
|
|
|
+
|
|
|
//查询课程数据
|
|
//查询课程数据
|
|
|
List<CourseListVo> allCourseList = this.baseMapper.getCourseList(statistics);
|
|
List<CourseListVo> allCourseList = this.baseMapper.getCourseList(statistics);
|
|
|
|
|
|
|
@@ -178,7 +183,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
|
|
|
|
|
//查询所有老师发起顶课通过的数量(只查询事假、病假),也要分别计算早自习、晚自习、正课、如果日期出入课时删除中,也需要跳过
|
|
//查询所有老师发起顶课通过的数量(只查询事假、病假),也要分别计算早自习、晚自习、正课、如果日期出入课时删除中,也需要跳过
|
|
|
List<CourseListVo> allSubstituteList = this.baseMapper.getSubstituteList(statistics);
|
|
List<CourseListVo> allSubstituteList = this.baseMapper.getSubstituteList(statistics);
|
|
|
-
|
|
|
|
|
|
|
+ List<ClassTimeStatisticsRecord> insertList = new ArrayList<>();
|
|
|
//循环教师,准备开始计算
|
|
//循环教师,准备开始计算
|
|
|
for (TeacherListVo teacher : teacherList) {
|
|
for (TeacherListVo teacher : teacherList) {
|
|
|
ClassTimeStatisticsRecord record = new ClassTimeStatisticsRecord();
|
|
ClassTimeStatisticsRecord record = new ClassTimeStatisticsRecord();
|
|
@@ -216,11 +221,12 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
List<CourseListVo> courseList = allCourseList.stream()
|
|
List<CourseListVo> courseList = allCourseList.stream()
|
|
|
.filter(x -> x.getTeacherId().contains(teacher.getId().toString()))
|
|
.filter(x -> x.getTeacherId().contains(teacher.getId().toString()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
//循环,统计出各项数据
|
|
//循环,统计出各项数据
|
|
|
for (CourseListVo courseListVo : courseList) {
|
|
for (CourseListVo courseListVo : courseList) {
|
|
|
//如果这个课程数据包含在被删除的课时中,跳过不计算
|
|
//如果这个课程数据包含在被删除的课时中,跳过不计算
|
|
|
Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
- if(deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
|
|
|
|
+ if(deleteDates != null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
if("早自习".equals(courseListVo.getShortName())){
|
|
if("早自习".equals(courseListVo.getShortName())){
|
|
@@ -233,12 +239,58 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
|
|
|
|
|
if(courseListVo.getAdjustType() != null && !courseListVo.getAdjustType().isEmpty()){
|
|
if(courseListVo.getAdjustType() != null && !courseListVo.getAdjustType().isEmpty()){
|
|
|
if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseListVo.getAdjustType())){
|
|
if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseListVo.getAdjustType())){
|
|
|
- classTime10 ++;
|
|
|
|
|
|
|
+ classTime10 += weightSetMap.get(courseListVo.getShortName());
|
|
|
}else if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseListVo.getAdjustType())){
|
|
}else if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseListVo.getAdjustType())){
|
|
|
- classTime11 ++;
|
|
|
|
|
|
|
+ classTime11 += weightSetMap.get(courseListVo.getShortName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ JsonObject weekDataJson = new JsonObject();
|
|
|
|
|
+ Double allTimes = 0d;
|
|
|
|
|
+ //存每周的数据
|
|
|
|
|
+ for (WeekTimeRangeVo timeRangeVo : weekTimeRangeVos) {
|
|
|
|
|
+ Double zkTimes = 0d;
|
|
|
|
|
+ Double wzxTimes = 0d;
|
|
|
|
|
+ Double dkTimes = 0d;
|
|
|
|
|
+ Double tkTimes = 0d;
|
|
|
|
|
+ for (CourseListVo courseListVo : courseList) {
|
|
|
|
|
+ LocalDate scheduleDate = courseListVo.getScheduleDate();
|
|
|
|
|
+ //如果这个课程数据包含在被删除的课时中,跳过不计算
|
|
|
|
|
+ Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
|
|
+ if(deleteDates != null && deleteDates.contains(scheduleDate)){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!(scheduleDate.isAfter(timeRangeVo.getMondayDate()) && scheduleDate.isBefore(timeRangeVo.getSundayDate()))){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if("早自习".equals(courseListVo.getShortName())){
|
|
|
|
|
+ zkTimes += weightSetMap.get(courseListVo.getShortName());
|
|
|
|
|
+ }else if(zkList.contains(courseListVo.getShortName())){
|
|
|
|
|
+ zkTimes += weightSetMap.get(courseListVo.getShortName());
|
|
|
|
|
+ }else if(wzxList.contains(courseListVo.getShortName())){
|
|
|
|
|
+ wzxTimes += weightSetMap.get(courseListVo.getShortName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(courseListVo.getAdjustType() != null && !courseListVo.getAdjustType().isEmpty()){
|
|
|
|
|
+ if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseListVo.getAdjustType())){
|
|
|
|
|
+ dkTimes += weightSetMap.get(courseListVo.getShortName());
|
|
|
|
|
+ }else if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseListVo.getAdjustType())){
|
|
|
|
|
+ tkTimes += weightSetMap.get(courseListVo.getShortName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ timeRangeVo.setZkTimes(zkTimes);
|
|
|
|
|
+ timeRangeVo.setWzxTimes(wzxTimes);
|
|
|
|
|
+ timeRangeVo.setDkTimes(dkTimes);
|
|
|
|
|
+ timeRangeVo.setTkTimes(tkTimes);
|
|
|
|
|
+ allTimes += (zkTimes + wzxTimes);
|
|
|
|
|
+ }
|
|
|
|
|
+ weekDataJson.add("weekData", new Gson().toJsonTree(weekTimeRangeVos));
|
|
|
|
|
+ weekDataJson.addProperty("allTimes", allTimes);
|
|
|
|
|
+ record.setWeekData(weekDataJson.toString());
|
|
|
|
|
+
|
|
|
//计算总课时
|
|
//计算总课时
|
|
|
allClassTime = allClassTime + classTime7 + classTime8 + classTime9;
|
|
allClassTime = allClassTime + classTime7 + classTime8 + classTime9;
|
|
|
record.setAllClassTime(allClassTime);
|
|
record.setAllClassTime(allClassTime);
|
|
@@ -262,7 +314,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
BigDecimal zzxCost = BigDecimal.ZERO;//早自习费用
|
|
BigDecimal zzxCost = BigDecimal.ZERO;//早自习费用
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
zzxCost = BigDecimal.valueOf(costSetMap.get("cost1"));
|
|
zzxCost = BigDecimal.valueOf(costSetMap.get("cost1"));
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
zzxCost = BigDecimal.valueOf(costSetMap.get("cost2"));
|
|
zzxCost = BigDecimal.valueOf(costSetMap.get("cost2"));
|
|
|
}
|
|
}
|
|
|
classTimeAmount += BigDecimal.valueOf(classTime7).multiply(zzxCost).doubleValue();
|
|
classTimeAmount += BigDecimal.valueOf(classTime7).multiply(zzxCost).doubleValue();
|
|
@@ -270,7 +322,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
BigDecimal zkCost = BigDecimal.ZERO;//正课费用
|
|
BigDecimal zkCost = BigDecimal.ZERO;//正课费用
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
zkCost = BigDecimal.valueOf(costSetMap.get("cost3"));
|
|
zkCost = BigDecimal.valueOf(costSetMap.get("cost3"));
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
zkCost = BigDecimal.valueOf(costSetMap.get("cost4"));
|
|
zkCost = BigDecimal.valueOf(costSetMap.get("cost4"));
|
|
|
}
|
|
}
|
|
|
classTimeAmount += BigDecimal.valueOf(classTime8).multiply(zkCost).doubleValue();
|
|
classTimeAmount += BigDecimal.valueOf(classTime8).multiply(zkCost).doubleValue();
|
|
@@ -278,7 +330,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
BigDecimal wzxCost = BigDecimal.ZERO;//晚自习费用
|
|
BigDecimal wzxCost = BigDecimal.ZERO;//晚自习费用
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
wzxCost = BigDecimal.valueOf(costSetMap.get("cost5"));
|
|
wzxCost = BigDecimal.valueOf(costSetMap.get("cost5"));
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
wzxCost = BigDecimal.valueOf(costSetMap.get("cost6"));
|
|
wzxCost = BigDecimal.valueOf(costSetMap.get("cost6"));
|
|
|
}
|
|
}
|
|
|
classTimeAmount += BigDecimal.valueOf(classTime9).multiply(wzxCost).doubleValue();
|
|
classTimeAmount += BigDecimal.valueOf(classTime9).multiply(wzxCost).doubleValue();
|
|
@@ -286,7 +338,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
BigDecimal dkCost = BigDecimal.ZERO;//顶课费用,顶课老师加钱
|
|
BigDecimal dkCost = BigDecimal.ZERO;//顶课费用,顶课老师加钱
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
dkCost = BigDecimal.valueOf(costSetMap.get("cost11"));
|
|
dkCost = BigDecimal.valueOf(costSetMap.get("cost11"));
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
dkCost = BigDecimal.valueOf(costSetMap.get("cost12"));
|
|
dkCost = BigDecimal.valueOf(costSetMap.get("cost12"));
|
|
|
}
|
|
}
|
|
|
classTimeAmount += BigDecimal.valueOf(classTime10).multiply(dkCost).doubleValue();
|
|
classTimeAmount += BigDecimal.valueOf(classTime10).multiply(dkCost).doubleValue();
|
|
@@ -294,7 +346,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
BigDecimal bdkCost = BigDecimal.ZERO;//顶课费用,被顶课老师扣钱
|
|
BigDecimal bdkCost = BigDecimal.ZERO;//顶课费用,被顶课老师扣钱
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
bdkCost = BigDecimal.valueOf(costSetMap.get("cost13"));
|
|
bdkCost = BigDecimal.valueOf(costSetMap.get("cost13"));
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
bdkCost = BigDecimal.valueOf(costSetMap.get("cost14"));
|
|
bdkCost = BigDecimal.valueOf(costSetMap.get("cost14"));
|
|
|
}
|
|
}
|
|
|
//计算被扣除的费用
|
|
//计算被扣除的费用
|
|
@@ -303,18 +355,81 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
//计算总课时费用
|
|
//计算总课时费用
|
|
|
classTimeAmount = BigDecimal.valueOf(classTimeAmount).subtract(reduceTimeAmount).doubleValue();
|
|
classTimeAmount = BigDecimal.valueOf(classTimeAmount).subtract(reduceTimeAmount).doubleValue();
|
|
|
|
|
|
|
|
- //计算超出的课时
|
|
|
|
|
- Double ccksTime = 0d;
|
|
|
|
|
|
|
+ //计算超出的课时,需要先计算出每个周的开始结束时间
|
|
|
|
|
+ BigDecimal ccksTime = BigDecimal.ZERO;//超出课时标准(每周)
|
|
|
|
|
+ if("FB1601".equals(teacher.getEmployType())){
|
|
|
|
|
+ ccksTime = BigDecimal.valueOf(costSetMap.get("cost7"));
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
|
|
+ ccksTime = BigDecimal.valueOf(costSetMap.get("cost8"));
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal ccksCost = BigDecimal.ZERO;
|
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
if("FB1601".equals(teacher.getEmployType())){
|
|
|
- bdkCost = BigDecimal.valueOf(costSetMap.get("cost9"));
|
|
|
|
|
- }else if("FB1602".equals(teacher.getEmployType())){
|
|
|
|
|
- bdkCost = BigDecimal.valueOf(costSetMap.get("cost10"));
|
|
|
|
|
|
|
+ ccksCost = BigDecimal.valueOf(costSetMap.get("cost9"));
|
|
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
|
|
+ ccksCost = BigDecimal.valueOf(costSetMap.get("cost10"));
|
|
|
}
|
|
}
|
|
|
|
|
+ //计算出总的超出课时并计算超课时费
|
|
|
|
|
+ BigDecimal allCcksTime = BigDecimal.valueOf(allClassTime).subtract(ccksTime.multiply(BigDecimal.valueOf(weekTimeRangeVos.size())));
|
|
|
|
|
+ beyondClassTimeAmount = allCcksTime.multiply(ccksCost).doubleValue();
|
|
|
|
|
+ if(!"FB1601".equals(teacher.getEmployType())){
|
|
|
|
|
+ record.setBeyondClassTimeAmount(beyondClassTimeAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //计算总金额,课时费+超课时费
|
|
|
|
|
+ Double totalAmount = classTimeAmount + beyondClassTimeAmount - reduceTimeAmount.doubleValue();
|
|
|
|
|
+ record.setTotalAmount(totalAmount);
|
|
|
|
|
+
|
|
|
|
|
+ insertList.add(record);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Double totalAmount = classTimeAmount + 0d;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(!insertList.isEmpty()){
|
|
|
|
|
+ //先删除
|
|
|
|
|
+ recordMapper.delete(
|
|
|
|
|
+ new QueryWrapper<ClassTimeStatisticsRecord>().lambda()
|
|
|
|
|
+ .eq(ClassTimeStatisticsRecord::getClassTimeStatisticsId, statistics.getId())
|
|
|
|
|
+ );
|
|
|
|
|
+ for (ClassTimeStatisticsRecord record : insertList) {
|
|
|
|
|
+ recordMapper.insert(record);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //计算日期内一共几个周,并返回每周的周一日期和周日日期
|
|
|
|
|
+ private static List<WeekTimeRangeVo> calculateNaturalWeeks(LocalDate startDate, LocalDate endDate) {
|
|
|
|
|
+ List<WeekTimeRangeVo> result = new ArrayList<>();
|
|
|
|
|
+ // 获取第一个周一
|
|
|
|
|
+ LocalDate currentMonday = startDate.with(DayOfWeek.MONDAY);
|
|
|
|
|
+ // 如果 startDate 不是周一,则用下一个周一
|
|
|
|
|
+ if (!startDate.isEqual(currentMonday) && startDate.isAfter(currentMonday)) {
|
|
|
|
|
+ currentMonday = currentMonday.plusWeeks(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int weeks = 1;
|
|
|
|
|
+ // 遍历每个周
|
|
|
|
|
+ while (!currentMonday.isAfter(endDate)) {
|
|
|
|
|
+ // 计算当前周的周日
|
|
|
|
|
+ LocalDate currentSunday = currentMonday.plusDays(6);
|
|
|
|
|
+
|
|
|
|
|
+ // 限制周日的范围
|
|
|
|
|
+ if (currentSunday.isAfter(endDate)) {
|
|
|
|
|
+ currentSunday = endDate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加结果
|
|
|
|
|
+ WeekTimeRangeVo timeRangeVo = new WeekTimeRangeVo();
|
|
|
|
|
+ timeRangeVo.setMondayDate(currentMonday);
|
|
|
|
|
+ timeRangeVo.setSundayDate(currentSunday);
|
|
|
|
|
+ timeRangeVo .setWeeks(weeks);
|
|
|
|
|
+ result.add(timeRangeVo);
|
|
|
|
|
+
|
|
|
|
|
+ // 移动到下一个周的周一
|
|
|
|
|
+ currentMonday = currentMonday.plusWeeks(1);
|
|
|
|
|
+ weeks ++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|