package com.sa.ibiz.demo.demo.service.dto;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.ibizutil.domain.ParentData;
import com.sa.ibiz.demo.demo.domain.BGYPSQMX;
import org.springframework.util.StringUtils;
import lombok.Data;
import java.util.Map;
import java.sql.Timestamp;
import com.sa.ibiz.demo.ibizutil.service.SearchFilterBase;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sa.ibiz.demo.ibizutil.helper.DataGridCustomSearchHelper;
import com.alibaba.fastjson.JSONObject;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class BGYPSQMXSearchFilter extends SearchFilterBase {

	private String query;
	private Page page;
	private QueryWrapper<BGYPSQMX> selectCond;
	private JSONObject customsearchval;
	public BGYPSQMXSearchFilter(){
		this.page =new Page<BGYPSQMX>(1,Short.MAX_VALUE);
		this.selectCond=new QueryWrapper<BGYPSQMX>();	
	}

	/**
	 * 设定自定义查询条件，在原有SQL基础上追加该SQL
	 */
	public void setCustomCond(String sql)
	{
		this.selectCond.apply(sql);
	}

	private String n_bgypid_eq;

	public void setN_bgypid_eq(String n_bgypid_eq) {
        this.n_bgypid_eq = n_bgypid_eq;
        if(!StringUtils.isEmpty(this.n_bgypid_eq)){
            this.selectCond.eq("bgypid", n_bgypid_eq);
        }
    }
	private String n_bgypname_eq;

	public void setN_bgypname_eq(String n_bgypname_eq) {
        this.n_bgypname_eq = n_bgypname_eq;
        if(!StringUtils.isEmpty(this.n_bgypname_eq)){
            this.selectCond.eq("bgypname", n_bgypname_eq);
        }
    }
	private String n_bgypname_like;

	public void setN_bgypname_like(String n_bgypname_like) {
        this.n_bgypname_like = n_bgypname_like;
        if(!StringUtils.isEmpty(this.n_bgypname_like)){
            this.selectCond.like("bgypname", n_bgypname_like);
        }
    }
	private String n_bgypsqid_eq;

	public void setN_bgypsqid_eq(String n_bgypsqid_eq) {
        this.n_bgypsqid_eq = n_bgypsqid_eq;
        if(!StringUtils.isEmpty(this.n_bgypsqid_eq)){
            this.selectCond.eq("bgypsqid", n_bgypsqid_eq);
        }
    }
	private String n_bgypsqmxname_like;

	public void setN_bgypsqmxname_like(String n_bgypsqmxname_like) {
        this.n_bgypsqmxname_like = n_bgypsqmxname_like;
        if(!StringUtils.isEmpty(this.n_bgypsqmxname_like)){
            this.selectCond.like("bgypsqmxname", n_bgypsqmxname_like);
        }
    }
	private String n_bgypsqname_eq;

	public void setN_bgypsqname_eq(String n_bgypsqname_eq) {
        this.n_bgypsqname_eq = n_bgypsqname_eq;
        if(!StringUtils.isEmpty(this.n_bgypsqname_eq)){
            this.selectCond.eq("bgypsqname", n_bgypsqname_eq);
        }
    }
	private String n_bgypsqname_like;

	public void setN_bgypsqname_like(String n_bgypsqname_like) {
        this.n_bgypsqname_like = n_bgypsqname_like;
        if(!StringUtils.isEmpty(this.n_bgypsqname_like)){
            this.selectCond.like("bgypsqname", n_bgypsqname_like);
        }
    }

	public void setSrfparentdata(Map<String, String> srfparentdata) {
		this.srfparentdata = srfparentdata;
		String strParentkey=this.getSrfparentdata().get("srfparentkey");
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_BGYPSQMX_BGYP_BGYPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_bgypid_eq("NA");
			}
			else{
				this.setN_bgypid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_BGYPSQMX_BGYPSQ_BGYPSQID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_bgypsqid_eq("NA");
			}
			else{
				this.setN_bgypsqid_eq(strParentkey);
			}
	}

	/**
	 * 启用快速搜索
	 */
	public void setQuery(String query)
	{
		 this.query=query;
		 if(!StringUtils.isEmpty(query)){
			this.selectCond.or().like("bgypsqmxname",query);
		 }
	}

	/**
	 * 自定义查询
	 * @param customsearchval
	 */
	public void setCustomsearchval(JSONObject customsearchval) {
		this.customsearchval = customsearchval;
		if(!StringUtils.isEmpty(customsearchval)){
			DataGridCustomSearchHelper customSearchHelper= DataGridCustomSearchHelper.getInstance();
			String customSql =customSearchHelper.parseCustomVal(customsearchval);
			this.selectCond.apply(customSql);
		}
	}

}