BAOLH
2026-11-10 4d730af0447c686133130d0116a0fa3dd82c2dca
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -1,22 +1,26 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.attendance.service.impl;
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository;
import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
@@ -29,8 +33,8 @@
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceGoOutMapper;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl;
import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.SysRostering;
import me.zhengjie.modules.system.domain.User;
@@ -56,40 +60,39 @@
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2023-01-04
**/
 * @author wcd
 * @website https://eladmin.vip
 * @description 服务实现
 * @date 2023-01-04
 **/
@Service
@RequiredArgsConstructor
public class AttendanceGoOutServiceImpl implements AttendanceGoOutService {
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceOvertimeService attendanceOvertimeService;
    private final AttendanceGoOutMapper attendanceGoOutMapper;
    private final UserRepository userRepository;
    private final AttendanceService attendanceService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final OpaiDingTalkService opaiDingTalkService;
    private final AttendanceRepository attendanceRepository;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final DictDetailRepository dictDetailRepository;
    private final DingTalkServiceImpl dingTalkService;
    private final WeComServiceImpl weComService;
    private final TemplateControlFieldService templateControlFieldService;
    private final SysConfigHolidayService sysConfigHolidayService;
    @Override
    public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){
        Page<AttendanceGoOut> page = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
    public Map<String, Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable) {
        Page<AttendanceGoOut> page = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceGoOut, AttendanceGoOutDto> func = new Function<AttendanceGoOut, AttendanceGoOutDto>(){
        Function<AttendanceGoOut, AttendanceGoOutDto> func = new Function<AttendanceGoOut, AttendanceGoOutDto>() {
            @Override
            public AttendanceGoOutDto apply(AttendanceGoOut attendanceGoOut) {
@@ -101,6 +104,13 @@
                //查询审批用户名
                User appUser = userRepository.findById(attendanceGoOutDto.getApprovalUserId()).orElseGet(User::new);
                attendanceGoOutDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceGoOut.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceGoOut.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceGoOutDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceGoOutDto;
            }
        };
@@ -108,7 +118,7 @@
    }
    @Override
    public List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria){
    public List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria) {
        List<AttendanceGoOutDto> attendanceGoOutDtoList = attendanceGoOutMapper.toDto(attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
        attendanceGoOutDtoList.forEach(attendanceGoOutDto -> {
            //查询用户信息
@@ -125,7 +135,7 @@
    @Transactional
    public AttendanceGoOutDto findById(Long id) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(id).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull(attendanceGoOut.getId(),"AttendanceGoOut","id",id);
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", id);
        return attendanceGoOutMapper.toDto(attendanceGoOut);
    }
@@ -157,30 +167,60 @@
        } else {
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(resources.getUserId() == null ? SecurityUtils.getCurrentUserId() : resources.getUserId());
            User approvalUser = userRepository.getOne(resources.getApprovalUserId());
            LocalDate startDate = resources.getOutStartTime().toLocalDateTime().toLocalDate();
            LocalDate endDate = resources.getOutEndTime().toLocalDateTime().toLocalDate();
            LocalTime startTime = resources.getOutStartTime().toLocalDateTime().toLocalTime();
            LocalTime endTime = resources.getOutEndTime().toLocalDateTime().toLocalTime();
            long distance = ChronoUnit.DAYS.between(startDate, endDate);
            List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
            Stream.iterate(startDate, d -> d.plusDays(1)).limit(distance + 1).forEach(localDate -> {
//                SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
//                if ((sysConfigHolidayDto == null && !isWeekend) ||
//                        sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
                    AttendanceGoOut attendanceGoOut = new AttendanceGoOut();
                    //resUserId为null说明是添加,反之
                    if (resources.getUserId() == null) {
                        resources.setUserId(user.getId());
                    }
                    resources.setOutStartTime(Timestamp.valueOf(localDate.atTime(startTime)));
                    resources.setOutEndTime(Timestamp.valueOf(localDate.atTime(endTime)));
                AttendanceGoOut attendanceGoOut = new AttendanceGoOut();
                // resUserId为null说明是添加,反之
                if (resources.getUserId() == null) {
                    resources.setUserId(user.getId());
                }
                    Double result = getRemainingTime(resources);
                    resources.setOutDuration(result);
                    resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
                    attendanceGoOut.copy(resources);
                    attendanceGoOutRepository.save(attendanceGoOut);
                LocalDateTime goOutStartTime = localDate.atStartOfDay();
                LocalDateTime goOutEndTime = localDate.atTime(23, 59, 59);
                if (localDate.equals(endDate)) {
                    goOutEndTime = localDate.atTime(endTime);
                }
                if (localDate.equals(startDate)) {
                    goOutStartTime = localDate.atTime(startTime);
                }
                resources.setOutStartTime(Timestamp.valueOf(goOutStartTime));
                resources.setOutEndTime(Timestamp.valueOf(goOutEndTime));
                Double result = getRemainingTime(resources);
                resources.setOutDuration(result);
                resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
                // 判断是否提交企微审批
                if (siteTypes.size() > 0) {
                    // 添加企微申请参数
                    resources.setWecomType(dictDetailRepository.findByDictNameAndValue("go_out_type", resources.getOutOfOfficeType()).getLabel());
                    resources.setWecomLocation("暂无");
                    resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR);
                    resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOutDuration()).multiply(new BigDecimal(3600)).longValue()));
                    resources.setWecomAttendanceType("4");
                    resources.setWecomApproveWecomId(approvalUser.getWeComId());
                    // 提交申请
                    Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, user.getWeComId());
                    if (approvalResultMap.containsKey("spNo")) {
                        resources.setWecomSpNo(approvalResultMap.get("spNo"));
                    } else {
                        throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
                    }
                }
                attendanceGoOut.copy(resources);
                attendanceGoOutRepository.save(attendanceGoOut);
