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.DataEntity;
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 DataEntitySearchFilter extends SearchFilterBase {

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

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

	private String n_acquerymodelid_eq;

	public void setN_acquerymodelid_eq(String n_acquerymodelid_eq) {
        this.n_acquerymodelid_eq = n_acquerymodelid_eq;
        if(!StringUtils.isEmpty(this.n_acquerymodelid_eq)){
            this.selectCond.eq("acquerymodelid", n_acquerymodelid_eq);
        }
    }
	private String n_acquerymodelname_eq;

	public void setN_acquerymodelname_eq(String n_acquerymodelname_eq) {
        this.n_acquerymodelname_eq = n_acquerymodelname_eq;
        if(!StringUtils.isEmpty(this.n_acquerymodelname_eq)){
            this.selectCond.eq("acquerymodelname", n_acquerymodelname_eq);
        }
    }
	private String n_acquerymodelname_like;

	public void setN_acquerymodelname_like(String n_acquerymodelname_like) {
        this.n_acquerymodelname_like = n_acquerymodelname_like;
        if(!StringUtils.isEmpty(this.n_acquerymodelname_like)){
            this.selectCond.like("acquerymodelname", n_acquerymodelname_like);
        }
    }
	private String n_acsortdir_eq;

	public void setN_acsortdir_eq(String n_acsortdir_eq) {
        this.n_acsortdir_eq = n_acsortdir_eq;
        if(!StringUtils.isEmpty(this.n_acsortdir_eq)){
            this.selectCond.eq("acsortdir", n_acsortdir_eq);
        }
    }
	private Integer n_datachglogmode_eq;

	public void setN_datachglogmode_eq(Integer n_datachglogmode_eq) {
        this.n_datachglogmode_eq = n_datachglogmode_eq;
        if(!StringUtils.isEmpty(this.n_datachglogmode_eq)){
            this.selectCond.eq("datachglogmode", n_datachglogmode_eq);
        }
    }
	private String n_dbstorage_eq;

	public void setN_dbstorage_eq(String n_dbstorage_eq) {
        this.n_dbstorage_eq = n_dbstorage_eq;
        if(!StringUtils.isEmpty(this.n_dbstorage_eq)){
            this.selectCond.eq("dbstorage", n_dbstorage_eq);
        }
    }
	private String n_degroup_eq;

	public void setN_degroup_eq(String n_degroup_eq) {
        this.n_degroup_eq = n_degroup_eq;
        if(!StringUtils.isEmpty(this.n_degroup_eq)){
            this.selectCond.eq("degroup", n_degroup_eq);
        }
    }
	private String n_dename_like;

	public void setN_dename_like(String n_dename_like) {
        this.n_dename_like = n_dename_like;
        if(!StringUtils.isEmpty(this.n_dename_like)){
            this.selectCond.like("dename", n_dename_like);
        }
    }
	private String n_der11deid_eq;

	public void setN_der11deid_eq(String n_der11deid_eq) {
        this.n_der11deid_eq = n_der11deid_eq;
        if(!StringUtils.isEmpty(this.n_der11deid_eq)){
            this.selectCond.eq("der11deid", n_der11deid_eq);
        }
    }
	private String n_der11dename_eq;

	public void setN_der11dename_eq(String n_der11dename_eq) {
        this.n_der11dename_eq = n_der11dename_eq;
        if(!StringUtils.isEmpty(this.n_der11dename_eq)){
            this.selectCond.eq("der11dename", n_der11dename_eq);
        }
    }
	private String n_der11dename_like;

	public void setN_der11dename_like(String n_der11dename_like) {
        this.n_der11dename_like = n_der11dename_like;
        if(!StringUtils.isEmpty(this.n_der11dename_like)){
            this.selectCond.like("der11dename", n_der11dename_like);
        }
    }
	private Integer n_detype_eq;

	public void setN_detype_eq(Integer n_detype_eq) {
        this.n_detype_eq = n_detype_eq;
        if(!StringUtils.isEmpty(this.n_detype_eq)){
            this.selectCond.eq("detype", n_detype_eq);
        }
    }
	private Integer n_indexmode_eq;

	public void setN_indexmode_eq(Integer n_indexmode_eq) {
        this.n_indexmode_eq = n_indexmode_eq;
        if(!StringUtils.isEmpty(this.n_indexmode_eq)){
            this.selectCond.eq("indexmode", n_indexmode_eq);
        }
    }
	private String n_printfunc_eq;

	public void setN_printfunc_eq(String n_printfunc_eq) {
        this.n_printfunc_eq = n_printfunc_eq;
        if(!StringUtils.isEmpty(this.n_printfunc_eq)){
            this.selectCond.eq("printfunc", n_printfunc_eq);
        }
    }
	private String n_storagetype_eq;

	public void setN_storagetype_eq(String n_storagetype_eq) {
        this.n_storagetype_eq = n_storagetype_eq;
        if(!StringUtils.isEmpty(this.n_storagetype_eq)){
            this.selectCond.eq("storagetype", n_storagetype_eq);
        }
    }
	private String n_tablespace_eq;

	public void setN_tablespace_eq(String n_tablespace_eq) {
        this.n_tablespace_eq = n_tablespace_eq;
        if(!StringUtils.isEmpty(this.n_tablespace_eq)){
            this.selectCond.eq("tablespace", n_tablespace_eq);
        }
    }

	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_DATAENTITY_QUERYMODEL_ACQUERYMODELID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_acquerymodelid_eq("NA");
			}
			else{
				this.setN_acquerymodelid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_DATAENTITY_DATAENTITY_DER11DEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_der11deid_eq("NA");
			}
			else{
				this.setN_der11deid_eq(strParentkey);
			}
	}

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

}