//package com.yida.data.school.userLeave.service.impl;
//
//import cc.mrbird.febs.common.redis.service.RedisService;
//import cn.hutool.core.collection.CollUtil;
//import cn.hutool.core.date.LocalDateTimeUtil;
//import cn.hutool.core.util.ObjectUtil;
//import cn.hutool.core.util.StrUtil;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.yida.data.attendance.dto.AddLeaveRequestStrategyDTO;
//import com.yida.data.attendance.feign.RemoteAttendanceStrategyService;
//import com.yida.data.common.core.entity.constant.AppConstant;
//import com.yida.data.common.core.entity.constant.CachePrefixConstant;
//import com.yida.data.common.core.entity.constant.NoticeTypeConstant;
//import com.yida.data.common.core.entity.notice.qywx.TemplateCardStaffNotice;
//import com.yida.data.common.core.entity.notice.qywx.TextSchoolNotice;
//import com.yida.data.common.core.entity.notice.qywx.inside.TemplateCardNotice;
//import com.yida.data.common.core.entity.notice.qywx.inside.Text;
//import com.yida.data.common.core.entity.notice.qywx.inside.templateCard.CardAction;
//import com.yida.data.common.core.entity.notice.qywx.inside.templateCard.HorizontalContent;
//import com.yida.data.common.core.entity.notice.qywx.inside.templateCard.Jump;
//import com.yida.data.common.core.entity.notice.qywx.inside.templateCard.MainTitle;
//import com.yida.data.common.core.entity.system.Dept;
//import com.yida.data.common.core.entity.system.EduApp;
//import com.yida.data.common.core.entity.system.enums.RoleEnum;
//import com.yida.data.common.core.entity.system.enums.SchoolNatureEnum;
//import com.yida.data.common.core.entity.user.EduStaff;
//import com.yida.data.common.core.entity.user.EduStaffDept;
//import com.yida.data.common.core.entity.user.EduStudent;
//import com.yida.data.common.core.entity.user.EduUserDept;
//import com.yida.data.common.core.entity.userLeave.*;
//import com.yida.data.common.core.enums.RoleName;
//import com.yida.data.common.core.enums.UserTypeEnum;
//import com.yida.data.common.core.enums.leave.ApprovalResultEnum;
//import com.yida.data.common.core.enums.leave.AuditModeEnum;
//import com.yida.data.common.core.enums.leave.LeaveRequestTypeEnum;
//import com.yida.data.common.core.exception.FebsException;
//import com.yida.data.common.core.utils.FebsUtil;
//import com.yida.data.common.core.utils.ThreadPoolUtil;
//import com.yida.data.common.core.utils.WxUtil;
//import com.yida.data.common.service.CommonService;
//import com.yida.data.school.dto.userLeave.AuditRequestDTO;
//import com.yida.data.school.dto.userLeave.LeaveRequestPageDTO;
//import com.yida.data.school.dto.userLeave.ListUserRequestDTO;
//import com.yida.data.school.dto.userLeave.SendStaffNoticeDTO;
//import com.yida.data.school.userLeave.mapper.EduLeaveRequestUserMapper;
//import com.yida.data.school.userLeave.service.*;
//import com.yida.data.school.vo.userLeave.EduLeaveRequestStatisticsVO;
//import com.yida.data.school.vo.userLeave.EduLeaveRequestUserVO;
//import com.yida.data.system.feign.RemoteDeptService;
//import com.yida.data.user.dto.ListStaffDTO;
//import com.yida.data.user.dto.ListStudentDTO;
//import com.yida.data.user.feign.RemoteStaffService;
//import com.yida.data.user.feign.RemoteStudentService;
//import com.yida.data.user.feign.RemoteTeacherService;
//import com.yida.data.user.feign.RemoteUserDeptService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.ApplicationContext;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.List;
//import java.util.Objects;
//import java.util.concurrent.ExecutorService;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
///**
// * Service实现
// *
// * @author wjm
// * @date 2022-12-01 10:51:19
// */
//@Slf4j
//@Service
//@RequiredArgsConstructor
//@Transactional(rollbackFor = Exception.class)
//public class EduLeaveRequestUserServiceImpl_b extends ServiceImpl
//        <EduLeaveRequestUserMapper, EduLeaveRequestUser> implements EduLeaveRequestUserService {
//
//    private final EduLeaveRequestProcessConfigService eduLeaveRequestProcessConfigService;
//    private final EduLeaveRequestProcessConfigApprovalUserService eduLeaveRequestProcessConfigApprovalUserService;
//    private final EduLeaveRequestProcessRecordService eduLeaveRequestProcessRecordService;
//    private final EduLeaveRequestProcessConfigViewService eduLeaveRequestProcessConfigViewService;
//    private final EduLeaveRequestUserViewService eduLeaveRequestUserViewService;
//
//    private final RemoteStudentService remoteStudentService;
//    private final RemoteStaffService remoteStaffService;
//    private final RemoteDeptService remoteDeptService;
//    private final RemoteUserDeptService remoteUserDeptService;
//    private final RemoteTeacherService remoteTeacherService;
//    private final RemoteAttendanceStrategyService remoteAttendanceStrategyService;
//
//    private final WxUtil wxUtil;
//    private final RedisService redisService;
//    private final CommonService commonService;
//
//    @Value("${febs.teacherLeaveRequestUrl}")
//    private String teacherLeaveRequestUrl;
//
//    @Value("${febs.studentLeaveRequestUrl}")
//    private String studentLeaveRequestUrl;
//
//    @Autowired
//    ApplicationContext applicationContext;
//
//    private static final ExecutorService ADD_LEAVE_REQUEST_POOL =
//            ThreadPoolUtil.getThreadPool("add-leave-request-pool-%d");
//
//    @Override
//    public EduLeaveRequestStatisticsVO selectLeaveRequestStatistics() {
//        // 学生id
//        List<Long> studentIdList;
//        // 查询权限对应的班级的学生
//        String rolePerms = FebsUtil.getCurrentUser().getRolePerms();
//        // 查询学生条件
//        ListStudentDTO param = new ListStudentDTO();
//        param.setOnlyId(true);
//        param.setIsQueryParent(false);
//        param.setIsQuerySchoolName(false);
//        param.setIsQueryUserDept(false);
//        // 非学校管理员
//        if (!rolePerms.contains(RoleEnum.ROLE_SCHOOL_PRINCIPAL.getValue())) {
//            List<Long> classIdList = remoteStaffService.listClassIdByStaffId().getData();
//            param.setClassIds(classIdList);
//        } else {
//            param.setSchoolId(FebsUtil.getDeptId());
//        }
//        studentIdList = remoteStudentService.listStudent(param).getData().stream().map(EduStudent::getId)
//                .collect(Collectors.toList());
//        if (CollUtil.isEmpty(studentIdList)) {
//            studentIdList = new ArrayList<>();
//            studentIdList.add(-1L);
//        }
//        // 周统计
//        long weekNumber = baseMapper.selectWeekNumber(studentIdList);
//        // 月统计
//        long monthNumber = baseMapper.selectMonthNumber(studentIdList);
//        return EduLeaveRequestStatisticsVO.builder()
//                .weekNumber(weekNumber)
//                .monthNumber(monthNumber)
//                .build();
//    }
//
//    @Override
//    public Page<EduLeaveRequestUser> findPageList(LeaveRequestPageDTO dto) {
//        dto.setSelectStudentId(0);
//        //查询权限
//        if (CollUtil.isEmpty(dto.getStudentIdList()) && ObjectUtil
//                .equals(UserTypeEnum.PARENT_USER_TYPE.getType(), dto.getRequestType())) {
//            // 查询学生条件
//            ListStudentDTO param = new ListStudentDTO();
//            param.setOnlyId(true);
//            param.setIsQueryParent(false);
//            param.setIsQuerySchoolName(false);
//            param.setIsQueryUserDept(false);
//            // 查询权限对应的班级的学生
//            String rolePerms = FebsUtil.getCurrentUser().getRolePerms();
//            if (Objects.nonNull(dto.getCampusId())) {
//                param.setCampusId(dto.getCampusId());
//                param.setSectionId(dto.getSectionId());
//                param.setGradeId(dto.getGradeId());
//                param.setClassId(dto.getClassId());
//                List<Long> studentIdList = remoteStudentService.listStudent(param).getData().stream().map(EduStudent::getId)
//                        .collect(Collectors.toList());
//                dto.setStudentIdList(studentIdList);
//                dto.setSelectStudentId(1);
//            } else {
//                // 非学校管理员
//                if (!rolePerms.contains(RoleEnum.ROLE_SCHOOL_PRINCIPAL.getValue())) {
//                    List<Long> classIdList = remoteStaffService.listClassIdByStaffId().getData();
//                    param.setClassIds(classIdList);
//                    List<Long> studentIdList = remoteStudentService.listStudent(param).getData().stream().map(EduStudent::getId)
//                            .collect(Collectors.toList());
//                    dto.setStudentIdList(studentIdList);
//                    dto.setSelectStudentId(1);
//                }
//            }
//        }
//        if (CollUtil.isEmpty(dto.getStudentIdList())) {
//            dto.setStudentIdList(Collections.singletonList(-1L));
//        }
//        // 查询请假列表
//        Page<EduLeaveRequestUser> eduLeaveRequestUserPage = baseMapper.findPage(dto.toPage(), dto);
//        List<EduLeaveRequestUser> records = eduLeaveRequestUserPage.getRecords();
//        for (EduLeaveRequestUser eduLeaveRequestUser : records) {
//            if (eduLeaveRequestUser.getRequestType() == 1) {
//                //学生
//                EduStudent student = (EduStudent) redisService
//                        .hget(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString());
//                if (student == null) {
//                    student = remoteStudentService.getStudentNoPermission(eduLeaveRequestUser.getUserId()).getData();
//                    if (student == null) {
//                        log.error("学生不存在,无法处理请假数据,id:[{}]", eduLeaveRequestUser.getUserId().toString());
//                        continue;
//                    } else {
//                        redisService
//                                .hset(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString(),
//                                        student);
//                    }
//                }
//
//                EduUserDept userGreadeDept = (EduUserDept) redisService
//                        .hget(CachePrefixConstant.USER_DEPT_DATA, student.getGradeId().toString());
//                EduUserDept userClassDept = (EduUserDept) redisService
//                        .hget(CachePrefixConstant.USER_DEPT_DATA, student.getClassId().toString());
//                if (ObjectUtil.isNull(userGreadeDept)) {
//                    userGreadeDept = remoteUserDeptService.getByDeptId(student.getGradeId()).getData();
//                    if (ObjectUtil.isNotNull(userGreadeDept)) {
//                        redisService.hset(CachePrefixConstant.USER_DEPT_DATA, student.getGradeId().toString(), userGreadeDept);
//                    }
//                }
//
//                if (ObjectUtil.isNull(userClassDept)) {
//                    userClassDept = remoteUserDeptService.getByDeptId(student.getClassId()).getData();
//                    if (ObjectUtil.isNotNull(userClassDept)) {
//                        redisService.hset(CachePrefixConstant.USER_DEPT_DATA, student.getClassId().toString(), userClassDept);
//                    }
//                }
//
//                eduLeaveRequestUser
//                        .setUserDeptName((ObjectUtil.isNull(userGreadeDept) ? ""
//                                : userGreadeDept.getDeptName()) + (ObjectUtil.isNull(userClassDept) ? ""
//                                : userClassDept.getDeptName())); //TODO 判断dept
//                eduLeaveRequestUser.setUserPicUrl(student.getAvatar());
//            } else {
//                //教师
//                //TODO 缓存获取职工信息
//                List<EduStaffDept> eduStaffDeptList = remoteStaffService
//                        .getStaffDeptByStaffIds(Collections.singletonList(eduLeaveRequestUser.getUserId())).getData();
//                log.info("职工信息：【{}】", eduStaffDeptList);
//                List<String> deptNameList = eduStaffDeptList.stream().map(EduStaffDept::getDeptName).collect(Collectors.toList());
//                eduLeaveRequestUser.setUserDeptName(StrUtil.join(",", deptNameList));
//                eduLeaveRequestUser.setUserPicUrl(eduStaffDeptList.get(0).getAvatar());
//            }
//
//            //查询下一步审核人信息
//            //查询已审核的sort
//            EduLeaveRequestProcessRecord arr = eduLeaveRequestProcessRecordService
//                    .getOne(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                            .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
//                            .eq(EduLeaveRequestProcessRecord::getApprovalResult, 1)
//                            .orderByAsc(EduLeaveRequestProcessRecord::getSort).last("limit 1"));
//
//            List<EduLeaveRequestProcessRecord> eduLeaveRequestProcessRecordList = eduLeaveRequestProcessRecordService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                            .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
//                            .eq(EduLeaveRequestProcessRecord::getApprovalResult, 0)
//                            .eq(EduLeaveRequestProcessRecord::getSort, ObjectUtil.isNull(arr) ? 0 : arr.getSort() + 1)
//                            .orderByAsc(EduLeaveRequestProcessRecord::getSort));
//
//            eduLeaveRequestUser.setEduLeaveRequestProcessRecordList(eduLeaveRequestProcessRecordList);
//
//        }
//        return eduLeaveRequestUserPage.setRecords(records);
//    }
//
//    /**
//     * @param page
//     * @param userId
//     * @param requestType
//     * @param schoolId
//     * @param statusList
//     * @param currentUserStatus 0=待处理，1=已处理
//     * @return
//     */
//    @Override
//    public Page<EduLeaveRequestUser> findApprovalUserLeaveList(Page<EduLeaveRequestUser> page, Long userId, Integer requestType,
//                                                               Long schoolId, List<Integer> statusList, Integer currentUserStatus) {
//        LocalDateTime preDateTime = LocalDate.now().minusMonths(1).atTime(23, 59, 59);
//        //用户参与审核的请假
//        List<EduLeaveRequestUser> approvalUserLeaveList = baseMapper
//                .findApprovalUserLeaveList(userId, requestType, schoolId, null, null, preDateTime);
//
//        //如果请假已通过或者未通过，表示已处理了
//        List<EduLeaveRequestUser> dealEdList = approvalUserLeaveList.stream()
//                .filter(e -> ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), e.getStatus())
//                        || ObjectUtil.equals(ApprovalResultEnum.AUDIT_NO.getResult(), e.getStatus()))
//                .collect(Collectors.toList());
//
//        //待处理/正在处理的请假
//        List<EduLeaveRequestUser> dealIngList = approvalUserLeaveList.stream()
//                .filter(e -> ObjectUtil.equals(ApprovalResultEnum.AUDIT.getResult(), e.getStatus())
//                        || ObjectUtil.equals(ApprovalResultEnum.AUDIT_ING.getResult(), e.getStatus()))
//                .collect(Collectors.toList());
//
//        List<Long> dealIngIdList = new ArrayList<>();
//        List<Long> dealEdIdList = new ArrayList<>();
//        dealEdIdList.addAll(dealEdList.stream().map(EduLeaveRequestUser::getId).collect(Collectors.toList()));
//        //待审核
//
//        for (EduLeaveRequestUser eduLeaveRequestUser : dealIngList) {
//            List<EduLeaveRequestUserView> viewList = eduLeaveRequestUserViewService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestUserView())
//                            .eq(EduLeaveRequestUserView::getRequestId, eduLeaveRequestUser.getId())
//                            .eq(EduLeaveRequestUserView::getStatus, ApprovalResultEnum.AUDIT.getResult())
//                            .orderByAsc(EduLeaveRequestUserView::getSort));
//            if (CollUtil.isEmpty(viewList)) {
//                continue;
//            }
//            EduLeaveRequestUserView view = viewList.get(0); //下一级审核
//            List<EduLeaveRequestProcessRecord> leaveRequestProcessRecordList = eduLeaveRequestProcessRecordService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                            .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
//                            .eq(EduLeaveRequestProcessRecord::getViewId, view.getId()));
//            if (leaveRequestProcessRecordList.stream().map(EduLeaveRequestProcessRecord::getApprovalId)
//                    .collect(Collectors.toList()).contains(userId)) {
//                dealIngIdList.add(eduLeaveRequestUser.getId());
//            }
//
//            //已审核通过的请假流程
//            List<EduLeaveRequestUserView> viewPassList = eduLeaveRequestUserViewService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestUserView())
//                            .eq(EduLeaveRequestUserView::getRequestId, eduLeaveRequestUser.getId())
//                            .eq(EduLeaveRequestUserView::getStatus, ApprovalResultEnum.AUDIT_PASS.getResult()));
//            if (CollUtil.isNotEmpty(viewPassList)) {
//                List<EduLeaveRequestProcessRecord> viewPassRecordList = eduLeaveRequestProcessRecordService
//                        .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                                .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
//                                .in(EduLeaveRequestProcessRecord::getViewId,
//                                        viewPassList.stream().map(EduLeaveRequestUserView::getId).collect(
//                                                Collectors.toList())));
//                if (viewPassRecordList.stream().map(EduLeaveRequestProcessRecord::getApprovalId)
//                        .collect(Collectors.toList()).contains(userId)) {
//                    dealEdIdList.add(eduLeaveRequestUser.getId());
//                }
//            }
//        }
//
//        if (CollUtil.isEmpty(dealEdIdList)) {
//            dealEdIdList.add(-1L);
//        }
//
//        if (CollUtil.isEmpty(dealIngIdList)) {
//            dealIngIdList.add(-1L);
//        }
//
//        LeaveRequestPageDTO dto = new LeaveRequestPageDTO();
//        dto.setPageNum((int) page.getPages());
//        dto.setPageSize((int) page.getSize());
//        dto.setSchoolId(schoolId);
//        dto.setIdList(
//                ObjectUtil.equals(ApprovalResultEnum.AUDIT.getResult(), currentUserStatus) ? dealIngIdList : dealEdIdList);
//        Page<EduLeaveRequestUser> eduLeaveRequestUserPage = baseMapper.findPage(dto.toPage(), dto);
//
//        List<EduLeaveRequestUser> records = eduLeaveRequestUserPage.getRecords();
//        for (EduLeaveRequestUser eduLeaveRequestUser : records) {
//            if (eduLeaveRequestUser.getRequestType() == 1) {
//                //学生
//                EduStudent student = commonService.getStudentById(eduLeaveRequestUser.getUserId());
//                if (ObjectUtil.isNull(student)) {
//                    log.error("学生【{}】不存在,无法处理请假数据", eduLeaveRequestUser.getUserId().toString());
//                    continue;
//                }
//                EduUserDept userGreadeDept = (EduUserDept) redisService
//                        .hget(CachePrefixConstant.USER_DEPT_DATA, student.getGradeId().toString());
//
//                EduUserDept userClassDept = (EduUserDept) redisService
//                        .hget(CachePrefixConstant.USER_DEPT_DATA, student.getClassId().toString());
//
//                if (ObjectUtil.isNull(userGreadeDept)) {
//                    userGreadeDept = remoteUserDeptService.getByDeptId(student.getGradeId()).getData();
//                    if (ObjectUtil.isNotNull(userGreadeDept)) {
//                        redisService.hset(CachePrefixConstant.USER_DEPT_DATA, student.getGradeId().toString(), userGreadeDept);
//                    }
//                }
//
//                if (ObjectUtil.isNull(userClassDept)) {
//                    userClassDept = remoteUserDeptService.getByDeptId(student.getClassId()).getData();
//                    if (ObjectUtil.isNotNull(userClassDept)) {
//                        redisService.hset(CachePrefixConstant.USER_DEPT_DATA, student.getClassId().toString(), userClassDept);
//                    }
//                }
//                if (ObjectUtil.isNull(userGreadeDept) && ObjectUtil.isNull(userGreadeDept)) {
//                    eduLeaveRequestUser.setUserDeptName("未知班级");
//                } else {
//                    eduLeaveRequestUser.setUserDeptName(
//                            (ObjectUtil.isNull(userGreadeDept) ? "" : userGreadeDept.getDeptName()) + (ObjectUtil
//                                    .isNull(userClassDept) ? "" : userClassDept.getDeptName()));
//                }
//                eduLeaveRequestUser.setUserPicUrl(student.getAvatar());
//            } else {
//                //教师
//                List<EduStaffDept> eduStaffDeptList = remoteStaffService
//                        .getStaffDeptByStaffIds(Collections.singletonList(eduLeaveRequestUser.getUserId())).getData();
//                List<String> deptNameList = eduStaffDeptList.stream().map(EduStaffDept::getDeptName).collect(Collectors.toList());
//                eduLeaveRequestUser.setUserDeptName(StrUtil.join(",", deptNameList));
//                eduLeaveRequestUser.setUserPicUrl(eduStaffDeptList.get(0).getAvatar());
//            }
//
//            //查询下一步审核人信息
//            //查询已审核的sort
////            EduLeaveRequestProcessRecord arr = eduLeaveRequestProcessRecordService
////                .getOne(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
////                    .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
////                    .eq(EduLeaveRequestProcessRecord::getApprovalResult, 1)
////                    .orderByAsc(EduLeaveRequestProcessRecord::getSort).last("limit 1"));
////
////            List<EduLeaveRequestProcessRecord> eduLeaveRequestProcessRecordList = eduLeaveRequestProcessRecordService
////                .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
////                    .eq(EduLeaveRequestProcessRecord::getRequestId, eduLeaveRequestUser.getId())
////                    .eq(EduLeaveRequestProcessRecord::getApprovalResult, 0)
////                    .eq(EduLeaveRequestProcessRecord::getSort, ObjectUtil.isNull(arr) ? 0 : arr.getSort() + 1)
////                    .orderByAsc(EduLeaveRequestProcessRecord::getSort));
////            eduLeaveRequestUser.setEduLeaveRequestProcessRecordList(eduLeaveRequestProcessRecordList);
//        }
//
//        return eduLeaveRequestUserPage.setRecords(records);
//    }
//
//    @Override
//    @Transactional
//    public void addLeaveRequest(EduLeaveRequestUser eduLeaveRequestUser) {
//        SendStaffNoticeDTO sendStaffNoticeDTO = new SendStaffNoticeDTO();
//        sendStaffNoticeDTO.setRequestFor(eduLeaveRequestUser.getRequestFor());
//        sendStaffNoticeDTO.setRequestReason(eduLeaveRequestUser.getRequestReason());
//        sendStaffNoticeDTO.setRequestStartTime(eduLeaveRequestUser.getStartTime());
//        sendStaffNoticeDTO.setRequestEndTime(eduLeaveRequestUser.getEndTime());
//        sendStaffNoticeDTO.setSchoolId(eduLeaveRequestUser.getSchoolId());
//        sendStaffNoticeDTO.setRequestTime(LocalDateTime.now());
//        sendStaffNoticeDTO.setType(eduLeaveRequestUser.getType());
//        if (ObjectUtil.isNull(eduLeaveRequestUser.getId())) {
//            //查找适用请假策略
//            List<Long> requestUserDeptIdList = new ArrayList<>();
//            if (eduLeaveRequestUser.getRequestType() == 1) { //学生请假
//                //1：找出学生所属部门
//                EduStudent student = (EduStudent) redisService
//                        .hget(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString());
//                if (student == null) {
//                    student = remoteStudentService.getStudentNoPermission(eduLeaveRequestUser.getUserId()).getData();
//                    if (student == null) {
//                        log.error("学生不存在,无法处理请假数据,id:[{}]", eduLeaveRequestUser.getUserId().toString());
//                    } else {
//                        redisService
//                                .hset(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString(),
//                                        student);
//                    }
//                }
//                requestUserDeptIdList = Stream
//                        .of(-student.getSchoolId(), student.getCampusId(), student.getSectionId(), student.getGradeId(),
//                                student.getClassId()).collect(
//                                Collectors.toList());
//
//                sendStaffNoticeDTO.setRequestUserName(student.getStuName());
//                sendStaffNoticeDTO.setRequestUserDeptName(
//                        String.join("/", student.getCampusName(), student.getGradeName(), student.getClassName()));
//            } else {
//                //找出教师所属部门
//                EduStaff staff = remoteStaffService.getStaff(eduLeaveRequestUser.getUserId()).getData();
//                eduLeaveRequestUser.setUserName(staff.getName());
//                List<EduStaffDept> staffDept = staff.getStaffDept();
//                List<Dept> deptList = remoteDeptService
//                        .listParentDeptByChild(staffDept.stream().map(EduStaffDept::getDeptId).collect(Collectors.toList()))
//                        .getData();
//                requestUserDeptIdList = deptList.stream().map(Dept::getDeptId).collect(Collectors.toList());
//
//                sendStaffNoticeDTO.setRequestUserName(staff.getName());
//                sendStaffNoticeDTO.setRequestUserDeptName(
//                        StringUtils.join(deptList.stream().map(Dept::getDeptName).collect(Collectors.toList()), "/"));
//            }
//
//            EduLeaveRequestProcessConfig config = null;
//
//            //请假时长
//            Long requestHours = LocalDateTimeUtil.between(eduLeaveRequestUser.getStartTime(), eduLeaveRequestUser.getEndTime())
//                    .toHours();
//            if (requestHours <= 12) {
//                //是否启用小于半天
//                List<EduLeaveRequestProcessConfig> list = eduLeaveRequestProcessConfigService
//                        .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessConfig())
//                                .eq(EduLeaveRequestProcessConfig::getSchoolId, eduLeaveRequestUser.getSchoolId())
//                                .eq(EduLeaveRequestProcessConfig::getLessHalfDay, 1));
//                if (CollUtil.isNotEmpty(list)) {
//                    List<EduLeaveRequestProcessConfig> collect = list.stream().filter(x -> x.getHours() >= requestHours)
//                            .collect(Collectors.toList());
//                    if (CollUtil.isNotEmpty(collect)) {
//                        config = collect.get(0);
//                    }
//                }
//            }
//            if (ObjectUtil.isNull(config)) {
//                //请假天数
//                Long requesUserDays = LocalDateTimeUtil
//                        .between(eduLeaveRequestUser.getStartTime(), eduLeaveRequestUser.getEndTime())
//                        .toDays();
//                List<EduLeaveRequestProcessConfig> configByDeptIds = eduLeaveRequestProcessConfigService
//                        .findConfigByDeptIds(requestUserDeptIdList, eduLeaveRequestUser.getRequestType(), requesUserDays);
//                if (CollUtil.isNotEmpty(configByDeptIds)) {
//                    config = configByDeptIds.get(0);
//                }
//            }
//
//            //适用的请假规则
//            if (ObjectUtil.isNull(config)) {
//                // TODO 如果没有对应的请假规则，学生可以就只有班主任一级审核，教师呢？
//                throw new FebsException("无匹配的请假规则，请创建！");
//            }
//            //保存请假主体
//            eduLeaveRequestUser.setViewSort(0);
//            save(eduLeaveRequestUser);
//
//            Dept school = commonService.getDept(config.getSchoolId());
//            List<EduLeaveRequestProcessConfigView> eduLeaveRequestProcessConfigViewList = eduLeaveRequestProcessConfigViewService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessConfigView())
//                            .eq(EduLeaveRequestProcessConfigView::getProcessId, config.getId())
//                            .orderByAsc(EduLeaveRequestProcessConfigView::getSort));
//            for (int i = 0; i < eduLeaveRequestProcessConfigViewList.size(); i++) {
//
//                log.info("请假流程：【{}】", i);
//                EduLeaveRequestProcessConfigView view = eduLeaveRequestProcessConfigViewList.get(i);
//                //保存流程
//                EduLeaveRequestUserView eduLeaveRequestUserView = new EduLeaveRequestUserView();
//                eduLeaveRequestUserView.setRequestId(eduLeaveRequestUser.getId());
//                eduLeaveRequestUserView.setProcessId(config.getId());
//                eduLeaveRequestUserView.setSort(view.getSort());
//                eduLeaveRequestUserView.setStatus(0);
//                eduLeaveRequestUserView.setApprovalUserType(view.getApprovalUserType());
//                eduLeaveRequestUserView.setApprovalType(view.getApprovalType());
//                eduLeaveRequestUserViewService.save(eduLeaveRequestUserView);
//
//                List<EduLeaveRequestProcessConfigApprovalUser> eduLeaveRequestProcessConfigApprovalUserList = eduLeaveRequestProcessConfigApprovalUserService
//                        .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessConfigApprovalUser())
//                                .eq(EduLeaveRequestProcessConfigApprovalUser::getProcessId, config.getId())
//                                .eq(EduLeaveRequestProcessConfigApprovalUser::getViewId, view.getId()));
//
//                for (EduLeaveRequestProcessConfigApprovalUser eduLeaveRequestProcessConfigApprovalUser : eduLeaveRequestProcessConfigApprovalUserList) {
//                    if (ObjectUtil.isNotNull(eduLeaveRequestProcessConfigApprovalUser.getStaffId())) {
//                        EduStaff staff = remoteStaffService
//                                .getStaff(eduLeaveRequestProcessConfigApprovalUser.getStaffId()).getData();
//                        //人员审核
//                        EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord = new EduLeaveRequestProcessRecord();
//                        eduLeaveRequestProcessRecord.setRequestId(eduLeaveRequestUser.getId());
//                        eduLeaveRequestProcessRecord.setProcessId(config.getId());
//                        eduLeaveRequestProcessRecord.setSchoolId(eduLeaveRequestUser.getSchoolId());
//                        eduLeaveRequestProcessRecord.setApprovalId(eduLeaveRequestProcessConfigApprovalUser.getStaffId());
//                        eduLeaveRequestProcessRecord.setApprovalName(staff.getName());
//                        eduLeaveRequestProcessRecord.setSort(eduLeaveRequestUserView.getSort());
//                        eduLeaveRequestProcessRecord.setViewId(eduLeaveRequestUserView.getId());
//                        eduLeaveRequestProcessRecordService.save(eduLeaveRequestProcessRecord);
//                        // 发送审核信息
//                        if (eduLeaveRequestUserView.getSort() == 0) {
//                            log.info("==========发送消息=====:{}", eduLeaveRequestUserView.getSort());
//                            sendStaffNoticeDTO.setStaffWxId(staff.getWxId());
//                            sendStaffNoticeDTO.setStaffName(staff.getName());
//                            sendStaffNoticeDTO.setSchoolType(school.getSchoolType());
//                            EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                    .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                            if (config.getProcessType() == 1) {
//                                bean.sendNotice(sendStaffNoticeDTO, 1, 1, eduLeaveRequestUser.getId());
//                            } else {
//                                bean.sendNotice(sendStaffNoticeDTO, 1, 0, eduLeaveRequestUser.getId());
//                            }
//                        }
//                    } else {
//                        if (config.getProcessType() == 1) {
//                            //学生请假
//                            //角色审核
//                            //查询学生
//                            EduStudent student = (EduStudent) redisService
//                                    .hget(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString());
//                            if (student == null) {
//                                student = remoteStudentService.getStudentNoPermission(eduLeaveRequestUser.getUserId()).getData();
//                                if (student == null) {
//                                    log.error("学生不存在,无法处理请假数据,id:[{}]", eduLeaveRequestUser.getUserId().toString());
//                                } else {
//                                    redisService
//                                            .hset(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString(),
//                                                    student);
//                                }
//                            }
//                            List<EduStaff> approvalUserList = new ArrayList<>();
//                            if (eduLeaveRequestProcessConfigApprovalUser.getStaffRoleId() == 1) {
//                                //班主任
//                                //查询学生班主任
//                                approvalUserList = remoteTeacherService.listTeacherByDeptId(student.getClassId(), "3").getData();
//                            } else {
//                                //高校系主任/K12年级主任
//                                if (student.getSchoolId() == 10593) {
//                                    //技师学院单独处理
//                                    approvalUserList = remoteTeacherService.listTeacherByDeptId(student.getCampusId(), "1")
//                                            .getData();
//                                } else {
//                                    Dept dept = commonService.getDept(student.getSchoolId());
//                                    log.info("学校性质：【{}】", dept.getSchoolNature());
//                                    if (ObjectUtil.equals(SchoolNatureEnum.UNI_TYPE.getValue(),
//                                            dept.getSchoolNature())) {
//                                        //高校
//                                        approvalUserList = remoteTeacherService.listTeacherByDeptId(student.getSectionId(), "5")
//                                                .getData();
//                                    } else {
//                                        //K12
//                                        approvalUserList = remoteTeacherService.listTeacherByDeptId(student.getGradeId(), "2")
//                                                .getData();
//                                    }
//                                }
//                            }
//                            if (CollUtil.isNotEmpty(approvalUserList)) {
//                                for (EduStaff eduStaff : approvalUserList) {
//                                    EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord = new EduLeaveRequestProcessRecord();
//                                    eduLeaveRequestProcessRecord.setRequestId(eduLeaveRequestUser.getId());
//                                    eduLeaveRequestProcessRecord.setProcessId(config.getId());
//                                    eduLeaveRequestProcessRecord.setSchoolId(eduLeaveRequestUser.getSchoolId());
//                                    eduLeaveRequestProcessRecord.setApprovalId(eduStaff.getId());
//                                    eduLeaveRequestProcessRecord.setApprovalName(eduStaff.getName());
//                                    eduLeaveRequestProcessRecord.setSort(eduLeaveRequestUserView.getSort());
//                                    eduLeaveRequestProcessRecord.setViewId(eduLeaveRequestUserView.getId());
//                                    eduLeaveRequestProcessRecordService.save(eduLeaveRequestProcessRecord);
//
//                                    sendStaffNoticeDTO.setStaffWxId(eduStaff.getWxId());
//                                    sendStaffNoticeDTO.setStaffName(eduStaff.getName());
//                                    sendStaffNoticeDTO.setSchoolType(school.getSchoolType());
//                                    EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                            .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                                    // 发送审核信息
//                                    if (eduLeaveRequestUserView.getSort() == 0) {
//                                        bean.sendNotice(sendStaffNoticeDTO, 1, 1, eduLeaveRequestUser.getId());
//                                    }
//                                }
//                            }
//                        } else {
//                            //教师请假
//                            List<EduStaff> approvalDeptUserList = remoteStaffService.listStaff(
//                                    ListStaffDTO.builder()
//                                            .deptId(eduLeaveRequestProcessConfigApprovalUser.getStaffRoleId().longValue())
//                                            .build()).getData();
//                            if (ObjectUtil.isNotNull(approvalDeptUserList)) {
//                                for (EduStaff eduStaff : approvalDeptUserList) {
//                                    EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord = new EduLeaveRequestProcessRecord();
//                                    eduLeaveRequestProcessRecord.setRequestId(eduLeaveRequestUser.getId());
//                                    eduLeaveRequestProcessRecord.setProcessId(config.getId());
//                                    eduLeaveRequestProcessRecord.setSchoolId(eduLeaveRequestUser.getSchoolId());
//                                    eduLeaveRequestProcessRecord.setApprovalId(eduStaff.getId());
//                                    eduLeaveRequestProcessRecord.setApprovalName(eduStaff.getName());
//                                    eduLeaveRequestProcessRecord.setSort(eduLeaveRequestUserView.getSort());
//                                    eduLeaveRequestProcessRecord.setViewId(eduLeaveRequestUserView.getId());
//                                    eduLeaveRequestProcessRecordService.save(eduLeaveRequestProcessRecord);
//
//                                    sendStaffNoticeDTO.setStaffWxId(eduStaff.getWxId());
//                                    sendStaffNoticeDTO.setStaffName(eduStaff.getName());
//                                    sendStaffNoticeDTO.setSchoolType(school.getSchoolType());
//                                    // 发送审核信息
//                                    if (eduLeaveRequestUserView.getSort() == 0) {
//                                        EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                                .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                                        bean.sendNotice(sendStaffNoticeDTO, 1, 0, eduLeaveRequestUser.getId());
//                                    }
//                                }
//                            }
//                        }
//                    }
//                }
//            }
//        }
//    }
//
//    @Override
//    public void auditRequest(AuditRequestDTO dto) {
//        //封装发送消息主体
//        EduLeaveRequestUser request = this.getById(dto.getRequestId());
//        SendStaffNoticeDTO sendStaffNoticeDTO = new SendStaffNoticeDTO();
//        sendStaffNoticeDTO.setRequestFor(request.getRequestFor());
//        sendStaffNoticeDTO.setRequestReason(request.getRequestReason());
//        sendStaffNoticeDTO.setRequestStartTime(request.getStartTime());
//        sendStaffNoticeDTO.setRequestEndTime(request.getEndTime());
//        sendStaffNoticeDTO.setSchoolId(request.getSchoolId());
//        sendStaffNoticeDTO.setRequestUserName(request.getUserName());
//        sendStaffNoticeDTO.setRequestTime(request.getCreateDate());
//        sendStaffNoticeDTO.setType(request.getType());
//        if (request.getRequestType() == 1) {
//            //学生
//            EduStudent student = (EduStudent) redisService
//                    .hget(CachePrefixConstant.STUDENT_DATA, request.getUserId().toString());
//            if (student == null) {
//                student = remoteStudentService.getStudentNoPermission(request.getUserId()).getData();
//                if (student == null) {
//                    log.error("学生不存在,无法处理请假数据,id:[{}]", request.getUserId().toString());
//                } else {
//                    redisService
//                            .hset(CachePrefixConstant.STUDENT_DATA, request.getUserId().toString(),
//                                    student);
//                }
//            }
//            sendStaffNoticeDTO
//                    .setRequestUserDeptName(
//                            String.join("/", remoteUserDeptService.getByDeptId(student.getCampusId()).getData().getDeptName(),
//                                    remoteUserDeptService.getByDeptId(student.getGradeId()).getData().getDeptName(),
//                                    remoteUserDeptService.getByDeptId(student.getClassId()).getData().getDeptName()));
//        } else {
//            //教师
//            List<EduStaffDept> eduStaffDeptList = remoteStaffService
//                    .getStaffDeptByStaffIds(Collections.singletonList(request.getUserId())).getData();
//            List<String> deptNameList = eduStaffDeptList.stream().map(EduStaffDept::getDeptName).collect(Collectors.toList());
//            sendStaffNoticeDTO.setRequestUserDeptName(StrUtil.join(",", deptNameList));
//        }
//
//        // 策略id
//        Long strategyId = 10000000 + dto.getRequestId();
//
//        //先判断审核权限
//        List<EduLeaveRequestProcessRecord> list = eduLeaveRequestProcessRecordService.list(
//                Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                        .eq(EduLeaveRequestProcessRecord::getRequestId, dto.getRequestId())
//                        .eq(EduLeaveRequestProcessRecord::getApprovalId, dto.getApprovalId())
//                        .orderByAsc(EduLeaveRequestProcessRecord::getSort));
//
//        EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord = new EduLeaveRequestProcessRecord();
//
//        for (int i = 0; i < list.size(); i++) {
//            EduLeaveRequestProcessRecord record = list.get(i);
//            if (record.getApprovalResult() == 0) {
//                eduLeaveRequestProcessRecord = record;
//                break;
//            }
//        }
//
//        EduLeaveRequestUserView view = eduLeaveRequestUserViewService.getById(eduLeaveRequestProcessRecord.getViewId());
//
////        EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord = eduLeaveRequestProcessRecordService.getById(dto.getId());
////        CurrentUser currentUser = FebsUtil.getCurrentUser();
////        if (eduLeaveRequestProcessRecord.getApprovalId() != currentUser.getIdentityId()) {
////            throw new FebsException("您无此审核权限");
////        }
//
//        eduLeaveRequestProcessRecord.setApprovalResult(dto.getApprovalResult());
//        eduLeaveRequestProcessRecord.setApprovalReason(dto.getApprovalReason());
//        eduLeaveRequestProcessRecord.setUpdateDate(LocalDateTime.now());
//        eduLeaveRequestProcessRecordService.updateById(eduLeaveRequestProcessRecord);
//
//        EduLeaveRequestProcessConfig config = eduLeaveRequestProcessConfigService
//                .getById(eduLeaveRequestProcessRecord.getProcessId());
//
//        sendStaffNoticeDTO.setPreStaffName(eduLeaveRequestProcessRecord.getApprovalName());
//        List<String> roleNames = new ArrayList<>();
//
//        List<Integer> teacherRoleTypeList = remoteStaffService
//                .listStaffRolesByStaffId(eduLeaveRequestProcessRecord.getApprovalId()).getData();
//        if (teacherRoleTypeList.contains(1)) {
//            roleNames.add(RoleName.CAMPUS.getName());
//        } else if (teacherRoleTypeList.contains(2)) {
//            roleNames.add(RoleName.GRADE.getName());
//        } else if (teacherRoleTypeList.contains(3)) {
//            roleNames.add(RoleName.MASTER.getName());
//        } else if (teacherRoleTypeList.contains(4)) {
//            roleNames.add(RoleName.COURSE.getName());
//        } else if (teacherRoleTypeList.contains(5)) {
//            roleNames.add(RoleName.SECTION.getName());
//        } else {
//            roleNames.add(RoleName.TEACHER.getName());
//        }
//        sendStaffNoticeDTO.setPreStaffRoleName(StrUtil.join("/", roleNames));
//
//        if (ObjectUtil.equals(AuditModeEnum.OR_AUDIT.getMode(), view.getApprovalType())) {
//            //或审
//            view.setStatus(dto.getApprovalResult() == 0 ? 2 : 1);
//            view.setAuditTime(LocalDateTime.now());
//
////            EduLeaveRequestProcessConfigView next = eduLeaveRequestProcessConfigViewService
////                .getOne(Wrappers.lambdaQuery(new EduLeaveRequestProcessConfigView())
////                    .eq(EduLeaveRequestProcessConfigView::getProcessId, dto.getProcessId())
////                    .eq(EduLeaveRequestProcessConfigView::getSort, view.getSort() + 1));
//
//            EduLeaveRequestUserView next = eduLeaveRequestUserViewService
//                    .getOne(Wrappers.lambdaQuery(new EduLeaveRequestUserView())
//                            .eq(EduLeaveRequestUserView::getRequestId, dto.getRequestId())
//                            .eq(EduLeaveRequestUserView::getSort, view.getSort() + 1));
//
//            EduLeaveRequestUser eduLeaveRequestUser = new EduLeaveRequestUser();
//            if (ObjectUtil.isNull(next)) {
//                //无下一流程则表示审核完毕
//                eduLeaveRequestUser.setId(dto.getRequestId());
//                if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), dto.getApprovalResult())) {  //审核通过
//                    eduLeaveRequestUser.setStrategyId(strategyId);
//                    eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_PASS.getResult());
//                } else {
//                    eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_NO.getResult());//审核不通过
//                    eduLeaveRequestUser.setRefuseReason(dto.getRefuseReason());
//                }
//            } else {
//                eduLeaveRequestUser.setViewSort(view.getSort() + 1);
//                eduLeaveRequestUser.setId(dto.getRequestId());
//                if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), dto.getApprovalResult())) {  //审核通过
//                    eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_ING.getResult());
//                    List<EduLeaveRequestProcessRecord> nextAppUser = eduLeaveRequestProcessRecordService.list(
//                            Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                                    .eq(EduLeaveRequestProcessRecord::getViewId, next.getId()));
//
//                    nextAppUser.forEach(eduLeaveRequestProcessRecord1 -> {
//                        // 发送提示审核消息
//                        Dept school = commonService.getDept(config.getSchoolId());
//                        EduStaff staff = remoteStaffService
//                                .getStaff(eduLeaveRequestProcessRecord1.getApprovalId()).getData();
//
//                        sendStaffNoticeDTO.setStaffWxId(staff.getWxId());
//                        sendStaffNoticeDTO.setStaffName(staff.getName());
//                        sendStaffNoticeDTO.setSchoolType(school.getSchoolType());
//                        EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                        if (ObjectUtil.equals(UserTypeEnum.PARENT_USER_TYPE.getType(), request.getRequestType())) {
//                            bean.sendNotice(sendStaffNoticeDTO, 0, 1, eduLeaveRequestUser.getId());
//                        } else {
//                            bean.sendNotice(sendStaffNoticeDTO, 0, 0, eduLeaveRequestUser.getId());
//                        }
//                    });
//                } else {
//                    eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_NO.getResult());//审核不通过
//                    eduLeaveRequestUser.setRefuseReason(dto.getRefuseReason());
//                }
//            }
//            this.updateById(eduLeaveRequestUser);
//
//            if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), eduLeaveRequestUser.getStatus())) {
//                // TODO 2023/2/2 eduLeaveRequestUser status=1 添加通行策略
//                EduLeaveRequestUser user = getById(eduLeaveRequestUser.getId());
//                addLeaveRequestStrategy(strategyId, user);
//            }
//            //通知家长
//            Dept school = commonService.getDept(config.getSchoolId());
//            if (ObjectUtil.equals(UserTypeEnum.PARENT_USER_TYPE.getType(), request.getRequestType())) {
//                if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), eduLeaveRequestUser.getStatus())
//                        && ObjectUtil.equals(ApprovalResultEnum.AUDIT_NO.getResult(), eduLeaveRequestUser.getStatus())) {
//                    EduLeaveRequestUser user = getById(eduLeaveRequestUser.getId());
//                    EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                            .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                    bean.sendParentNotice(school,
//                            eduLeaveRequestUser.getStatus(),
//                            user.getUserName(), user.getUserId(), request.getCreateDate(), request.getId());
//                }
//            } else {
//                //发送教师端审批结果通知
//                if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), eduLeaveRequestUser.getStatus())
//                        && ObjectUtil.equals(ApprovalResultEnum.AUDIT_NO.getResult(), eduLeaveRequestUser.getStatus())) {
//                    EduStaff staff = remoteStaffService.getStaff(request.getUserId()).getData();
//                    SendStaffNoticeDTO noticeDTO = new SendStaffNoticeDTO();
//                    noticeDTO.setRequestTime(request.getCreateDate());
//                    noticeDTO.setRequestStartTime(request.getStartTime());
//                    noticeDTO.setRequestEndTime(request.getEndTime());
//                    noticeDTO.setStatus(eduLeaveRequestUser.getStatus());
//                    noticeDTO.setStaffName(request.getUserName());
//                    noticeDTO.setStaffWxId(staff.getWxId());
//                    noticeDTO.setSchoolType(school.getSchoolType());
//                    EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                            .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                    bean.sendStaffNotice(noticeDTO, request.getId());
//                }
//            }
//        } else {
//            //会审
//            //本次请假此流程对应的全部审核人员
//            List<EduLeaveRequestProcessRecord> eduLeaveRequestProcessRecordList = eduLeaveRequestProcessRecordService
//                    .list(Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                            .eq(EduLeaveRequestProcessRecord::getProcessId, eduLeaveRequestProcessRecord.getProcessId())
//                            .eq(EduLeaveRequestProcessRecord::getRequestId, dto.getRequestId())
//                            .eq(EduLeaveRequestProcessRecord::getViewId, eduLeaveRequestProcessRecord.getViewId()));
//
//            //已通过的人员
//            List<EduLeaveRequestProcessRecord> passRecordList = eduLeaveRequestProcessRecordList.stream()
//                    .filter(x -> ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), x.getApprovalResult()))
//                    .collect(Collectors.toList());
//
//            if (ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), dto.getApprovalResult())) {
//                //审核通过
//                if (passRecordList.size() == eduLeaveRequestProcessRecordList.size()) {
//                    //1：都审核通过表示此级别审核通过，
//                    //2：查看是否需要下一级别审核
//                    EduLeaveRequestUserView next = eduLeaveRequestUserViewService
//                            .getOne(Wrappers.lambdaQuery(new EduLeaveRequestUserView())
//                                    .eq(EduLeaveRequestUserView::getRequestId, dto.getRequestId())
//                                    .eq(EduLeaveRequestUserView::getSort, view.getSort() + 1));
//
//                    if (ObjectUtil.isNull(next)) {
//                        EduLeaveRequestUser eduLeaveRequestUser = new EduLeaveRequestUser();
//                        eduLeaveRequestUser.setId(dto.getRequestId());
//                        eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_PASS.getResult());
//                        eduLeaveRequestUser.setStrategyId(strategyId);
//                        this.updateById(eduLeaveRequestUser);
//                        // TODO 2023/2/2 eduLeaveRequestUser status=1 添加通行策略
//                        EduLeaveRequestUser user = getById(eduLeaveRequestUser.getId());
//                        addLeaveRequestStrategy(strategyId, user);
////
////                        remoteAttendanceStrategyService.addLeaveRequestStrategy(
////                                AddLeaveRequestStrategyDTO.builder()
////                                        .requestId(user.getId())
////                                        .userId(user.getUserId())
////                                        .strategyId(strategyId)
////                                        .requestType(user.getRequestType())
////                                        .schoolId(user.getSchoolId())
////                                        .startTime(user.getStartTime())
////                                        .endTime(user.getEndTime())
////                                        .build());
//                        Dept school = commonService.getDept(config.getSchoolId());
//                        if (ObjectUtil.equals(UserTypeEnum.PARENT_USER_TYPE.getType(), request.getRequestType())) {
//                            //通知家长
//                            EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                    .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                            bean.sendParentNotice(school, ApprovalResultEnum.AUDIT_PASS.getResult(),
//                                    user.getUserName(), user.getUserId(), request.getCreateDate(), request.getId());
//                        } else {
//                            //发送教师端审批结果通知
//                            EduStaff staff = remoteStaffService.getStaff(request.getUserId()).getData();
//                            SendStaffNoticeDTO noticeDTO = new SendStaffNoticeDTO();
//                            noticeDTO.setRequestTime(request.getCreateDate());
//                            noticeDTO.setRequestStartTime(request.getStartTime());
//                            noticeDTO.setRequestEndTime(request.getEndTime());
//                            noticeDTO.setStatus(ApprovalResultEnum.AUDIT_PASS.getResult());
//                            noticeDTO.setStaffName(request.getUserName());
//                            noticeDTO.setStaffWxId(staff.getWxId());
//                            noticeDTO.setSchoolType(school.getSchoolType());
//
//                            EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                    .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                            bean.sendStaffNotice(noticeDTO, request.getId());
//                        }
//                    } else {
//                        EduLeaveRequestUser eduLeaveRequestUser = new EduLeaveRequestUser();
//                        eduLeaveRequestUser.setId(dto.getRequestId());
//                        eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_ING.getResult());
//                        eduLeaveRequestUser.setViewSort(next.getSort());
//                        this.updateById(eduLeaveRequestUser);
//                        // 通知下一级审核
//                        List<EduLeaveRequestProcessRecord> nextAppUser = eduLeaveRequestProcessRecordService.list(
//                                Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                                        .eq(EduLeaveRequestProcessRecord::getViewId, next.getId()));
//
//                        nextAppUser.forEach(nextRecord -> {
//                            // 发送提示审核消息
//                            Dept school = commonService.getDept(config.getSchoolId());
//                            EduStaff staff = remoteStaffService
//                                    .getStaff(nextRecord.getApprovalId()).getData();
//
//                            sendStaffNoticeDTO.setStaffWxId(staff.getWxId());
//                            sendStaffNoticeDTO.setStaffName(staff.getName());
//                            sendStaffNoticeDTO.setSchoolType(school.getSchoolType());
//                            EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                                    .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                            if (ObjectUtil.equals(UserTypeEnum.PARENT_USER_TYPE.getType(), request.getRequestType())) {
//                                bean.sendNotice(sendStaffNoticeDTO, 0, UserTypeEnum.PARENT_USER_TYPE.getType(),
//                                        eduLeaveRequestUser.getId());
//                            } else {
//                                bean.sendNotice(sendStaffNoticeDTO, 0, UserTypeEnum.STAFF_USER_TYPE.getType(),
//                                        eduLeaveRequestUser.getId());
//                            }
//                        });
//                    }
//                    view.setStatus(ApprovalResultEnum.AUDIT_PASS.getResult());
//                    view.setAuditTime(LocalDateTime.now());
//                } else {
//                    view.setStatus(ApprovalResultEnum.AUDIT_ING.getResult()); //当前流程审核中
//                    view.setAuditTime(LocalDateTime.now());
//
//                    EduLeaveRequestUser eduLeaveRequestUser = new EduLeaveRequestUser();
//                    eduLeaveRequestUser.setId(dto.getRequestId());
//                    eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_ING.getResult());
//                    this.updateById(eduLeaveRequestUser);
//                }
//            } else {
//                //审核不通过
//                EduLeaveRequestUser eduLeaveRequestUser = new EduLeaveRequestUser();
//                eduLeaveRequestUser.setId(dto.getRequestId());
//                eduLeaveRequestUser.setStatus(ApprovalResultEnum.AUDIT_NO.getResult());
//                eduLeaveRequestUser.setRequestReason(dto.getRefuseReason());
//                this.updateById(eduLeaveRequestUser);
//
//                view.setStatus(ApprovalResultEnum.AUDIT_NO.getResult());
//                view.setAuditTime(LocalDateTime.now());
//
//                Dept school = commonService.getDept(config.getSchoolId());
//                if (request.getRequestType() == 1) {
//                    //通知家长
//                    EduLeaveRequestUser user = getById(eduLeaveRequestUser.getId());
//                    EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                            .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                    bean.sendParentNotice(school, ApprovalResultEnum.AUDIT_NO.getResult(),
//                            user.getUserName(), user.getUserId(), request.getCreateDate(), request.getId());
//                } else {
//                    //发送教师端审批结果通知
//                    EduStaff staff = remoteStaffService.getStaff(request.getUserId()).getData();
//                    SendStaffNoticeDTO noticeDTO = new SendStaffNoticeDTO();
//                    noticeDTO.setRequestTime(request.getCreateDate());
//                    noticeDTO.setRequestStartTime(request.getStartTime());
//                    noticeDTO.setRequestEndTime(request.getEndTime());
//                    noticeDTO.setStatus(0);
//                    noticeDTO.setStaffName(request.getUserName());
//                    noticeDTO.setStaffWxId(staff.getWxId());
//                    noticeDTO.setSchoolType(school.getSchoolType());
//                    EduLeaveRequestUserServiceImpl_b bean = applicationContext
//                            .getBean(EduLeaveRequestUserServiceImpl_b.class);
//                    bean.sendStaffNotice(noticeDTO, request.getId());
//                }
//            }
//        }
//        eduLeaveRequestUserViewService.updateById(view);
//    }
//
//    @Override
//    public EduLeaveRequestUserVO getRequest(Long requestId) {
//        EduLeaveRequestUserVO eduLeaveRequestUserVO = new EduLeaveRequestUserVO();
//        EduLeaveRequestUser eduLeaveRequestUser = getById(requestId);
//        BeanUtils.copyProperties(eduLeaveRequestUser, eduLeaveRequestUserVO);
//
//        List<EduLeaveRequestUserView> userViewList = eduLeaveRequestUserViewService
//                .list(Wrappers.lambdaQuery(new EduLeaveRequestUserView()).eq(EduLeaveRequestUserView::getRequestId, requestId)
//                        .orderByAsc(EduLeaveRequestUserView::getSort));
//
//        userViewList.forEach(eduLeaveRequestUserView -> {
//            List<EduLeaveRequestProcessRecord> list = eduLeaveRequestProcessRecordService.list(
//                    Wrappers.lambdaQuery(new EduLeaveRequestProcessRecord())
//                            .eq(EduLeaveRequestProcessRecord::getViewId, eduLeaveRequestUserView.getId())
//                            .eq(EduLeaveRequestProcessRecord::getRequestId, requestId));
//
//            ListStaffDTO dto = new ListStaffDTO();
//            dto.setIds(list.stream().map(EduLeaveRequestProcessRecord::getApprovalId).collect(Collectors.toList()));
//            for (EduLeaveRequestProcessRecord eduLeaveRequestProcessRecord : list) {
//                EduStaff staff = (EduStaff) redisService
//                        .hget(CachePrefixConstant.STAFF_DATA, eduLeaveRequestProcessRecord.getApprovalId().toString());
//                if (ObjectUtil.isNull(staff)) {
//                    staff = remoteStaffService.getStaff(eduLeaveRequestProcessRecord.getApprovalId()).getData();
//                    if (ObjectUtil.isNotNull(staff)) {
//                        redisService
//                                .hset(CachePrefixConstant.STAFF_DATA, eduLeaveRequestProcessRecord.getApprovalId().toString(), staff);
//                    }
//                }
//                if (ObjectUtil.isNotNull(staff)) {
//                    eduLeaveRequestProcessRecord.setApprovaler(staff);
//                }
//            }
////
////            Map<Long, List<EduStaff>> staffMap = remoteStaffService.listStaff(dto).getData().stream()
////                .collect(Collectors.groupingBy(EduStaff::getId));
////
////            list.forEach(e -> {
////                List<EduStaff> staffList = staffMap.get(e.getApprovalId());
////                e.setApprovaler(staffList.get(0));
////            });
//            eduLeaveRequestUserView.setEduLeaveRequestProcessRecordList(list);
//        });
//        eduLeaveRequestUserVO.setEduLeaveRequestUserViewList(userViewList);
//        if (eduLeaveRequestUser.getRequestType() == 1) {
//            EduStudent student = (EduStudent) redisService
//                    .hget(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString());
//            if (ObjectUtil.isNull(student)) {
//                student = remoteStudentService.getStudentNoPermission(eduLeaveRequestUser.getUserId()).getData();
//                if (ObjectUtil.isNotNull(student)) {
//                    redisService.hset(CachePrefixConstant.STUDENT_DATA, eduLeaveRequestUser.getUserId().toString(), student);
//                }
//            }
//            eduLeaveRequestUserVO
//                    .setStudent(student);
//        } else {
//            EduStaff staff = (EduStaff) redisService
//                    .hget(CachePrefixConstant.STAFF_DATA, eduLeaveRequestUser.getUserId().toString());
//            if (ObjectUtil.isNull(staff)) {
//                staff = remoteStaffService.getStaff(eduLeaveRequestUser.getUserId()).getData();
//                if (ObjectUtil.isNotNull(staff)) {
//                    redisService
//                            .hset(CachePrefixConstant.STAFF_DATA, eduLeaveRequestUser.getUserId().toString(), staff);
//                }
//            }
//            eduLeaveRequestUserVO.setStaff(staff);
//        }
//        return eduLeaveRequestUserVO;
//    }
//
//    @Override
//    public void testTamplateCardNotice(String wxId, Long schoolId) {
//        Integer type = 1;
//        Integer isFirst = 1;
//        SendStaffNoticeDTO dto = new SendStaffNoticeDTO();
//        dto.setRequestTime(LocalDateTime.now());
//        dto.setSchoolId(schoolId);
//        dto.setStaffName("张无忌");
//        dto.setRequestEndTime(LocalDateTime.now());
//        dto.setRequestStartTime(LocalDateTime.now());
//        dto.setSchoolType("0");
//        dto.setStaffWxId(wxId);
//        dto.setStatus(0);
//        dto.setRequestUserName("张小小");
//        dto.setRequestUserDeptName("三年二班");
//        dto.setRequestReason("牙疼，需要做手术");
//        log.info("接收发送数据：【{}】", dto);
//        //发送企业微信通知
//        if (dto.getSchoolType().contains("0")) {
//            EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null,
//                    dto.getSchoolId());
//            if (ObjectUtil.isNull(app)) {
//                app = commonService.getAppByCodeAndSchool(AppConstant.TEACHER_LEAVE_REQUEST, null,
//                        dto.getSchoolId());
//            }
//            String accessToken = wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret());
////            String url = String
////                .format("%s&loginType=0&state=%s&userType=0", teacherLeaveRequestUrl + app.getWxCorpId(), app.getCode());
//            String url = String
//                    .format("%s?appId=%s&schoolId=%s&userType=0&titleName=%s", teacherLeaveRequestUrl, app.getWxCorpId(),
//                            FebsUtil.getTopDeptId(), "请假管理");
//            //模板卡片消息--文本通知型
//            TemplateCardNotice templateCardNotice = new TemplateCardNotice();
//            templateCardNotice.setCard_type(NoticeTypeConstant.TEMPLATE_NOTICE_TYPE_TEXT);
//            templateCardNotice.setMain_title(MainTitle.builder().title(type == 1 ? "学生请假申请提醒" : "职工请假申请提醒").build());
//            if (type == 1) {
//                //学生请假
//                if (isFirst == 1) {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，%S同学于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                } else {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，你好！%S老师【%S】已同意%S同学于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getPreStaffName(), dto.getPreStaffRoleName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                }
//            } else {
//                if (isFirst == 1) {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，%S职工于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                } else {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，你好！%S老师【%S】已同意%S职工于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getPreStaffName(), dto.getPreStaffRoleName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                }
//            }
//
//            List<HorizontalContent> horizontalContentList = new ArrayList<>();
//            horizontalContentList
//                    .add(HorizontalContent.builder().keyname(type == 1 ? "班级" : "部门").value(dto.getRequestUserDeptName()).build());
//            horizontalContentList
//                    .add(HorizontalContent.builder().keyname(type == 1 ? "学生" : "职工").value(dto.getRequestUserName()).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假时间")
//                    .value(String.join("至", LocalDateTimeUtil.format(dto.getRequestStartTime(), "yyyy-MM-dd HH:mm"),
//                            LocalDateTimeUtil.format(dto.getRequestEndTime(), "yyyy-MM-dd HH:mm"))).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假原因").value(dto.getRequestReason()).build());
//            templateCardNotice.setHorizontal_content_list(horizontalContentList);
//            templateCardNotice.setCard_action(CardAction.builder().type(1).url(url).build());
//            templateCardNotice
//                    .setJump_list(Collections.singletonList(Jump.builder().type(1).title("点击查看详情并处理").url(url).build()));
//
//            TemplateCardStaffNotice templateCardStaffNotice = new TemplateCardStaffNotice();
//            templateCardStaffNotice.setTouser(dto.getStaffWxId());
//            templateCardStaffNotice.setAgentid(app.getWxAgentId());
//            templateCardStaffNotice.setTemplate_card(templateCardNotice);
//            //发送微信通知
//            wxUtil.pushStaffNotice(accessToken, templateCardStaffNotice);
//        }
//        //TODO 发送易达APP消息
//    }
//
//    @Override
//    public List<EduLeaveRequestUserVO> findUserRequestList(ListUserRequestDTO dto) {
//        return baseMapper.findUserRequestList(dto);
//    }
//
//    /**
//     * 发送职工企业微信端模板消息
//     *
//     * @param dto
//     * @param type    1学生请假，0职工请假
//     * @param isFirst 是否为初次审核 0否，1是
//     */
//    @Async
//    public void sendNotice(SendStaffNoticeDTO dto, Integer isFirst, Integer type, Long requestId) {
////        log.info("接收发送数据：【{}】", dto);
//        //发送企业微信通知
//        if (dto.getSchoolType().contains("0")) {
//
//            EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null,
//                    dto.getSchoolId());
//            if (ObjectUtil.isNull(app)) {
//                app = commonService.getAppByCodeAndSchool(AppConstant.TEACHER_LEAVE_REQUEST, null,
//                        dto.getSchoolId());
//            }
//            String accessToken = wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret());
//            String url = String
//                    .format("%s?corpId=%s&schoolId=%s&userType=%s&requestId=%s&requestUserType=%s", teacherLeaveRequestUrl,
//                            app.getWxCorpId(),
//                            dto.getSchoolId(), 0, requestId, type == 1 ? 1 : 0);
//            //模板卡片消息--文本通知型
//            TemplateCardNotice templateCardNotice = new TemplateCardNotice();
//            templateCardNotice.setCard_type(NoticeTypeConstant.TEMPLATE_NOTICE_TYPE_TEXT);
//            templateCardNotice.setMain_title(MainTitle.builder().title(type == 1 ? "学生请假申请提醒" : "职工请假申请提醒").build());
//            if (type == 1) {
//                //学生请假
//                if (isFirst == 1) {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，%S同学于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                } else {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，你好！%S老师【%S】已同意%S同学于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getPreStaffName(), dto.getPreStaffRoleName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                }
//            } else {
//                if (isFirst == 1) {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，%S职工于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                } else {
//                    templateCardNotice
//                            .setSub_title_text(String.format("尊敬的%s老师，你好！%S老师【%S】已同意%S职工于%S提交的请假申请，等待您的审批!",
//                                    dto.getStaffName(), dto.getPreStaffName(), dto.getPreStaffRoleName(), dto.getRequestUserName(),
//                                    LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//                }
//            }
//
//            List<HorizontalContent> horizontalContentList = new ArrayList<>();
//            horizontalContentList
//                    .add(HorizontalContent.builder().keyname(type == 1 ? "班级" : "部门").value(dto.getRequestUserDeptName()).build());
//            horizontalContentList
//                    .add(HorizontalContent.builder().keyname(type == 1 ? "学生" : "职工").value(dto.getRequestUserName()).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假类型")
//                    .value(ObjectUtil.isNull(dto.getType()) ? "其他" : LeaveRequestTypeEnum.getName(dto.getType())).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假时间")
//                    .value(String.join("至", LocalDateTimeUtil.format(dto.getRequestStartTime(), "yyyy-MM-dd HH:mm"),
//                            LocalDateTimeUtil.format(dto.getRequestEndTime(), "yyyy-MM-dd HH:mm"))).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假去向").value(dto.getRequestFor()).build());
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假原因").value(dto.getRequestReason()).build());
//            templateCardNotice.setHorizontal_content_list(horizontalContentList);
//            templateCardNotice.setCard_action(CardAction.builder().type(1).url(url).build());
//            templateCardNotice
//                    .setJump_list(Collections.singletonList(Jump.builder().type(1).title("点击查看详情并处理").url(url).build()));
//
//            TemplateCardStaffNotice templateCardStaffNotice = new TemplateCardStaffNotice();
//            templateCardStaffNotice.setTouser(dto.getStaffWxId());
//            templateCardStaffNotice.setAgentid(app.getWxAgentId());
//            templateCardStaffNotice.setTemplate_card(templateCardNotice);
//            //发送微信通知
//            wxUtil.pushStaffNotice(accessToken, templateCardStaffNotice);
//        }
//        //TODO 发送易达APP消息
//    }
//
//    /**
//     * 发送家长通知 -- 请假结果
//     *
//     * @param school
//     * @param
//     */
//    @Async
//    public void sendParentNotice(Dept school, Integer type, String studentName, Long studentId, LocalDateTime requestTime,
//                                 Long requestId) {
//        //发送企业微信通知
//        if (school.getSchoolType().contains("0")) {
//            TextSchoolNotice textSchoolNotice = new TextSchoolNotice();
//
//            EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.INDEX_PARENT, null,
//                    school.getDeptId());
//
//            List<String> parentId = remoteStudentService.findParentWxId(Collections.singletonList(studentId)).getData();
//
//            Text text = new Text();
//            textSchoolNotice.setText(text);
//            textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId());
//            String url = String
//                    .format("%s?corpId=%s&schoolId=%s&userType=%s&requestId=%s&requestUserType=%s", teacherLeaveRequestUrl,
//                            appByCodeAndSchool.getWxCorpId(),
//                            school.getDeptId(), 1, requestId, 1);
//
//            String msg = ObjectUtil.equals(ApprovalResultEnum.AUDIT_PASS.getResult(), type) ? "已通过" : "未通过";
//            text.setContent(
//                    "<a href='" + url + "'>" + studentName + "同学于" + LocalDateTimeUtil.format(requestTime, "yyyy-MM-dd HH:mm:ss")
//                            + "的请假审核" + msg + "，点击可查看详情" + "</a>");
//            textSchoolNotice.setTo_parent_userid(parentId);
//            String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret());
//            wxUtil.pushSchoolNotice(accessToken, textSchoolNotice);
//        }
//        //TODO 发送易达APP消息
//    }
//
//
//    /**
//     * 发送职工请假结果通知
//     */
//    @Async
//    public void sendStaffNotice(SendStaffNoticeDTO dto, Long requestId) {
//
//        log.info("发送职工请假结果通知：【{}】", dto);
//        //发送企业微信通知
//        if (dto.getSchoolType().contains("0")) {
//            EduApp app = commonService.getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null,
//                    dto.getSchoolId());
//            if (ObjectUtil.isNull(app)) {
//                app = commonService.getAppByCodeAndSchool(AppConstant.TEACHER_LEAVE_REQUEST, null,
//                        dto.getSchoolId());
//            }
//            String accessToken = wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret());
//
//            String url = String
//                    .format("%s?corpId=%s&schoolId=%s&userType=%s&requestId=%s&requestUserType=%s", teacherLeaveRequestUrl,
//                            app.getWxCorpId(),
//                            dto.getSchoolId(), 0, requestId, 0);
//            //模板卡片消息--文本通知型
//            TemplateCardNotice templateCardNotice = new TemplateCardNotice();
//            templateCardNotice.setCard_type(NoticeTypeConstant.TEMPLATE_NOTICE_TYPE_TEXT);
//            templateCardNotice.setMain_title(MainTitle.builder().title("请假结果通知").build());
//
//            templateCardNotice
//                    .setSub_title_text(String.format("尊敬的%S老师，您好，您于%S的请假申请结果",
//                            dto.getStaffName(), LocalDateTimeUtil.format(dto.getRequestTime(), "yyyy-MM-dd HH:mm:ss")));
//
//            List<HorizontalContent> horizontalContentList = new ArrayList<>();
//            horizontalContentList.add(HorizontalContent.builder().keyname("请假时间")
//                    .value(String.join("至", LocalDateTimeUtil.format(dto.getRequestStartTime(), "yyyy-MM-dd HH:mm"),
//                            LocalDateTimeUtil.format(dto.getRequestEndTime(), "yyyy-MM-dd HH:mm"))).build());
//            horizontalContentList
//                    .add(HorizontalContent.builder().keyname("结果").value(dto.getStatus() == 1 ? "审批通过" : "审批未通过").build());
////            horizontalContentList.add(HorizontalContent.builder().keyname("请假原因").value(dto.getRequestReason()).build());
//            templateCardNotice.setHorizontal_content_list(horizontalContentList);
//            templateCardNotice.setCard_action(CardAction.builder().type(1).url(url).build());
//            templateCardNotice.setJump_list(Collections.singletonList(Jump.builder().type(1).title("点击查看详情").url(url).build()));
//
//            TemplateCardStaffNotice templateCardStaffNotice = new TemplateCardStaffNotice();
//            templateCardStaffNotice.setTouser(dto.getStaffWxId());
//            templateCardStaffNotice.setAgentid(app.getWxAgentId());
//            templateCardStaffNotice.setTemplate_card(templateCardNotice);
//            //发送微信通知
//            wxUtil.pushStaffNotice(accessToken, templateCardStaffNotice);
//        }
//    }
//
//    /**
//     * 添加请假策略
//     */
//    public void addLeaveRequestStrategy(Long strategyId, EduLeaveRequestUser user) {
//        ADD_LEAVE_REQUEST_POOL.execute(() -> {
//            remoteAttendanceStrategyService.addLeaveRequestStrategy(
//                    AddLeaveRequestStrategyDTO.builder()
//                            .requestId(user.getId())
//                            .userId(user.getUserId())
//                            .strategyId(strategyId)
//                            .requestType(user.getRequestType())
//                            .schoolId(user.getSchoolId())
//                            .startTime(user.getStartTime())
//                            .endTime(user.getEndTime())
//                            .build());
//        });
//    }
//}
