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.WFInstance;
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 WFInstanceSearchFilter extends SearchFilterBase {

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

	/**
	 * 设定自定义查询条件，在原有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_pwfinstanceid_eq;

	public void setN_pwfinstanceid_eq(String n_pwfinstanceid_eq) {
        this.n_pwfinstanceid_eq = n_pwfinstanceid_eq;
        if(!StringUtils.isEmpty(this.n_pwfinstanceid_eq)){
            this.selectCond.eq("pwfinstanceid", n_pwfinstanceid_eq);
        }
    }
	private String n_pwfinstancename_eq;

	public void setN_pwfinstancename_eq(String n_pwfinstancename_eq) {
        this.n_pwfinstancename_eq = n_pwfinstancename_eq;
        if(!StringUtils.isEmpty(this.n_pwfinstancename_eq)){
            this.selectCond.eq("pwfinstancename", n_pwfinstancename_eq);
        }
    }
	private String n_pwfinstancename_like;

	public void setN_pwfinstancename_like(String n_pwfinstancename_like) {
        this.n_pwfinstancename_like = n_pwfinstancename_like;
        if(!StringUtils.isEmpty(this.n_pwfinstancename_like)){
            this.selectCond.like("pwfinstancename", n_pwfinstancename_like);
        }
    }
	private String n_userdata_like;

	public void setN_userdata_like(String n_userdata_like) {
        this.n_userdata_like = n_userdata_like;
        if(!StringUtils.isEmpty(this.n_userdata_like)){
            this.selectCond.like("userdata", n_userdata_like);
        }
    }
	private String n_userdata2_like;

	public void setN_userdata2_like(String n_userdata2_like) {
        this.n_userdata2_like = n_userdata2_like;
        if(!StringUtils.isEmpty(this.n_userdata2_like)){
            this.selectCond.like("userdata2", n_userdata2_like);
        }
    }
	private String n_userdata3_like;

	public void setN_userdata3_like(String n_userdata3_like) {
        this.n_userdata3_like = n_userdata3_like;
        if(!StringUtils.isEmpty(this.n_userdata3_like)){
            this.selectCond.like("userdata3", n_userdata3_like);
        }
    }
	private String n_userdata4_like;

	public void setN_userdata4_like(String n_userdata4_like) {
        this.n_userdata4_like = n_userdata4_like;
        if(!StringUtils.isEmpty(this.n_userdata4_like)){
            this.selectCond.like("userdata4", n_userdata4_like);
        }
    }
	private String n_wfinstancename_like;

	public void setN_wfinstancename_like(String n_wfinstancename_like) {
        this.n_wfinstancename_like = n_wfinstancename_like;
        if(!StringUtils.isEmpty(this.n_wfinstancename_like)){
            this.selectCond.like("wfinstancename", n_wfinstancename_like);
        }
    }
	private String n_wfworkflowid_eq;

	public void setN_wfworkflowid_eq(String n_wfworkflowid_eq) {
        this.n_wfworkflowid_eq = n_wfworkflowid_eq;
        if(!StringUtils.isEmpty(this.n_wfworkflowid_eq)){
            this.selectCond.eq("wfworkflowid", n_wfworkflowid_eq);
        }
    }
	private String n_wfworkflowname_eq;

	public void setN_wfworkflowname_eq(String n_wfworkflowname_eq) {
        this.n_wfworkflowname_eq = n_wfworkflowname_eq;
        if(!StringUtils.isEmpty(this.n_wfworkflowname_eq)){
            this.selectCond.eq("wfworkflowname", n_wfworkflowname_eq);
        }
    }
	private String n_wfworkflowname_like;

	public void setN_wfworkflowname_like(String n_wfworkflowname_like) {
        this.n_wfworkflowname_like = n_wfworkflowname_like;
        if(!StringUtils.isEmpty(this.n_wfworkflowname_like)){
            this.selectCond.like("wfworkflowname", n_wfworkflowname_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_WFINSTANCE_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_WFINSTANCE_WFINSTANCE_PWFINSTANCEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_pwfinstanceid_eq("NA");
			}
			else{
				this.setN_pwfinstanceid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_WFINSTANCE_WFWORKFLOW_WFWORKFLOWID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfworkflowid_eq("NA");
			}
			else{
				this.setN_wfworkflowid_eq(strParentkey);
			}
	}

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

}