package cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo;

import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

@Schema(description = "管理后台 - 用户打卡记录新增/修改 Request VO")
@Data
public class AttendancePunchRecordSaveReqVO {
    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "65")
    private Long id;

    @Schema(description = "考勤组管理员id", example = "11409")
    private Long userId;

    @Schema(description = "考勤组id", example = "22293")
    private Long attendanceGroupId;

    @Schema(description = "班次id", example = "10780")
    private Long attendanceGroupShiftId;

    @Schema(description = "班次子表id", example = "10780")
    private Long attendanceGroupShiftItemId;

    @Schema(description = "考勤类型 1固定班制 2排班制", example = "2")
    private Integer type;

    @Schema(description = "打卡类型 1考勤机 2小程序范围打卡", example = "2")
    private Integer punchType;

    @Schema(description = "上下班类型 0上班 1下班", example = "1")
    private Integer workType;

    @Schema(description = "级别 1到～", example = "1")
    private Integer level;

    @Schema(description = "打卡状态 0正常 1迟到 2早退 3缺卡 4补卡", example = "1")
    private Integer status;

    @Schema(description = "是否外勤 0否 1是", example = "1")
    private Integer fieldServiceFlag;

    @Schema(description = "日期yyyy-MM-dd格式")
    private String dayTime;

    @Schema(description = "应打卡时间")
    private LocalDateTime shouldPunchTime;

    @Schema(description = "打卡时间")
    private LocalDateTime punchTime;

    @Schema(description = "打卡备注", example = "你说的对")
    private String remark;

    @Schema(description = "图片")
    private String image;

    @Schema(description = "用户打卡地点")
    private String punchAddress;


    @Schema(description = "迟到时长时间戳")
    private Long lateTime;

    @Schema(description = "早退时长时间戳")
    private Long leaveEarlyTime;


    /**
     * 打卡类型(0上班卡 1下班卡 2迟到卡 3早退卡 4未到打卡时间) 转 打卡状态 0正常 1迟到 2早退 3缺卡 4补卡
     *
     * @param punchType
     * @return
     */
    public static Integer convertStatus(Integer punchType) {
        if (punchType == 0 || punchType == 1) {
            return 0;
        } else if (punchType == 2) {
            return 1;
        } else if (punchType == 3) {
            return 2;
        }
        return null;
    }

}