|
@@ -1,6 +1,7 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dao.TeacherCourseStatisticsDao;
|
|
|
import com.ym.mec.biz.dal.entity.Subject;
|
|
|
import com.ym.mec.biz.dal.entity.TeacherCourseStatistics;
|
|
@@ -11,9 +12,11 @@ import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -22,6 +25,8 @@ public class TeacherCourseStatisticsServiceImpl extends BaseServiceImpl<Long, Te
|
|
|
|
|
|
@Autowired
|
|
|
private TeacherCourseStatisticsDao teacherCourseStatisticsDao;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigDao sysConfigDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, TeacherCourseStatistics> getDAO() {
|
|
@@ -45,4 +50,49 @@ public class TeacherCourseStatisticsServiceImpl extends BaseServiceImpl<Long, Te
|
|
|
}
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void teacherCourseStatistic() {
|
|
|
+ Date nextMonthDate = DateUtil.addMonths(new Date(), 1);
|
|
|
+ Date startDate = DateUtil.getFirstDayOfMonth(nextMonthDate);
|
|
|
+ Date endDate = DateUtil.getLastDayOfMonth(nextMonthDate);
|
|
|
+ String salaryConfig = sysConfigDao.findConfigValue("warning_min_course_salary");
|
|
|
+ BigDecimal salary = new BigDecimal(salaryConfig);
|
|
|
+ List<TeacherCourseStatistics> teacherCourseStatisticsList = teacherCourseStatisticsDao.findUserByWarringSalary(startDate, endDate, salary);
|
|
|
+ if (teacherCourseStatisticsList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Integer> userIds = teacherCourseStatisticsList.stream().map(TeacherCourseStatistics::getUserId).collect(Collectors.toList());
|
|
|
+ List<TeacherCourseStatistics> teCourseSalaryStatisAndTypes = teacherCourseStatisticsDao.findUserCourseSalaryByUserIds(userIds, startDate, endDate);
|
|
|
+
|
|
|
+ for (TeacherCourseStatistics teacherCourseStatistics : teacherCourseStatisticsList) {
|
|
|
+ int vipCourseNum = 0;
|
|
|
+ int musicCourseNum = 0;
|
|
|
+ BigDecimal expectVipCourseSalary = BigDecimal.ZERO;
|
|
|
+ BigDecimal expectMusicCourseSalary = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (TeacherCourseStatistics teCourseSalaryStatisAndType : teCourseSalaryStatisAndTypes) {
|
|
|
+ if (!teacherCourseStatistics.getUserId().equals(teCourseSalaryStatisAndType.getUserId())) continue;
|
|
|
+
|
|
|
+ if (teCourseSalaryStatisAndType.getGroupType().equals("VIP")) {
|
|
|
+ expectVipCourseSalary = teCourseSalaryStatisAndType.getExpectTotalSalary();
|
|
|
+ vipCourseNum = teCourseSalaryStatisAndType.getMusicCourseNum();
|
|
|
+ } else if (teCourseSalaryStatisAndType.getGroupType().equals("MUSIC")) {
|
|
|
+ expectMusicCourseSalary = teCourseSalaryStatisAndType.getExpectTotalSalary();
|
|
|
+ musicCourseNum = teCourseSalaryStatisAndType.getMusicCourseNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ teacherCourseStatistics.setExpectVipCourseSalary(expectVipCourseSalary);
|
|
|
+ teacherCourseStatistics.setExpectMusicCourseSalary(expectMusicCourseSalary);
|
|
|
+ teacherCourseStatistics.setVipCourseNum(vipCourseNum);
|
|
|
+ teacherCourseStatistics.setMusicCourseNum(musicCourseNum);
|
|
|
+
|
|
|
+ if (teacherCourseStatistics.getSubjectIdList() == null) {
|
|
|
+ teacherCourseStatistics.setSubjectIdList("");
|
|
|
+ }
|
|
|
+ teacherCourseStatistics.setMonth(startDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ teacherCourseStatisticsDao.batchAdd(teacherCourseStatisticsList);
|
|
|
+ }
|
|
|
}
|