退伍复学-企业消息推送
This commit is contained in:
@@ -104,8 +104,8 @@ public class SysDisBasicController extends BaseController {
|
|||||||
for (SysDisMate mate : item.getMaList()){
|
for (SysDisMate mate : item.getMaList()){
|
||||||
dao1.setOldgrade(mate.getOldgrade());
|
dao1.setOldgrade(mate.getOldgrade());
|
||||||
dao1.setOldmajor(mate.getOldmajor());
|
dao1.setOldmajor(mate.getOldmajor());
|
||||||
dao1.setNewgrade(mate.getNewgrade());
|
// dao1.setNewgrade(mate.getNewgrade());
|
||||||
dao1.setNewmajor(mate.getNewmajor());
|
// dao1.setNewmajor(mate.getNewmajor());
|
||||||
dao1.setProof(baseUrl.substring(0,baseUrl.length()-1) + mate.getProof());
|
dao1.setProof(baseUrl.substring(0,baseUrl.length()-1) + mate.getProof());
|
||||||
dao1.setIdcard(baseUrl.substring(0,baseUrl.length()-1) + mate.getIdcard());
|
dao1.setIdcard(baseUrl.substring(0,baseUrl.length()-1) + mate.getIdcard());
|
||||||
dao1.setMaterial(baseUrl.substring(0,baseUrl.length()-1) + mate.getMaterial());
|
dao1.setMaterial(baseUrl.substring(0,baseUrl.length()-1) + mate.getMaterial());
|
||||||
|
|||||||
@@ -3,10 +3,15 @@ package com.srs.flowable.listener.disbasic;
|
|||||||
import com.srs.common.core.domain.entity.SysUser;
|
import com.srs.common.core.domain.entity.SysUser;
|
||||||
import com.srs.common.doman.vo.TeacherVo;
|
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.common.utils.spring.SpringUtils;
|
||||||
import com.srs.flowable.domain.DisBasic;
|
import com.srs.flowable.domain.DisBasic;
|
||||||
|
import com.srs.flowable.domain.NotificationManage;
|
||||||
import com.srs.flowable.mapper.DisBasicMapper;
|
import com.srs.flowable.mapper.DisBasicMapper;
|
||||||
import com.srs.flowable.mapper.EnlistmentReserveMapper;
|
import com.srs.flowable.mapper.EnlistmentReserveMapper;
|
||||||
|
import com.srs.flowable.mapper.LeaveMapper;
|
||||||
import com.srs.system.service.ISysUserService;
|
import com.srs.system.service.ISysUserService;
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
import org.flowable.bpmn.model.BpmnModel;
|
||||||
import org.flowable.bpmn.model.FlowNode;
|
import org.flowable.bpmn.model.FlowNode;
|
||||||
@@ -76,6 +81,8 @@ public class DiscListener implements ExecutionListener {
|
|||||||
execution.setVariable("approval", nextAssigneeId);
|
execution.setVariable("approval", nextAssigneeId);
|
||||||
execution.setVariable("currentNode", currentNodeName);
|
execution.setVariable("currentNode", currentNodeName);
|
||||||
}
|
}
|
||||||
|
// ========== 发送通知逻辑 ==========
|
||||||
|
sendApprovalNotification(execution, currentNodeName, nextAssigneeId, stId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,9 +195,6 @@ public class DiscListener implements ExecutionListener {
|
|||||||
// 暂时选择学籍管理科第一个人作为审核人
|
// 暂时选择学籍管理科第一个人作为审核人
|
||||||
return shenDataInfo.get(0).getUserId();
|
return shenDataInfo.get(0).getUserId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case "教务处主管":
|
case "教务处主管":
|
||||||
// 最后一个节点通过后 → 流程结束(无需设置负责人)
|
// 最后一个节点通过后 → 流程结束(无需设置负责人)
|
||||||
List<TeacherVo> teacherVos = sysDisBasicMapper.getShenDataInfo("教务处主管领导");
|
List<TeacherVo> 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),<a href='https://zhxg.gxsdxy.cn/wab/#/pages/Approval/index'>请点击前往处理</a>",
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -70,20 +70,6 @@ public class SysDisMateDao {
|
|||||||
@Excel(name = "原专业")
|
@Excel(name = "原专业")
|
||||||
private String oldmajor;
|
private String oldmajor;
|
||||||
|
|
||||||
/**
|
|
||||||
* 新年级
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("新年级")
|
|
||||||
@Excel(name = "新年级")
|
|
||||||
private String newgrade;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新专业
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("新专业")
|
|
||||||
@Excel(name = "新专业")
|
|
||||||
private String newmajor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退役证明
|
* 退役证明
|
||||||
*/
|
*/
|
||||||
@@ -104,22 +90,8 @@ public class SysDisMateDao {
|
|||||||
@ApiModelProperty("材料")
|
@ApiModelProperty("材料")
|
||||||
@Excel(name = "材料")
|
@Excel(name = "材料")
|
||||||
private String material;
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.srs.routine.service.impl;
|
package com.srs.routine.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.srs.routine.domain.dto.SysDisMateDao;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
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.domain.SysDisMate;
|
||||||
import com.srs.routine.service.ISysDisMateService;
|
import com.srs.routine.service.ISysDisMateService;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退伍复学材料Service业务层处理
|
* 退伍复学材料Service业务层处理
|
||||||
*
|
*
|
||||||
@@ -84,4 +88,5 @@ public class SysDisMateServiceImpl extends ServiceImpl<SysDisMateMapper,SysDisMa
|
|||||||
public int deleteSysDisMateById(Long id) {
|
public int deleteSysDisMateById(Long id) {
|
||||||
return sysDisMateMapper.deleteSysDisMateById(id);
|
return sysDisMateMapper.deleteSysDisMateById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user