package com.chushang.inspection.work.query;

import cn.hutool.core.date.DatePattern;
import com.chushang.common.mybatis.annotation.Condition;
import com.chushang.common.mybatis.page.CommonParam;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ReviewedQuery extends CommonParam {

    /**
     * 工单编号
     */
    @Condition(name = "work_no", tableName = "i")
    private String workNo;

    /**
     * 商户编号
     */
    @Condition(name = "store_no", tableName = "isr")
    @Size(max = 64, message = "商户编号不能超过64个字符")
    private String storeNo;

    /**
     * 终端sn号
     */
    @Condition(name = "terminal_sn", tableName = "itr")
    @Size(max = 100, message = "终端sn号不能超过100个字符")
    private String terminalSn;

    /**
     * 终端编号
     */
    @Condition(name = "terminal_no", tableName = "itr")
    @Size(max = 30, message = "终端sn号不能超过30个字符")
    private String terminalNo;

    /**
     * 任务id
     */
    @Condition(name = "task_id", tableName = "i")
    private Long taskId;

    /**
     * 工单类型
     */
    @Condition(name = "work_type", tableName = "i")
    @Range(min = 1, max = 50, message = "工单类型非法")
    private Integer workType;

    /**
     * 工单状态
     * 2 待初审,
     * 3 待复审
     * 4 归档
     * null 全部
     */
    private int wrkStatus;

    /**
     * 终端类型
     */
    @Condition(name = "terminal_type", tableName = "itr")
    private Integer terminalType;

    /**
     * 巡检频次
     */
    @Condition(name = "ins_fre", tableName = "isr")
    private Integer insFre;

    /**
     * 处理时间
     */
    @Condition(name = "dispose_time", type = Condition.ConditionType.between, tableName = "i")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    private List<LocalDateTime> disposeTime;

    /**
     * 审核时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    private List<LocalDateTime> auditTime;

    /**
     * 领用时间
     */
    @Condition(name = "create_time", type = Condition.ConditionType.between, tableName = "i")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    private List<LocalDateTime> createTime;

    /**
     * 复审时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    private List<LocalDateTime> reviewTime;

    /**
     * 工单状态
     */
    @Condition(name = "wrk_status", type = Condition.ConditionType.in, tableName = "i")
    @Null(message = "内部参数，不允许访问")
    private List<Integer> states;

    /**
     * 业务员名称/门店名称
     */
    @Size(max = 128, message = "业务员名称/门店名称不能超过128个字符")
    @Condition(name = "shop_name,user_name,store_name", type = Condition.ConditionType.or_like, tableName = "isr")
    private String universal;

    /**
     * 下级任务id
     */
    @Condition(name = "lower_task_id", type = Condition.ConditionType.in, tableName = "i")
    private List<Long> lowerTaskIds;

    /**
     * 商户id
     */
    @Condition(name = "store_id", type = Condition.ConditionType.eq, tableName = "isr")
    private Long storeId;

    @Condition(name = "terminal_source", type = Condition.ConditionType.eq, tableName = "itr")
    private Integer terminalSource;

    @Condition(name = "terminal_status", type = Condition.ConditionType.eq, tableName = "itr")
    private Integer terminalStatus;

}
