|
@@ -17,6 +17,7 @@ import com.keao.edu.util.collection.MapUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -43,6 +44,7 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void teacherSalarySettlementWithExam(Long examId) {
|
|
|
List<ExamRoom> examRooms = examRoomDao.getWithExam(null, examId);
|
|
|
if(CollectionUtils.isEmpty(examRooms)){
|
|
@@ -87,6 +89,55 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void teacherSalarySettlementWithExam(List<Long> examIds) {
|
|
|
+ if(CollectionUtils.isEmpty(examIds)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Long examId : examIds) {
|
|
|
+ List<ExamRoom> examRooms = examRoomDao.getWithExam(null, examId);
|
|
|
+ if(CollectionUtils.isEmpty(examRooms)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Integer, List<ExamRoom>> teacherExamRoomMap=new HashMap<>();
|
|
|
+ for (ExamRoom examRoom : examRooms) {
|
|
|
+ if(!teacherExamRoomMap.containsKey(examRoom.getMainTeacherUserId())){
|
|
|
+ teacherExamRoomMap.put(examRoom.getMainTeacherUserId(), new ArrayList<>());
|
|
|
+ }
|
|
|
+ teacherExamRoomMap.get(examRoom.getMainTeacherUserId()).add(examRoom);
|
|
|
+ if(StringUtils.isBlank(examRoom.getAssistantTeacherUserIdList())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (String assistantTeacherId : examRoom.getAssistantTeacherUserIdList().split(",")) {
|
|
|
+ if(!teacherExamRoomMap.containsKey(Integer.valueOf(assistantTeacherId))){
|
|
|
+ teacherExamRoomMap.put(Integer.valueOf(assistantTeacherId), new ArrayList<>());
|
|
|
+ }
|
|
|
+ teacherExamRoomMap.get(Integer.valueOf(assistantTeacherId)).add(examRoom);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExamRoomStudentRelation> examRoomStudentRelations = examRoomStudentRelationDao.getExamRoomStudentRelations(examId, null, null);
|
|
|
+
|
|
|
+ List<ExamTeacherSalary> examTeacherSalaries = examTeacherSalaryDao.queryWithExam(examId);
|
|
|
+ for (ExamTeacherSalary examTeacherSalary : examTeacherSalaries) {
|
|
|
+ List<ExamRoom> teacherExamRooms = teacherExamRoomMap.get(examTeacherSalary.getTeacherId());
|
|
|
+ if(CollectionUtils.isEmpty(teacherExamRooms)){
|
|
|
+ examTeacherSalary.setTotalInvigilationNum(0);
|
|
|
+ examTeacherSalary.setTotalInvigilationStudentNum(0);
|
|
|
+ examTeacherSalary.setTotalSettlementCost(BigDecimal.ZERO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Set<Long> examRoomIds = teacherExamRooms.stream().map(ExamRoom::getId).collect(Collectors.toSet());
|
|
|
+ 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)));
|
|
|
+ }
|
|
|
+ examTeacherSalaryDao.batchUpdate(examTeacherSalaries);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public PageInfo<ExamTeacherSalaryDto> queryExamTeacherSalary(ExamTeacherSalaryQueryInfo queryInfo) {
|
|
|
PageInfo<ExamTeacherSalaryDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|