diff --git a/src/main/java/com/ffii/tsms/modules/common/mail/service/MailReminderService.kt b/src/main/java/com/ffii/tsms/modules/common/mail/service/MailReminderService.kt index d425551..b058c07 100644 --- a/src/main/java/com/ffii/tsms/modules/common/mail/service/MailReminderService.kt +++ b/src/main/java/com/ffii/tsms/modules/common/mail/service/MailReminderService.kt @@ -115,7 +115,29 @@ open class MailReminderService( mailService.send(mailRequestList) } -// @Scheduled(cron = "0 0 6 7 * ?") // (SS/MM/HH/DD/MM/YY) + private fun createEmailRequestWithAdditionalInfo(content: String, emailTo: List, info: String) { + val subject = settingsService.findByName(SettingNames.TIMESHEET_MAIL_SUBJECT).orElseThrow().value + val template = settingsService.findByName(SettingNames.TIMESHEET_MAIL_TEMPLATE).orElseThrow().value + val cc = settingsService.findByName(SettingNames.TIMESHEET_MAIL_CC).orElseThrow().value.split(",") + val bcc = settingsService.findByName(SettingNames.TIMESHEET_MAIL_BCC).orElseThrow().value.split(",") + val mailRequest = MailRequest.Builder() + .subject("<$info> $subject") + .templateContent(template) + .args( + mapOf( + Pair("date", content), + ) + ) + .addTo(emailTo) + .addCc(cc) + .addBcc(bcc) + .build() + val mailRequestList = mutableListOf() + mailRequestList += mailRequest + mailService.send(mailRequestList) + } + + @Scheduled(cron = "0 0 6 7 * ?") // (SS/MM/HH/DD/MM/YY) open fun sendTimesheetToTeamLead7TH() { logger.info("-----------------------") logger.info("Scheduled Start: 7th email reminder") @@ -244,7 +266,8 @@ open class MailReminderService( .filter { it.missingDates.isNotEmpty() } } - @Scheduled(cron = "0 0 6 7 * ?") // (SS/MM/HH/DD/MM/YY) + // This function will send email to team lead with cumulative record, fallback to v1 +// @Scheduled(cron = "0 0 6 7 * ?") // (SS/MM/HH/DD/MM/YY) open fun sendMissingTimesheetDateToTeamLead7th(){ logger.info("-----------------------") logger.info("Scheduled Start: 7th email reminder V2") @@ -733,6 +756,15 @@ open class MailReminderService( } println(fullLog) } + } + open fun testEmail() { + logger.info("-----------------------") + logger.info("Test Email Reminder: Email name and cc") + val intro = StringBuilder("Jason, Staffs Missing Timesheet in the Table Below: \n") + val emailContent = intro + val receiver = listOf("jason.tom@2fi-solutions.com.hk") + createEmailRequestWithAdditionalInfo(emailContent.toString(), receiver, "Group") } + } \ No newline at end of file diff --git a/src/main/java/com/ffii/tsms/modules/common/mail/web/MailController.kt b/src/main/java/com/ffii/tsms/modules/common/mail/web/MailController.kt index 385b3eb..e38e371 100644 --- a/src/main/java/com/ffii/tsms/modules/common/mail/web/MailController.kt +++ b/src/main/java/com/ffii/tsms/modules/common/mail/web/MailController.kt @@ -37,7 +37,7 @@ class MailController( } @GetMapping("/test7th") fun test7th() { - mailReminderService.sendMissingTimesheetDateToTeamLead7th() + mailReminderService.sendTimesheetToTeamLead7TH() } @GetMapping("/test15th") fun test15th() { @@ -53,4 +53,9 @@ class MailController( fun test15thStaffList(){ mailReminderService.test15thStaffList() } + + @GetMapping("/test-email") + fun testEmail(){ + mailReminderService.testEmail() + } } \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250807_01_jasonT/01_add_authority_maintain_all_projects.sql b/src/main/resources/db/changelog/changes/20250807_01_jasonT/01_add_authority_maintain_all_projects.sql new file mode 100644 index 0000000..bef39de --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250807_01_jasonT/01_add_authority_maintain_all_projects.sql @@ -0,0 +1,6 @@ +-- liquibase formatted sql +-- changeset jasonT:add_authories_records_maintain_all_projects + +INSERT INTO `authority` (`authority`, `name`) VALUES +('MAINTAIN_ALL_PROJECTS', 'maintain all projects'); + diff --git a/src/main/resources/db/changelog/changes/20250807_01_jasonT/02_add_authority_generate_project_manhour.sql b/src/main/resources/db/changelog/changes/20250807_01_jasonT/02_add_authority_generate_project_manhour.sql new file mode 100644 index 0000000..1e831e5 --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250807_01_jasonT/02_add_authority_generate_project_manhour.sql @@ -0,0 +1,6 @@ +-- liquibase formatted sql +-- changeset jasonT:add_authories_records_maintain_all_projects + +INSERT INTO `authority` (`authority`, `name`) VALUES +('G_PROJ_MANHOUR_SUMMARY_MONTHLY_R', 'generate project manhour summary monthly report'); + diff --git a/src/main/resources/db/changelog/changes/20250807_01_jasonT/03_add_authority_generate_project_manhour_daily.sql b/src/main/resources/db/changelog/changes/20250807_01_jasonT/03_add_authority_generate_project_manhour_daily.sql new file mode 100644 index 0000000..528404d --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250807_01_jasonT/03_add_authority_generate_project_manhour_daily.sql @@ -0,0 +1,5 @@ +-- liquibase formatted sql +-- changeset jasonT:add_authories_records_daily_report + +INSERT INTO `authority` (`authority`, `name`) VALUES +('G_PROJ_MANHOUR_SUMMARY_DAILY_R', 'generate project manhour summary daily report'); \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250807_01_jasonT/04_add_authority_generate_last_modify_report.sql b/src/main/resources/db/changelog/changes/20250807_01_jasonT/04_add_authority_generate_last_modify_report.sql new file mode 100644 index 0000000..ff5f9ba --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250807_01_jasonT/04_add_authority_generate_last_modify_report.sql @@ -0,0 +1,5 @@ +-- liquibase formatted sql +-- changeset jasonT:add_authories_records_last_modified + +INSERT INTO `authority` (`authority`, `name`) VALUES +('G_LAST_MODIFIED_REPORT', 'generate last modified report'); \ No newline at end of file