| | |
| | | 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);
|