Browse Source

1. add lock user function

2. update task & timesheet
tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1 year ago
parent
commit
e8ef84bcc0
4 changed files with 59 additions and 2 deletions
  1. +33
    -0
      src/main/java/com/ffii/tsms/modules/data/service/StaffsService.kt
  2. +1
    -1
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  3. +1
    -1
      src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt
  4. +24
    -0
      src/main/resources/db/changelog/changes/20240814_01_cyril/01_update_timesheet_and_task.sql

+ 33
- 0
src/main/java/com/ffii/tsms/modules/data/service/StaffsService.kt View File

@@ -4,16 +4,21 @@ import com.ffii.core.exception.UnprocessableEntityException
import com.ffii.core.support.AbstractBaseEntityService
import com.ffii.core.support.JdbcDao
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.projections.StaffSearchInfo
import com.ffii.tsms.modules.data.web.models.NewStaffRequest
import com.ffii.tsms.modules.data.web.models.SalaryEffectiveInfo
import com.ffii.tsms.modules.user.entity.User
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.crypto.password.PasswordEncoder
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate
import java.util.*
import kotlin.jvm.optionals.getOrNull

@@ -138,6 +143,7 @@ open class StaffsService(
name = req.name
phone1 = req.phone1
email = req.email ?: null
locked = LocalDate.now().isAfter(req.departDate)
}
)

@@ -226,6 +232,14 @@ open class StaffsService(
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.updateSalaryEffective(staff.id!!, req.salaryEffectiveInfo?.sortedBy { it.date }, req.delSalaryEffectiveInfo)

@@ -267,4 +281,23 @@ open class StaffsService(
val latestSalaryPoint = salaryEffectInfo?.maxByOrNull { it.date }?.salaryPoint
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)
}
}

+ 1
- 1
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt View File

@@ -777,7 +777,7 @@ open class ReportService(
}

createCell(2).apply {
setCellValue((project.expectedTotalFee ?: 0.0) - (project.subContractFee ?: 0.0))
setCellValue(project.expectedTotalFee ?: 0.0)
cellStyle.dataFormat = accountingStyle
}
}


+ 1
- 1
src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt View File

@@ -288,7 +288,7 @@ open class TimesheetsService(
logger.info("---------project task-------")
val projectTask = null

val nonBillableTask = taskRepository.findById(44).orElseThrow()
val nonBillableTask = taskRepository.findById(42).orElseThrow()
// process record date
logger.info("---------record date-------")
val formatter = DateTimeFormatter.ofPattern("dd-MMM-yyyy")


+ 24
- 0
src/main/resources/db/changelog/changes/20240814_01_cyril/01_update_timesheet_and_task.sql View File

@@ -0,0 +1,24 @@
-- liquibase formatted sql
-- changeset cyril:timesheet,project_task,task_template_tasks,task

UPDATE timesheet t, project_task pt1, project_task pt2
SET t.projectTaskId = pt2.id
WHERE t.projectTaskId = pt1.id and t.projectId = pt2.project_id and pt2.task_id = 44 and (pt1.task_id = 42 or pt1.task_id = 43);

UPDATE timesheet SET nonBillableTaskId = 42 where nonBillableTaskId in (43, 44);

DELETE FROM project_task WHERE task_id in (42, 43);

UPDATE project_task SET task_id = 42 WHERE task_id = 44;

DELETE FROM task_template_tasks WHERE tasksId in (42, 43);

UPDATE task_template_tasks SET tasksId = 42 WHERE tasksId = 44;

DELETE FROM task
WHERE id=43;
DELETE FROM task
WHERE id=44;
UPDATE task
SET name='5.9 Others and remain fast time input'
WHERE id=42;

Loading…
Cancel
Save