| | |
| | | }else {
|
| | | // 获取当前登陆人信息,设置为请假发起人
|
| | | User user = userRepository.getOne(resources.getUserId());
|
| | | User approvalUser = userRepository.getOne(resources.getApprovalUserId());
|
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
|
| | | // 查询节假日
|
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
|
| | |
| | | if (siteTypes.size() > 0) {
|
| | | // 添加企微申请参数
|
| | | if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) {
|
| | | attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
|
| | | attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR);
|
| | | attendanceLeave.setWecomDuration(String.valueOf(new BigDecimal(attendanceLeave.getLeaveDuration()).multiply(new BigDecimal(3600)).longValue()));
|
| | | } else {
|
| | | attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HALFDAY);
|
| | |
| | | }
|
| | | // 添加企微申请参数
|
| | | Map<String, String> leaveTypeMap = dictDetailRepository.findByDictName(Constant.LEAVE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
|
| | | attendanceLeave.setWecomOptionKey(templateService.getVacationKey(leaveTypeMap.get(attendanceLeave.getLeaveType())));
|
| | | // attendanceLeave.setWecomOptionKey(templateService.getVacationKey(leaveTypeMap.get(attendanceLeave.getLeaveType())));
|
| | | attendanceLeave.setWecomOptionKey(leaveTypeMap.get(attendanceLeave.getLeaveType()));
|
| | | attendanceLeave.setWecomApproveWecomId(approvalUser.getWeComId());
|
| | | // 提交申请
|
| | | String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
|
| | | Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(attendanceLeave, weComId);
|
| | | Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(attendanceLeave, user.getWeComId());
|
| | | if (approvalResultMap.containsKey("spNo")) {
|
| | | attendanceLeave.setWecomSpNo(approvalResultMap.get("spNo"));
|
| | | } else {
|
| | |
| | | resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
|
| | | resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
|
| | | }
|
| | | Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
|
| | | Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId(), resources.getLeaveType().equals(Constant.LEAVE_TYPE_LACTATION_LEAVE) ? 1 : null);
|
| | | Double result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | resources.setLeaveDuration(result);
|
| | | }
|
| | |
| | | @Override
|
| | | public AttendanceLeaveDto calcTimeLength(AttendanceLeave resources) throws Exception {
|
| | | AttendanceLeaveDto attendanceLeaveDto = new AttendanceLeaveDto();
|
| | | //根据字典名称查询
|
| | | // 根据字典名称查询
|
| | | List<DictDetail> dictDetailList = dictDetailRepository.findByDictName("leave_type");
|
| | | List<String> leaveTypes = new ArrayList<>();
|
| | | for(DictDetail dictDetail : dictDetailList){
|
| | | if(dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)){
|
| | | //事假和年假
|
| | | for (DictDetail dictDetail : dictDetailList) {
|
| | | if (dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_LACTATION_LEAVE)) {
|
| | | // 事假/年假/调休假/哺乳假
|
| | | leaveTypes.add(dictDetail.getValue());
|
| | | }
|
| | | }
|
| | |
| | | calculate.setStart(resources.getLeaveStartTime().toLocalDateTime());
|
| | | calculate.setEnd(resources.getLeaveEndTime().toLocalDateTime());
|
| | | Double result = new Double(0.00);
|
| | | //判断集合是否包含年假或事假,包含计算以时为单位,反之以天为单位进行计算
|
| | | if(leaveTypes.contains(resources.getLeaveType())){
|
| | | Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
|
| | | // 判断集合是否包含年假或事假,包含计算以时为单位,反之以天为单位进行计算
|
| | | if (leaveTypes.contains(resources.getLeaveType())) {
|
| | | // 以小时为单位计算
|
| | | Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId(), resources.getLeaveType().equals(Constant.LEAVE_TYPE_LACTATION_LEAVE) ? 1 : null);
|
| | | result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_HOUR);
|
| | | }else{
|
| | | } else {
|
| | | // 以天为单位计算
|
| | | Integer days = attendanceService.calculateDays(calculate);
|
| | | result = Double.valueOf(new BigDecimal(days).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_DAY);
|