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.TSSDTaskPolicy;
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 TSSDTaskPolicySearchFilter extends SearchFilterBase {

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

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

	private String n_tssdpolicyid_eq;

	public void setN_tssdpolicyid_eq(String n_tssdpolicyid_eq) {
        this.n_tssdpolicyid_eq = n_tssdpolicyid_eq;
        if(!StringUtils.isEmpty(this.n_tssdpolicyid_eq)){
            this.selectCond.eq("tssdpolicyid", n_tssdpolicyid_eq);
        }
    }
	private String n_tssdpolicyname_eq;

	public void setN_tssdpolicyname_eq(String n_tssdpolicyname_eq) {
        this.n_tssdpolicyname_eq = n_tssdpolicyname_eq;
        if(!StringUtils.isEmpty(this.n_tssdpolicyname_eq)){
            this.selectCond.eq("tssdpolicyname", n_tssdpolicyname_eq);
        }
    }
	private String n_tssdpolicyname_like;

	public void setN_tssdpolicyname_like(String n_tssdpolicyname_like) {
        this.n_tssdpolicyname_like = n_tssdpolicyname_like;
        if(!StringUtils.isEmpty(this.n_tssdpolicyname_like)){
            this.selectCond.like("tssdpolicyname", n_tssdpolicyname_like);
        }
    }
	private String n_tssdtaskid_eq;

	public void setN_tssdtaskid_eq(String n_tssdtaskid_eq) {
        this.n_tssdtaskid_eq = n_tssdtaskid_eq;
        if(!StringUtils.isEmpty(this.n_tssdtaskid_eq)){
            this.selectCond.eq("tssdtaskid", n_tssdtaskid_eq);
        }
    }
	private String n_tssdtaskname_eq;

	public void setN_tssdtaskname_eq(String n_tssdtaskname_eq) {
        this.n_tssdtaskname_eq = n_tssdtaskname_eq;
        if(!StringUtils.isEmpty(this.n_tssdtaskname_eq)){
            this.selectCond.eq("tssdtaskname", n_tssdtaskname_eq);
        }
    }
	private String n_tssdtaskname_like;

	public void setN_tssdtaskname_like(String n_tssdtaskname_like) {
        this.n_tssdtaskname_like = n_tssdtaskname_like;
        if(!StringUtils.isEmpty(this.n_tssdtaskname_like)){
            this.selectCond.like("tssdtaskname", n_tssdtaskname_like);
        }
    }
	private String n_tssdtaskpolicyname_like;

	public void setN_tssdtaskpolicyname_like(String n_tssdtaskpolicyname_like) {
        this.n_tssdtaskpolicyname_like = n_tssdtaskpolicyname_like;
        if(!StringUtils.isEmpty(this.n_tssdtaskpolicyname_like)){
            this.selectCond.like("tssdtaskpolicyname", n_tssdtaskpolicyname_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_TSSDTASKPOLICY_TSSDPOLICY_TSSDPOLICYID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_tssdpolicyid_eq("NA");
			}
			else{
				this.setN_tssdpolicyid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_TSSDTASKPOLICY_TSSDTASK_TSSDTASKID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_tssdtaskid_eq("NA");
			}
			else{
				this.setN_tssdtaskid_eq(strParentkey);
			}
	}

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

}