|
|
@@ -28,9 +28,12 @@ open class StaffsService( |
|
|
|
private val staffRepository: StaffRepository, |
|
|
|
private val userRepository: UserRepository, |
|
|
|
private val positionRepository: PositionRepository, |
|
|
|
private val positionLogRepository: PositionLogRepository, |
|
|
|
private val companyRepository: CompanyRepository, |
|
|
|
private val gradeRepository: GradeRepository, |
|
|
|
private val gradeLogRepository: GradeLogRepository, |
|
|
|
private val teamRepository: TeamRepository, |
|
|
|
private val teamLogRepository: TeamLogRepository, |
|
|
|
private val skillRepository: SkillRepository, |
|
|
|
private val salaryRepository: SalaryRepository, |
|
|
|
private val salaryEffectiveRepository: SalaryEffectiveRepository, |
|
|
@@ -49,7 +52,7 @@ open class StaffsService( |
|
|
|
open fun allStaff(): List<StaffSearchInfo> { |
|
|
|
return staffRepository.findStaffSearchInfoByAndDeletedFalseOrderByStaffIdAsc(); |
|
|
|
} |
|
|
|
open fun StaffWithoutTeam(): List<StaffSearchInfo> { |
|
|
|
open fun staffWithoutTeam(): List<StaffSearchInfo> { |
|
|
|
return staffRepository.findStaffSearchInfoByAndDeletedFalseAndTeamIdIsNullOrderByStaffIdAsc(); |
|
|
|
} |
|
|
|
|
|
|
@@ -214,6 +217,45 @@ open class StaffsService( |
|
|
|
val salary = salaryRepository.findBySalaryPoint(salaryPoint).orElseThrow() |
|
|
|
val department = if (req.departmentId != null && req.departmentId > 0L) departmentRepository.findById(req.departmentId).orElseThrow() else null |
|
|
|
|
|
|
|
val latestTeam = teamLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) |
|
|
|
val latestGrade = gradeLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) |
|
|
|
val latestPosition = positionLogRepository.findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(staff.id) |
|
|
|
if (latestTeam.team.id != req.teamId) { |
|
|
|
val teamLog = TeamLog().apply { |
|
|
|
this.staff = staff |
|
|
|
this.team = team |
|
|
|
from = LocalDate.now() |
|
|
|
} |
|
|
|
val lastRecordTeam = latestTeam.apply { |
|
|
|
to = LocalDate.now() |
|
|
|
} |
|
|
|
teamLogRepository.save(teamLog) |
|
|
|
teamLogRepository.save(lastRecordTeam) |
|
|
|
} |
|
|
|
if (latestGrade.grade.id != req.gradeId) { |
|
|
|
val gradeLog = GradeLog().apply { |
|
|
|
this.staff = staff |
|
|
|
this.grade = grade |
|
|
|
from = LocalDate.now() |
|
|
|
} |
|
|
|
val lastRecordGrade = latestGrade.apply { |
|
|
|
to = LocalDate.now() |
|
|
|
} |
|
|
|
gradeLogRepository.save(gradeLog) |
|
|
|
gradeLogRepository.save(lastRecordGrade) |
|
|
|
} |
|
|
|
if (latestPosition.position.id != req.currentPositionId) { |
|
|
|
val positionLog = PositionLog().apply { |
|
|
|
this.staff = staff |
|
|
|
this.position = currentPosition |
|
|
|
from = LocalDate.now() |
|
|
|
} |
|
|
|
val lastRecordPosition = latestPosition.apply { |
|
|
|
to = LocalDate.now() |
|
|
|
} |
|
|
|
positionLogRepository.save(positionLog) |
|
|
|
positionLogRepository.save(lastRecordPosition) |
|
|
|
} |
|
|
|
staff.apply { |
|
|
|
joinDate = req.joinDate |
|
|
|
name = req.name |
|
|
|