package cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.AssertTrue; import java.math.BigDecimal; import java.time.LocalTime; @Schema(description = "管理后台 - 考勤规则新增/修改 Request VO") @Data public class HrmAttendanceRuleSaveReqVO { @Schema(description = "规则ID(修改时必填)", example = "1") private Long id; @Schema(description = "规则名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "标准考勤规则") @NotBlank(message = "规则名称不能为空") private String name; @Schema(description = "适用部门ID(空表示全局)", example = "1") private Long deptId; @Schema(description = "上班时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") @NotNull(message = "上班时间不能为空") private LocalTime workStartTime; @Schema(description = "下班时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "18:00:00") @NotNull(message = "下班时间不能为空") private LocalTime workEndTime; @Schema(description = "迟到允许分钟数", example = "10") private Integer lateAllowMinutes; @Schema(description = "早退允许分钟数", example = "10") private Integer earlyAllowMinutes; @Schema(description = "加班起算时长(小时)", example = "1") private BigDecimal overtimeThreshold; @Schema(description = "打卡地点名称") private String locationName; @Schema(description = "打卡地点地址") private String locationAddress; @Schema(description = "地点经度(WGS84)") private BigDecimal longitude; @Schema(description = "地点纬度(WGS84)") private BigDecimal latitude; @Schema(description = "允许打卡半径,单位米") private Integer radiusMeters; @Schema(description = "是否启用位置限制") private Boolean locationRequired; @Schema(description = "坐标系,仅支持 WGS84") private String coordinateSystem; @AssertTrue(message = "启用定位打卡时,地点名称、经纬度和10~5000米打卡半径必须完整配置") public boolean isLocationConfigValid() { if (!Boolean.TRUE.equals(locationRequired)) { return true; } return locationName != null && !locationName.isBlank() && longitude != null && latitude != null && radiusMeters != null && radiusMeters >= 10 && radiusMeters <= 5000 && "WGS84".equalsIgnoreCase(coordinateSystem); } @Schema(description = "状态:0-启用,1-禁用", example = "0") private Integer status; @Schema(description = "备注", example = "适用于研发部门") private String remark; }