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.WFTmpStepActor;
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 WFTmpStepActorSearchFilter extends SearchFilterBase {

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

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

	private String n_prevwfstepid_eq;

	public void setN_prevwfstepid_eq(String n_prevwfstepid_eq) {
        this.n_prevwfstepid_eq = n_prevwfstepid_eq;
        if(!StringUtils.isEmpty(this.n_prevwfstepid_eq)){
            this.selectCond.eq("prevwfstepid", n_prevwfstepid_eq);
        }
    }
	private String n_prevwfstepname_eq;

	public void setN_prevwfstepname_eq(String n_prevwfstepname_eq) {
        this.n_prevwfstepname_eq = n_prevwfstepname_eq;
        if(!StringUtils.isEmpty(this.n_prevwfstepname_eq)){
            this.selectCond.eq("prevwfstepname", n_prevwfstepname_eq);
        }
    }
	private String n_prevwfstepname_like;

	public void setN_prevwfstepname_like(String n_prevwfstepname_like) {
        this.n_prevwfstepname_like = n_prevwfstepname_like;
        if(!StringUtils.isEmpty(this.n_prevwfstepname_like)){
            this.selectCond.like("prevwfstepname", n_prevwfstepname_like);
        }
    }
	private String n_wfactorid_eq;

	public void setN_wfactorid_eq(String n_wfactorid_eq) {
        this.n_wfactorid_eq = n_wfactorid_eq;
        if(!StringUtils.isEmpty(this.n_wfactorid_eq)){
            this.selectCond.eq("wfactorid", n_wfactorid_eq);
        }
    }
	private String n_wfactorname_eq;

	public void setN_wfactorname_eq(String n_wfactorname_eq) {
        this.n_wfactorname_eq = n_wfactorname_eq;
        if(!StringUtils.isEmpty(this.n_wfactorname_eq)){
            this.selectCond.eq("wfactorname", n_wfactorname_eq);
        }
    }
	private String n_wfactorname_like;

	public void setN_wfactorname_like(String n_wfactorname_like) {
        this.n_wfactorname_like = n_wfactorname_like;
        if(!StringUtils.isEmpty(this.n_wfactorname_like)){
            this.selectCond.like("wfactorname", n_wfactorname_like);
        }
    }
	private String n_wftmpstepactorname_like;

	public void setN_wftmpstepactorname_like(String n_wftmpstepactorname_like) {
        this.n_wftmpstepactorname_like = n_wftmpstepactorname_like;
        if(!StringUtils.isEmpty(this.n_wftmpstepactorname_like)){
            this.selectCond.like("wftmpstepactorname", n_wftmpstepactorname_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_WFTMPSTEPACTOR_WFSTEP_PREVWFSTEPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_prevwfstepid_eq("NA");
			}
			else{
				this.setN_prevwfstepid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_WFTMPSTEPACTOR_WFACTOR_WFACTORID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfactorid_eq("NA");
			}
			else{
				this.setN_wfactorid_eq(strParentkey);
			}
	}

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

}