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.WFWorkList;
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 WFWorkListSearchFilter extends SearchFilterBase {

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

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

	private String n_originalwfuserid_eq;

	public void setN_originalwfuserid_eq(String n_originalwfuserid_eq) {
        this.n_originalwfuserid_eq = n_originalwfuserid_eq;
        if(!StringUtils.isEmpty(this.n_originalwfuserid_eq)){
            this.selectCond.eq("originalwfuserid", n_originalwfuserid_eq);
        }
    }
	private String n_originalwfusername_eq;

	public void setN_originalwfusername_eq(String n_originalwfusername_eq) {
        this.n_originalwfusername_eq = n_originalwfusername_eq;
        if(!StringUtils.isEmpty(this.n_originalwfusername_eq)){
            this.selectCond.eq("originalwfusername", n_originalwfusername_eq);
        }
    }
	private String n_originalwfusername_like;

	public void setN_originalwfusername_like(String n_originalwfusername_like) {
        this.n_originalwfusername_like = n_originalwfusername_like;
        if(!StringUtils.isEmpty(this.n_originalwfusername_like)){
            this.selectCond.like("originalwfusername", n_originalwfusername_like);
        }
    }
	private String n_wfinstanceid_eq;

	public void setN_wfinstanceid_eq(String n_wfinstanceid_eq) {
        this.n_wfinstanceid_eq = n_wfinstanceid_eq;
        if(!StringUtils.isEmpty(this.n_wfinstanceid_eq)){
            this.selectCond.eq("wfinstanceid", n_wfinstanceid_eq);
        }
    }
	private String n_wfinstancename_eq;

	public void setN_wfinstancename_eq(String n_wfinstancename_eq) {
        this.n_wfinstancename_eq = n_wfinstancename_eq;
        if(!StringUtils.isEmpty(this.n_wfinstancename_eq)){
            this.selectCond.eq("wfinstancename", n_wfinstancename_eq);
        }
    }
	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_wfworklistname_like;

	public void setN_wfworklistname_like(String n_wfworklistname_like) {
        this.n_wfworklistname_like = n_wfworklistname_like;
        if(!StringUtils.isEmpty(this.n_wfworklistname_like)){
            this.selectCond.like("wfworklistname", n_wfworklistname_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_WFWORKLIST_WFUSER_ORIGINALWFUSERID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_originalwfuserid_eq("NA");
			}
			else{
				this.setN_originalwfuserid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_WFWORKLIST_WFINSTANCE_WFINSTANCEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfinstanceid_eq("NA");
			}
			else{
				this.setN_wfinstanceid_eq(strParentkey);
			}
	}

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

}