生日提醒任务增强功能
在生日提醒任务中,新增合同到期提醒功能。系统将检查当前日期,如果用户的合同到期,将通过订阅消息发送公司通知。同时,优化了生日提醒逻辑,现在可以直接传递用户列表,而不是角色ID,以提高处理效率。 此外,修正了正面提醒和生日提醒方法中错误的消息类型参数,确保现在发送的是统一的"formal"类型公司通知。
This commit is contained in:
parent
a5d7dba43d
commit
384f443111
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.job.birthday;
|
package cn.iocoder.yudao.module.system.job.birthday;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||||
@ -66,17 +67,46 @@ public class BirthdayJob {
|
|||||||
// 获取提醒时长
|
// 获取提醒时长
|
||||||
Integer remindDuration = object.getInt("remindDuration");
|
Integer remindDuration = object.getInt("remindDuration");
|
||||||
|
|
||||||
|
Set<Long> userIds = permissionService.getUserRoleIdListByRoleId(CollectionUtils.singleton(roleId));
|
||||||
|
//获得用户组中 用户信息
|
||||||
|
List<AdminUserDO> userDOs = userService.getUserList(userIds);
|
||||||
|
|
||||||
// 生日提醒
|
// 生日提醒
|
||||||
birthdayRemind(roleId);
|
birthdayRemind(userDOs);
|
||||||
|
|
||||||
// 转正提醒
|
// 转正提醒
|
||||||
PositiveReminders(remindDuration);
|
PositiveReminders(remindDuration);
|
||||||
|
|
||||||
|
// 合同到期提醒
|
||||||
|
ContractReminders(userDOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回执行成功
|
// 返回执行成功
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同到期提醒
|
||||||
|
*/
|
||||||
|
private void ContractReminders(List<AdminUserDO> userDOs) {
|
||||||
|
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
List<LaborContractDO> laborContractDOS = laborContractService.getListByEndTime(now);
|
||||||
|
if (CollectionUtil.isNotEmpty(laborContractDOS)) {
|
||||||
|
|
||||||
|
// 修改合同状态为过期
|
||||||
|
laborContractService.updateLaborContractList(convertList(laborContractDOS, LaborContractDO::getId), 2);
|
||||||
|
|
||||||
|
for (AdminUserDO adminUserDO : userDOs) {
|
||||||
|
if( adminUserDO.getOpenId() != null && !adminUserDO.getOpenId().isEmpty()) {
|
||||||
|
|
||||||
|
subscribeMessageSendApi.sendCompanyNotice(NoticeConvert.INSTANCE.convertBirthday(
|
||||||
|
"contract", adminUserDO.getOpenId(), "formal"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转正提醒
|
* 转正提醒
|
||||||
*/
|
*/
|
||||||
@ -99,8 +129,8 @@ public class BirthdayJob {
|
|||||||
for (AdminUserDO adminUserDO : positiveUserList) {
|
for (AdminUserDO adminUserDO : positiveUserList) {
|
||||||
if( adminUserDO.getOpenId() != null && !adminUserDO.getOpenId().isEmpty()) {
|
if( adminUserDO.getOpenId() != null && !adminUserDO.getOpenId().isEmpty()) {
|
||||||
|
|
||||||
subscribeMessageSendApi.sendCompanyNotice(NoticeConvert.INSTANCE.convertRegular(
|
subscribeMessageSendApi.sendCompanyNotice(NoticeConvert.INSTANCE.convertBirthday(
|
||||||
adminUserDO.getOpenId(), "formal"));
|
"regular", adminUserDO.getOpenId(), "formal"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +140,7 @@ public class BirthdayJob {
|
|||||||
/**
|
/**
|
||||||
* 生日提醒
|
* 生日提醒
|
||||||
*/
|
*/
|
||||||
private void birthdayRemind(Long roleId) {
|
private void birthdayRemind(List<AdminUserDO> userDOs) {
|
||||||
|
|
||||||
if (roleId != null) {
|
|
||||||
|
|
||||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("MM-dd"));
|
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("MM-dd"));
|
||||||
// -- 获取当天月日 生日的人员列表
|
// -- 获取当天月日 生日的人员列表
|
||||||
@ -120,14 +148,11 @@ public class BirthdayJob {
|
|||||||
.like(AdminUserDO::getBirthdayDay, time));
|
.like(AdminUserDO::getBirthdayDay, time));
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
|
|
||||||
Set<Long> userIds = permissionService.getUserRoleIdListByRoleId(CollectionUtils.singleton(roleId));
|
|
||||||
//获得用户组中 用户信息
|
|
||||||
List<AdminUserDO> userDOs = userService.getUserList(userIds);
|
|
||||||
for (AdminUserDO adminUserDO : userDOs) {
|
for (AdminUserDO adminUserDO : userDOs) {
|
||||||
if( adminUserDO.getOpenId() != null && !adminUserDO.getOpenId().isEmpty()) {
|
if( adminUserDO.getOpenId() != null && !adminUserDO.getOpenId().isEmpty()) {
|
||||||
|
|
||||||
subscribeMessageSendApi.sendCompanyNotice(NoticeConvert.INSTANCE.convertBirthday(
|
subscribeMessageSendApi.sendCompanyNotice(NoticeConvert.INSTANCE.convertBirthday(
|
||||||
adminUserDO.getOpenId(), "formal"));
|
"birthday", adminUserDO.getOpenId(), "formal"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,4 +160,3 @@ public class BirthdayJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user