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.OrgSector;
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 OrgSectorSearchFilter extends SearchFilterBase {

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

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

	private String n_orgid_eq;

	public void setN_orgid_eq(String n_orgid_eq) {
        this.n_orgid_eq = n_orgid_eq;
        if(!StringUtils.isEmpty(this.n_orgid_eq)){
            this.selectCond.eq("orgid", n_orgid_eq);
        }
    }
	private String n_orgname_eq;

	public void setN_orgname_eq(String n_orgname_eq) {
        this.n_orgname_eq = n_orgname_eq;
        if(!StringUtils.isEmpty(this.n_orgname_eq)){
            this.selectCond.eq("orgname", n_orgname_eq);
        }
    }
	private String n_orgname_like;

	public void setN_orgname_like(String n_orgname_like) {
        this.n_orgname_like = n_orgname_like;
        if(!StringUtils.isEmpty(this.n_orgname_like)){
            this.selectCond.like("orgname", n_orgname_like);
        }
    }
	private String n_orgsectorname_like;

	public void setN_orgsectorname_like(String n_orgsectorname_like) {
        this.n_orgsectorname_like = n_orgsectorname_like;
        if(!StringUtils.isEmpty(this.n_orgsectorname_like)){
            this.selectCond.like("orgsectorname", n_orgsectorname_like);
        }
    }
	private String n_porgsectorid_eq;

	public void setN_porgsectorid_eq(String n_porgsectorid_eq) {
        this.n_porgsectorid_eq = n_porgsectorid_eq;
        if(!StringUtils.isEmpty(this.n_porgsectorid_eq)){
            this.selectCond.eq("porgsectorid", n_porgsectorid_eq);
        }
    }
	private String n_porgsectorname_eq;

	public void setN_porgsectorname_eq(String n_porgsectorname_eq) {
        this.n_porgsectorname_eq = n_porgsectorname_eq;
        if(!StringUtils.isEmpty(this.n_porgsectorname_eq)){
            this.selectCond.eq("porgsectorname", n_porgsectorname_eq);
        }
    }
	private String n_porgsectorname_like;

	public void setN_porgsectorname_like(String n_porgsectorname_like) {
        this.n_porgsectorname_like = n_porgsectorname_like;
        if(!StringUtils.isEmpty(this.n_porgsectorname_like)){
            this.selectCond.like("porgsectorname", n_porgsectorname_like);
        }
    }
	private String n_reporgsectorid_eq;

	public void setN_reporgsectorid_eq(String n_reporgsectorid_eq) {
        this.n_reporgsectorid_eq = n_reporgsectorid_eq;
        if(!StringUtils.isEmpty(this.n_reporgsectorid_eq)){
            this.selectCond.eq("reporgsectorid", n_reporgsectorid_eq);
        }
    }
	private String n_reporgsectorname_eq;

	public void setN_reporgsectorname_eq(String n_reporgsectorname_eq) {
        this.n_reporgsectorname_eq = n_reporgsectorname_eq;
        if(!StringUtils.isEmpty(this.n_reporgsectorname_eq)){
            this.selectCond.eq("reporgsectorname", n_reporgsectorname_eq);
        }
    }
	private String n_reporgsectorname_like;

	public void setN_reporgsectorname_like(String n_reporgsectorname_like) {
        this.n_reporgsectorname_like = n_reporgsectorname_like;
        if(!StringUtils.isEmpty(this.n_reporgsectorname_like)){
            this.selectCond.like("reporgsectorname", n_reporgsectorname_like);
        }
    }
	private String n_shortname_like;

	public void setN_shortname_like(String n_shortname_like) {
        this.n_shortname_like = n_shortname_like;
        if(!StringUtils.isEmpty(this.n_shortname_like)){
            this.selectCond.like("shortname", n_shortname_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_ORGSECTOR_ORG_ORGID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_orgid_eq("NA");
			}
			else{
				this.setN_orgid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORGSECTOR_ORGSECTOR_PORGSECTORID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_porgsectorid_eq("NA");
			}
			else{
				this.setN_porgsectorid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORGSECTOR_ORGSECTOR_REPORGSECTORID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_reporgsectorid_eq("NA");
			}
			else{
				this.setN_reporgsectorid_eq(strParentkey);
			}
	}

	/**
	 * 启用快速搜索
	 */
	public void setQuery(String query)
	{
		 this.query=query;
		 if(!StringUtils.isEmpty(query)){
			this.selectCond.or().like("orgsectorname",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);
		}
	}

}