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.DataSyncOut;
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 DataSyncOutSearchFilter extends SearchFilterBase {

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

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

	private String n_datasyncoutname_like;

	public void setN_datasyncoutname_like(String n_datasyncoutname_like) {
        this.n_datasyncoutname_like = n_datasyncoutname_like;
        if(!StringUtils.isEmpty(this.n_datasyncoutname_like)){
            this.selectCond.like("datasyncoutname", n_datasyncoutname_like);
        }
    }
	private String n_deid_eq;

	public void setN_deid_eq(String n_deid_eq) {
        this.n_deid_eq = n_deid_eq;
        if(!StringUtils.isEmpty(this.n_deid_eq)){
            this.selectCond.eq("deid", n_deid_eq);
        }
    }
	private String n_dename_eq;

	public void setN_dename_eq(String n_dename_eq) {
        this.n_dename_eq = n_dename_eq;
        if(!StringUtils.isEmpty(this.n_dename_eq)){
            this.selectCond.eq("dename", n_dename_eq);
        }
    }
	private String n_dename_like;

	public void setN_dename_like(String n_dename_like) {
        this.n_dename_like = n_dename_like;
        if(!StringUtils.isEmpty(this.n_dename_like)){
            this.selectCond.like("dename", n_dename_like);
        }
    }
	private Integer n_eventtype_eq;

	public void setN_eventtype_eq(Integer n_eventtype_eq) {
        this.n_eventtype_eq = n_eventtype_eq;
        if(!StringUtils.isEmpty(this.n_eventtype_eq)){
            this.selectCond.eq("eventtype", n_eventtype_eq);
        }
    }
	private String n_syncagent_eq;

	public void setN_syncagent_eq(String n_syncagent_eq) {
        this.n_syncagent_eq = n_syncagent_eq;
        if(!StringUtils.isEmpty(this.n_syncagent_eq)){
            this.selectCond.eq("syncagent", n_syncagent_eq);
        }
    }

	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_DATASYNCOUT_DATAENTITY_DEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_deid_eq("NA");
			}
			else{
				this.setN_deid_eq(strParentkey);
			}
	}

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

}