上传的图像用于项目: 'CST技术支持'
  1. CST技术支持
  2. SLAL2-1070

林清轩-考勤休假加班汇总表导出报错

XMLWord打印

    • Icon: Change Change
    • 解决结果: 完成
    • Icon: Medium Medium
    • 202009
    • Y-易路产品-
    • linqingxuan
    • 时间管理

      考勤工时的计算公式如下:

      result = {}
      attendance_period = pre_data['attendance_period']
      day_types_without_schedule = pre_data['day_types_without_schedule']
      for employee_id in employee_ids:
      employee_periods = attendance_period.get(employee_id, {})
      employee_days_type = day_types_without_schedule.get(employee_id, {})
      fmt='%Y-%m-%d'
      result[employee_id] = {}
      attendance_hours = 0
      for attendance_date, day_periods in employee_periods.items():
      for day_calendar_id, period in day_periods.items():
      if not period['day_type']:
      continue

      1. 标准工时员工工作日考勤
        if period['day_type'] == 'workday':
        attendance_hours += period['attendance_hours']
      2. 排班工作日考勤
        elif period['day_type'] == 'schedule_workday':
      3. 排班考勤跨天
        if period['clock_in_time'] and period['clock_out_time'] and period['clock_in_time'][0:10]<period['clock_out_time'][0:10]:
        year_1, month_1, day_1 = time.strptime(period['clock_out_time'][0:10], fmt)[:3]
        year_2, month_2, day_2 = time.strptime(period['clock_in_time'][0:10], fmt)[:3]
      4. 签入签出都在法定节假日
        if employee_days_type.get(datetime.date(year_1, month_1, day_1 )) in ['statutory_holiday'] and employee_days_type.get(datetime.date(year_2, month_2, day_2))in ['statutory_holiday']:
        continue
      5. 签入时间在法定节假日,签出时间不在法定节假日
        elif employee_days_type.get(datetime.date(year_2, month_2, day_2)) in ['statutory_holiday'] and employee_days_type.get(datetime.date(year_1, month_1, day_1 )) not in ['statutory_holiday']:
        clock_in_str = '%s 00:00:00'% period['clock_out_time'][0:10]
        clock_in = datetime.datetime.strptime(clock_in_str, '%Y-%m-%d %H:%M:%S')
        clock_out = datetime.datetime.strptime(period['clock_out_time'][0:19],
        '%Y-%m-%d %H:%M:%S')
        clock_buckets = TimeBucketMulti([TimeBucket(clock_in, clock_out)])
        attendance_hours += round(clock_buckets.total_seconds() / 3600.0, 2)
      1. 签入时间不在法定节假日,签出时间在法定节假日
        elif employee_days_type.get(datetime.date(year_2, month_2, day_2)) not in ['statutory_holiday'] and employee_days_type.get(datetime.date(year_1, month_1, day_1 )) in ['statutory_holiday']:
        clock_in = datetime.datetime.strptime(period['clock_in_time'][0:19], '%Y-%m-%d %H:%M:%S')
        clock_out_str = '%s 23:59:59' % period['clock_in_time'][0:10]
        clock_out = datetime.datetime.strptime(clock_out_str, '%Y-%m-%d %H:%M:%S')
        clock_buckets = TimeBucketMulti([TimeBucket(clock_in, clock_out)])
        attendance_hours += round(clock_buckets.total_seconds() / 3600.0, 2)
      1. 签入签出都不在法定节假日
        elif employee_days_type.get(datetime.date(year_1, month_1, day_1 )) not in ['statutory_holiday'] and employee_days_type.get(datetime.date(year_2, month_2, day_2)) not in ['statutory_holiday']:
        attendance_hours += period['attendance_hours']
      1. 没有跨天
        else:
        for day in employee_days_type:
        if employee_days_type.get(day) != 'statutory_holiday' and day.strftime('%Y-%m-%d') == period['attendance_date']:
        attendance_hours += period['attendance_hours']

      else:
      continue
      else:
      continue
      result[employee_id] = attendance_hours

            chengdd 程丹丹
            yuant 袁彤
            表决:
            0 为这个问题表决

              创建日期:
              已更新:
              已解决: