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.chushang.security.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
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 WrkAppQuery extends CommonParam {

    /**
     * 用户id
     */
    @Builder.Default
    @JsonIgnore
    @Condition(name = "user_id", tableName = "i")
    private Long userId = SecurityUtils.getUserId();

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

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

    /**
     * 工单状态
     */
    @NotNull(message = "工单状态不能为空")
    @Range(min = 1, max = 7, message = "工单状态非法")
    private Integer wrkStatus;

    /**
     * 终端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 = "终端编号不能超过30个字符")
    private String terminalNo;

    /**
     * 商户名称
     */
    @Size(max = 128, message = "商户名称不能超过128个字符")
    @Condition(name = "store_name", type = Condition.ConditionType.like, tableName = "isr")
    private String storeName;

    /**
     * 下级任务名称
     */
    @Size(max = 64, message = "下级任务名称不能超过64个字符")
    @Condition(name = "task_name", type = Condition.ConditionType.like, tableName = "i")
    private String taskName;

    /**
     * 门店名称
     */
    @Condition(name = "shop_name", type = Condition.ConditionType.like, tableName = "isr")
    @Size(max = 128, message = "门店名称不能超过128个字符")
    private String shopName;

    /**
     * 商戶地址
     */
    @Condition(name = "store_address", type = Condition.ConditionType.like, tableName = "isr")
    @Size(max = 300, message = "商戶地址不能超过300个字符")
    private String storeAddress;
    /**
     * 处理时间
     */
    @Condition(name = "dispose_time", type = Condition.ConditionType.between, tableName = "i")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    private List<LocalDateTime> disposeTimes;

    /**
     * 工单状态, 当查询 审核通过时, 此处为3,4 拒绝时此处为5,6
     */
    @Condition(name = "wrk_status", type = Condition.ConditionType.in, tableName = "i")
    @Null(message = "内部流转参数")
    private List<Integer> wrkStatusList;


}
