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.QJ;
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 QJSearchFilter extends SearchFilterBase {

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

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

	private String n_qjlx_eq;

	public void setN_qjlx_eq(String n_qjlx_eq) {
        this.n_qjlx_eq = n_qjlx_eq;
        if(!StringUtils.isEmpty(this.n_qjlx_eq)){
            this.selectCond.eq("qjlx", n_qjlx_eq);
        }
    }
	private String n_qjname_like;

	public void setN_qjname_like(String n_qjname_like) {
        this.n_qjname_like = n_qjname_like;
        if(!StringUtils.isEmpty(this.n_qjname_like)){
            this.selectCond.like("qjname", n_qjname_like);
        }
    }
	private String n_qjwfstate_eq;

	public void setN_qjwfstate_eq(String n_qjwfstate_eq) {
        this.n_qjwfstate_eq = n_qjwfstate_eq;
        if(!StringUtils.isEmpty(this.n_qjwfstate_eq)){
            this.selectCond.eq("qjwfstate", n_qjwfstate_eq);
        }
    }
	private String n_wfstep_eq;

	public void setN_wfstep_eq(String n_wfstep_eq) {
        this.n_wfstep_eq = n_wfstep_eq;
        if(!StringUtils.isEmpty(this.n_wfstep_eq)){
            this.selectCond.eq("wfstep", n_wfstep_eq);
        }
    }

	public void setSrfparentdata(Map<String, String> srfparentdata) {
		this.srfparentdata = srfparentdata;
		String strParentkey=this.getSrfparentdata().get("srfparentkey");
	}

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

}