| @@ -193,6 +193,29 @@ open class StaffsService( | |||||
| } | } | ||||
| } | } | ||||
| salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.salaryPoint.toLong()) | salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.salaryPoint.toLong()) | ||||
| if (team != null) { | |||||
| val teamLog = TeamLog().apply { | |||||
| this.staff = staff | |||||
| this.team = team | |||||
| from = LocalDate.now() | |||||
| } | |||||
| teamLogRepository.save(teamLog) | |||||
| } | |||||
| val gradeLog = GradeLog().apply { | |||||
| this.staff = staff | |||||
| this.grade = grade | |||||
| from = LocalDate.now() | |||||
| } | |||||
| gradeLogRepository.save(gradeLog) | |||||
| val positionLog = PositionLog().apply { | |||||
| this.staff = staff | |||||
| this.position = currentPosition | |||||
| from = LocalDate.now() | |||||
| } | |||||
| positionLogRepository.save(positionLog) | |||||
| return staff | return staff | ||||
| } | } | ||||
| @Transactional(rollbackFor = [Exception::class]) | @Transactional(rollbackFor = [Exception::class]) | ||||
| @@ -223,7 +246,7 @@ open class StaffsService( | |||||
| val latestTeam = teamLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | val latestTeam = teamLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | ||||
| val latestGrade = gradeLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | val latestGrade = gradeLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | ||||
| val latestPosition = positionLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | val latestPosition = positionLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) | ||||
| if (latestTeam.team.id != req.teamId) { | |||||
| if (latestTeam != null && latestTeam.team.id != req.teamId) { | |||||
| val teamLog = TeamLog().apply { | val teamLog = TeamLog().apply { | ||||
| this.staff = staff | this.staff = staff | ||||
| this.team = team | this.team = team | ||||
| @@ -235,7 +258,7 @@ open class StaffsService( | |||||
| teamLogRepository.save(teamLog) | teamLogRepository.save(teamLog) | ||||
| teamLogRepository.save(lastRecordTeam) | teamLogRepository.save(lastRecordTeam) | ||||
| } | } | ||||
| if (latestGrade.grade.id != req.gradeId) { | |||||
| if (latestGrade != null && latestGrade.grade.id != req.gradeId) { | |||||
| val gradeLog = GradeLog().apply { | val gradeLog = GradeLog().apply { | ||||
| this.staff = staff | this.staff = staff | ||||
| this.grade = grade | this.grade = grade | ||||
| @@ -247,7 +270,7 @@ open class StaffsService( | |||||
| gradeLogRepository.save(gradeLog) | gradeLogRepository.save(gradeLog) | ||||
| gradeLogRepository.save(lastRecordGrade) | gradeLogRepository.save(lastRecordGrade) | ||||
| } | } | ||||
| if (latestPosition.position.id != req.currentPositionId) { | |||||
| if (latestPosition != null && latestPosition.position.id != req.currentPositionId) { | |||||
| val positionLog = PositionLog().apply { | val positionLog = PositionLog().apply { | ||||
| this.staff = staff | this.staff = staff | ||||
| this.position = currentPosition | this.position = currentPosition | ||||