package com.jwipc.order.model.query;

import cn.hutool.core.util.StrUtil;
import com.jwipc.db.DbUtil;
import com.jwipc.query.BaseSortQuery;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serial;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Data
public class PurchaseOrderDetailQuery extends BaseSortQuery {
    @Serial
    private static final long serialVersionUID = 8254796759953372704L;
    private int replay;
    private String startTime;
    private String endTime;
    private String viewCode;
    private String orderId;
    private String orderCode;
    private String createName;
    private String company;
    private String supplierErpCode;
    private String supplierErpCodeStr;
    private String mrp;
    private String factoryCode;
    private String material;
    private String supplierCode;
    private String startCreateDate;
    private String endCreateDate;
    //需求日期起止查询条件
    private String requireStartDate;
    private String requireEndDate;
    private String supplierName;
    private String orderTypeCode;
    private String purchaseGroupCode;
    private Set<String> userPurchaseGroupCodes;
    private String markFlag;
    private String finishJaoHuo;
    private String devCount = "";
    private int devCount1 = -1;
    private String loginSupplierCode;
    private int forCreateDelivery = 0;
    private Integer delFlag;
    private String warningFlag;
    private String statusStr;
    private List<String> statusStrs;
    private Integer supplierVisible;
    private String rowTypeCode;
    private String remark;
    private String exportType;
    private String noClearNum;
    private String supplierCode1;
    private String supplierName1;
    public List<String> getStatusStrs(){
        if (StringUtils.isNotEmpty(this.statusStr)){
            return  Arrays.asList(StringUtils.split(this.statusStr, ","));
        }
        return null;
    }

    public String getOrderCode() {
        return DbUtil.toRegexp(this.orderCode);
    }

    public String getSupplierErpCode() {
        return DbUtil.toRegexp(this.supplierErpCode);
    }
    public String getSupplierName() {
        return DbUtil.toRegexp(this.supplierName);
    }

    public String getSupplierCode1() {
        if(this.supplierCode1 == null || "0".equals(this.supplierCode1)) {
            return  StrUtil.EMPTY;
        }
        return this.supplierCode1;
    }
    public String getSupplierErpCodeStr() {
        return DbUtil.toRegexp(this.supplierErpCodeStr);
    }
    public String getMaterial() {
        return DbUtil.toRegexp(this.material);
    }

    public String getSupplierCode() {
        return DbUtil.toRegexp(this.supplierCode);
    }

    public String getCompany() {
        return DbUtil.toRegexp(this.company);
    }
}
