| | |
| | |
|
| | | 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;
|
| | |
| | | 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.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;
|
| | |
| | | import java.time.temporal.ChronoUnit;
|
| | | import java.util.*;
|
| | | import java.util.function.Function;
|
| | | import java.util.stream.Collectors;
|
| | | import java.util.stream.Stream;
|
| | |
|
| | | /**
|
| | | * @author wcd
|
| | | * @website https://eladmin.vip
|
| | | * @description 服务实现
|
| | | * @author wcd
|
| | | * @date 2023-01-04
|
| | | **/
|
| | | @Service
|
| | |
| | | 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 WeComServiceImpl weComService;
|
| | | private final TemplateControlFieldService templateControlFieldService;
|
| | |
|
| | | private final SysConfigHolidayService sysConfigHolidayService;
|
| | |
|
| | |
| | | //查询审批用户名
|
| | | 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;
|
| | | }
|
| | | };
|
| | |
| | | Double result = getRemainingTime(resources);
|
| | | resources.setOutDuration(result);
|
| | | resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
|
| | |
|
| | | // 判断是否提交企微审批
|
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
|
| | | if (siteTypes.size() > 0) {
|
| | | // 添加企微申请参数
|
| | | resources.setWecomType(dictDetailRepository.findByDictNameAndValue("go_out_type", resources.getOutOfOfficeType()).getLabel());
|
| | | resources.setWecomLocation("暂无");
|
| | | resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
|
| | | resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOutDuration()).multiply(new BigDecimal(3600)).longValue()));
|
| | | resources.setWecomAttendanceType("4");
|
| | | // 提交申请
|
| | | String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
|
| | | Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, weComId);
|
| | | 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);
|
| | | // }
|
| | |
| | | // 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);
|
| | | }
|
| | |
| | |
|
| | | /**
|
| | | * 验证其他状态的表是否有重复
|
| | | *
|
| | | * @param goStartTime
|
| | | * @param goEndTime
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 计算外出时长
|
| | | *
|
| | | * @param attendanceGoOut
|
| | | * @return
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 审核/撤销功能
|
| | | *
|
| | | * @param resources /
|
| | | */
|
| | | @Override
|
| | |
| | |
|
| | | /**
|
| | | * 批量审核(外出)
|
| | | *
|
| | | * @param request
|
| | | * @throws Exception
|
| | | */
|