package com.engine.salary.formlua.entity.parameter;

import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.formlua.entity.standard.FormulaFilterData;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class DataType implements Serializable {
	public final static String STRING="string";
	public final static String NUMBER="number";
	public final static String DATE="date";
	public final static String OPTION="option";
	public final static String BOOL="boolean";
	public final static String FORM="form";
	public final static String DATASOURCE="dataSource";
	private static final long serialVersionUID = 4694252986617988427L;
	/**
	 * 非COUNT函数使用
	 */
	private String fieldId;
	/**
	 * 数据类型
	 */
	private String dataType;
	/**
	 * 数据类型，表单可以直接从FormField中获取
	 */
	private String componentKey;
	/**
	 * 模块标识，聚合函数使用
	 */
	private String module;
	/**
	 * 人员参数
	 */
	private DataCollectionEmployee employee;
	/**
	 * 表单ID，也可以是数据源ID，聚合函数、查找函数使用
	 */
	private Long formId;
	/**
	 * 子表ID，聚合函数使用
	 */
	private Long subFormId;
	/**
	 * 字段值，包括：数字类型、文本类型、日期类型、选项类型的ID等
	 */
	private Object content;
	/**
	 * 富文本的值
	 */
	private String text;
	/**
	 * 分数，表单控件中只有选项型控件有分数
	 */
	private Double score;
	/**
	 * 标题
	 */
	private String name;
	/**
	 * 保留字段兼容老数据使用的
	 */
	private String aggCndKey;
	/**
	 * 选项数据的文本内容
	 */
	private String optionContent;
	/**
	 * 明细子表数据
	 */
	private List<DataType> subFormData;
	/**
	 * 保留字段，兼容老数据使用
	 */
//	private FormField formField;
	/**
	 * 高级搜索条件，由函数的逻辑操作符和逻辑函数构建，模块不需要处理
	 */
	List<FormulaFilterData> formulaFilterDataList=null;
	private List<String> subLogic=new ArrayList<>();
	public static boolean checkType(String dataTypeL,String dataTypeR){
		if(returnType(dataTypeL).equalsIgnoreCase(dataTypeR)){
			return true;
		}else {
			return false;
		}
	}
	public static String returnType(String type){
		String finalType;
		switch (type){
			case "string":
			case "date":
				finalType="string";
				break;
			case "boolean":
				finalType="boolean";
				break;
			case "form":
				finalType="form";
				break;
			case "dataSource":
			case "option":
				finalType="option";
				break;
			case "number":
				finalType="number";
				break;
			default:
				finalType=type;
				break;
		}
		return finalType;
	}
	public DataType() {
	}
	public DataType(String dataType, Object content,String componentKey) {
		this.dataType = dataType;
		this.content = content;
		this.componentKey=componentKey;
	}
	public DataType(String dataType, Object content) {
		this.dataType = dataType;
		this.content = content;
	}

	public DataType(String dataType, String module, DataCollectionEmployee employee, Long formId, Object content, String text, Double score) {
		this.dataType = dataType;
		this.module = module;
		this.employee = employee;
		this.formId = formId;
		this.content = content;
		this.text = text;
		this.score = score;
	}

	public List<String> getSubLogic() {
		return subLogic;
	}

	public void setSubLogic(List<String> subLogic) {
		this.subLogic = subLogic;
	}

	public String getOptionContent() {
		return optionContent;
	}

	public void setOptionContent(String optionContent) {
		this.optionContent = optionContent;
	}

	public String getComponentKey() {
		return componentKey;
	}

	public void setComponentKey(String componentKey) {
		this.componentKey = componentKey;
	}

	public Long getSubFormId() {
		return subFormId;
	}

	public void setSubFormId(Long subFormId) {
		this.subFormId = subFormId;
	}

//	public FormField getFormField() {
//		return formField;
//	}
//
//	public void setFormField(FormField formField) {
//		this.formField = formField;
//	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public DataCollectionEmployee getEmployee() {
		return employee;
	}

	public void setEmployee(DataCollectionEmployee employee) {
		this.employee = employee;
	}

	public String getModule() {
		return module;
	}

	public void setModule(String module) {
		this.module = module;
	}

	public static String getSTRING() {
		return STRING;
	}

	public Long getFormId() {
		return formId;
	}

	public void setFormId(Long formId) {
		this.formId = formId;
	}

	public String getFieldId() {
		return fieldId;
	}

	public void setFieldId(String fieldId) {
		this.fieldId = fieldId;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public Object getContent() {
		return content;
	}

	public void setContent(Object content) {
		this.content = content;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getAggCndKey() {
		return aggCndKey;
	}

	public void setAggCndKey(String aggCndKey) {
		this.aggCndKey = aggCndKey;
	}

	public Double getScore() {
		return score;
	}

	public void setScore(Double score) {
		this.score = score;
	}

	public List<DataType> getSubFormData() {
		return subFormData;
	}

	public void setSubFormData(List<DataType> subFormData) {
		this.subFormData = subFormData;
	}

	public List<FormulaFilterData> getFormulaFilterDataList() {
		return formulaFilterDataList;
	}

	public void setFormulaFilterDataList(List<FormulaFilterData> formulaFilterDataList) {
		this.formulaFilterDataList = formulaFilterDataList;
	}
}
