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.WFWorkflow;
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 WFWorkflowSearchFilter extends SearchFilterBase {

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

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

	private String n_remindmsgtemplid_eq;

	public void setN_remindmsgtemplid_eq(String n_remindmsgtemplid_eq) {
        this.n_remindmsgtemplid_eq = n_remindmsgtemplid_eq;
        if(!StringUtils.isEmpty(this.n_remindmsgtemplid_eq)){
            this.selectCond.eq("remindmsgtemplid", n_remindmsgtemplid_eq);
        }
    }
	private String n_remindmsgtemplname_eq;

	public void setN_remindmsgtemplname_eq(String n_remindmsgtemplname_eq) {
        this.n_remindmsgtemplname_eq = n_remindmsgtemplname_eq;
        if(!StringUtils.isEmpty(this.n_remindmsgtemplname_eq)){
            this.selectCond.eq("remindmsgtemplname", n_remindmsgtemplname_eq);
        }
    }
	private String n_remindmsgtemplname_like;

	public void setN_remindmsgtemplname_like(String n_remindmsgtemplname_like) {
        this.n_remindmsgtemplname_like = n_remindmsgtemplname_like;
        if(!StringUtils.isEmpty(this.n_remindmsgtemplname_like)){
            this.selectCond.like("remindmsgtemplname", n_remindmsgtemplname_like);
        }
    }
	private Integer n_wfstate_eq;

	public void setN_wfstate_eq(Integer n_wfstate_eq) {
        this.n_wfstate_eq = n_wfstate_eq;
        if(!StringUtils.isEmpty(this.n_wfstate_eq)){
            this.selectCond.eq("wfstate", n_wfstate_eq);
        }
    }
	private String n_wftype_eq;

	public void setN_wftype_eq(String n_wftype_eq) {
        this.n_wftype_eq = n_wftype_eq;
        if(!StringUtils.isEmpty(this.n_wftype_eq)){
            this.selectCond.eq("wftype", n_wftype_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_WFWORKFLOW_MSGTEMPLATE_REMINDMSGTEMPLID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_remindmsgtemplid_eq("NA");
			}
			else{
				this.setN_remindmsgtemplid_eq(strParentkey);
			}
	}

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

}