|
@@ -95,7 +95,6 @@ open class StaffsService( |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
open fun saveStaff(req: NewStaffRequest): Staff { |
|
|
open fun saveStaff(req: NewStaffRequest): Staff { |
|
|
// if (req.staffId) |
|
|
|
|
|
val checkStaffIdList: List<StaffSearchInfo> = staffRepository.findStaffSearchInfoByAndDeletedFalse() |
|
|
val checkStaffIdList: List<StaffSearchInfo> = staffRepository.findStaffSearchInfoByAndDeletedFalse() |
|
|
checkStaffIdList.forEach{ s -> |
|
|
checkStaffIdList.forEach{ s -> |
|
|
if (s.staffId == req.staffId) { |
|
|
if (s.staffId == req.staffId) { |
|
@@ -158,31 +157,31 @@ open class StaffsService( |
|
|
staffSkillsetRepository.save(ss) |
|
|
staffSkillsetRepository.save(ss) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// val skillBatchInsertValues: MutableList<MutableMap<String, Any>> |
|
|
|
|
|
// if (!req.skillSetId.isNullOrEmpty()) { |
|
|
|
|
|
// skillBatchInsertValues = req.skillSetId.stream() |
|
|
|
|
|
// .map { skillId -> mutableMapOf<String, Any>(("staffId" to staff.id) as Pair<String, Any>, "skillId" to skillId) } |
|
|
|
|
|
// .collect(Collectors.toList()) |
|
|
|
|
|
// jdbcDao.batchUpdate( |
|
|
|
|
|
// "INSERT IGNORE INTO staff_skillset (staffId, skillId)" |
|
|
|
|
|
// + " VALUES (:staffId, :skillId)", |
|
|
|
|
|
// skillBatchInsertValues); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.id!!) |
|
|
salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.id!!) |
|
|
return staff |
|
|
return staff |
|
|
} |
|
|
} |
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
open fun updateStaff(req: NewStaffRequest, staff: Staff): Staff { |
|
|
open fun updateStaff(req: NewStaffRequest, staff: Staff): Staff { |
|
|
|
|
|
val args = java.util.Map.of<String, Any>("staffId", staff.id) |
|
|
|
|
|
if(!req.skillSetId.isNullOrEmpty()) { |
|
|
|
|
|
// remove all skills of the staff |
|
|
|
|
|
jdbcDao.executeUpdate("DELETE FROM staff_skillset WHERE staffId = :staffId", args); |
|
|
|
|
|
// add skiils |
|
|
|
|
|
for (skillId in req.skillSetId) { |
|
|
|
|
|
val skill = skillRepository.findById(skillId).orElseThrow() |
|
|
|
|
|
val ss = StaffSkillset().apply { |
|
|
|
|
|
this.staff = staff |
|
|
|
|
|
this.skill = skill |
|
|
|
|
|
} |
|
|
|
|
|
staffSkillsetRepository.save(ss) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() |
|
|
val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() |
|
|
val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() |
|
|
val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() |
|
|
val company = companyRepository.findById(req.companyId).orElseThrow() |
|
|
val company = companyRepository.findById(req.companyId).orElseThrow() |
|
|
val grade = if (req.gradeId != null && req.gradeId > 0L) gradeRepository.findById(req.gradeId).orElseThrow() else null |
|
|
val grade = if (req.gradeId != null && req.gradeId > 0L) gradeRepository.findById(req.gradeId).orElseThrow() else null |
|
|
val team = if (req.teamId != null && req.teamId > 0L) teamRepository.findById(req.teamId).orElseThrow() else null |
|
|
val team = if (req.teamId != null && req.teamId > 0L) teamRepository.findById(req.teamId).orElseThrow() else null |
|
|
// val skill = if (req.skillSetId != null && req.skillSetId > 0L) skillRepository.findById(req.skillSetId).orElseThrow() else null |
|
|
|
|
|
val salary = salaryRepository.findById(req.salaryId).orElseThrow() |
|
|
val salary = salaryRepository.findById(req.salaryId).orElseThrow() |
|
|
// val salaryEffective = salaryEffectiveRepository.findById(req.salaryEffId).orElseThrow() |
|
|
|
|
|
val department = departmentRepository.findById(req.departmentId).orElseThrow() |
|
|
val department = departmentRepository.findById(req.departmentId).orElseThrow() |
|
|
|
|
|
|
|
|
staff.apply { |
|
|
staff.apply { |
|
@@ -203,7 +202,6 @@ open class StaffsService( |
|
|
this.company = company |
|
|
this.company = company |
|
|
this.grade = grade |
|
|
this.grade = grade |
|
|
this.team = team |
|
|
this.team = team |
|
|
// this.skill = skill |
|
|
|
|
|
this.salary = salary |
|
|
this.salary = salary |
|
|
this.department = department |
|
|
this.department = department |
|
|
} |
|
|
} |
|
|