package com.jwipc.spe.model.query;

import com.google.common.collect.Lists;
import com.jwipc.query.BasePageQuery;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 绩效考核整改通知单 查询实体类
 * </p>
 *
 * @author likui
 * @version 1.0
 * @since 2019/9/13
 */
@Data
public class AppraiseRectifiedNoticeQuery extends BasePageQuery {

    /**
     * 绩效考核结果ID
     */
    private Long resultId;
    /**
     * 通知单ID
     */
    private Long noticeId;
    /**
     * 通知单号
     */
    private String noticeCode;
    /**
     * 通知单状态 -1:全部 0:待整改 1:待跟踪 2:待审批 3:已完结
     */
    private Integer status;

    /**
     * 供应商编码
     */
    private String supplierCode;

    /**
     * 供应商主键
     */
    private Long supplierId;
    /**
     * 供应商名称
     */
    private String supplierName;

    private String level;
    /**
     * 多个数据状态字符串 逗号分隔
     */
    private String statusStr;

    public String getStatusStr() {
        if (Objects.nonNull(this.status)) {
            return null;
        }
        return statusStr;
    }

    /**
     * 创建人编码
     */
    private String confirmUserCode;


    public String getNoticeCodeLike() {
        return StringUtils.isEmpty(this.noticeCode) ? null : "%" + this.noticeCode + "%";
    }

    public String getSupplierCodeLike() {
        return StringUtils.isEmpty(this.supplierCode) ? null : "%" + this.supplierCode + "%";
    }

    public String getSupplierNameLike() {
        return StringUtils.isEmpty(this.supplierName) ? null : "%" + this.supplierName + "%";
    }

    public List<Integer> getStatusList() {
        if (StringUtils.isNotEmpty(this.getStatusStr())) {
            List<Integer> res = Lists.newArrayList();
            String[] strArray = StringUtils.split(this.getStatusStr(), ",");
            for (String str : strArray) {
                res.add(Integer.parseInt(str));
            }
            return res;
        }
        return null;
    }

}
