| @@ -24,7 +24,6 @@ public class GradeLog extends BaseEntity<Long> { | |||||
| @Column(name = "from", length = 30) | @Column(name = "from", length = 30) | ||||
| private LocalDate from; | private LocalDate from; | ||||
| @NotNull | |||||
| @Column(name = "to", length = 30) | @Column(name = "to", length = 30) | ||||
| private LocalDate to; | private LocalDate to; | ||||
| @@ -43,4 +42,8 @@ public class GradeLog extends BaseEntity<Long> { | |||||
| public LocalDate getFrom() { return from; } | public LocalDate getFrom() { return from; } | ||||
| public void setFrom(LocalDate from) { this.from = from; } | public void setFrom(LocalDate from) { this.from = from; } | ||||
| public LocalDate getTo() { return to; } | |||||
| public void setTo(LocalDate to) { this.to = to; } | |||||
| } | } | ||||
| @@ -6,5 +6,6 @@ import com.ffii.tsms.modules.data.entity.projections.GradeLogInfo; | |||||
| import java.util.List; | import java.util.List; | ||||
| public interface GradeLogRepository extends AbstractRepository<GradeLog, Long> { | public interface GradeLogRepository extends AbstractRepository<GradeLog, Long> { | ||||
| List<GradeLogInfo> findGradeLogInfoByStaffIdAndDeletedFalse(Long staffId); | |||||
| List<GradeLogInfo> findGradeLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| GradeLog findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| } | } | ||||
| @@ -24,7 +24,6 @@ public class PositionLog extends BaseEntity<Long> { | |||||
| @Column(name = "from", length = 30) | @Column(name = "from", length = 30) | ||||
| private LocalDate from; | private LocalDate from; | ||||
| @NotNull | |||||
| @Column(name = "to", length = 30) | @Column(name = "to", length = 30) | ||||
| private LocalDate to; | private LocalDate to; | ||||
| @@ -43,4 +42,8 @@ public class PositionLog extends BaseEntity<Long> { | |||||
| public LocalDate getFrom() { return from; } | public LocalDate getFrom() { return from; } | ||||
| public void setFrom(LocalDate from) { this.from = from; } | public void setFrom(LocalDate from) { this.from = from; } | ||||
| public LocalDate getTo() { return to; } | |||||
| public void setTo(LocalDate to) { this.to = to; } | |||||
| } | } | ||||
| @@ -7,5 +7,8 @@ import com.ffii.tsms.modules.data.entity.projections.PositionLogInfo; | |||||
| import java.util.List; | import java.util.List; | ||||
| public interface PositionLogRepository extends AbstractRepository<PositionLog, Long> { | public interface PositionLogRepository extends AbstractRepository<PositionLog, Long> { | ||||
| List<PositionLogInfo> findPositionLogInfoByStaffIdAndDeletedFalse(Long staffId); | |||||
| List<PositionLogInfo> findPositionLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| PositionLog findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| } | } | ||||
| @@ -24,7 +24,6 @@ public class TeamLog extends BaseEntity<Long> { | |||||
| @Column(name = "from", length = 30) | @Column(name = "from", length = 30) | ||||
| private LocalDate from; | private LocalDate from; | ||||
| @NotNull | |||||
| @Column(name = "to", length = 30) | @Column(name = "to", length = 30) | ||||
| private LocalDate to; | private LocalDate to; | ||||
| @@ -43,4 +42,8 @@ public class TeamLog extends BaseEntity<Long> { | |||||
| public LocalDate getFrom() { return from; } | public LocalDate getFrom() { return from; } | ||||
| public void setFrom(LocalDate from) { this.from = from; } | public void setFrom(LocalDate from) { this.from = from; } | ||||
| public LocalDate getTo() { return to; } | |||||
| public void setTo(LocalDate to) { this.to = to; } | |||||
| } | } | ||||
| @@ -1,11 +1,11 @@ | |||||
| package com.ffii.tsms.modules.data.entity; | package com.ffii.tsms.modules.data.entity; | ||||
| import com.ffii.core.support.AbstractRepository; | import com.ffii.core.support.AbstractRepository; | ||||
| import com.ffii.tsms.modules.data.entity.projections.PositionLogInfo; | |||||
| import com.ffii.tsms.modules.data.entity.projections.TeamLogInfo; | import com.ffii.tsms.modules.data.entity.projections.TeamLogInfo; | ||||
| import java.util.List; | import java.util.List; | ||||
| public interface TeamLogRepository extends AbstractRepository<TeamLog, Long> { | public interface TeamLogRepository extends AbstractRepository<TeamLog, Long> { | ||||
| List<TeamLogInfo> findTeamLogInfoByStaffIdAndDeletedFalse(Long staffId); | |||||
| List<TeamLogInfo> findTeamLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| TeamLog findFirstByStaffIdAndDeletedFalseOrderByCreatedDesc(Long staffId); | |||||
| } | } | ||||
| @@ -3,9 +3,11 @@ package com.ffii.tsms.modules.data.entity.projections | |||||
| import com.ffii.tsms.modules.data.entity.Grade | import com.ffii.tsms.modules.data.entity.Grade | ||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||
| import java.time.LocalDate | import java.time.LocalDate | ||||
| import java.time.LocalDateTime | |||||
| interface GradeLogInfo { | interface GradeLogInfo { | ||||
| val id: Long | val id: Long | ||||
| val created: LocalDateTime | |||||
| @get:Value("#{target.staff.id}") | @get:Value("#{target.staff.id}") | ||||
| val staffId: Long | val staffId: Long | ||||
| @@ -2,9 +2,11 @@ package com.ffii.tsms.modules.data.entity.projections | |||||
| import com.ffii.tsms.modules.data.entity.Position | import com.ffii.tsms.modules.data.entity.Position | ||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||
| import java.time.LocalDate | import java.time.LocalDate | ||||
| import java.time.LocalDateTime | |||||
| interface PositionLogInfo { | interface PositionLogInfo { | ||||
| val id: Long | val id: Long | ||||
| val created: LocalDateTime | |||||
| @get:Value("#{target.staff.id}") | @get:Value("#{target.staff.id}") | ||||
| val staffId: Long | val staffId: Long | ||||
| @@ -4,6 +4,7 @@ import com.ffii.tsms.modules.data.entity.Grade | |||||
| import com.ffii.tsms.modules.data.entity.Team | import com.ffii.tsms.modules.data.entity.Team | ||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||
| import java.time.LocalDate | import java.time.LocalDate | ||||
| import java.time.LocalDateTime | |||||
| interface TeamInfo { | interface TeamInfo { | ||||
| val id: Long | val id: Long | ||||
| @@ -23,6 +24,7 @@ interface TeamInfo { | |||||
| interface TeamLogInfo { | interface TeamLogInfo { | ||||
| val id: Long | val id: Long | ||||
| val created: LocalDateTime | |||||
| @get:Value("#{target.staff.id}") | @get:Value("#{target.staff.id}") | ||||
| val staffId: Long | val staffId: Long | ||||
| @@ -15,7 +15,7 @@ open class GradeLogService( | |||||
| private val jdbcDao: JdbcDao, | private val jdbcDao: JdbcDao, | ||||
| ) : AbstractBaseEntityService<GradeLog, Long, GradeLogRepository>(jdbcDao, gradeLogRepository) { | ) : AbstractBaseEntityService<GradeLog, Long, GradeLogRepository>(jdbcDao, gradeLogRepository) { | ||||
| open fun allGradeLog(staffId: Long): List<GradeLogInfo> { | open fun allGradeLog(staffId: Long): List<GradeLogInfo> { | ||||
| return gradeLogRepository.findGradeLogInfoByStaffIdAndDeletedFalse(staffId) | |||||
| return gradeLogRepository.findGradeLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(staffId).drop(1) | |||||
| } | } | ||||
| } | } | ||||
| @@ -15,6 +15,6 @@ open class PositionLogService ( | |||||
| private val jdbcDao: JdbcDao, | private val jdbcDao: JdbcDao, | ||||
| ) : AbstractBaseEntityService<PositionLog, Long, PositionLogRepository>(jdbcDao, positionLogRepository) { | ) : AbstractBaseEntityService<PositionLog, Long, PositionLogRepository>(jdbcDao, positionLogRepository) { | ||||
| open fun allPositionLog(staffId: Long): List<PositionLogInfo> { | open fun allPositionLog(staffId: Long): List<PositionLogInfo> { | ||||
| return positionLogRepository.findPositionLogInfoByStaffIdAndDeletedFalse(staffId) | |||||
| return positionLogRepository.findPositionLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(staffId).drop(1) | |||||
| } | } | ||||
| } | } | ||||
| @@ -28,9 +28,12 @@ open class StaffsService( | |||||
| private val staffRepository: StaffRepository, | private val staffRepository: StaffRepository, | ||||
| private val userRepository: UserRepository, | private val userRepository: UserRepository, | ||||
| private val positionRepository: PositionRepository, | private val positionRepository: PositionRepository, | ||||
| private val positionLogRepository: PositionLogRepository, | |||||
| private val companyRepository: CompanyRepository, | private val companyRepository: CompanyRepository, | ||||
| private val gradeRepository: GradeRepository, | private val gradeRepository: GradeRepository, | ||||
| private val gradeLogRepository: GradeLogRepository, | |||||
| private val teamRepository: TeamRepository, | private val teamRepository: TeamRepository, | ||||
| private val teamLogRepository: TeamLogRepository, | |||||
| private val skillRepository: SkillRepository, | private val skillRepository: SkillRepository, | ||||
| private val salaryRepository: SalaryRepository, | private val salaryRepository: SalaryRepository, | ||||
| private val salaryEffectiveRepository: SalaryEffectiveRepository, | private val salaryEffectiveRepository: SalaryEffectiveRepository, | ||||
| @@ -49,7 +52,7 @@ open class StaffsService( | |||||
| open fun allStaff(): List<StaffSearchInfo> { | open fun allStaff(): List<StaffSearchInfo> { | ||||
| return staffRepository.findStaffSearchInfoByAndDeletedFalseOrderByStaffIdAsc(); | return staffRepository.findStaffSearchInfoByAndDeletedFalseOrderByStaffIdAsc(); | ||||
| } | } | ||||
| open fun StaffWithoutTeam(): List<StaffSearchInfo> { | |||||
| open fun staffWithoutTeam(): List<StaffSearchInfo> { | |||||
| return staffRepository.findStaffSearchInfoByAndDeletedFalseAndTeamIdIsNullOrderByStaffIdAsc(); | return staffRepository.findStaffSearchInfoByAndDeletedFalseAndTeamIdIsNullOrderByStaffIdAsc(); | ||||
| } | } | ||||
| @@ -214,6 +217,45 @@ open class StaffsService( | |||||
| val salary = salaryRepository.findBySalaryPoint(salaryPoint).orElseThrow() | val salary = salaryRepository.findBySalaryPoint(salaryPoint).orElseThrow() | ||||
| val department = if (req.departmentId != null && req.departmentId > 0L) departmentRepository.findById(req.departmentId).orElseThrow() else null | 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 { | staff.apply { | ||||
| joinDate = req.joinDate | joinDate = req.joinDate | ||||
| name = req.name | name = req.name | ||||
| @@ -14,6 +14,6 @@ open class TeamLogService ( | |||||
| private val jdbcDao: JdbcDao, | private val jdbcDao: JdbcDao, | ||||
| ) : AbstractBaseEntityService<TeamLog, Long, TeamLogRepository>(jdbcDao, teamLogRepository) { | ) : AbstractBaseEntityService<TeamLog, Long, TeamLogRepository>(jdbcDao, teamLogRepository) { | ||||
| open fun allTeamLog(staffId: Long): List<TeamLogInfo> { | open fun allTeamLog(staffId: Long): List<TeamLogInfo> { | ||||
| return teamLogRepository.findTeamLogInfoByStaffIdAndDeletedFalse(staffId) | |||||
| return teamLogRepository.findTeamLogInfoByStaffIdAndDeletedFalseOrderByCreatedDesc(staffId).drop(1) | |||||
| } | } | ||||
| } | } | ||||
| @@ -29,8 +29,8 @@ class StaffsController(private val staffsService: StaffsService) { | |||||
| } | } | ||||
| @GetMapping("/noteam") | @GetMapping("/noteam") | ||||
| fun StaffWithoutTeam(): List<StaffSearchInfo> { | |||||
| return staffsService.StaffWithoutTeam() | |||||
| fun staffWithoutTeam(): List<StaffSearchInfo> { | |||||
| return staffsService.staffWithoutTeam() | |||||
| } | } | ||||
| @GetMapping("/staff-projects/{id}") | @GetMapping("/staff-projects/{id}") | ||||
| @@ -71,7 +71,6 @@ class StaffsController(private val staffsService: StaffsService) { | |||||
| } | } | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| fun saveStaff(@Valid @RequestBody newStaff: NewStaffRequest): Staff { | fun saveStaff(@Valid @RequestBody newStaff: NewStaffRequest): Staff { | ||||
| println("---------------------------------------------------------") | |||||
| return staffsService.saveOrUpdate(newStaff) | return staffsService.saveOrUpdate(newStaff) | ||||
| } | } | ||||
| } | } | ||||
| @@ -38,11 +38,35 @@ data class NewStaffRequest( | |||||
| val departReason: String?, | val departReason: String?, | ||||
| val remark: String?, | val remark: String?, | ||||
| val salaryEffectiveInfo: List<SalaryEffectiveInfo>?, | val salaryEffectiveInfo: List<SalaryEffectiveInfo>?, | ||||
| val delSalaryEffectiveInfo: List<Long>? | |||||
| val teamHistory: List<TeamHistory>?, | |||||
| val gradeHistory: List<GradeHistory>?, | |||||
| val positionHistory: List<PositionHistory>?, | |||||
| val delSalaryEffectiveInfo: List<Long>?, | |||||
| val delTeamHistory: List<Long>?, | |||||
| val delGradeHistory: List<Long>?, | |||||
| val delPositionHistory: List<Long>?, | |||||
| ) | ) | ||||
| data class SalaryEffectiveInfo( | data class SalaryEffectiveInfo( | ||||
| val id: Long, | val id: Long, | ||||
| val salaryPoint: Long, | val salaryPoint: Long, | ||||
| val date: LocalDate | val date: LocalDate | ||||
| ) | |||||
| data class TeamHistory( | |||||
| val id: Long, | |||||
| val team: Long, | |||||
| val from: LocalDate, | |||||
| val to: LocalDate? | |||||
| ) | |||||
| data class GradeHistory( | |||||
| val id: Long, | |||||
| val grade: Long, | |||||
| val from: LocalDate, | |||||
| val to: LocalDate? | |||||
| ) | |||||
| data class PositionHistory( | |||||
| val id: Long, | |||||
| val position: Long, | |||||
| val from: LocalDate, | |||||
| val to: LocalDate? | |||||
| ) | ) | ||||