diff --git a/dms-dormitory/src/main/java/com/srs/dormitory/service/impl/ISrsDormitoryStudentServiceImpl.java b/dms-dormitory/src/main/java/com/srs/dormitory/service/impl/ISrsDormitoryStudentServiceImpl.java index 1682fdc..82ce7a0 100644 --- a/dms-dormitory/src/main/java/com/srs/dormitory/service/impl/ISrsDormitoryStudentServiceImpl.java +++ b/dms-dormitory/src/main/java/com/srs/dormitory/service/impl/ISrsDormitoryStudentServiceImpl.java @@ -843,6 +843,13 @@ public class ISrsDormitoryStudentServiceImpl extends ServiceImpl stuList = srsDormitoryStudentMapper.listSmokeEarly(teacherEmployeeId); + + List kshList = stuList.stream().map(SrsStuReg::getKSH).collect(Collectors.toList()); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("ksh",kshList); + _newRegMapper.delete(queryWrapper); + List dormList = srsDormitoryStudentMapper.listFdyCanDorm(teacherEmployeeId); // 查询所有已分配的ksh,避免重复插入 diff --git a/dms-dormitory/src/main/resources/mapper/dormitory/DmsDormitoryCheckMapper.xml b/dms-dormitory/src/main/resources/mapper/dormitory/DmsDormitoryCheckMapper.xml index e2e6bb4..88eed0b 100644 --- a/dms-dormitory/src/main/resources/mapper/dormitory/DmsDormitoryCheckMapper.xml +++ b/dms-dormitory/src/main/resources/mapper/dormitory/DmsDormitoryCheckMapper.xml @@ -93,18 +93,30 @@ - - \ No newline at end of file + diff --git a/dms-dormitory/src/main/resources/mapper/dormitory/DmsNewRegMapper.xml b/dms-dormitory/src/main/resources/mapper/dormitory/DmsNewRegMapper.xml index ff266d7..0601499 100644 --- a/dms-dormitory/src/main/resources/mapper/dormitory/DmsNewRegMapper.xml +++ b/dms-dormitory/src/main/resources/mapper/dormitory/DmsNewRegMapper.xml @@ -108,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.dormitory_id = #{dormitoryId} and b.BJDM = #{classCode} + order by a.ksh asc + select a.* + from srs_add_record as a + left join cph_iam as b on a.iam_id = b.id + where b.audit_status not in (6,12) + + + + + + + diff --git a/srs-comprehensive/src/main/resources/mapper/comprehensive/CphProRankingMapper.xml b/srs-comprehensive/src/main/resources/mapper/comprehensive/CphProRankingMapper.xml index dd83be7..844153c 100644 --- a/srs-comprehensive/src/main/resources/mapper/comprehensive/CphProRankingMapper.xml +++ b/srs-comprehensive/src/main/resources/mapper/comprehensive/CphProRankingMapper.xml @@ -55,17 +55,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - - and stu_id = #{stuId} - and stu_year_id = #{stuYearId} - and ce_score = #{ceScore} - and stu.class_id = #{student.classId} - and stu.stu_no = #{student.stuNo} - and stu.name like #{student.name} + + and stu_id = #{stuId} + and stu_year_id = #{stuYearId} + and ce_score = #{ceScore} + and stu.class_id = #{student.classId} + and stu.stu_no = #{student.stuNo} + and stu.name like #{student.name} - select id, stu_id, stu_year_id, ce_score, del_flag, create_by, create_time, update_by, update_time + select id, + stu_id, + stu_year_id, + ce_score, + del_flag, + create_by, + create_time, + update_by, + update_time from srs_ce_score - + - + insert into srs_ce_score @@ -95,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_by, update_time, stu_no - + #{stuId}, #{stuYearId}, @@ -106,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{updateBy}, #{updateTime}, #{stuNo} - + @@ -124,12 +139,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + + - delete from srs_ce_score where id = #{id} + delete + from srs_ce_score + where id = #{id} - delete from srs_ce_score where id in + delete from srs_ce_score where id in #{id} @@ -137,16 +157,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - \ No newline at end of file + diff --git a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsMajorsMapper.xml b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsMajorsMapper.xml index 5698f6c..3191fb7 100644 --- a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsMajorsMapper.xml +++ b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsMajorsMapper.xml @@ -169,4 +169,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{majorId} + + diff --git a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsStudentMapper.xml b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsStudentMapper.xml index afba5a4..60aaa7f 100644 --- a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsStudentMapper.xml +++ b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsStudentMapper.xml @@ -1,38 +1,39 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -46,106 +47,152 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - + + - - - + + + - - - - + + + + - - - - - - - + + + + + + + - - + + - select s.stu_id,s.stu_no, s.name, s.gender, s.birthday, AES_DECRYPT(UNHEX(s.id_card),'zhxg') as id_card , s.dept_id, major_id, class_id, s.phone, s.address, - s.status, s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag,s.xhk,s.bank_addr + select s.stu_id, + s.stu_no, + s.name, + s.gender, + s.birthday, + AES_DECRYPT(UNHEX(s.id_card), 'zhxg') as id_card, + s.dept_id, + major_id, + class_id, + s.phone, + s.address, + s.status, + s.create_by, + s.create_time, + s.update_by, + s.update_time, + s.del_flag, + s.xhk, + s.bank_addr from srs_student s - select s.stu_id,s.stu_no, s.name, s.gender, s.birthday,AES_DECRYPT(UNHEX(s.id_card),'zhxg') as id_card , d.dept_id, m.major_id, c.class_id, s.phone, s.address, - s.status, s.status as status2,s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag,s.xhk,s.bank_addr,e.name as cphName,f.grade_name, - d.*,m.*,c.*,g.* + select s.stu_id, + s.stu_no, + s.name, + s.gender, + s.birthday, + AES_DECRYPT(UNHEX(s.id_card), 'zhxg') as id_card, + d.dept_id, + m.major_id, + c.class_id, + s.phone, + s.address, + s.status, + s.status as status2, + s.create_by, + s.create_time, + s.update_by, + s.update_time, + s.del_flag, + s.xhk, + s.bank_addr, + e.name as cphName, + f.grade_name, + d.*, + m.*, + c.*, + g.* from srs_student s left JOIN srs_class c ON s.class_id = c.class_id left JOIN srs_majors m ON c.major_id = m.major_id left JOIN sys_dept d ON m.college_id = d.dept_id left join cph_teacher as e on c.teacher_id = e.teacher_id - left join srs_grade as f on f.grade_id=c.grade_id - left join cph_stu_extra_info g on g.stu_no=s.stu_no + left join srs_grade as f on f.grade_id = c.grade_id + left join cph_stu_extra_info g on g.stu_no = s.stu_no - + select a.stu_no, a.`name` as stu_name, b.class_name + from srs_student as a + left join srs_class as b on a.class_id = b.class_id where a.stu_no = #{stuNo} @@ -158,7 +205,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where stu_no = #{stuNo} insert into srs_student @@ -181,7 +230,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" del_flag, room_id, - + #{name}, #{stuNo}, @@ -200,7 +249,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{updateTime}, #{delFlag}, #{roomId}, - + @@ -228,7 +277,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from srs_student where stu_id = #{stuId} + delete + from srs_student + where stu_id = #{stuId} @@ -249,7 +300,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE stu_no = #{student.stuNo} - + update srs_student @@ -333,42 +384,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + select count(a.stu_no) as stu_count, b.grade_name from cph_biye_apply as a left join view_stu_info as b on a.stu_no = b.stu_no where a.apply_status = 6 GROUP BY b.grade_id - + select count(a.stu_no) as stu_count, case b.grade_name is null when true then "无年级" else b.grade_name end as grade_name, @@ -380,8 +433,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by b.grade_id - + SELECT * FROM srs_student + WHERE class_id IN + + #{classId} + + AND del_flag = '0' + + + - + select sum(b.occupancy) as all_in, + a.park_name, + a.campus_name, + sum(a.bed_num) as `all`, + (select count(t1.stu_no) from view_stu_info as t1 where t1.`status` = '01') as stu_count from view_dorm_info as a left join view_dorm_stu_count as b on a.id = b.dormitory_id GROUP BY a.park_id @@ -516,185 +588,237 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.grade_id = #{gradeId} - + select + quit_school_id,stu_no,stu_name,applicant_name,department_name,grade_name,class_name,jg,mz,quit_type,quit_category,quit_year,process_instance_id,deploy_id + from rt_stu_quit_school apply_status = 1 - and department_name=#{departmentName} - and stu_no=#{stuNo} - and stu_name=#{stuName} + and department_name=#{departmentName} + and stu_no=#{stuNo} + and stu_name=#{stuName} order by grade_name,class_name - + select + application_id,stu_no,stu_name,applicant_name,department_name,grade_name,class_name,jg,mz,penalty_type,process_instance_id,deploy_id + from rt_stu_disciplinary_application penalty_status = 0 - and department_name=#{departmentName} - and stu_no=#{stuNo} - and stu_name=#{stuName} + and department_name=#{departmentName} + and stu_no=#{stuNo} + and stu_name=#{stuName} order by grade_name,class_name - + select + drop_out_school_id,stu_no,stu_name,applicant_name,department_name,grade_name,class_name,jg,mz,quit_year,drop_out_type,drop_out_category,process_instance_id,deploy_id + from rt_stu_drop_out_school apply_status = 1 - and department_name=#{departmentName} - and stu_no=#{stuNo} - and stu_name=#{stuName} + and department_name=#{departmentName} + and stu_no=#{stuNo} + and stu_name=#{stuName} order by grade_name,class_name - select id,xh,xm,xb,mz,hjszd,bj,xy,nj,xsqmyj,apply_year from srs_knrd_apply a - where stu_year_id = (select id from srs_stu_year where status=1) and step >= 5 and xsqmyj !=4 - and xy=#{departmentName} - and xh=#{stuNo} - and xm=#{stuName} + where stu_year_id = (select id from srs_stu_year where status=1) and step >= 5 and xsqmyj !=4 + and xy=#{departmentName} + and xh=#{stuNo} + and xm=#{stuName} order by NJ desc,bj desc - + select id,xh,xm,xb,mz,dz,bj,xy,nj, kndj,apply_year from srs_zxj_apply + where stu_year_id = (select id FROM srs_stu_year where status=1) and step =4 + and xy=#{departmentName} + and xh=#{stuNo} + and xm=#{stuName} + order by NJ desc,bj desc - + select f.grade_code as gradeCode, count(1) as number + from srs_student s + left join srs_class c on s.class_id = c.class_id + left join srs_majors m on c.major_id = m.major_id + left join sys_dept d on m.college_id = d.dept_id + left join cph_teacher as e on c.teacher_id = e.teacher_id + left join srs_grade as f on f.grade_id = c.grade_id + where f.grade_code >= year (date_sub(curdate(), interval 5 year)) + group by f.grade_code + order by f.grade_code diff --git a/srs-comprehensive/src/main/resources/mapper/comprehensive/TeacherEvaluationStatusMapper.xml b/srs-comprehensive/src/main/resources/mapper/comprehensive/TeacherEvaluationStatusMapper.xml new file mode 100644 index 0000000..c0107f8 --- /dev/null +++ b/srs-comprehensive/src/main/resources/mapper/comprehensive/TeacherEvaluationStatusMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + select t.teacher_id, t.name as teacher_name, t.employee_id, + t.dept_id, d.dept_name, + y.id as stu_year_id, y.stu_year_name, + CASE + WHEN (COALESCE(todo_count.cnt, 0) = 0) AND (COALESCE(score_count.cnt, 0) > 0) + THEN 1 + ELSE 0 + END as is_completed, + COALESCE(todo_count.cnt, 0) as todo_count, + CASE WHEN COALESCE(score_count.cnt, 0) > 0 THEN 1 ELSE 0 END as score_imported + from cph_teacher t + left join sys_dept d on t.dept_id = d.dept_id + left join srs_stu_year y on 1=1 + left join ( + select c.teacher_id, COUNT(*) as cnt, ci.stu_year_id as year_id + from cph_audit_details cad + inner join cph_iam ci on cad.project_id = ci.id + inner join srs_student s on cad.submitter_id = s.stu_id + inner join srs_class c on s.class_id = c.class_id + where cad.status_code in (1, 2) + group by c.teacher_id, ci.stu_year_id + ) todo_count on t.teacher_id = todo_count.teacher_id and y.id = todo_count.year_id + left join ( + select c.teacher_id, sc.stu_year_id, COUNT(*) as cnt + from srs_class c + inner join srs_student s on c.class_id = s.class_id + inner join srs_ce_score sc on s.stu_id = sc.stu_id + group by c.teacher_id, sc.stu_year_id + ) score_count on t.teacher_id = score_count.teacher_id and y.id = score_count.stu_year_id + + + + + + + + + + + + diff --git a/srs-flowable/src/main/java/com/srs/flowable/domain/NotificationManage.java b/srs-flowable/src/main/java/com/srs/flowable/domain/NotificationManage.java new file mode 100644 index 0000000..5cb6aed --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/domain/NotificationManage.java @@ -0,0 +1,84 @@ +package com.srs.flowable.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.srs.common.core.domain.BaseEntity; +import lombok.*; + +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("srs_notification") +public class NotificationManage extends BaseEntity { + private static final long serialVersionUID=1L; + + /** + * 通知ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 通知标题 + */ + @TableField("title") + private String title; + + /** + * 通知内容 + */ + @TableField("content") + private String content; + + /** + * 年级ID列表,以逗号分隔 + */ + @TableField("grade_ids") + private String gradeIds; + + /** + * 年级名称 + */ + @TableField("gradeName") + private String gradeName; + + /** + * 发送人用户ID + */ + @TableField("sender") + private Long sender; + + /** + * 接收人用户ID(用于cph_msg表) + */ + @TableField("receiver") + private Long receiver; + + /** + * 创建者 + */ + @TableField("create_by") + private String createBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @TableField("update_by") + private String updateBy; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ) + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/BoStartListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/BoStartListener.java new file mode 100644 index 0000000..5d653e4 --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/BoStartListener.java @@ -0,0 +1,137 @@ +package com.srs.flowable.listener; + +import com.srs.common.doman.vo.TeacherVo; +import com.srs.common.utils.DateUtils; +import com.srs.common.utils.WeChatUtil; +import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.domain.NotificationManage; +import com.srs.flowable.domain.StuLeaveApplication; +import com.srs.flowable.mapper.LeaveMapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 二级学院书记审批或学生销假开始监听器 + * 邵政文 + */ +@Component +@Slf4j +public class BoStartListener implements ExecutionListener { + @Override + public void notify(DelegateExecution delegateExecution) { + LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + + String deptId = delegateExecution.getVariable("deptId").toString(); + + // 二级学院书记审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + + // 获取流程ID + String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); + + // 获取请假信息 + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); + + // 获取校领导信息 + List lingDataInfo = leaveMapper.getLingDataInfo(185362L); + + // 设置流程变量 + //delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId()); + + // todo 企业微信推送消息(邵政文) + log.info("请假信息:{}", stuLeaveApplication); + try { + log.info("二级学院书记审批或学生销假开始监听器"); + + // 步骤 3: 检查是否成功获取到 userName + //向系统发送通知 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setReceiver(lingDataInfo.get(0).getUserId()); + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + //向学工领导添加通知信息 + // 获取二级学院书记信息 + List secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId); + //由于这里查到了多个数据,由于时间原因,暂时还没有研究到工作流中多用户节点的同时进行(所以取了第一条数据用于发消息) + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setSender(secondaryLeaderInfo.get(0).getUserId()); // 发送方 + notificationManage.setReceiver(Long.parseLong(approval)); // 接收方 + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + //向企业微信发消息 + TeacherVo updateDeptId = leaveMapper.getUpdateDeptId(approval); + // 步骤 2: 使用updateDeptId.getUserName()获取辅导员工号 + String userName = updateDeptId.getUserName(); + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + //weChatUtil.sendTextMessage(userName, content); + log.info("已成功向学工领导(userName:{})发送企业微信请假审批通知。", userName); + } + return; + } + // 获取请假人id + Long stuId = (Long) delegateExecution.getVariable("stuId"); + + // 查询辅导员工信息 + TeacherVo teacherInfo = leaveMapper.getCounselorInfo(stuId); + + //查询请假人用户信息 + TeacherVo shenUserInfo = leaveMapper.getShenUserInfo(stuId); + + notificationManage.setContent("您有一条【请假人已提交销假审批】需待处理"); // 消息内容 + notificationManage.setReceiver(teacherInfo.getUserId()); + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManages.getId()); + log.info("删除成功{}", delRes); + //向请假人添加通知信息 + //由于这里查到了多个数据,由于时间原因,暂时还没有研究到工作流中多用户节点的同时进行(所以取了第一条数据用于发消息) + notificationManage.setContent("您有一条【请假申请审批已通过】需待处理"); // 消息内容 + notificationManage.setSender(teacherInfo.getUserId()); // 发送方 + notificationManage.setReceiver(shenUserInfo.getUserId()); // 接收方 + NotificationManage userMsge = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userMsge == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + //向企业微信发消息 + // 步骤 2: 使用shenUserInfo.getUserName()获取辅导员工号 + String userName = shenUserInfo.getUserName(); + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向请假人(userName:{})发送企业微信请假审批通知。", userName); + } + } + + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } + } +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/CancellationListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/CancellationListener.java index 2477c2c..f87b94e 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/CancellationListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/CancellationListener.java @@ -3,6 +3,7 @@ package com.srs.flowable.listener; import com.srs.common.utils.DateUtils; import com.srs.common.utils.SecurityUtils; import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.domain.NotificationManage; import com.srs.flowable.domain.StuLeaveApplication; import com.srs.flowable.mapper.LeaveMapper; import lombok.extern.slf4j.Slf4j; @@ -28,7 +29,6 @@ public class CancellationListener implements ExecutionListener { // 拿到流程所有参数 String approved = delegateExecution.getVariable("approved").toString(); - // 请假单id // 报错信息 String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); @@ -45,5 +45,27 @@ public class CancellationListener implements ExecutionListener { stuLeaveApplication.setUpdateTime(DateUtils.getNowDate()); leaveMapper.updateRtStuLeaveApplication(stuLeaveApplication); + + // 推送消息(邵政文) + //查询指定用户的通知信息并且删除 + log.info("辅导员处理销假审批"); + log.info("接收人为{}",approval); + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【请假人已提交销假审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); // 接收人 + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + int delRes; + if(userManage != null) { + //删除指定通知信息 + delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + if(delRes > 0) { + log.info("删除成功{}", delRes); + } else { + log.info("删除失败成功,没有要删除的消息"); + } + } + else { + log.info("没有查到通知消息,请核实是否发起了请假申请"); + } } } diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/CounselorListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/CounselorListener.java index 3a5ef48..668b3f0 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/CounselorListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/CounselorListener.java @@ -3,7 +3,9 @@ package com.srs.flowable.listener; 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.NotificationManage; import com.srs.flowable.domain.StuLeaveApplication; import com.srs.flowable.mapper.LeaveMapper; import lombok.extern.slf4j.Slf4j; @@ -22,11 +24,17 @@ public class CounselorListener implements ExecutionListener { public void notify(DelegateExecution delegateExecution) { LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + // 审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + // 获取请假人id Long stuId = (Long) delegateExecution.getVariable("stuId"); TeacherVo teacherInfo = leaveMapper.getCounselorInfo(stuId); + //查询请假人用户信息 + TeacherVo shenUserInfo = leaveMapper.getShenUserInfo(stuId); + // 把辅导员的userId放到approval中 delegateExecution.setVariable("approval", teacherInfo.getUserId()); @@ -45,10 +53,57 @@ public class CounselorListener implements ExecutionListener { leaveMapper.updateRtStuLeaveApplication(stuLeaveApplication); - // todo 企业微信推送消息 + // todo 企业微信推送消息(邵政文) + log.info("向辅导员发送企业微信销假通知。"); + try { + // 步骤 2: 获取辅导员工号teacherInfo.getUserName() + log.info("查询辅导员信息:{}", teacherInfo.getUserName()); + log.info("请假人id:{}", stuId); + //辅导员工号teacherInfo.getUserName() + String userName = teacherInfo.getUserName(); + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //查询指定用户的通知信息并且删除 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("请假申请审批"); // 消息内容 + notificationManage.setReceiver(shenUserInfo.getUserId()); // 接收人 + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + //删除指定通知信息 + if(userManage != null) { + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } - log.info("查询辅导员信息:{}", teacherInfo); + //向系统发送通知 + notificationManage.setContent("您有一条【请假人已提交销假审批】需待处理"); // 消息内容 + notificationManage.setSender(shenUserInfo.getUserId()); + notificationManage.setReceiver(teacherInfo.getUserId()); + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + } + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向辅导员(userName:{})发送企业微信销假通知。", userName); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } } } diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/LeadAuditListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadAuditListener.java index 3d7196c..378b040 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/LeadAuditListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadAuditListener.java @@ -1,17 +1,23 @@ package com.srs.flowable.listener; +import com.srs.common.doman.vo.TeacherVo; import com.srs.common.enums.ApplicationStatus; 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.NotificationManage; import com.srs.flowable.domain.StuLeaveApplication; import com.srs.flowable.mapper.LeaveMapper; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hpsf.Decimal; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.math.BigDecimal; +import java.util.List; /** * 领导审核 @@ -21,6 +27,7 @@ import java.math.BigDecimal; @Slf4j public class LeadAuditListener implements ExecutionListener { + @Override public void notify(DelegateExecution delegateExecution) { LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); @@ -36,6 +43,8 @@ public class LeadAuditListener implements ExecutionListener { // 获取请假天数 BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); + // 获取请假人id + Long stuId = (Long) delegateExecution.getVariable("stuId"); // 请假单id // 报错信息 @@ -43,6 +52,9 @@ public class LeadAuditListener implements ExecutionListener { log.info("审批结果为:", approval); + //查询请假人用户信息 + TeacherVo shenUserInfo = leaveMapper.getShenUserInfo(stuId); + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); if (stuLeaveApplication != null) { @@ -59,5 +71,91 @@ public class LeadAuditListener implements ExecutionListener { leaveMapper.updateRtStuLeaveApplication(stuLeaveApplication); log.info("审核成功"); + + //企业微信推送消息(邵政文) + try { + log.info("请假人"); + log.info("请假人数据为:{}", stuLeaveApplication); + log.info("审批结果为:{}", approval); + // 步骤 2: 发送消息的接收人stuLeaveApplication.getCreateBy() + String userName = stuLeaveApplication.getCreateBy(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //构建通知信息 + NotificationManage notificationManage = new NotificationManage(); + + // 判断请假天数 + int leaveDay = leaveDays.intValue(); + // 向系统发送通知 + if(leaveDay >= 4 && leaveDay <= 7) { + //查询指定用户的通知信息 + notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); //接收人 + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //构建通知信息内容 + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送方 + } + if(leaveDay >= 8 && leaveDay <= 14) { + //查询指定用户的通知信息 + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong("185043")); //接收人需添加appvoval + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //构建通知信息内容 + notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送方 + } + if(leaveDay >= 15 && leaveDay <= 30) { + notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setReceiver(185362L); //接收人 + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //构建通知信息内容 + notificationManage.setContent("您有一条【学院领导已提交请假申请审批】待处理"); // 消息内容 + notificationManage.setSender(185362L); // 发送方 + } + notificationManage.setReceiver(shenUserInfo.getUserId()); + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + + //获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向辅导员(userName:{})发送企业微信销假通知。", userName); + log.info("已成功向送企业微信销假通知。{}", stuLeaveApplication.getStuId()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } } } diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/LeadEentListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadEentListener.java new file mode 100644 index 0000000..e942d72 --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadEentListener.java @@ -0,0 +1,125 @@ +package com.srs.flowable.listener; + +import com.srs.common.doman.vo.TeacherVo; +import com.srs.common.enums.ApplicationStatus; +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.NotificationManage; +import com.srs.flowable.domain.StuLeaveApplication; +import com.srs.flowable.mapper.LeaveMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hpsf.Decimal; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 领导审核 + * 邵政文 + */ +@Component +@Slf4j +public class LeadEentListener implements ExecutionListener { + @Override + public void notify(DelegateExecution delegateExecution) { + LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + + log.info("任务流相关数据", delegateExecution); + + // 学工审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + + // 拿到流程所有参数 + String approved = delegateExecution.getVariable("approved").toString(); + + // 获取请假天数 + BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); + + + // 请假单id + // 报错信息 + String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); + + log.info("审批结果为:", approval); + + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); + + // 获取校领导信息 + //TeacherVo updateDeptId = leaveMapper.getUpdateDeptId(SecurityUtils.getUserId().toString()); + List lingDataInfo = leaveMapper.getLingDataInfo(185362L); + + if (stuLeaveApplication != null) { + // 同意 + if ("true".equals(approved)) { + stuLeaveApplication.setStatus(ApplicationStatus.APPROVED.getCode()); + } + } + + stuLeaveApplication.setUpdateBy(SecurityUtils.getUsername()); + + stuLeaveApplication.setUpdateTime(DateUtils.getNowDate()); + + leaveMapper.updateRtStuLeaveApplication(stuLeaveApplication); + + log.info("审核成功"); + + //企业微信推送消息(邵政文) + try { + log.info("学工审批结果"); + log.info("请假人数据为:{}", stuLeaveApplication); + log.info("审批结果为:{}", approval); + log.info("校领导信息为:{}", lingDataInfo); + // 步骤 2: 使用lingDataInfo.get(0).getUserId()向校领导发送信息 + String userName = lingDataInfo.get(0).getUserName(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //查询指定用户的通知信息并且删除 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //向系统发送通知 + notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送人 + notificationManage.setReceiver(lingDataInfo.get(0).getUserId()); // 接收人 + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + } + + //获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向辅导员(userName:{})发送企业微信销假通知。", userName); + log.info("已成功向送企业微信销假通知。{}", stuLeaveApplication.getStuId()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } + } +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/LeadStartListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadStartListener.java new file mode 100644 index 0000000..e1ff947 --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/LeadStartListener.java @@ -0,0 +1,101 @@ +package com.srs.flowable.listener; + +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.NotificationManage; +import com.srs.flowable.domain.StuLeaveApplication; +import com.srs.flowable.mapper.LeaveMapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 获取该二级学院书记所在的学工信息 + * 邵政文 + */ +@Component +@Slf4j +public class LeadStartListener implements ExecutionListener { + @Override + public void notify(DelegateExecution delegateExecution) { + LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + + // 二级学院书记审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + + // 获取请假天数 + BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); + + // 获取流程ID + String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); + + // 获取请假信息 + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); + + // 获取学工信息 + //TeacherVo updateDeptId = leaveMapper.getUpdateDeptId(approval); + List updateDeptIdInfo = leaveMapper.getUpdateDeptIdInfo(1045L); + + // 设置流程变量 + delegateExecution.setVariable("approval", updateDeptIdInfo.get(0).getUserId()); + + // todo 企业微信推送消息(邵政文) + log.info("请假信息:{}", stuLeaveApplication); + log.info("辅导员信息:{}", updateDeptIdInfo); + try { + log.info("学工收到二级学院书记发送过来的通知"); + // 步骤 2: 使用updateDeptIdInfo.get(0).getUserId()获取学工工号 + String userName = updateDeptIdInfo.get(0).getUserName(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //查询指定用户的通知信息 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //向系统发送通知 + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送方 + notificationManage.setReceiver(updateDeptIdInfo.get(0).getUserId()); // 接收方 + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + } + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向辅导员(userName:{})发送企业微信请假审批通知。", userName); + log.info("已成功向送企业微信审批通知。{}", updateDeptIdInfo.get(0).getUserName()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } + } +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveApproveListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveApproveListener.java index 8123ef7..037883f 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveApproveListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveApproveListener.java @@ -3,14 +3,14 @@ package com.srs.flowable.listener; import com.srs.common.enums.ApplicationStatus; 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.NotificationManage; import com.srs.flowable.domain.StuLeaveApplication; import com.srs.flowable.mapper.LeaveMapper; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.ExecutionListener; -import org.flowable.engine.delegate.TaskListener; -import org.flowable.task.service.delegate.DelegateTask; import org.springframework.stereotype.Component; import java.math.BigDecimal; @@ -38,7 +38,6 @@ public class LeaveApproveListener implements ExecutionListener { // 获取请假天数 BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); - // 请假单id // 报错信息 String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); @@ -66,6 +65,61 @@ public class LeaveApproveListener implements ExecutionListener { log.info("审核成功"); - //todo 推送消息,推送给辅导员,目的要拿到辅导员工号 + //企业微信推送消息(邵政文) + try { + log.info("向请假人发送销假消息"); + log.info("请假消息。{}", stuLeaveApplication); + log.info("创建人。{}", stuLeaveApplication.getCreateBy()); + log.info("修改人。{}", stuLeaveApplication.getUpdateBy()); + log.info("辅导员审批结果。{}", approval); + log.info("流程所有参数。{}", approved); + + // 判断请假天数 + int leaveDay = leaveDays.intValue(); + if(leaveDay >= 1 && leaveDay <= 3) { + // 步骤 2: 使用stuLeaveApplication.getCreateBy()向请假人发送销假消息 + String userName = stuLeaveApplication.getCreateBy(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //查询指定用户的通知信息 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【请假人提交的请假申请】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //向系统发送通知 + notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送人 + notificationManage.setReceiver(stuLeaveApplication.getStuId()); // 接收人 + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); // 发送消息的方法 + log.info("已成功向请假人({})发送企业微信销假通知。", userName); + log.info("发件人id。{}", stuLeaveApplication.getStuId()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + } + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } } } diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveStartApproveListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveStartApproveListener.java new file mode 100644 index 0000000..d5cbc3c --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/LeaveStartApproveListener.java @@ -0,0 +1,101 @@ +package com.srs.flowable.listener; + +import com.srs.common.doman.vo.TeacherVo; +import com.srs.common.utils.DateUtils; +import com.srs.common.utils.WeChatUtil; +import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.domain.NotificationManage; +import com.srs.flowable.domain.StuLeaveApplication; +import com.srs.flowable.mapper.LeaveMapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; + +/** + * 获取该生所在辅导员信息 + * 邵政文 + */ +@Component +@Slf4j +public class LeaveStartApproveListener implements ExecutionListener { + + @Override + public void notify(DelegateExecution delegateExecution) { + LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper"); + + String deptId = delegateExecution.getVariable("deptId").toString(); + + // 获取请假天数 + BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); + + // 辅导员审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + + // 获取流程ID + String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); + + // 获取请假信息 + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); + + // 获取辅导员 + TeacherVo secondaryLeaderInfo = leaveMapper.getCounselorInfo(stuLeaveApplication.getStuId()); + + // 设置流程变量 + delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId()); + + // todo 企业微信推送消息(邵政文) + log.info("请假信息:{}", stuLeaveApplication); + log.info("辅导员信息:{}", secondaryLeaderInfo); + try { + log.info("辅导员收到请假人发送过来的通知"); + // 步骤 2: 使用secondaryLeaderInfo.getUserName()获取辅导员工号 + String userName = secondaryLeaderInfo.getUserName(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //向系统发送通知 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【请假人提交的请假申请】需待处理"); // 消息内容 + notificationManage.setSender(stuLeaveApplication.getStuId()); + notificationManage.setReceiver(secondaryLeaderInfo.getUserId()); + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManage == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + } + //新添地方 + notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManages.getId()); + log.info("删除成功{}", delRes); + } + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向辅导员(userName:{})发送企业微信请假审批通知。", userName); + log.info("已成功向送企业微信审批通知。{}", secondaryLeaderInfo.getUserName()); + log.info("请假人id:{}", stuLeaveApplication.getStuId()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送通知或处理通知时出现异常。错误详情: {}", e.getMessage(), e); + } + } +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/SecondaryLeaderListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/SecondaryLeaderListener.java index 8c36399..43d0b1f 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/SecondaryLeaderListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/SecondaryLeaderListener.java @@ -1,7 +1,11 @@ package com.srs.flowable.listener; import com.srs.common.doman.vo.TeacherVo; +import com.srs.common.utils.DateUtils; +import com.srs.common.utils.WeChatUtil; import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.domain.NotificationManage; +import com.srs.flowable.domain.StuLeaveApplication; import com.srs.flowable.mapper.LeaveMapper; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.delegate.DelegateExecution; @@ -10,6 +14,9 @@ import org.flowable.engine.delegate.TaskListener; import org.flowable.task.service.delegate.DelegateTask; import org.springframework.stereotype.Component; +import java.math.BigDecimal; +import java.util.List; + /** * 获取该生所在二级学院领导信息 */ @@ -23,10 +30,107 @@ public class SecondaryLeaderListener implements ExecutionListener { String deptId = delegateExecution.getVariable("deptId").toString(); - // 获取高辅导员 - TeacherVo secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId); - delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId()); - // todo 企业微信推送消息 + // 辅导员审批结果 + String approval = delegateExecution.getVariable("approval").toString(); + + // 获取请假天数 + BigDecimal leaveDays = (BigDecimal) delegateExecution.getVariable("leaveDays"); + + // 获取二级学院书记用户信息 + //TeacherVo secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId); + //delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId()); + List secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId); + //由于这里查到了多个数据,由于时间原因,暂时还没有研究到工作流中多用户节点的同时进行(所以取了第一条数据用于发消息) + delegateExecution.setVariable("approval", secondaryLeaderInfo.get(0).getUserId()); + + // 获取请假申请ID + String leaveApplicationId = delegateExecution.getVariable("leaveApplicationId").toString(); + // 获取请假信息 + StuLeaveApplication stuLeaveApplication = leaveMapper.selectRtStuLeaveApplicationByLeaveApplicationId(leaveApplicationId); + + // todo 企业微信推送消息(邵政文) log.info("查询二级学院书记信息:{}", secondaryLeaderInfo); + try { + //int leaveDay = leaveDays.intValue(); + // 步骤 2: 使用secondaryLeaderInfo.get(0).getUserName()获取二级学院书记工号 + String userName = secondaryLeaderInfo.get(0).getUserName(); + + // 步骤 3: 检查是否成功获取到 userName + if (userName != null && !userName.isEmpty()) { + //查询指定用户的通知信息 + NotificationManage notificationManage = new NotificationManage(); + notificationManage.setContent("您有一条【请假人提交的请假申请】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); //接收人 + NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if(userManage != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userManage.getId()); + log.info("删除成功{}", delRes); + } + + //向多人发消息的逻辑如下: +// notificationManage.setSender(Long.parseLong(approval)); // 发送人 +// notificationManage.setCreateTime(DateUtils.getNowDate()); // 创建时间 +// for(TeacherVo teacherVo : secondaryLeaderInfo) { +// //向系统发送通知 +// notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 +// notificationManage.setReceiver(teacherVo.getUserId()); // 接收人 +// NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); +// if (userManages == null) { +// int res = leaveMapper.insertCphMsg(notificationManage); +// log.info("添加成功{}", res); +// } +// +// // 获取向企业微信发通知的工具类 +// WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); +// +// // 构造包含超链接的消息内容 +// String content = "您有待处理任务,请点击前往处理"; +// +// // 步骤 4: 使用 userName 作为接收人发送消息 +// //weChatUtil.sendTextMessage(userName, content); +// log.info("已成功向二级学院书记(userName:{})发送企业微信请假审批通知。", userName); +// log.info("已成功向送企业微信审批通知。{}", teacherVo.getUserId()); +// } + + //向系统发送通知 + notificationManage.setContent("您有一条【辅导员已提交请假审批】需待处理"); // 消息内容 + notificationManage.setSender(Long.parseLong(approval)); // 发送人 + notificationManage.setReceiver(secondaryLeaderInfo.get(0).getUserId()); // 接收人 + NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userManages == null) { + notificationManage.setCreateTime(DateUtils.getNowDate()); + int res = leaveMapper.insertCphMsg(notificationManage); + log.info("添加成功{}", res); + } + //新添地方 + notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 + notificationManage.setReceiver(Long.parseLong(approval)); // 接收人 + NotificationManage userMsge = leaveMapper.selectCphMsgListForFlowable(notificationManage); + if (userMsge != null) { + //删除指定通知信息 + int delRes = leaveMapper.deleteCphMsgById(userMsge.getId()); + log.info("删除成功{}", delRes); + } + + // 获取向企业微信发通知的工具类 + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + + // 构造包含超链接的消息内容 + String content = "您有待处理任务,请点击前往处理"; + + // 步骤 4: 使用 userName 作为接收人发送消息 + weChatUtil.sendTextMessage(userName, content); + log.info("已成功向二级学院书记(userName:{})发送企业微信请假审批通知。", userName); + log.info("已成功向此人{}送企业微信审批通知。", secondaryLeaderInfo.get(0).getUserName()); + + } else { + // 如果找不到userName,记录警告日志,但流程继续 + log.warn("没有找到对应审批人,无法发送通知。"); + } + } catch (Exception e) { + // 捕获所有异常,仅记录日志,确保主流程不受影响 + log.error("发送企业微信通知时出现异常。错误详情: {}", e.getMessage(), e); + } } } diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/WSSListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/WSSListener.java new file mode 100644 index 0000000..92bc73d --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/WSSListener.java @@ -0,0 +1,58 @@ +package com.srs.flowable.listener.disciplinary; + +import com.srs.common.utils.WeChatUtil; +import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.mapper.DisciplinaryMapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author 宁博 + */ +@Component +@Slf4j +public class WSSListener implements ExecutionListener { + @Override + public void notify(DelegateExecution delegateExecution) { + DisciplinaryMapper disciplinaryMapper = SpringUtils.getBean(DisciplinaryMapper.class); + + // 1. 【核心】定义"卫生所" wss + final String TARGET_ROLE_KEY = "wss"; + log.info("流程实例 [{}]: 准备向角色 '{}' 发送通知。", delegateExecution.getProcessInstanceId(), TARGET_ROLE_KEY); + + // 2. 根据这个固定的角色Key,查询该角色的所有成员ID(即使只有一个)。 + List userIdList = disciplinaryMapper.getApprovalByRoleKey(TARGET_ROLE_KEY); + // 3. 检查是否找到了成员。 + if (userIdList == null || userIdList.isEmpty()) { + log.error("根据角色Key '{}' 未找到任何用户,无法发送通知。", TARGET_ROLE_KEY); + return; // 中止执行,不抛出异常以免中断流程 + } + + // 4. 发送企业微信通知。 + // (我们的批量发送逻辑即使只有一个用户也能完美处理) + try { + // 批量查询userName (即使只有一个ID,这个方法也能正常工作) + List userNameList = disciplinaryMapper.getUserNamesByUserIdList(userIdList); + + if (!userNameList.isEmpty()) { + // 将列表拼接成 "username1|username2|..." 的格式 + String toUser = String.join("|", userNameList); + + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + String content = "您有一条新的学生违纪审批任务待处理,请点击前往处理。"; + + weChatUtil.sendTextMessage(toUser, content); + log.info("已成功向角色 '{}' 的成员发送通知。接收人: {}", TARGET_ROLE_KEY, toUser); + } else { + log.warn("角色 '{}' 中找到了 {} 个用户,但无人配置企业微信账号,未发送任何通知。", TARGET_ROLE_KEY, userIdList.size()); + } + } catch (Exception e) { + log.error("向角色 '{}' 发送企业微信通知时出现异常。流程将继续。错误详情: {}", TARGET_ROLE_KEY, e.getMessage(), e); + } + } +} + diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XLZXListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XLZXListener.java new file mode 100644 index 0000000..34058cd --- /dev/null +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XLZXListener.java @@ -0,0 +1,57 @@ +package com.srs.flowable.listener.disciplinary; + +import com.srs.common.utils.WeChatUtil; +import com.srs.common.utils.spring.SpringUtils; +import com.srs.flowable.mapper.DisciplinaryMapper; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.ExecutionListener; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author 宁博 + */ +@Slf4j +@Component +public class XLZXListener implements ExecutionListener { + @Override + public void notify(DelegateExecution delegateExecution) { + DisciplinaryMapper disciplinaryMapper = SpringUtils.getBean(DisciplinaryMapper.class); + + // 1. 【核心】定义"心理中心" xlzx + final String TARGET_ROLE_KEY = "xlzx"; + log.info("流程实例 [{}]: 准备向角色 '{}' 发送通知。", delegateExecution.getProcessInstanceId(), TARGET_ROLE_KEY); + + // 2. 根据这个固定的角色Key,查询该角色的所有成员ID(即使只有一个)。 + List userIdList = disciplinaryMapper.getApprovalByRoleKey(TARGET_ROLE_KEY); + // 3. 检查是否找到了成员。 + if (userIdList == null || userIdList.isEmpty()) { + log.error("根据角色Key '{}' 未找到任何用户,无法发送通知。", TARGET_ROLE_KEY); + return; // 中止执行,不抛出异常以免中断流程 + } + + // 4. 发送企业微信通知。 + // (我们的批量发送逻辑即使只有一个用户也能完美处理) + try { + // 批量查询userName (即使只有一个ID,这个方法也能正常工作) + List userNameList = disciplinaryMapper.getUserNamesByUserIdList(userIdList); + + if (!userNameList.isEmpty()) { + // 将列表拼接成 "username1|username2|..." 的格式 + String toUser = String.join("|", userNameList); + + WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class); + String content = "您有一条新的学生违纪审批任务待处理,请点击前往处理。"; + + weChatUtil.sendTextMessage(toUser, content); + log.info("已成功向角色 '{}' 的成员发送通知。接收人: {}", TARGET_ROLE_KEY, toUser); + } else { + log.warn("角色 '{}' 中找到了 {} 个用户,但无人配置企业微信账号,未发送任何通知。", TARGET_ROLE_KEY, userIdList.size()); + } + } catch (Exception e) { + log.error("向角色 '{}' 发送企业微信通知时出现异常。流程将继续。错误详情: {}", TARGET_ROLE_KEY, e.getMessage(), e); + } + } +} diff --git a/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XWGSListener.java b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XWGSListener.java index 5345fb0..79cacd1 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XWGSListener.java +++ b/srs-flowable/src/main/java/com/srs/flowable/listener/disciplinary/XWGSListener.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; /** - * 根据辅导员的部门id,查询该部门的学无干事人员 知无涯 + * 根据辅导员的部门id,查询该部门的学务干事人员 知无涯 */ @Component @Slf4j diff --git a/srs-flowable/src/main/java/com/srs/flowable/mapper/LeaveMapper.java b/srs-flowable/src/main/java/com/srs/flowable/mapper/LeaveMapper.java index c1e4ad9..834cfc7 100644 --- a/srs-flowable/src/main/java/com/srs/flowable/mapper/LeaveMapper.java +++ b/srs-flowable/src/main/java/com/srs/flowable/mapper/LeaveMapper.java @@ -2,8 +2,11 @@ package com.srs.flowable.mapper; import com.srs.common.doman.vo.TeacherVo; +import com.srs.flowable.domain.NotificationManage; import com.srs.flowable.domain.StuLeaveApplication; +import java.util.List; + /** * 考勤mapper */ @@ -22,7 +25,8 @@ public interface LeaveMapper { * @param deptId * @return */ - TeacherVo getSecondaryLeaderInfo(String deptId); + //TeacherVo getSecondaryLeaderInfo(String deptId); + List getSecondaryLeaderInfo(String deptId); /** * 查询学生请假申请 @@ -40,4 +44,62 @@ public interface LeaveMapper { */ int updateRtStuLeaveApplication(StuLeaveApplication rtStuLeaveApplication); + /** + * 新增消息 + * @param notificationManage 消息 + * @return 结果 + * 邵政文 + */ + int insertCphMsg(NotificationManage notificationManage); + + /** + * 查询指定发送人所对应的消息 + * @param notificationManage 消息 + * @return 结果 + * 邵政文 + */ + NotificationManage selectCphMsgListForFlowable(NotificationManage notificationManage); + + /** + * 根据id删除指定通知 + * + * @param id + * @return 结果 + * 邵政文 + */ + int deleteCphMsgById(Long id); + + /** + * 根据审批人工号查询部门id + * + * @param userId 审批人id + * @return 结果 + * 邵政文 + */ + TeacherVo getUpdateDeptId(String userId); + + /** + * 获取学工信息 + * @param deptId + * @return + * 邵政文 + */ + List getUpdateDeptIdInfo(Long deptId); + + /** + * 获取校领导信息 + * @param userId + * @return + * 邵政文 + */ + List getLingDataInfo(Long userId); + + /** + * 获取请假申请人信息 + * @param stuId + * @return + * 邵政文 + */ + TeacherVo getShenUserInfo(Long stuId); + } diff --git a/srs-flowable/src/main/resources/mapper/LeaveMapper.xml b/srs-flowable/src/main/resources/mapper/LeaveMapper.xml index ec43ee1..26b4404 100644 --- a/srs-flowable/src/main/resources/mapper/LeaveMapper.xml +++ b/srs-flowable/src/main/resources/mapper/LeaveMapper.xml @@ -35,7 +35,6 @@ - + + + + + + + + + + + + + + + + + + insert into cph_msg + + sender, + receiver, + content, + create_by, + create_time, + update_by, + update_time, + + + #{sender}, + #{receiver}, + #{content}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + update rt_stu_leave_application @@ -86,4 +147,10 @@ where leave_application_id = #{leaveApplicationId} + + + + delete from cph_msg where id = #{id} + + \ No newline at end of file diff --git a/srs-quartz/src/main/java/com/srs/quartz/task/RegTask.java b/srs-quartz/src/main/java/com/srs/quartz/task/RegTask.java index af87264..f8ebb00 100644 --- a/srs-quartz/src/main/java/com/srs/quartz/task/RegTask.java +++ b/srs-quartz/src/main/java/com/srs/quartz/task/RegTask.java @@ -27,9 +27,9 @@ public class RegTask { srsStuCheck.setIsCheck(m.getIsCheck()); srsStuCheck.setKsh(m.getKsh()); srsStuCheck.setCheckTime(m.getCheckTime()); - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("ksh",m.getKsh()); - checkService.update(srsStuCheck,updateWrapper); +// UpdateWrapper updateWrapper = new UpdateWrapper<>(); +// updateWrapper.eq("ksh",m.getKsh()); + checkService.saveOrUpdate(srsStuCheck); } } diff --git a/srs-routine/src/main/java/com/srs/routine/service/impl/RtStuLeaveApplicationServiceImpl.java b/srs-routine/src/main/java/com/srs/routine/service/impl/RtStuLeaveApplicationServiceImpl.java index bd7fea6..5d30587 100644 --- a/srs-routine/src/main/java/com/srs/routine/service/impl/RtStuLeaveApplicationServiceImpl.java +++ b/srs-routine/src/main/java/com/srs/routine/service/impl/RtStuLeaveApplicationServiceImpl.java @@ -175,7 +175,8 @@ public class RtStuLeaveApplicationServiceImpl extends ServiceImpl { + @DataSource(DataSourceType.SLAVE) + public List listXsxxTemp(GxsdxySjzx009Temp2024xsxx param); + public List> countRoomBed(); public List> countStuXb(); diff --git a/srs-stureg/src/main/java/com/srs/stureg/service/ISrsStuRegService.java b/srs-stureg/src/main/java/com/srs/stureg/service/ISrsStuRegService.java index 297a426..55b5beb 100644 --- a/srs-stureg/src/main/java/com/srs/stureg/service/ISrsStuRegService.java +++ b/srs-stureg/src/main/java/com/srs/stureg/service/ISrsStuRegService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.srs.common.core.domain.AjaxResult; import com.srs.comprehensive.domain.Vo.CphSearch; import com.srs.comprehensive.domain.Vo.DataScreen; +import com.srs.stureg.domain.GxsdxySjzx009Temp2024xsxx; import com.srs.stureg.domain.SrsStuReg; import org.apache.poi.ss.formula.functions.T; import org.springframework.web.bind.annotation.PathVariable; @@ -24,6 +25,10 @@ import java.util.concurrent.Future; */ public interface ISrsStuRegService extends IService { + public AjaxResult syncClassCode(); + + public List listXsxxTemp(GxsdxySjzx009Temp2024xsxx param); + public List> countRoomBed(); public List> countStuXb(); diff --git a/srs-stureg/src/main/java/com/srs/stureg/service/impl/SrsStuRegServiceImpl.java b/srs-stureg/src/main/java/com/srs/stureg/service/impl/SrsStuRegServiceImpl.java index 4e6a089..c46e94f 100644 --- a/srs-stureg/src/main/java/com/srs/stureg/service/impl/SrsStuRegServiceImpl.java +++ b/srs-stureg/src/main/java/com/srs/stureg/service/impl/SrsStuRegServiceImpl.java @@ -3,19 +3,20 @@ package com.srs.stureg.service.impl; import java.lang.management.LockInfo; import java.text.SimpleDateFormat; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import com.srs.common.annotation.DataSource; import com.srs.common.core.domain.AjaxResult; import com.srs.common.core.domain.entity.SysDictData; import com.srs.common.core.domain.entity.SysUser; +import com.srs.common.enums.DataSourceType; import com.srs.common.exception.ServiceException; import com.srs.common.utils.DateUtils; import com.srs.common.utils.SecurityUtils; @@ -45,7 +46,11 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.web.multipart.MultipartFile; import static com.srs.common.utils.SecurityUtils.getUsername; @@ -97,6 +102,151 @@ public class SrsStuRegServiceImpl extends ServiceImpl(1000), + new ThreadFactory() { + private final AtomicInteger counter = new AtomicInteger(1); + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "update-pool-1-" + counter.getAndIncrement()); + } + }, + new ThreadPoolExecutor.CallerRunsPolicy() // 任务满时让提交线程执行,避免丢失 + ); + + ThreadPoolExecutor pool2 = new ThreadPoolExecutor( + Runtime.getRuntime().availableProcessors() / 2, + Runtime.getRuntime().availableProcessors(), + 60L, TimeUnit.SECONDS, + new LinkedBlockingQueue<>(1000), + new ThreadFactory() { + private final AtomicInteger counter = new AtomicInteger(1); + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "update-pool-2-" + counter.getAndIncrement()); + } + }, + new ThreadPoolExecutor.CallerRunsPolicy() + ); + + try { + List stuList = this.list(); + List tempList = srsStuRegMapper.listXsxxTemp(new GxsdxySjzx009Temp2024xsxx()); + + tempList.forEach(x -> { + x.临时学号报到后给新的 = x.临时学号报到后给新的.replace("LS", ""); + }); + + List needUpdateList = new ArrayList<>(); + for (SrsStuReg srsStuReg : stuList) { + GxsdxySjzx009Temp2024xsxx temp = tempList.stream() + .filter(x -> x.临时学号报到后给新的.equals(srsStuReg.getKSH())) + .findFirst() + .orElse(null); + if (temp != null) { + SrsStuReg stu = new SrsStuReg(); + stu.setId(srsStuReg.getId()); + stu.setBJDM(temp.教务系统班级编号); + stu.setBJ(temp.班级名称); + needUpdateList.add(stu); + } + } + + if (needUpdateList.isEmpty()) { + return AjaxResult.success("没有需要更新的数据"); + } + + // 将更新列表拆分为两部分,分配给两个线程池 + int mid = needUpdateList.size() / 2; + List part1 = needUpdateList.subList(0, mid); + List part2 = needUpdateList.subList(mid, needUpdateList.size()); + + // 用于等待所有线程完成 + CountDownLatch countDownLatch = new CountDownLatch(2); + // 用于捕获线程中的异常 + AtomicReference exceptionRef = new AtomicReference<>(); + + // 提交第一个任务到线程池1 + pool1.submit(() -> { + try { + if (!part1.isEmpty()) { + boolean res = this.updateBatchById(part1); + if (!res) { + throw new Exception("线程池1批量更新失败"); + } + } + } catch (Exception e) { + exceptionRef.set(e); + } finally { + countDownLatch.countDown(); + } + }); + + // 提交第二个任务到线程池2 + pool2.submit(() -> { + try { + if (!part2.isEmpty()) { + boolean res = this.updateBatchById(part2); + if (!res) { + throw new Exception("线程池2批量更新失败"); + } + } + } catch (Exception e) { + exceptionRef.set(e); + } finally { + countDownLatch.countDown(); + } + }); + + // 等待所有任务完成(最多等待30秒) + boolean await = countDownLatch.await(30, TimeUnit.SECONDS); + if (!await) { + throw new Exception("批量更新超时"); + } + + // 检查是否有异常 + if (exceptionRef.get() != null) { + throw exceptionRef.get(); + } + + return AjaxResult.success("同步班级代码成功,共更新" + needUpdateList.size() + "条数据"); + } catch (Exception ex) { + return AjaxResult.error(ex.getMessage()); + } finally { + // 关闭线程池 + pool1.shutdown(); + pool2.shutdown(); + try { + // 等待线程池关闭(最多等5秒) + if (!pool1.awaitTermination(5, TimeUnit.SECONDS)) { + pool1.shutdownNow(); + } + if (!pool2.awaitTermination(5, TimeUnit.SECONDS)) { + pool2.shutdownNow(); + } + } catch (InterruptedException e) { + pool1.shutdownNow(); + pool2.shutdownNow(); + } + } + } + + + @Override + @DataSource(DataSourceType.SLAVE) + public List listXsxxTemp(GxsdxySjzx009Temp2024xsxx param){ + return srsStuRegMapper.listXsxxTemp(param); + } + public SrsStuRegServiceImpl(List userList) { this.userList = userList; @@ -136,6 +286,7 @@ public class SrsStuRegServiceImpl extends ServiceImpl + + + + @@ -73,11 +77,11 @@ and a.ZZMM = #{ZZMM} and a.MZ = #{MZ} and a.XH = #{XH} - and a.XY = #{XY} + and a.XY like concat('%', #{XY}, '%') and a.XYDM = #{XYDM} and a.ZY = #{ZY} and a.ZYDM = #{ZYDM} - and a.BJ = #{BJ} + and a.BJ like concat('%',#{BJ}, '%') and a.BJDM = #{BJDM} and a.last_school = #{lastSchool} and a.last_school_addr = #{lastSchoolAddr} @@ -646,7 +650,7 @@ select a.*,b.class_name,f.major_name,g.dept_name, case e.room_no is NULL when true then "无" - else concat(e.park_name,' ',e.building_name,' ',e.room_no) end as dorm + else concat(e.park_name,' ',e.building_name,' ',e.room_no) end as dorm,a.is_smoke,a.is_early,a.hobby from srs_stu_reg as a left join srs_class as b on a.BJDM = b.class_code left join cph_teacher as c on b.teacher_id = c.teacher_id @@ -741,7 +745,6 @@ left join srs_class cl on a.bjdm=class_code left join cph_teacher t on cl.teacher_id=t.teacher_id - a.reg_status in (1,3,4) and a.BJDM = #{BJDM} and t.employee_id = #{params.tNo} and a.MZ like concat('%', #{MZ},'%') @@ -998,4 +1001,13 @@ (#{item.XSXM}, #{item.KSH}, #{item.SFZH}, #{item.SJH},#{item.XB},#{item.ZZMM},#{item.MZ},#{item.XY},#{item.ZY},#{item.lastSchool},#{item.famNowAddr},#{item.sfzAddr},#{item.createTime},#{item.createBy},#{item.BJ},#{item.BJDM}) + + diff --git a/srs-system/src/main/java/com/srs/system/mapper/QgzxTeacherMapper.java b/srs-system/src/main/java/com/srs/system/mapper/QgzxTeacherMapper.java index 6101a69..75680b4 100644 --- a/srs-system/src/main/java/com/srs/system/mapper/QgzxTeacherMapper.java +++ b/srs-system/src/main/java/com/srs/system/mapper/QgzxTeacherMapper.java @@ -20,6 +20,7 @@ public interface QgzxTeacherMapper extends BaseMapper { * @return 教职工信息 */ public QgzxTeacher selectQgzxTeacherByTeacherId(Long teacherId); + public QgzxTeacher selectQgzxTeacherByEmployeeId(String employeeId); /** * 查询教职工信息列表 @@ -44,6 +45,7 @@ public interface QgzxTeacherMapper extends BaseMapper { * @return 结果 */ int updateQgzxTeacher(QgzxTeacher qgzxTeacher); + int updateQgzxTeacherNew(QgzxTeacher qgzxTeacher); /** * 删除教职工信息 diff --git a/srs-system/src/main/resources/mapper/system/QgzxTeacherMapper.xml b/srs-system/src/main/resources/mapper/system/QgzxTeacherMapper.xml index 140925a..7da8eb0 100644 --- a/srs-system/src/main/resources/mapper/system/QgzxTeacherMapper.xml +++ b/srs-system/src/main/resources/mapper/system/QgzxTeacherMapper.xml @@ -47,6 +47,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from sys_dept as a where dept_code = #{ksh} + insert into qgzx_teacher @@ -104,6 +108,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where teacher_id = #{teacherId} + + update qgzx_teacher + + name = #{name}, + gender = #{gender}, + age = #{age}, + dept_id = #{deptId}, + phone_number = #{phoneNumber}, + status = #{status}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where employee_id = #{employeeId} + + delete from qgzx_teacher where teacher_id = #{teacherId}