//                }
//                SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
@@ -222,12 +262,6 @@
//                    attendanceGoOutRepository.save(attendanceGoOut);
//                }
//            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了外出审批,请登录PMS系统处理", "card");
        }
        return attendanceGoOutMapper.toDto(resources);
    }
@@ -236,11 +270,11 @@
    @Transactional(rollbackFor = Exception.class)
    public void update(AttendanceGoOut resources) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", resources.getId());
        attendanceGoOut.copy(resources);
        //审核通过或者退回不能修改
        if(attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
        if (attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)) {
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
@@ -248,8 +282,8 @@
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Role role = user1.getRoles().iterator().next();
        //除超管、总经理只能修改自己信息
        if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
        if (!Constant.SUPER_LEVEL_LIST.contains(Long.valueOf(role.getLevel()))) {
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                throw new BadRequestException("只能修改自己的记录");
            }
        }
@@ -387,21 +421,22 @@
    /**
     * 验证其他状态的表是否有重复
     *
     * @param goStartTime
     * @param goEndTime
     */
    public void repeatValidation(String goStartTime, String goEndTime, Long userId){
    public void repeatValidation(String goStartTime, String goEndTime, Long userId) {
        // 查询请假表(时单位)
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime,goEndTime, userId);
        if(attendanceLeaveList.size() > 0){
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime, goEndTime, userId);
        if (attendanceLeaveList.size() > 0) {
            AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
                    + "已经存在请假记录,请调整时间");
        }
        // 查询出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0,10),goEndTime.substring(0,10), userId);
        if(attendanceBusinessTravelList.size() > 0){
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0, 10), goEndTime.substring(0, 10), userId);
        if (attendanceBusinessTravelList.size() > 0) {
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
@@ -415,16 +450,16 @@
            //根据id查询记录
            Optional<AttendanceGoOut> attendanceGoOut = attendanceGoOutRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
            if (attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)) {
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
            //获取当前登入人信息
            // 获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Role role = user.getRoles().iterator().next();
            //除超管、总经理只能删除自己信息
            if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
                if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
            // 除超管、总经理只能删除自己信息
            if (!Constant.SUPER_LEVEL_LIST.contains(Long.valueOf(role.getLevel()))) {
                if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
@@ -439,7 +474,7 @@
        for (AttendanceGoOutDto attendanceGoOut : all) {
            String outOfOfficeType = attendanceGoOut.getOutOfOfficeType() != null ? dictDetailRepository.findByDictNameAndValue("go_out_type", attendanceGoOut.getOutOfOfficeType()).getLabel() : "";
            String outDurationUnit = attendanceGoOut.getDurationUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TIME_TYPE, attendanceGoOut.getDurationUnit()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("申请者", attendanceGoOut.getUserName());
            map.put("审批者", attendanceGoOut.getAppUserName());
            map.put("外出开始时间", attendanceGoOut.getOutStartTime());
@@ -462,6 +497,7 @@
    /**
     * 计算外出时长
     *
     * @param attendanceGoOut
     * @return
     */
@@ -495,57 +531,75 @@
        LocalTime endTime = calculate.getEnd().toLocalTime();
        long distance = ChronoUnit.DAYS.between(startDate, endDate);
        return Stream.iterate(startDate, d -> d.plusDays(1)).limit(distance + 1).map(localDate -> {
            SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
            if ((sysConfigHolidayDto == null && !isWeekend) ||
                    sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
//            SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//            Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
//            if ((sysConfigHolidayDto == null && !isWeekend) ||
//                    sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
//
//                LocalDateTime goOutStartTime = localDate.atTime(startTime);
//                LocalDateTime goOutEndTime = localDate.atTime(endTime);
//                LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
//                LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
//
//
//                if (goOutEndTime.isBefore(lunchStartTime) || goOutStartTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
//                } else if (!goOutEndTime.isBefore(lunchStartTime) && !goOutEndTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, lunchStartTime);
//                } else if (!goOutStartTime.isBefore(lunchStartTime) && !goOutStartTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(lunchEndTime, goOutEndTime);
//                } else {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime) - 3600;
//                }
//            } else {
//                LocalDateTime goOutStartTime = localDate.atTime(startTime);
//                LocalDateTime goOutEndTime = localDate.atTime(endTime);
//                return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
//            }
                LocalDateTime goOutStartTime = localDate.atTime(startTime);
                LocalDateTime goOutEndTime = localDate.atTime(endTime);
                LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
                LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
                if (goOutEndTime.isBefore(lunchStartTime) || goOutStartTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
                } else if (!goOutEndTime.isBefore(lunchStartTime) && !goOutEndTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(goOutStartTime, lunchStartTime);
                } else if (!goOutStartTime.isBefore(lunchStartTime) && !goOutStartTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(lunchEndTime, goOutEndTime);
                } else {
                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime) - 3600;
                }
            } else {
                LocalDateTime goOutStartTime = localDate.atTime(startTime);
                LocalDateTime goOutEndTime = localDate.atTime(endTime);
                return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
            // TODO:20250806修改 减去下班后休息时段
            LocalDateTime goOutStartTime = localDate.atStartOfDay();
            LocalDateTime goOutEndTime = localDate.atTime(LocalTime.MAX);
            if (localDate.equals(endDate)) {
                goOutEndTime = localDate.atTime(endTime);
            }
            if (localDate.equals(startDate)) {
                goOutStartTime = localDate.atTime(startTime);
            }
            LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
            LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
            LocalDateTime offStartTime = localDate.atTime(sysRostering.getWorkEndTime());
            LocalDateTime offEndTime = offStartTime.plusMinutes(30L);
            Duration duration = Calculate.calculateRemainingDuration(new Calculate(goOutStartTime, goOutEndTime), new Calculate(lunchStartTime, lunchEndTime), new Calculate(offStartTime, offEndTime));
            return duration.get(ChronoUnit.SECONDS);
        }).reduce(0L, (result, current) -> result + current);
    }
    /**
     * 审核/撤销功能
     *
     * @param resources /
     */
    @Override
    public void updateApprove(AttendanceGoOut resources) throws Exception {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", resources.getId());
        attendanceGoOut.copy(resources);
        attendanceGoOutRepository.save(attendanceGoOut);
        // 调用定时任务修改考勤记录
        List<User> userList = new ArrayList<>();
        if(ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())){
        if (ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())) {
            User user = userRepository.findById(attendanceGoOut.getUserId()).orElseGet(User::new);
            userList.add(user);
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String attendanceDate = df.format(attendanceGoOut.getOutStartTime());
        dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList);
        weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
    }
    /**
     * 批量审核(外出)
     *
     * @param request
     * @throws Exception
     */
@@ -553,8 +607,8 @@
    public void updateAgree(AgreeUpdateRequest request) throws Exception {
        for (Long id : request.getIds()) {
            AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(id).orElseGet(AttendanceGoOut::new);
            ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",id);
            if (request.getNum().equals(Long.valueOf(1))){
            ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", id);
            if (request.getNum().equals(Long.valueOf(1))) {
                attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_AGREE);
            } else {
                attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REFUSE);
@@ -562,13 +616,13 @@
            attendanceGoOutRepository.save(attendanceGoOut);
            // 调用定时任务修改考勤记录
            List<User> userList = new ArrayList<>();
            if(ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())){
            if (ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())) {
                User user = userRepository.findById(attendanceGoOut.getUserId()).orElseGet(User::new);
                userList.add(user);
            }
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String attendanceDate = df.format(attendanceGoOut.getOutStartTime());
            dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList);
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
        }
    }
}