|
@@ -4,16 +4,21 @@ import com.ffii.core.exception.UnprocessableEntityException |
|
|
import com.ffii.core.support.AbstractBaseEntityService |
|
|
import com.ffii.core.support.AbstractBaseEntityService |
|
|
import com.ffii.core.support.JdbcDao |
|
|
import com.ffii.core.support.JdbcDao |
|
|
import com.ffii.tsms.modules.common.SecurityUtils |
|
|
import com.ffii.tsms.modules.common.SecurityUtils |
|
|
|
|
|
import com.ffii.tsms.modules.common.SettingNames |
|
|
|
|
|
import com.ffii.tsms.modules.common.mail.pojo.MailRequest |
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo |
|
|
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo |
|
|
import com.ffii.tsms.modules.data.web.models.NewStaffRequest |
|
|
import com.ffii.tsms.modules.data.web.models.NewStaffRequest |
|
|
import com.ffii.tsms.modules.data.web.models.SalaryEffectiveInfo |
|
|
import com.ffii.tsms.modules.data.web.models.SalaryEffectiveInfo |
|
|
import com.ffii.tsms.modules.user.entity.User |
|
|
import com.ffii.tsms.modules.user.entity.User |
|
|
import com.ffii.tsms.modules.user.entity.UserRepository |
|
|
import com.ffii.tsms.modules.user.entity.UserRepository |
|
|
|
|
|
import jakarta.mail.internet.InternetAddress |
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled |
|
|
import org.springframework.security.core.GrantedAuthority |
|
|
import org.springframework.security.core.GrantedAuthority |
|
|
import org.springframework.security.crypto.password.PasswordEncoder |
|
|
import org.springframework.security.crypto.password.PasswordEncoder |
|
|
import org.springframework.stereotype.Service |
|
|
import org.springframework.stereotype.Service |
|
|
import org.springframework.transaction.annotation.Transactional |
|
|
import org.springframework.transaction.annotation.Transactional |
|
|
|
|
|
import java.time.LocalDate |
|
|
import java.util.* |
|
|
import java.util.* |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
|
|
|
|
|
@@ -138,6 +143,7 @@ open class StaffsService( |
|
|
name = req.name |
|
|
name = req.name |
|
|
phone1 = req.phone1 |
|
|
phone1 = req.phone1 |
|
|
email = req.email ?: null |
|
|
email = req.email ?: null |
|
|
|
|
|
locked = LocalDate.now().isAfter(req.departDate) |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@@ -226,6 +232,14 @@ open class StaffsService( |
|
|
this.department = department |
|
|
this.department = department |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (req.departDate != null) { |
|
|
|
|
|
val user = userRepository.findByUsernameAndDeletedFalse(req.staffId).orElseThrow() |
|
|
|
|
|
user.apply { |
|
|
|
|
|
locked = LocalDate.now().isAfter(req.departDate) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userRepository.save(user) |
|
|
|
|
|
} |
|
|
// salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.salaryPoint.toLong()) |
|
|
// salaryEffectiveService.saveSalaryEffective(staff.id!!, salary.salaryPoint.toLong()) |
|
|
salaryEffectiveService.updateSalaryEffective(staff.id!!, req.salaryEffectiveInfo?.sortedBy { it.date }, req.delSalaryEffectiveInfo) |
|
|
salaryEffectiveService.updateSalaryEffective(staff.id!!, req.salaryEffectiveInfo?.sortedBy { it.date }, req.delSalaryEffectiveInfo) |
|
|
|
|
|
|
|
@@ -267,4 +281,23 @@ open class StaffsService( |
|
|
val latestSalaryPoint = salaryEffectInfo?.maxByOrNull { it.date }?.salaryPoint |
|
|
val latestSalaryPoint = salaryEffectInfo?.maxByOrNull { it.date }?.salaryPoint |
|
|
return latestSalaryPoint |
|
|
return latestSalaryPoint |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 0 * * ?") // Runs at 00:00 AM every day |
|
|
|
|
|
open fun checkDepartStaffs() { |
|
|
|
|
|
val staffs = staffRepository.findAll() |
|
|
|
|
|
|
|
|
|
|
|
val users = mutableListOf<User>() |
|
|
|
|
|
|
|
|
|
|
|
staffs.forEach { staff -> |
|
|
|
|
|
val user = userRepository.findByUsernameAndDeletedFalse(staff.staffId).orElseThrow() |
|
|
|
|
|
|
|
|
|
|
|
user.apply { |
|
|
|
|
|
locked = LocalDate.now().isAfter(staff.departDate) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
users += user |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userRepository.saveAll(users) |
|
|
|
|
|
} |
|
|
} |
|
|
} |