|
@@ -11,6 +11,7 @@ import com.keao.edu.user.dao.*;
|
|
|
import com.keao.edu.user.dto.*;
|
|
|
import com.keao.edu.user.entity.ExamTeacherSalary;
|
|
|
import com.keao.edu.user.entity.Teacher;
|
|
|
+import com.keao.edu.user.enums.TeacherSettlementTypeEnum;
|
|
|
import com.keao.edu.user.page.ExamTeacherSalaryQueryInfo;
|
|
|
import com.keao.edu.user.service.ExamTeacherSalaryService;
|
|
|
import com.keao.edu.util.collection.MapUtil;
|
|
@@ -83,10 +84,41 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
|
|
|
long studentNum = examRoomStudentRelations.stream().filter(e -> examRoomIds.contains(e.getExamRoomId())).count();
|
|
|
examTeacherSalary.setTotalInvigilationNum(examRoomIds.size());
|
|
|
examTeacherSalary.setTotalInvigilationStudentNum((int) studentNum);
|
|
|
- examTeacherSalary.setTotalSettlementCost(examTeacherSalary.getShareProfitAmount().multiply(new BigDecimal(studentNum)));
|
|
|
+ if(TeacherSettlementTypeEnum.SINGLE.equals(examTeacherSalary.getSettlementType())){
|
|
|
+ examTeacherSalary.setTotalSettlementCost(examTeacherSalary.getShareProfitAmount().multiply(new BigDecimal(examRoomIds.size())));
|
|
|
+ }else if(TeacherSettlementTypeEnum.PEOPLE_NUM.equals(examTeacherSalary.getSettlementType())){
|
|
|
+ examTeacherSalary.setTotalSettlementCost(examTeacherSalary.getShareProfitAmount().multiply(new BigDecimal(studentNum)));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(examTeacherSalaries)){
|
|
|
examTeacherSalaryDao.batchUpdate(examTeacherSalaries);
|
|
|
+ Set<Integer> teacherIds = examTeacherSalaries.stream().map(ExamTeacherSalary::getTeacherId).collect(Collectors.toSet());
|
|
|
+ List<ExamTeacherSalary> teacherAllExamSalarys = examTeacherSalaryDao.getWithTeachers(new ArrayList<>(teacherIds));
|
|
|
+ Map<Integer, List<ExamTeacherSalary>> teacherExamSalarysMap = teacherAllExamSalarys.stream().collect(Collectors.groupingBy(ExamTeacherSalary::getTeacherId));
|
|
|
+ List<Teacher> updateTeachers=new ArrayList<>();
|
|
|
+ for (Integer teacherId : teacherIds) {
|
|
|
+ List<ExamTeacherSalary> examSalarys = teacherExamSalarysMap.get(teacherId);
|
|
|
+ Integer totalInvigilationNum=0;
|
|
|
+ Integer totalInvigilationStudentNum=0;
|
|
|
+ BigDecimal totalSettlementCost=BigDecimal.ZERO;
|
|
|
+ if(!CollectionUtils.isEmpty(examSalarys)){
|
|
|
+ for (ExamTeacherSalary examSalary : examSalarys) {
|
|
|
+ totalInvigilationNum += examSalary.getTotalInvigilationNum();
|
|
|
+ totalInvigilationStudentNum += examSalary.getTotalInvigilationStudentNum();
|
|
|
+ totalSettlementCost=totalSettlementCost.add(examSalary.getTotalSettlementCost());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Teacher teacher=new Teacher();
|
|
|
+ teacher.setUserId(teacherId);
|
|
|
+ teacher.setTotalInvigilationNum(totalInvigilationNum);
|
|
|
+ teacher.setTotalInvigilationStudentNum(totalInvigilationStudentNum);
|
|
|
+ teacher.setTotalSettlementCost(totalSettlementCost);
|
|
|
+ updateTeachers.add(teacher);
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(updateTeachers)){
|
|
|
+ teacherDao.batchUpdate(updateTeachers);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|