From 43cdc41b717bdacc5301fe2b6a6db0e1f68ccc7c Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Thu, 24 Jul 2025 18:29:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E5=81=87=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BusLeaveServiceImpl.java | 26 ++++++++++++++---- .../domain/enums/SysNotificationsEnum.java | 27 +++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/enums/SysNotificationsEnum.java diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusLeaveServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusLeaveServiceImpl.java index 96746f6..bafbdc5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusLeaveServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.HttpStatus; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.DateUtils; @@ -16,7 +17,6 @@ import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.contractor.domain.SubConstructionUser; import org.dromara.contractor.domain.enums.SubConstructionUserRoleEnum; import org.dromara.contractor.service.ISubConstructionUserService; -import org.dromara.contractor.service.ISubContractorService; import org.dromara.project.domain.BusAttendance; import org.dromara.project.domain.BusLeave; import org.dromara.project.domain.BusProjectTeam; @@ -31,6 +31,9 @@ import org.dromara.project.service.IBusAttendanceService; import org.dromara.project.service.IBusLeaveService; import org.dromara.project.service.IBusProjectTeamMemberService; import org.dromara.project.service.IBusProjectTeamService; +import org.dromara.system.domain.dto.notifications.SysNotificationsCreateBatchReq; +import org.dromara.system.domain.enums.SysNotificationsEnum; +import org.dromara.system.service.SysNotificationsService; import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -46,6 +49,7 @@ import java.util.stream.Collectors; * @author lilemy * @date 2025-04-08 */ +@Slf4j @Service public class BusLeaveServiceImpl extends ServiceImpl implements IBusLeaveService { @@ -60,7 +64,7 @@ public class BusLeaveServiceImpl extends ServiceImpl private ISubConstructionUserService constructionUserService; @Resource - private ISubContractorService contractorService; + private SysNotificationsService notificationsService; @Lazy @Resource @@ -153,8 +157,20 @@ public class BusLeaveServiceImpl extends ServiceImpl .eq(SubConstructionUser::getContractorId, oldLeave.getContractorId()) .eq(SubConstructionUser::getUserRole, SubConstructionUserRoleEnum.ADMIN.getValue()) .list(); - if (CollUtil.isNotEmpty(constructionAdminUsers)){ - + if (CollUtil.isNotEmpty(constructionAdminUsers)) { + SysNotificationsCreateBatchReq notifications = new SysNotificationsCreateBatchReq(); + List idList = constructionAdminUsers.stream().map(SubConstructionUser::getUserId).toList(); + notifications.setRecipientIds(idList); + notifications.setSenderId(constructionUser.getUserId()); + notifications.setType(SysNotificationsEnum.LEVEL_REVIEW.getCode()); + notifications.setTitle(SysNotificationsEnum.LEVEL_REVIEW.getDescription()); + notifications.setContent(SysNotificationsEnum.LEVEL_REVIEW.getDescription()); + // todo 跳转页面 +// notifications.setActionUrl(); + Boolean sendBatch = notificationsService.sendBatch(notifications); + if (!sendBatch) { + throw new ServiceException("通知发送失败", HttpStatus.ERROR); + } } return true; } @@ -344,7 +360,7 @@ public class BusLeaveServiceImpl extends ServiceImpl Long teamId = leave.getTeamId(); String teamName = null; if (teamIdTeamMap.containsKey(teamId)) { - teamName = projectTeamService.getVo(teamIdTeamMap.get(teamId).get(0)).getTeamName(); + teamName = projectTeamService.getVo(teamIdTeamMap.get(teamId).getFirst()).getTeamName(); } leaveVo.setTeamName(teamName); // 添加审核状态 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/enums/SysNotificationsEnum.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/enums/SysNotificationsEnum.java new file mode 100644 index 0000000..9dc5375 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/enums/SysNotificationsEnum.java @@ -0,0 +1,27 @@ +package org.dromara.system.domain.enums; + +import lombok.Getter; + +/** + * @author lilemy + * @date 2025-07-24 17:50 + */ +@Getter +public enum SysNotificationsEnum { + + LEVEL_REVIEW("1", "请假审批", "您有一条新的请假申请需要审核"), + REISSUE_CARD_REVIEW("2", "补卡审批", ""); + + private final String code; + + private final String message; + + private final String description; + + SysNotificationsEnum(String code, String message, String description) { + this.code = code; + this.message = message; + this.description = description; + } + +}