package com.gci.boot.modules.gis.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gci.boot.annotation.Query.OrderQuery;
import com.gci.boot.annotation.Query.SelectQuery;
import com.gci.boot.annotation.repeat.FieldRepeat;
import com.gci.boot.annotation.repeat.TableRepeat;
import com.gci.boot.common.dict.annotation.Dict;
import com.gci.boot.common.validated.SaveValidated;
import com.gci.boot.common.validated.UpdateValidated;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.*;

/**
 * <p>
 * 围栏方案表
 * </p>
 *
 * @author 2464
 * @since 2023-08-30
 */
@Data
@TableName("tb_gis_fence_plan")
@ApiModel(value = "TbGisFencePlan对象", description = "围栏方案表")
@TableRepeat(aClass = TbGisFencePlan.class,groups = {SaveValidated.class,UpdateValidated.class})
public class TbGisFencePlan implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotBlank(message = "id不能为空！",groups = {UpdateValidated.class})
    private String id;

    @ApiModelProperty("方案名称")
    @SelectQuery
    @NotBlank(message = "方案名称不能为空",groups = {SaveValidated.class,UpdateValidated.class})
    @Size(max = 64,message = "方案名称不能超过64位字符！",groups = {SaveValidated.class,UpdateValidated.class})
    @FieldRepeat(message = "方案名称不能重复！")
    private String name;

    @ApiModelProperty("所属项目id")
    @SelectQuery
    @Dict(dicCode = "id",dictTable = "tb_projects",dicText = "project_name")
    @NotBlank(message = "项目不能为空!",groups = {SaveValidated.class,UpdateValidated.class})
    private String projectId;

    @ApiModelProperty("围栏类型 1-停场 2-行驶")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dicCode = "fence_type")
    @NotNull(message = "围栏类型不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private Integer fenceType;

    @ApiModelProperty("开始时间")
    @Pattern(regexp = "^(?:[01]\\d|2[0-3]):[0-5]\\d$",message = "开始时间格式错误",groups = {SaveValidated.class, UpdateValidated.class})
    private String startTime;

    @ApiModelProperty("结束时间")
    @Pattern(regexp = "^(?:[01]\\d|2[0-3]):[0-5]\\d$",message = "结束时间格式错误",groups = {SaveValidated.class, UpdateValidated.class})
    private String endTime;

    @ApiModelProperty("是否跨天")
    @NotNull(message = "是否跨天不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private Integer isOvernight;

    @ApiModelProperty("车辆驶出围栏多少分钟后开始告警，整数")
//    @NotNull(message = "告警时间限制不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private Integer alertDelayMinutes;

    @ApiModelProperty("是否有效 0-无效 1-有效")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dicCode = "yes_no")
    @NotNull(message = "是否有效不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private Integer isValid;

    @ApiModelProperty("所属机构")
    @ExcelIgnore
    private String sysOrgCode;

    @ApiModelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ExcelIgnore
    @OrderQuery(sort = 1)
    private Date createTime;

    @ApiModelProperty("创建人")
    @ExcelIgnore
    private String createBy;

    @ApiModelProperty("更新时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ExcelIgnore
    private Date updateTime;

    @ApiModelProperty("更新人")
    @ExcelIgnore
    @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname")
    private String updateBy;

    @ApiModelProperty("围栏gso列表")
    @ExcelIgnore

    @Valid
    @TableField(exist = false)
    @NotEmpty(message = "围栏信息不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private List<TbGisFenceInfo> gisFenceInfoList;

    @TableField(exist = false)
    private List<String> vehicleList;
}
