From 21e967a72e09238082cf5500b83f5c4b47558c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E4=B8=9C=E6=81=92?= <1747763533@qq.com> Date: Thu, 19 Mar 2026 15:48:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E4=BC=8D=E5=A4=8D=E5=AD=A6-=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routine/SysDisBasicController.java | 4 +- .../listener/disbasic/DiscListener.java | 98 ++++++++++++++++++- .../srs/routine/domain/dto/SysDisMateDao.java | 32 +----- .../service/impl/SysDisMateServiceImpl.java | 5 + .../mapper/routine/SysDisMateMapper.xml | 4 +- 5 files changed, 106 insertions(+), 37 deletions(-) diff --git a/srs-admin/src/main/java/com/srs/web/controller/routine/SysDisBasicController.java b/srs-admin/src/main/java/com/srs/web/controller/routine/SysDisBasicController.java index 24d05a7..2be457e 100644 --- a/srs-admin/src/main/java/com/srs/web/controller/routine/SysDisBasicController.java +++ b/srs-admin/src/main/java/com/srs/web/controller/routine/SysDisBasicController.java @@ -104,8 +104,8 @@ public class SysDisBasicController extends BaseController { for (SysDisMate mate : item.getMaList()){ dao1.setOldgrade(mate.getOldgrade()); dao1.setOldmajor(mate.getOldmajor()); - dao1.setNewgrade(mate.getNewgrade()); - dao1.setNewmajor(mate.getNewmajor()); +// dao1.setNewgrade(mate.getNewgrade()); +// dao1.setNewmajor(mate.getNewmajor()); dao1.setProof(baseUrl.substring(0,baseUrl.length()-1) + mate.getProof()); dao1.setIdcard(baseUrl.substring(0,baseUrl.length()-1) + mate.getIdcard()); dao1.setMaterial(baseUrl.substring(0,baseUrl.length()-1) + mate.getMaterial()); diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/disbasic/DiscListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/disbasic/DiscListener.java index 73e2be3..499c03f 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/disbasic/DiscListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/disbasic/DiscListener.java @@ -3,10 +3,15 @@ package com.srs.flowable.listener.disbasic; import com.srs.common.core.domain.entity.SysUser; import com.srs.common.doman.vo.TeacherVo; +import com.srs.common.utils.DateUtils; +import com.srs.common.utils.SecurityUtils; +import com.srs.common.utils.WeChatUtil; import com.srs.common.utils.spring.SpringUtils; import com.srs.flowable.domain.DisBasic; +import com.srs.flowable.domain.NotificationManage; import com.srs.flowable.mapper.DisBasicMapper; import com.srs.flowable.mapper.EnlistmentReserveMapper; +import com.srs.flowable.mapper.LeaveMapper; import com.srs.system.service.ISysUserService; import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.FlowNode; @@ -76,6 +81,8 @@ public class DiscListener implements ExecutionListener { execution.setVariable("approval", nextAssigneeId); execution.setVariable("currentNode", currentNodeName); } + // ========== 发送通知逻辑 ========== + sendApprovalNotification(execution, currentNodeName, nextAssigneeId, stId); } /** @@ -188,9 +195,6 @@ public class DiscListener implements ExecutionListener { // 暂时选择学籍管理科第一个人作为审核人 return shenDataInfo.get(0).getUserId(); - - - case "教务处主管": // 最后一个节点通过后 → 流程结束(无需设置负责人) List teacherVos = sysDisBasicMapper.getShenDataInfo("教务处主管领导"); @@ -207,4 +211,92 @@ public class DiscListener implements ExecutionListener { } } + /** + * 发送审批通知(系统通知+企业微信通知) + * 适配DisBasic(退伍复学)业务场景 + */ + private void sendApprovalNotification(DelegateExecution execution, String currentNodeName, + Long nextAssigneeId, Long basicId) { + try { + // 1. 获取需要的Mapper和工具类(通过SpringUtils获取,避免Autowired循环依赖) + LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 2. 查询退伍复学申请详情 + DisBasicMapper disBasicMapper = (DisBasicMapper) SpringUtils.getBean(DisBasicMapper.class); + DisBasic disBasic = disBasicMapper.selectSysDisBasicById(basicId); + if (disBasic == null) { + log.warn("未找到退伍复学申请记录,basicId:{}", basicId); + return; + } + + // 3. 查询下一个审批人的信息 + SysUser nextApprover = sysUserService.selectUserById(nextAssigneeId); + if (nextApprover == null) { + log.warn("未找到审批人信息,用户ID:{}", nextAssigneeId); + return; + } + String approverUserName = nextApprover.getUserName(); // 审批人工号/用户名 + String approverName = nextApprover.getNickName(); // 审批人姓名 + + log.info("开始发送【退伍复学审批】通知,审批节点:{},审批人:{}({}),申请ID:{}", + currentNodeName, approverName, approverUserName, basicId); + + // 4. 处理系统通知(先删后加,避免重复通知) + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent(String.format("您有一条【退伍复学审批】待处理(节点:%s)", currentNodeName)); + notificationManage.setReceiver(nextAssigneeId); // 接收人:下一个审批人 + + // 4.1 查询是否已有相同通知,有则删除 + NotificationManage existNotify = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (existNotify != null) { + int delRes = leaveMapper.deleteCphMsgById(existNotify.getId()); + log.info("删除重复的系统通知,通知ID:{},删除结果:{}", existNotify.getId(), delRes); + } + + // 4.2 添加新的系统通知 + notificationManage.setSender(SecurityUtils.getUserId()); // 发送人:当前操作人 + notificationManage.setCreateTime(DateUtils.getNowDate()); // 创建时间 + int addRes = leaveMapper.insertCphMsg(notificationManage); + log.info("新增系统通知成功,接收人ID:{},添加结果:{}", nextAssigneeId, addRes); + + // 5. 企业微信推送消息(带超链接) + if (approverUserName != null && !approverUserName.isEmpty()) { + String weChatContent = String.format( + "您有一条【退伍复学审批】待处理(节点:%s),请点击前往处理", + currentNodeName + ); + weChatUtil.sendTextMessage(approverUserName, weChatContent); + log.info("企业微信通知发送成功,接收人工号:{},节点:{},申请ID:{}", approverUserName, currentNodeName, basicId); + } else { + log.warn("审批人工号为空,无法发送企业微信通知,用户ID:{},申请ID:{}", nextAssigneeId, basicId); + } + + // 6. 删除当前审批人的待处理通知(清理已处理的待办) + Long currentApproverId = SecurityUtils.getUserId(); + if (currentApproverId == null) { + log.warn("当前审批人ID为空,无法删除其待处理通知,申请ID:{}", basicId); + return; + } + + NotificationManage currentNotifyQuery = new NotificationManage(); + currentNotifyQuery.setContent(String.format("您有一条【退伍复学审批】待处理(节点:%s)", currentNodeName)); + currentNotifyQuery.setReceiver(currentApproverId); + + NotificationManage currentExistNotify = leaveMapper.selectCphMsgListForFlowable(currentNotifyQuery); + if (currentExistNotify != null) { + int currentDelRes = leaveMapper.deleteCphMsgById(currentExistNotify.getId()); + log.info("删除当前审批人({})的【{}】待处理通知,通知ID:{},删除结果:{},申请ID:{}", + currentApproverId, currentNodeName, currentExistNotify.getId(), currentDelRes, basicId); + } else { + log.info("当前审批人({})无【{}】节点的待处理通知,无需删除,申请ID:{}", currentApproverId, currentNodeName, basicId); + } + + } catch (Exception e) { + // 捕获所有异常,仅记录日志,不影响主流程 + log.error("发送退伍复学审批通知失败,节点:{},审批人ID:{},申请ID:{},错误信息:{}", + currentNodeName, nextAssigneeId, basicId, e.getMessage(), e); + } + } + } \ No newline at end of file diff --git a/srs-routine/src/main/java/com/srs/routine/domain/dto/SysDisMateDao.java b/srs-routine/src/main/java/com/srs/routine/domain/dto/SysDisMateDao.java index 5e95791..5810b09 100644 --- a/srs-routine/src/main/java/com/srs/routine/domain/dto/SysDisMateDao.java +++ b/srs-routine/src/main/java/com/srs/routine/domain/dto/SysDisMateDao.java @@ -70,20 +70,6 @@ public class SysDisMateDao { @Excel(name = "原专业") private String oldmajor; - /** - * 新年级 - */ - @ApiModelProperty("新年级") - @Excel(name = "新年级") - private String newgrade; - - /** - * 新专业 - */ - @ApiModelProperty("新专业") - @Excel(name = "新专业") - private String newmajor; - /** * 退役证明 */ @@ -104,22 +90,8 @@ public class SysDisMateDao { @ApiModelProperty("材料") @Excel(name = "材料") private String material; -// -// /** -// * 保留字段1 -// */ -// @ApiModelProperty("保留字段1") -// @TableField("data1") -// @Excel(name = "保留字段1") -// private String data1; -// -// /** -// * 保留字段2 -// */ -// @ApiModelProperty("保留字段2") -// @TableField("data2") -// @Excel(name = "保留字段2") -// private String data2; + + } diff --git a/srs-routine/src/main/java/com/srs/routine/service/impl/SysDisMateServiceImpl.java b/srs-routine/src/main/java/com/srs/routine/service/impl/SysDisMateServiceImpl.java index 4311aba..f86bfeb 100644 --- a/srs-routine/src/main/java/com/srs/routine/service/impl/SysDisMateServiceImpl.java +++ b/srs-routine/src/main/java/com/srs/routine/service/impl/SysDisMateServiceImpl.java @@ -1,6 +1,8 @@ package com.srs.routine.service.impl; import java.util.List; + +import com.srs.routine.domain.dto.SysDisMateDao; import org.springframework.beans.factory.annotation.Autowired; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -8,6 +10,8 @@ import com.srs.routine.mapper.SysDisMateMapper; import com.srs.routine.domain.SysDisMate; import com.srs.routine.service.ISysDisMateService; +import javax.servlet.http.HttpServletResponse; + /** * 退伍复学材料Service业务层处理 * @@ -84,4 +88,5 @@ public class SysDisMateServiceImpl extends ServiceImpl and finallabel = #{finallabel} - + - + insert into sys_dis_mate