package cn.ibizlab.core.extensions.domain;

import cn.ibizlab.core.lite.extensions.domain.ModelObj;
import cn.ibizlab.core.rule.domain.ExecResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

@Data
public class BaseRequest
{
	private String id;
	private String msg;
	private String systemid;

	@Override
	public String toString() {
		return "BaseRequest{" +
				"id='" + id + '\'' +
				", msg='" + msg + '\'' +
				", datas=" + datas.size() +
				", model='" + model + '\'' +
				", batch='" + batch + '\'' +
				", engineId='" + engineId + '\'' +
				", extCond='" + extCond + '\'' +
				", isAutoRun='" + isAutoRun + '\'' +
				", rules=" + rules.size() +
				'}';
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public String toString2() {
		return "BaseRequest{" +
				"id='" + id + '\'' +
				", msg='" + msg + '\'' +
				", datas=" + datas +
				", model='" + model + '\'' +
				", batch='" + batch + '\'' +
				", rules=" + rules.size() +
				'}';
	}

	private List<ModelObj> datas;
	private String modelId;
	private String model;
	private String engineId;
	private boolean isAutoRun = false;
	private String resultDataSource;
	private String resultTableName;
	private String resultTopic;
	private String extCond;
	private String batch;
	private List<String> rules;
	private List<String> ruleIds;
	private List<ExecResult> results;

	private HashSet<String> fillpropertys;


	public String getBatch()
	{
		if(batch==null || batch.equals(""))
		{

			batch= new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date())+"["+model+"]";
		}

		return this.batch;
	}


	public BaseRequest copy(boolean reset)
	{
		BaseRequest baseRequest = JSON.parseObject(JSON.toJSONString(this),BaseRequest.class);

		return baseRequest;
	}

}
