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