package com.uas.search.console.b2b.util;

import com.uas.search.console.b2b.model.*;
import com.uas.search.util.CollectionUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.FloatDocValuesField;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import com.uas.search.util.StringUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.uas.platform.core.model.Constant;
import com.uas.search.b2b.service.SearchService.Table_name;
import com.uas.search.console.b2b.platformmanager.model.UserSpaceDetailSimpleInfo;

import net.sf.ehcache.search.SearchException;

/**
 * 将对象转换为Document的工具类
 * 
 * @author sunyj
 * @since 2016年11月9日 上午11:49:52
 */
public class ObjectToDocumentUtils {

	/**
	 * 将对象转为Document
	 * 
	 * @param object
	 *            对象，可为PurchaseOrderSimpleInfo、MakeOrderSimpleInfo.....
	 * @return 转换的Document
	 */
	public static Document toDocument(Object object) {
		if (object == null) {
			return null;
		}
		if (object instanceof PurchaseOrderSimpleInfo) {
			return toDocument((PurchaseOrderSimpleInfo) object);
		} else if (object instanceof MakeOrderSimpleInfo) {
			return toDocument((MakeOrderSimpleInfo) object);
		} else if (object instanceof PurchaseAcceptSimpleInfo) {
			return toDocument((PurchaseAcceptSimpleInfo) object);
		} else if (object instanceof SaleQuotationSimpleInfo) {
			return toDocument((SaleQuotationSimpleInfo) object);
		} else if (object instanceof PurchaseApbillSimpleInfo) {
			return toDocument((PurchaseApbillSimpleInfo) object);
		} else if (object instanceof PurchaseBadinSimpleInfo) {
			return toDocument((PurchaseBadinSimpleInfo) object);
		} else if (object instanceof PurchaseBadoutSimpleInfo) {
			return toDocument((PurchaseBadoutSimpleInfo) object);
		} else if (object instanceof PurchaseForecastSimpleInfo) {
			return toDocument((PurchaseForecastSimpleInfo) object);
		} else if (object instanceof PurchaseMrbSimpleInfo) {
			return toDocument((PurchaseMrbSimpleInfo) object);
		} else if (object instanceof PurchaseChangesSimpleInfo) {
			return toDocument((PurchaseChangesSimpleInfo) object);
		} else if (object instanceof PurchaseProofingItemSimpleInfo) {
			return toDocument((PurchaseProofingItemSimpleInfo) object);
		} else if (object instanceof PurchaseReturnSimpleInfo) {
			return toDocument((PurchaseReturnSimpleInfo) object);
		} else if (object instanceof MakeAcceptSimpleInfo) {
			return toDocument((MakeAcceptSimpleInfo) object);
		} else if (object instanceof MakeOrderChangeItemSimpleInfo) {
			return toDocument((MakeOrderChangeItemSimpleInfo) object);
		} else if (object instanceof MakeReturnSimpleInfo) {
			return toDocument((MakeReturnSimpleInfo) object);
		} else if (object instanceof SaleSendSimpleInfo) {
			return toDocument((SaleSendSimpleInfo) object);
		} else if (object instanceof PurchaseNoticeSimpleInfo) {
			return toDocument((PurchaseNoticeSimpleInfo) object);
		} else if (object instanceof PurcProofingapprovalSimpleInfo) {
			return toDocument((PurcProofingapprovalSimpleInfo) object);
		} else if (object instanceof PurcProofingsendSimpleInfo) {
			return toDocument((PurcProofingsendSimpleInfo) object);
		} else if (object instanceof SaleArcheckSimpleInfo) {
			return toDocument((SaleArcheckSimpleInfo) object);
		} else if (object instanceof PurchaseApCheckSimpleInfo) {
			return toDocument((PurchaseApCheckSimpleInfo) object);
		} else if (object instanceof PurchaseInquiryItemSimpleInfo) {
			return toDocument((PurchaseInquiryItemSimpleInfo) object);
		} else if (object instanceof PurchaseInquiryMouldSimpleInfo) {
			return toDocument((PurchaseInquiryMouldSimpleInfo) object);
		} else if (object instanceof ProdSimpleInfo) {
			return toDocument((ProdSimpleInfo) object);
		} else if (object instanceof EnterpriseSearchSimpleInfo) {
			return toDocument((EnterpriseSearchSimpleInfo) object);
		} else if (object instanceof ProductComponentSimpleInfo) {
			return toDocument((ProductComponentSimpleInfo) object);
		} else if (object instanceof DeputyOrderSimpleInfo) {
			return toDocument((DeputyOrderSimpleInfo) object);
		} else if (object instanceof PurchaseTenderSimpleInfo) {
			return toDocument((PurchaseTenderSimpleInfo) object);
		} else if (object instanceof PagingReleaseDetailSimpleInfo) {
			return toDocument((PagingReleaseDetailSimpleInfo) object);
		} else if (object instanceof VendorSimpleInfo) {
			return toDocument((VendorSimpleInfo) object);
		} else if (object instanceof CustmerSimpleInfo) {
			return toDocument((CustmerSimpleInfo) object);
		} else if (object instanceof ProductBrandSimpleInfo) {
			return toDocument((ProductBrandSimpleInfo) object);
		} else if (object instanceof UserSpaceDetailSimpleInfo) {
			return toDocument((UserSpaceDetailSimpleInfo) object);
		} else if (object instanceof PurcInquirySimpleInfo) {
			return toDocument((PurcInquirySimpleInfo) object);
		} else if (object instanceof PurcInquiryItemSimpleInfo2) {
			return toDocument((PurcInquiryItemSimpleInfo2) object);
		} else if (object instanceof InvitationRecordSimpleInfo) {
			return toDocument((InvitationRecordSimpleInfo) object);
		} else if (object instanceof ErpSaleTenderSimpleInfo) {
			return toDocument((ErpSaleTenderSimpleInfo) object);
		} else if (object instanceof CartSimpleInfo) {
			return toDocument((CartSimpleInfo) object);
		} else if (object instanceof ProdStandardSimpleInfo) {
			return toDocument((ProdStandardSimpleInfo) object);
		} else if (object instanceof ProdNonStandardSimpleInfo) {
			return toDocument((ProdNonStandardSimpleInfo) object);
		} else if (object instanceof KindSimpleInfo) {
			return toDocument((KindSimpleInfo) object);
		} else if (object instanceof B2BSaleTenderSimpleInfo) {
			return toDocument((B2BSaleTenderSimpleInfo) object);
		} else if (object instanceof PurchaseApBillOutSimpleInfo) {
			return toDocument((PurchaseApBillOutSimpleInfo) object);
		} else if (object instanceof SaleTenderQuestionSimpleInfo) {
			return toDocument((SaleTenderQuestionSimpleInfo) object);
		} else if (object instanceof VendorPerformanceAssessSimpleInfo) {
			return toDocument((VendorPerformanceAssessSimpleInfo) object);
		} else if (object instanceof ProductUsersSimpleInfo) {
            return toDocument((ProductUsersSimpleInfo) object);
        }
		// TODO 其他表
		else {
			throw new SearchException("不支持将以下类型转换为Document：" + object.getClass().getName());
		}
	}

	/**
	 * PurchaseOrderSimpleInfo对象转为Document
	 * 
	 * @param purchaseOrder
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseOrderSimpleInfo purchaseOrder) {
		if (purchaseOrder == null || purchaseOrder.getId() == null || StringUtils.isEmpty(purchaseOrder.getCode())
				|| purchaseOrder.getStatus() == null || purchaseOrder.getDate() == null
				|| purchaseOrder.getEnterprise() == null || purchaseOrder.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purchaseOrder.getEnterprise().getEnName()) || purchaseOrder.getVend() == null
				|| purchaseOrder.getVend().getUu() == null || StringUtils.isEmpty(purchaseOrder.getDate())
				|| StringUtils.isEmpty(purchaseOrder.getVend().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseOrderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ID_FIELD),
				String.valueOf(purchaseOrder.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.CODE_FIELD),
				purchaseOrder.getCode(), Store.YES));
		// TODO 暂时将未结案的设为0，以后在数据源头进行处理
		if (purchaseOrder.getEnd() != null) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.END_FIELD),
							String.valueOf(purchaseOrder.getEnd()), Store.YES));
		} else {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.END_FIELD),
							String.valueOf(0), Store.YES));
		}
		// TODO 暂时将未回复的设为0，以后在数据源头进行处理
		if (purchaseOrder.getReply() != null) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.REPLY_FIELD),
							String.valueOf(purchaseOrder.getReply()), Store.YES));
		} else {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.REPLY_FIELD),
							String.valueOf(0), Store.YES));
		}
		if (purchaseOrder.getDisplay() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.DISPLAY_FIELD),
							String.valueOf(purchaseOrder.getDisplay()), Store.YES));
		}
		if (purchaseOrder.getUserUU() != null) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.USERUU_FIELD),
					String.valueOf(purchaseOrder.getUserUU()), Store.YES));
		}
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.STATUS_FIELD),
						String.valueOf(purchaseOrder.getStatus()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.DATE_FIELD),
				purchaseOrder.getDate().getTime(), Store.YES));
		// enterprise、vend和orderItems以json的格式存储
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(purchaseOrder.getEnterprise()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(purchaseOrder.getVend()), Store.YES));
		if (!CollectionUtils.isEmpty(purchaseOrder.getOrderItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purchaseOrder.getOrderItems()), Store.YES));
		}
		// 排序字段

		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.DISPLAY_FIELD),
				purchaseOrder.getDisplay()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.DATE_FIELD),
				purchaseOrder.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ID_FIELD),
				purchaseOrder.getId()));
		return document;
	}

	/**
	 * MakeOrderSimpleInfo对象转为Document
	 * 
	 * @param makeOrder
	 * @return 转换的Document
	 */
	public static Document toDocument(MakeOrderSimpleInfo makeOrder) {
		if (makeOrder == null || makeOrder.getId() == null || StringUtils.isEmpty(makeOrder.getCode())
				|| makeOrder.getStatus() == null || makeOrder.getVend() == null || makeOrder.getVend().getUu() == null
				|| StringUtils.isEmpty(makeOrder.getVend().getEnName()) || makeOrder.getEnterprise() == null
				|| makeOrder.getEnterprise().getUu() == null || StringUtils.isEmpty(makeOrder.getDate())
				|| StringUtils.isEmpty(makeOrder.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeOrderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.ID_FIELD),
				String.valueOf(makeOrder.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.CODE_FIELD),
				makeOrder.getCode(), Store.YES));
		// TODO 暂时将未结案的设为0，以后在数据源头进行处理
		if (makeOrder.getEnd() != null) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.END_FIELD),
					String.valueOf(makeOrder.getEnd()), Store.YES));
		} else {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.END_FIELD),
					String.valueOf(0), Store.YES));
		}
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.STATUS_FIELD),
				String.valueOf(makeOrder.getStatus()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.DATE_FIELD),
				makeOrder.getDate().getTime(), Store.YES));
		// enterprise、vend和orderItems以json的格式存储
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(makeOrder.getEnterprise()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(makeOrder.getVend()), Store.YES));
		if (makeOrder.getProduct() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.PRODUCT_FIELD),
							JSONObject.toJSONString(makeOrder.getProduct()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.DATE_FIELD),
				makeOrder.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.ID_FIELD), makeOrder.getId()));
		return document;
	}

	/**
	 * PurchaseAcceptSimpleInfo对象转为Document
	 * 
	 * @param purcAccept
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseAcceptSimpleInfo purcAccept) {
		if (purcAccept == null || purcAccept.getId() == null || StringUtils.isEmpty(purcAccept.getCode())
				|| purcAccept.getVend() == null || purcAccept.getVend().getUu() == null
				|| StringUtils.isEmpty(purcAccept.getVend().getEnName()) || purcAccept.getEnterprise() == null
				|| purcAccept.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcAccept.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseAcceptSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ID_FIELD),
				String.valueOf(purcAccept.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.CODE_FIELD),
				String.valueOf(purcAccept.getCode()), Store.YES));
		if (!StringUtils.isEmpty(purcAccept.getSendCode())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.SENDCODE_FIELD),
					String.valueOf(purcAccept.getCode()), Store.YES));
		}
		if (!StringUtils.isEmpty(purcAccept.getDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.DATE_FIELD),
							purcAccept.getDate().getTime(), Store.YES));
		}
		// vend和items以json的格式存储
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(purcAccept.getVend()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(purcAccept.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purcAccept.getAcceptItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purcAccept.getAcceptItems()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(purcAccept.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.DATE_FIELD),
					purcAccept.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ID_FIELD), purcAccept.getId()));
		return document;
	}

	/**
	 * SaleQuotationSimpleInfo对象转为Document
	 * 
	 * @param saleQuotation
	 * @return
	 */

	public static Document toDocument(SaleQuotationSimpleInfo saleQuotation) {
		if (saleQuotation == null || saleQuotation.getId() == null || StringUtils.isEmpty(saleQuotation.getCode())
				|| saleQuotation.getVend() == null || saleQuotation.getVend().getUu() == null
				|| StringUtils.isEmpty(saleQuotation.getVend().getEnName())
				|| StringUtils.isEmpty(saleQuotation.getDate()) || saleQuotation.getEnterprise() == null
				|| saleQuotation.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(saleQuotation.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleQuotationSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ID_FIELD),
				String.valueOf(saleQuotation.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.CODE_FIELD),
				String.valueOf(saleQuotation.getCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.DATE_FIELD),
				saleQuotation.getDate().getTime(), Store.YES));
		if (!StringUtils.isEmpty(saleQuotation.getEndDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ENDDATE_FIELD),
							saleQuotation.getEndDate().getTime(), Store.YES));
		}
		if (null != saleQuotation.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.OVERDUE_FIELD),
					String.valueOf(saleQuotation.getOverdue()), Store.YES));
		}
		if (null != saleQuotation.getAgreed()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.AGREED_FIELD),
					String.valueOf(saleQuotation.getAgreed()), Store.YES));
		}
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.STATUS_FIELD),
						String.valueOf(saleQuotation.getStatus()), Store.YES));
		// vend和items以json的格式存储
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(saleQuotation.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(saleQuotation.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(saleQuotation.getSaleQuotationItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(saleQuotation.getSaleQuotationItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.DATE_FIELD),
				saleQuotation.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ID_FIELD),
				saleQuotation.getId()));
		return document;
	}

	/**
	 * PurchaseApbillSimpleInfo对象转为Document
	 * 
	 * @param purchapbill
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseApbillSimpleInfo purchapbill) {
		if (purchapbill == null || purchapbill.getId() == null || StringUtils.isEmpty(purchapbill.getCode())
				|| purchapbill.getVend() == null || purchapbill.getVend().getUu() == null
				|| StringUtils.isEmpty(purchapbill.getVend().getEnName()) || StringUtils.isEmpty(purchapbill.getDate())
				|| purchapbill.getEnterprise() == null || purchapbill.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purchapbill.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseApbillSimpleInfo.class);
		Document document = new Document();
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ID_FIELD),
				String.valueOf(purchapbill.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.CODE_FIELD),
				String.valueOf(purchapbill.getCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.DATE_FIELD),
				purchapbill.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.VEND_FIELD),
						JSONObject.toJSONString(purchapbill.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(purchapbill.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purchapbill.getItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purchapbill.getItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.DATE_FIELD),
				purchapbill.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ID_FIELD),
				purchapbill.getId()));
		return document;
	}

	/**
	 * PurchaseBadinSimpleInfo对象转为Document
	 * 
	 * @param purchBadin
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseBadinSimpleInfo purchBadin) {
		if (purchBadin == null || purchBadin.getId() == null || StringUtils.isEmpty(purchBadin.getCode())
				|| purchBadin.getVend() == null || purchBadin.getVend().getUu() == null
				|| StringUtils.isEmpty(purchBadin.getVend().getEnName()) || purchBadin.getEnterprise() == null
				|| purchBadin.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purchBadin.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseBadinSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ID_FIELD),
				String.valueOf(purchBadin.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.CODE_FIELD),
				String.valueOf(purchBadin.getCode()), Store.YES));
		if (!StringUtils.isEmpty(purchBadin.getDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.DATE_FIELD),
							purchBadin.getDate().getTime(), Store.YES));
		}

		if (!StringUtils.isEmpty(purchBadin.getSendCode())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.SENDCODE_FIELD),
					String.valueOf(purchBadin.getSendCode()), Store.YES));
		}
		// vend和items以json的格式存储
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(purchBadin.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(purchBadin.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purchBadin.getBadInItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purchBadin.getBadInItems()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(purchBadin.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.DATE_FIELD),
					purchBadin.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ID_FIELD), purchBadin.getId()));
		return document;
	}

	/**
	 * PurchaseBadoutSimpleInfo对象转为Document
	 * 
	 * @param purchaseBadout
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseBadoutSimpleInfo purchaseBadout) {
		if (purchaseBadout == null || purchaseBadout.getId() == null || StringUtils.isEmpty(purchaseBadout.getCode())
				|| purchaseBadout.getVend() == null || purchaseBadout.getVend().getUu() == null
				|| StringUtils.isEmpty(purchaseBadout.getVend().getEnName()) || purchaseBadout.getEnterprise() == null
				|| purchaseBadout.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purchaseBadout.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseBadoutSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ID_FIELD),
				String.valueOf(purchaseBadout.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.CODE_FIELD),
				String.valueOf(purchaseBadout.getCode()), Store.YES));
		if (!StringUtils.isEmpty(purchaseBadout.getDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.DATE_FIELD),
							purchaseBadout.getDate().getTime(), Store.YES));
		}
		if (!StringUtils.isEmpty(purchaseBadout.getSendCode())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.SENDCODE_FIELD),
					String.valueOf(purchaseBadout.getSendCode()), Store.YES));
		}
		// vend和items以json的格式存储
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.VEND_FIELD),
						JSONObject.toJSONString(purchaseBadout.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(purchaseBadout.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purchaseBadout.getBadOutItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purchaseBadout.getBadOutItems()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(purchaseBadout.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.DATE_FIELD),
					purchaseBadout.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ID_FIELD),
				purchaseBadout.getId()));
		return document;
	}

	/**
	 * PurchaseForecastSimpleInfo对象转为Document
	 * 
	 * @param purchaseForecast
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseForecastSimpleInfo purchaseForecast) {
		if (purchaseForecast == null || purchaseForecast.getId() == null
				|| StringUtils.isEmpty(purchaseForecast.getCode()) || purchaseForecast.getVend() == null
				|| purchaseForecast.getVend().getUu() == null || StringUtils.isEmpty(purchaseForecast.getDate())
				|| StringUtils.isEmpty(purchaseForecast.getVend().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseForecastSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ID_FIELD),
						String.valueOf(purchaseForecast.getId()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.CODE_FIELD),
						String.valueOf(purchaseForecast.getCode()), Store.YES));
		document.add(
				new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.DATE_FIELD),
						purchaseForecast.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.VEND_FIELD),
						JSONObject.toJSONString(purchaseForecast.getVend()), Store.YES));
		if (!CollectionUtils.isEmpty(purchaseForecast.getForecastItems())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(purchaseForecast.getForecastItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.DATE_FIELD),
				purchaseForecast.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ID_FIELD),
				purchaseForecast.getId()));
		return document;
	}

	/**
	 * PurchaseMrbSimpleInfo对象转为Document
	 * 
	 * @param purcMrb
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseMrbSimpleInfo purcMrb) {
		if (purcMrb == null || purcMrb.getId() == null || StringUtils.isEmpty(purcMrb.getCode())
				|| purcMrb.getVend() == null || purcMrb.getVend().getUu() == null
				|| StringUtils.isEmpty(purcMrb.getVend().getEnName()) || StringUtils.isEmpty(purcMrb.getDate())
				|| purcMrb.getEnterprise() == null || purcMrb.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcMrb.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseMrbSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ID_FIELD),
				String.valueOf(purcMrb.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.CODE_FIELD),
				String.valueOf(purcMrb.getCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.DATE_FIELD),
				purcMrb.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(purcMrb.getVend()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(purcMrb.getEnterprise()), Store.YES));
		if (purcMrb.getOrderItem() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purcMrb.getOrderItem()), Store.YES));
		}
		if (purcMrb.getBadIn() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.BADITEMS_FIELD),
							JSONObject.toJSONString(purcMrb.getBadIn()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.DATE_FIELD),
				purcMrb.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ID_FIELD), purcMrb.getId()));
		return document;

	}

	/**
	 * PurchaseChangesSimpleInfo对象转为Document
	 * 
	 * @param purcChanges
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseChangesSimpleInfo purcChanges) {
		if (purcChanges == null || purcChanges.getId() == null || StringUtils.isEmpty(purcChanges.getCode())
				|| StringUtils.isEmpty(purcChanges.getOrderCode()) || purcChanges.getVend() == null
				|| purcChanges.getVend().getUu() == null || StringUtils.isEmpty(purcChanges.getVend().getEnName())
				|| StringUtils.isEmpty(purcChanges.getDate()) || purcChanges.getEnterprise() == null
				|| purcChanges.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcChanges.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseChangesSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ID_FIELD),
				String.valueOf(purcChanges.getId()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.STATUS_FIELD),
						String.valueOf(purcChanges.getStatus()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.CODE_FIELD),
				String.valueOf(purcChanges.getCode()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ORDERCODE_FIELD),
						String.valueOf(purcChanges.getOrderCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.DATE_FIELD),
				purcChanges.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.VEND_FIELD),
						JSONObject.toJSONString(purcChanges.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(purcChanges.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purcChanges.getOrderChangeItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purcChanges.getOrderChangeItems()), Store.YES));
		}
		if (null != purcChanges.getUnNeedReply()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.UNNEEDREPLY_FIELD),
					String.valueOf(purcChanges.getUnNeedReply()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.DATE_FIELD),
				purcChanges.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ID_FIELD),
				purcChanges.getId()));
		return document;
	}

	/**
	 * PurchaseProofingItemSimpleInfo对象转为Document
	 * 
	 * @param purcProofingItem
	 * @return 转换的Document
	 */
	public static Document toDocument(PurchaseProofingItemSimpleInfo purcProofingItem) {
		if (purcProofingItem == null || purcProofingItem.getId() == null || purcProofingItem.getStatus() == null
				|| purcProofingItem.getEnterprise() == null || purcProofingItem.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcProofingItem.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseProofingItemSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.ID_FIELD),
						String.valueOf(purcProofingItem.getId()), Store.YES));
		document.add(new TextField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.STATUS_FIELD),
				String.valueOf(purcProofingItem.getStatus()), Store.YES));
		// vend和items以json的格式存储
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(purcProofingItem.getEnterprise()), Store.YES));
		if (purcProofingItem.getDate() != null){
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.DATE_FIELD),
					purcProofingItem.getDate().getTime(), Store.YES));
		}
		if (purcProofingItem.getProofing() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.PROOFING_FIELD),
					JSONObject.toJSONString(purcProofingItem.getProofing()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.ID_FIELD),
				purcProofingItem.getId()));
		return document;
	}

	/**
	 * 将PurchaseReturnSimpleInfo转换成Document
	 * 
	 * @param purcReturn
	 * @return
	 */
	public static Document toDocument(PurchaseReturnSimpleInfo purcReturn) {
		if (purcReturn == null || purcReturn.getId() == null || StringUtils.isEmpty(purcReturn.getCode())
				|| purcReturn.getVend() == null || purcReturn.getVend().getUu() == null
				|| StringUtils.isEmpty(purcReturn.getVend().getEnName()) || purcReturn.getEnterprise() == null
				|| purcReturn.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcReturn.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseReturnSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ID_FIELD),
				String.valueOf(purcReturn.getId()), Store.YES));
		if (purcReturn.getSendCode() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.SENDCODE_FIELD),
					String.valueOf(purcReturn.getSendCode()), Store.YES));
		}
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.CODE_FIELD),
				String.valueOf(purcReturn.getCode()), Store.YES));
		if (!StringUtils.isEmpty(purcReturn.getDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.DATE_FIELD),
							purcReturn.getDate().getTime(), Store.YES));
		}
		// vend和items以json的格式存储
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.VEND_FIELD),
						JSONObject.toJSONString(purcReturn.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ENTERPRISE_FIELD),
				JSONObject.toJSONString(purcReturn.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(purcReturn.getReturnItems())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purcReturn.getReturnItems()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(purcReturn.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.DATE_FIELD),
					purcReturn.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ID_FIELD), purcReturn.getId()));
		return document;
	}

	/**
	 * 将MakeAcceptSimpleInfo转换成Documment
	 * 
	 * @param makeAccept
	 * @return
	 */
	public static Document toDocument(MakeAcceptSimpleInfo makeAccept) {
		if (makeAccept == null || makeAccept.getId() == null || StringUtils.isEmpty(makeAccept.getCode())
				|| makeAccept.getVend() == null || makeAccept.getVend().getUu() == null
				|| StringUtils.isEmpty(makeAccept.getVend().getEnName()) || makeAccept.getEnterprise() == null
				|| makeAccept.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(makeAccept.getEnterprise().getEnName())
				|| StringUtils.isEmpty(makeAccept.getDate())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeAcceptSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ID_FIELD),
				String.valueOf(makeAccept.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.CODE_FIELD),
				String.valueOf(makeAccept.getCode()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.SENDCODE_FIELD),
				String.valueOf(makeAccept.getSendCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.DATE_FIELD),
				makeAccept.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(makeAccept.getVend()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(makeAccept.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(makeAccept.getAcceptItems())) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(makeAccept.getAcceptItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.DATE_FIELD),
				makeAccept.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ID_FIELD), makeAccept.getId()));
		return document;
	}

	/**
	 * 将MakeOrderChangeItemSimpleInfo转换成Document
	 * 
	 * @param makeChangeItems
	 * @return
	 */
	public static Document toDocument(MakeOrderChangeItemSimpleInfo makeChangeItems) {
		if (makeChangeItems == null || makeChangeItems.getId() == null
				|| StringUtils.isEmpty(makeChangeItems.getOrderCode()) || makeChangeItems.getVend() == null
				|| makeChangeItems.getVend().getUu() == null
				|| StringUtils.isEmpty(makeChangeItems.getVend().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeOrderChangeItemSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.ID_FIELD),
						String.valueOf(makeChangeItems.getId()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.CODE_FIELD),
						String.valueOf(makeChangeItems.getOrderCode()), Store.YES));
		// vend和items以json的格式存储
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(makeChangeItems.getVend()), Store.YES));
		if (!StringUtils.isEmpty(makeChangeItems.getProduct())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.PRODUCT_FIELD),
					JSONObject.toJSONString(makeChangeItems.getProduct()), Store.YES));
		}
		if (!StringUtils.isEmpty(makeChangeItems.getMakeChanges())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.MAKE_FIELD),
					JSONObject.toJSONString(makeChangeItems.getMakeChanges()), Store.YES));
		}
		if (null != makeChangeItems.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.DATE_FIELD),
					makeChangeItems.getDate().getTime(), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.ID_FIELD),
				makeChangeItems.getId()));
		return document;
	}

	/**
	 * 将MakeReturnSimpleInfo转换成Document
	 * 
	 * @param makeRetrun
	 * @return
	 */
	public static Document toDocument(MakeReturnSimpleInfo makeRetrun) {
		if (makeRetrun == null || makeRetrun.getId() == null || StringUtils.isEmpty(makeRetrun.getCode())
				|| makeRetrun.getVend() == null || makeRetrun.getVend().getUu() == null
				|| StringUtils.isEmpty(makeRetrun.getVend().getEnName()) || makeRetrun.getEnterprise() == null
				|| makeRetrun.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(makeRetrun.getEnterprise().getEnName())
				|| StringUtils.isEmpty(makeRetrun.getDate())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeReturnSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ID_FIELD),
				String.valueOf(makeRetrun.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.CODE_FIELD),
				String.valueOf(makeRetrun.getCode()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.SENDCODE_FIELD),
				String.valueOf(makeRetrun.getSendCode()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.DATE_FIELD),
				makeRetrun.getDate().getTime(), Store.YES));
		// vend和items以json的格式存储
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(makeRetrun.getVend()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(makeRetrun.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(makeRetrun.getReturnItems())) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(makeRetrun.getReturnItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.DATE_FIELD),
				makeRetrun.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ID_FIELD), makeRetrun.getId()));
		return document;
	}

	/**
	 * 将SaleSendSimpleInfo转换成Document
	 * 
	 * @param saleSend
	 * @return
	 */
	public static Document toDocument(SaleSendSimpleInfo saleSend) {
		if (saleSend == null || saleSend.getId() == null || StringUtils.isEmpty(saleSend.getCode())
				|| saleSend.getVend() == null || saleSend.getVend().getUu() == null
				|| StringUtils.isEmpty(saleSend.getVend().getEnName()) || saleSend.getEnterprise() == null
				|| saleSend.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(saleSend.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleSendSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ID_FIELD),
				String.valueOf(saleSend.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.CODE_FIELD),
				String.valueOf(saleSend.getCode()), Store.YES));
		if (saleSend.getVerifystatus() != null) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.STATUS_FIELD),
							String.valueOf(saleSend.getVerifystatus()), Store.YES));
		}
		if (!StringUtils.isEmpty(saleSend.getDate())) {
			document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.DATE_FIELD),
					saleSend.getDate().getTime(), Store.YES));
		}
		// vend和items以json的格式存储
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.VEND_FIELD),
				JSONObject.toJSONString(saleSend.getVend()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ENTERPRISE_FIELD),
						JSONObject.toJSONString(saleSend.getEnterprise()), Store.YES));
		if (!CollectionUtils.isEmpty(saleSend.getSendItems())) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(saleSend.getSendItems()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(saleSend.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.DATE_FIELD),
					saleSend.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ID_FIELD), saleSend.getId()));
		return document;
	}

	/**
	 * 将PurchaseNoticeSimpleInfo转换成Document
	 * 
	 * @param purcNotice
	 * @return
	 */
	public static Document toDocument(PurchaseNoticeSimpleInfo purcNotice) {
		if (purcNotice == null || purcNotice.getId() == null || purcNotice.getVend() == null
				|| StringUtils.isEmpty(purcNotice.getDate()) || purcNotice.getVend().getUu() == null
				|| StringUtils.isEmpty(purcNotice.getVend().getEnName()) || purcNotice.getWaiting() == null
				|| purcNotice.getEnterprise() == null || purcNotice.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcNotice.getEnterprise().getEnName())) {

			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseNoticeSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ID_FIELD),
				String.valueOf(purcNotice.getId()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.DATE_FIELD),
				purcNotice.getDate().getTime(), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.VEND_FIELD),
						JSON.toJSONString(purcNotice.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(purcNotice.getEnterprise()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.STATUS_FIELD),
						String.valueOf(purcNotice.getStatus()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ISWAITING_FIELD),
				String.valueOf(purcNotice.getWaiting()), Store.YES));
		// 是否结案，如果为空录入为未结案
		if (purcNotice.getEnd() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.END_FIELD),
							String.valueOf(purcNotice.getEnd()), Store.YES));
		} else {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.END_FIELD),
							String.valueOf(Constant.NO), Store.YES));
		}
		// vend和orderItems以json的格式存储
		if (purcNotice.getOrderItem() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ORDERITEMS_FIELD),
					JSONObject.toJSONString(purcNotice.getOrderItem()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.DATE_FIELD),
				purcNotice.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ID_FIELD), purcNotice.getId()));
		return document;
	}

	/**
	 * 将PurcProofingapprovalSimpleInfo转换成Document
	 * 
	 * @param purcProofingapproval
	 * @return
	 */
	public static Document toDocument(PurcProofingapprovalSimpleInfo purcProofingapproval) {
		if (purcProofingapproval == null || purcProofingapproval.getId() == null
				|| purcProofingapproval.getVend() == null || purcProofingapproval.getVend().getUu() == null
				|| StringUtils.isEmpty(purcProofingapproval.getVend().getEnName())
				|| purcProofingapproval.getEnterprise() == null || purcProofingapproval.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcProofingapproval.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcProofingapprovalSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.ID_FIELD),
						String.valueOf(purcProofingapproval.getId()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.CODE_FIELD),
						purcProofingapproval.getCode(), Store.YES));
		if (!StringUtils.isEmpty(purcProofingapproval.getDate())) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.DATE_FIELD),
					purcProofingapproval.getDate().getTime(), Store.YES));
		}
		if (purcProofingapproval.getProdCode() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODCODE_FIELD),
					purcProofingapproval.getProdCode(), Store.YES));
		}
		if (purcProofingapproval.getProdDetail() != null) {

			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODDETAIL_FIELD),
					purcProofingapproval.getProdDetail(), Store.YES));
		}
		if (purcProofingapproval.getProdSpec() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODSPEC_FIELD),
					purcProofingapproval.getProdSpec(), Store.YES));
		}
		if (purcProofingapproval.getPscode() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PSCODE_FIELD),
					purcProofingapproval.getPscode(), Store.YES));
		}
		if (purcProofingapproval.getResult() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.RESULT_FIELD),
					purcProofingapproval.getResult(), Store.YES));
		}
		if (purcProofingapproval.getSscode() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.SSCODE_FIELD),
					purcProofingapproval.getSscode(), Store.YES));
		}
		// vend和orderItems以json的格式存储
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.VEND_FIELD),
				JSON.toJSONString(purcProofingapproval.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(purcProofingapproval.getEnterprise()), Store.YES));
		// 排序字段
		if (!StringUtils.isEmpty(purcProofingapproval.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.DATE_FIELD),
					purcProofingapproval.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.ID_FIELD),
				purcProofingapproval.getId()));
		return document;
	}

	/**
	 * 将PurcProofingsendSimpleInfo转换成Document
	 * 
	 * @param purcProofingsend
	 * @return
	 */
	public static Document toDocument(PurcProofingsendSimpleInfo purcProofingsend) {
		if (purcProofingsend == null || purcProofingsend.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcProofingsendSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ID_FIELD),
						String.valueOf(purcProofingsend.getId()), Store.YES));
		if (!StringUtils.isEmpty(purcProofingsend.getBrand())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.BRAND_FIELD),
					purcProofingsend.getBrand(), Store.YES));
		}
		if (!StringUtils.isEmpty(purcProofingsend.getDate())) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.DATE_FIELD),
							purcProofingsend.getDate().getTime(), Store.YES));
		}
		if (!StringUtils.isEmpty(purcProofingsend.getCode())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.CODE_FIELD),
							purcProofingsend.getCode(), Store.YES));
		}
		// vend和orderItems以json的格式存储
		if (purcProofingsend.getProofingItem() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(purcProofingsend.getProofingItem()), Store.YES));
		}
		// 排序字段
		if (!StringUtils.isEmpty(purcProofingsend.getDate())) {
			document.add(new NumericDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.DATE_FIELD),
					purcProofingsend.getDate().getTime()));
		}
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ID_FIELD),
				purcProofingsend.getId()));
		return document;
	}

	/**
	 * 将PurchaseApCheckSimpleInfo转换成Document
	 * 
	 * @param purcApcheck
	 * @return
	 */
	public static Document toDocument(PurchaseApCheckSimpleInfo purcApcheck) {
		if (purcApcheck == null || purcApcheck.getId() == null || purcApcheck.getCode() == null
				|| purcApcheck.getVendor() == null || purcApcheck.getVendor().getUu() == null
				|| StringUtils.isEmpty(purcApcheck.getVendor().getEnName()) || purcApcheck.getEnterprise() == null
				|| purcApcheck.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(purcApcheck.getEnterprise().getEnName()) || purcApcheck.getDate() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseApCheckSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ID_FIELD),
				String.valueOf(purcApcheck.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.CODE_FIELD),
				purcApcheck.getCode(), Store.YES));
		if (!StringUtils.isEmpty(purcApcheck.getCheckstatus())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.CHECKSTATUS_FIELD),
					purcApcheck.getCheckstatus(), Store.YES));
		}
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.DATE_FIELD),
				purcApcheck.getDate().getTime(), Store.YES));
		if (null != purcApcheck.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.STATUS_FIELD),
					String.valueOf(purcApcheck.getStatus()), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(purcApcheck.getEnterprise()), Store.YES));
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.VEND_FIELD),
						JSON.toJSONString(purcApcheck.getVendor()), Store.YES));
		// vend和orderItems以json的格式存储
		if (purcApcheck.getItems() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(purcApcheck.getItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.DATE_FIELD),
				purcApcheck.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ID_FIELD),
				purcApcheck.getId()));
		return document;
	}

	/**
	 * 将SaleArcheckSimpleInfo转换成Document
	 * 
	 * @param saleArcheck
	 * @return
	 */
	public static Document toDocument(SaleArcheckSimpleInfo saleArcheck) {
		if (saleArcheck == null || saleArcheck.getId() == null || saleArcheck.getCode() == null
				|| saleArcheck.getVendor() == null || saleArcheck.getVendor().getUu() == null
				|| StringUtils.isEmpty(saleArcheck.getVendor().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleArcheckSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ID_FIELD),
				String.valueOf(saleArcheck.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.CODE_FIELD),
				saleArcheck.getCode(), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.DATE_FIELD),
				saleArcheck.getDate().getTime(), Store.YES));
		if (null != saleArcheck.getStatus()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.STATUS_FIELD),
							String.valueOf(saleArcheck.getStatus()), Store.YES));
		}
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ENTERPRISE_FIELD),
						JSON.toJSONString(saleArcheck.getEnterprise()), Store.YES));
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.VEND_FIELD),
				JSON.toJSONString(saleArcheck.getVendor()), Store.YES));
		// vend和orderItems以json的格式存储
		if (saleArcheck.getItems() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ITEMS_FIELD),
							JSONObject.toJSONString(saleArcheck.getItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ID_FIELD), saleArcheck.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.DATE_FIELD),
				saleArcheck.getDate().getTime()));
		return document;
	}

	/**
	 * 将PurchaseInquiryItemSimpleInfo转换成Document
	 * 
	 * @param inquiryItem
	 * @return
	 */
	public static Document toDocument(PurchaseInquiryItemSimpleInfo inquiryItem) {
		if (inquiryItem == null || inquiryItem.getId() == null || inquiryItem.getSendStatus() == null
				|| StringUtils.isEmpty(inquiryItem.getEnterprise().getEnName())
				|| inquiryItem.getEnterprise().getUu() == null || inquiryItem.getStatus() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseInquiryItemSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.ID_FIELD),
						String.valueOf(inquiryItem.getId()), Store.YES));
		if (null != inquiryItem.getSendStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.SENDSTATUS_FIELD),
					String.valueOf(inquiryItem.getSendStatus()), Store.YES));
		}
		if (null != inquiryItem.getVendToDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.VENDTODATE_FIELD),
					inquiryItem.getVendToDate().getTime(), Store.YES));
		}
		if (null != inquiryItem.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.STATUS_FIELD),
					String.valueOf(inquiryItem.getStatus()), Store.YES));
		}
		if (null != inquiryItem.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.OVERDUE_FIELD),
					String.valueOf(inquiryItem.getOverdue()), Store.YES));
		}
		if (null != inquiryItem.getInvalid()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.INVALID_FIELD),
					String.valueOf(inquiryItem.getInvalid()), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.VEND_FIELD),
				JSON.toJSONString(inquiryItem.getEnterprise()), Store.YES));
		if (inquiryItem.getInquiry() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.INQUIRY_FIELD),
					JSONObject.toJSONString(inquiryItem.getInquiry()), Store.YES));
		}
		if (inquiryItem.getProduct() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.PRODUCT_FIELD),
					JSONObject.toJSONString(inquiryItem.getProduct()), Store.YES));
		}
		if (inquiryItem.getSourceapp() != null) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.SOURCEAPP_FIELD),
					String.valueOf(inquiryItem.getSourceapp()), Store.YES));
		}
		if (null != inquiryItem.getAgreed()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.AGREED_FIELD),
					String.valueOf(inquiryItem.getAgreed()), Store.YES));
		}
		if (null != inquiryItem.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.DATE_FIELD),
					Long.valueOf(inquiryItem.getDate().getTime()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.ID_FIELD),
				inquiryItem.getId()));
		return document;
	}

	/**
	 * 将PurchaseInquiryMouldSimpleInfo转换成Document
	 * 
	 * @param inquiryMould
	 * @return
	 */
	public static Document toDocument(PurchaseInquiryMouldSimpleInfo inquiryMould) {
		if (inquiryMould == null || inquiryMould.getId() == null || inquiryMould.getCode() == null
				|| inquiryMould.getEnterprise() == null || inquiryMould.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(inquiryMould.getEnterprise().getEnName()) || inquiryMould.getVend() == null
				|| inquiryMould.getVend().getUu() == null || StringUtils.isEmpty(inquiryMould.getVend().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseInquiryMouldSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ID_FIELD),
						String.valueOf(inquiryMould.getId()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.CODE_FIELD),
						String.valueOf(inquiryMould.getCode()), Store.YES));
		if (null != inquiryMould.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.DATE_FIELD),
					Long.valueOf(inquiryMould.getDate().getTime()), Store.YES));
		}
		if (null != inquiryMould.getEndDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ENDDATE_FIELD),
					Long.valueOf(inquiryMould.getEndDate().getTime()), Store.YES));
		}
		if (null != inquiryMould.getSendstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.SENDSTATUS_FIELD),
					String.valueOf(inquiryMould.getSendstatus()), Store.YES));
		}
		if (null != inquiryMould.getAdoptstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ADOPTSTATUS_FIELD),
					String.valueOf(inquiryMould.getAdoptstatus()), Store.YES));
		}
		if (null != inquiryMould.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.STATUS_FIELD),
					String.valueOf(inquiryMould.getStatus()), Store.YES));
		}
		if (null != inquiryMould.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.OVERDUE_FIELD),
					String.valueOf(inquiryMould.getOverdue()), Store.YES));
		}

		if (null != inquiryMould.getValid()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.VALID_FIELD),
					String.valueOf(inquiryMould.getValid()), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.VEND_FIELD),
				JSON.toJSONString(inquiryMould.getVend()), Store.YES));
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(inquiryMould.getEnterprise()), Store.YES));
		if (inquiryMould.getMouldItems() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(inquiryMould.getMouldItems()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ID_FIELD),
				inquiryMould.getId()));
		return document;
	}

	/**
	 * 将ProdSimpleInfo转换成Document
	 * 
	 * @param prodSimpleInfo
	 * @return
	 */
	public static Document toDocument(ProdSimpleInfo prodSimpleInfo) {
		if (prodSimpleInfo == null || prodSimpleInfo.getId() == null || prodSimpleInfo.getProdCode() == null
				|| prodSimpleInfo.getEnterprise() == null || prodSimpleInfo.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(prodSimpleInfo.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProdSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ID_FIELD),
				String.valueOf(prodSimpleInfo.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.CODE_FIELD),
				prodSimpleInfo.getProdCode(), Store.YES));
		if (null != prodSimpleInfo.getProdTitle()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.TITLE_FIELD),
					String.valueOf(prodSimpleInfo.getProdTitle()), Store.YES));
		}
		if (null != prodSimpleInfo.getProdSpec()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.SPEC_FIELD),
					String.valueOf(prodSimpleInfo.getProdSpec()), Store.YES));
		}
		if (null != prodSimpleInfo.getBrand()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.BRAND_FIELD),
					String.valueOf(prodSimpleInfo.getBrand()), Store.YES));
		}
		if (null != prodSimpleInfo.getIssale()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ISSALE_FIELD),
					String.valueOf(prodSimpleInfo.getIssale()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPurchase()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ISPURC_FIELD),
					String.valueOf(prodSimpleInfo.getIsPurchase()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsShow()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ISSHOW_FIELD),
					String.valueOf(prodSimpleInfo.getIsShow()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPubsale()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ISPUBSALE_FIELD),
					String.valueOf(prodSimpleInfo.getIsPubsale()), Store.YES));
		}
		if (null != prodSimpleInfo.getUuid()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.UUID_FIELD),
					String.valueOf(prodSimpleInfo.getUuid()), Store.YES));
		}
		if (null != prodSimpleInfo.getCmpCode()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.CMPCODE_FIELD),
					String.valueOf(prodSimpleInfo.getCmpCode()), Store.YES));
		}
		if (null != prodSimpleInfo.getStandard()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.STANDARD_FIELD),
					String.valueOf(prodSimpleInfo.getStandard()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchstatus()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.MATCHESTAUTS_FIELD),
							String.valueOf(prodSimpleInfo.getMatchstatus()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchsize()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.MATCHESIZE_FIELD),
							String.valueOf(prodSimpleInfo.getMatchsize()), Store.YES));
		}
		if (null != prodSimpleInfo.getKind()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.KIND_FIELD),
					String.valueOf(prodSimpleInfo.getKind()), Store.YES));
		}
		if (null != prodSimpleInfo.getKinden()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.KINDEN_FIELD),
					String.valueOf(prodSimpleInfo.getKinden()), Store.YES));
		}
		if (null != prodSimpleInfo.getPbrand()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.PBRAND_FIELD),
					String.valueOf(prodSimpleInfo.getPbrand()), Store.YES));
		}
		if (null != prodSimpleInfo.getPbranden()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.PBRANDEN_FIELD),
					String.valueOf(prodSimpleInfo.getPbranden()), Store.YES));
		}
		if (null != prodSimpleInfo.getPcmpcode()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.PCMPCODE_FIELD),
					String.valueOf(prodSimpleInfo.getPcmpcode()), Store.YES));
		}
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(prodSimpleInfo.getEnterprise()), Store.YES));

		if (null != prodSimpleInfo.getGoodsnover()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.NOVER_FIELD),
					String.valueOf(prodSimpleInfo.getGoodsnover()), Store.YES));
		}
		if (null != prodSimpleInfo.getGoodstaxno()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.TAXNO_FIELD),
					String.valueOf(prodSimpleInfo.getGoodstaxno()), Store.YES));
		}
		if (null != prodSimpleInfo.getTaxpre()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.TAXPRE_FIELD),
					String.valueOf(prodSimpleInfo.getTaxpre()), Store.YES));
		}
		if (null != prodSimpleInfo.getTaxprecon()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.TAXPRECON_FIELD),
					String.valueOf(prodSimpleInfo.getTaxprecon()), Store.YES));
		}

		if (null != prodSimpleInfo.getB2benabled()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.B2BENABLED_FIELD),
					String.valueOf(prodSimpleInfo.getB2benabled()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ID_FIELD),
				prodSimpleInfo.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.MATCHESIZE_FIELD),
				prodSimpleInfo.getMatchsize()));
		return document;
	}

	/**
	 * 将ProdStandardSimpleInfo转换成Document
	 * 
	 * @param prodSimpleInfo
	 * @return
	 */
	public static Document toDocument(ProdStandardSimpleInfo prodSimpleInfo) {
		if (prodSimpleInfo == null || prodSimpleInfo.getId() == null || prodSimpleInfo.getProdCode() == null
				|| prodSimpleInfo.getEnterprise() == null || prodSimpleInfo.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(prodSimpleInfo.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProdStandardSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ID_FIELD),
				String.valueOf(prodSimpleInfo.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.CODE_FIELD),
				prodSimpleInfo.getProdCode(), Store.YES));
		if (null != prodSimpleInfo.getIssale()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ISSALE_FIELD),
							String.valueOf(prodSimpleInfo.getIssale()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPurchase()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ISPURC_FIELD),
							String.valueOf(prodSimpleInfo.getIsPurchase()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsShow()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ISSHOW_FIELD),
							String.valueOf(prodSimpleInfo.getIsShow()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPubsale()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ISPUBSALE_FIELD),
					String.valueOf(prodSimpleInfo.getIsPubsale()), Store.YES));
		}
		if (null != prodSimpleInfo.getUuid()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.UUID_FIELD),
							String.valueOf(prodSimpleInfo.getUuid()), Store.YES));
		}
		if (null != prodSimpleInfo.getStandard()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.STANDARD_FIELD),
					String.valueOf(prodSimpleInfo.getStandard()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.MATCHESTAUTS_FIELD),
					String.valueOf(prodSimpleInfo.getMatchstatus()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchsize()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.MATCHESIZE_FIELD),
					String.valueOf(prodSimpleInfo.getMatchsize()), Store.YES));
		}
		if (null != prodSimpleInfo.getKind()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.KIND_FIELD),
							String.valueOf(prodSimpleInfo.getKind()), Store.YES));
		}
		if (null != prodSimpleInfo.getKinden()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.KINDEN_FIELD),
							String.valueOf(prodSimpleInfo.getKinden()), Store.YES));
		}
		if (null != prodSimpleInfo.getPbrand()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.PBRAND_FIELD),
							String.valueOf(prodSimpleInfo.getPbrand()), Store.YES));
		}
		if (null != prodSimpleInfo.getPbranden()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.PBRANDEN_FIELD),
					String.valueOf(prodSimpleInfo.getPbranden()), Store.YES));
		}
		if (null != prodSimpleInfo.getPcmpcode()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.PCMPCODE_FIELD),
					String.valueOf(prodSimpleInfo.getPcmpcode()), Store.YES));
		}
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ENTERPRISE_FIELD),
						JSON.toJSONString(prodSimpleInfo.getEnterprise()), Store.YES));
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.ID_FIELD),
				prodSimpleInfo.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProdStandardSimpleInfo.MATCHESIZE_FIELD),
				prodSimpleInfo.getMatchsize()));
		return document;
	}

	/**
	 * 将ProdNonStandardSimpleInfo转换成Document
	 * 
	 * @param prodSimpleInfo
	 * @return
	 */
	public static Document toDocument(ProdNonStandardSimpleInfo prodSimpleInfo) {
		if (prodSimpleInfo == null || prodSimpleInfo.getId() == null || prodSimpleInfo.getProdCode() == null
				|| prodSimpleInfo.getEnterprise() == null || prodSimpleInfo.getEnterprise().getUu() == null
				|| StringUtils.isEmpty(prodSimpleInfo.getEnterprise().getEnName())) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProdNonStandardSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ID_FIELD),
				String.valueOf(prodSimpleInfo.getId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.CODE_FIELD),
				prodSimpleInfo.getProdCode(), Store.YES));
		if (null != prodSimpleInfo.getProdTitle()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.TITLE_FIELD),
							String.valueOf(prodSimpleInfo.getProdTitle()), Store.YES));
		}
		if (null != prodSimpleInfo.getProdSpec()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.SPEC_FIELD),
							String.valueOf(prodSimpleInfo.getProdSpec()), Store.YES));
		}
		if (null != prodSimpleInfo.getBrand()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.BRAND_FIELD),
							String.valueOf(prodSimpleInfo.getBrand()), Store.YES));
		}
		if (null != prodSimpleInfo.getIssale()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ISSALE_FIELD),
					String.valueOf(prodSimpleInfo.getIssale()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPurchase()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ISPURC_FIELD),
					String.valueOf(prodSimpleInfo.getIsPurchase()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsShow()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ISSHOW_FIELD),
					String.valueOf(prodSimpleInfo.getIsShow()), Store.YES));
		}
		if (null != prodSimpleInfo.getIsPubsale()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ISPUBSALE_FIELD),
					String.valueOf(prodSimpleInfo.getIsPubsale()), Store.YES));
		}
		if (null != prodSimpleInfo.getUuid()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.UUID_FIELD),
							String.valueOf(prodSimpleInfo.getUuid()), Store.YES));
		}
		if (null != prodSimpleInfo.getCmpCode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.CMPCODE_FIELD),
					String.valueOf(prodSimpleInfo.getCmpCode()), Store.YES));
		}
		if (null != prodSimpleInfo.getStandard()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.STANDARD_FIELD),
					String.valueOf(prodSimpleInfo.getStandard()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.MATCHESTAUTS_FIELD),
					String.valueOf(prodSimpleInfo.getMatchstatus()), Store.YES));
		}
		if (null != prodSimpleInfo.getMatchsize()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.MATCHESIZE_FIELD),
					String.valueOf(prodSimpleInfo.getMatchsize()), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(prodSimpleInfo.getEnterprise()), Store.YES));
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.ID_FIELD),
				prodSimpleInfo.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProdNonStandardSimpleInfo.MATCHESIZE_FIELD),
				prodSimpleInfo.getMatchsize()));
		return document;
	}

	/**
	 * 将EnterpriseSearchSimpleInfo转换为Document
	 * 
	 * @param enterprise
	 * @return
	 */
	public static Document toDocument(EnterpriseSearchSimpleInfo enterprise) {
		if (enterprise == null || enterprise.getEnuu() == null || enterprise.getEnName() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(EnterpriseSearchSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ID_FIELD),
						String.valueOf(enterprise.getEnuu()), Store.YES));
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.NAME_FIELD),
						enterprise.getEnName(), Store.YES));
		if (null != enterprise.getEnShortname()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SHORTNAME_FIELD),
					enterprise.getEnShortname(), Store.YES));
		}
		if (null != enterprise.getEnAdminuu()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ADMINUU_FIELD),
					String.valueOf(enterprise.getEnAdminuu()), Store.YES));
		}
		if (null != enterprise.getEnIsErp()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ISERP_FIELD),
					String.valueOf(enterprise.getEnIsErp()), Store.YES));
		}
		if (null != enterprise.getEnSaasSendStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASSENDSTATUS_FIELD),
					String.valueOf(enterprise.getEnSaasSendStatus()), Store.YES));
		}
		if (null != enterprise.getEnSaasStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASSTATUS_FIELD),
					String.valueOf(enterprise.getEnSaasStatus()), Store.YES));
		}
		if (null != enterprise.getEnSendStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SENDSTATUS_FIELD),
					String.valueOf(enterprise.getEnSendStatus()), Store.YES));
		}
		if (null != enterprise.getEnStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.STATUS_FIELD),
					String.valueOf(enterprise.getEnStatus()), Store.YES));
		}
		if (null != enterprise.getEnAddress()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ADDRESS_FIELD),
					String.valueOf(enterprise.getEnAddress()), Store.YES));
		}
		if (null != enterprise.getEnArea()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.AREA_FIELD),
							String.valueOf(enterprise.getEnArea()), Store.YES));
		}
		if (null != enterprise.getEnBussinessCode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.BUSSINESSCODE_FIELD),
					String.valueOf(enterprise.getEnBussinessCode()), Store.YES));
		}
		if (null != enterprise.getEnCorporation()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.CORPORATION_FIELD),
					String.valueOf(enterprise.getEnCorporation()), Store.YES));
		}
		if (null != enterprise.getEnDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.DATE_FIELD),
							Long.valueOf(enterprise.getEnDate().getTime()), Store.YES));
		}
		if (null != enterprise.getEnDeliverAddr()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.DELIVERYADDR_FIELD),
					String.valueOf(enterprise.getEnDeliverAddr()), Store.YES));
		}
		if (null != enterprise.getEnFax()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.FAX_FIELD),
							String.valueOf(enterprise.getEnFax()), Store.YES));
		}
		if (null != enterprise.getEnIndustry()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.INDUSTRY_FIELD),
					String.valueOf(enterprise.getEnIndustry()), Store.YES));
		}
		if (null != enterprise.getEnRegistercapital()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.REGISTERCAPITAL_FIELD),
					String.valueOf(enterprise.getEnRegistercapital()), Store.YES));
		}
		if (null != enterprise.getEnSaasUrl()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASURL_FIELD),
					String.valueOf(enterprise.getEnSaasUrl()), Store.YES));
		}
		if (null != enterprise.getEnTaxcode()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TAXCODE_FIELD),
					String.valueOf(enterprise.getEnTaxcode()), Store.YES));
		}
		if (null != enterprise.getEnTel()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TEL_FIELD),
							String.valueOf(enterprise.getEnTel()), Store.YES));
		}
		if (null != enterprise.getEnType()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TYPE_FIELD),
					String.valueOf(enterprise.getEnType()), Store.YES));
		}
		if (null != enterprise.getEnUrl()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.URL_FIELD),
							String.valueOf(enterprise.getEnUrl()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ID_FIELD),
				enterprise.getEnuu()));
		return document;
	}

	public static Document toDocument(ProductComponentSimpleInfo prodComp) {
		if (prodComp == null || prodComp.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProductComponentSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		if (prodComp.getId() != null) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.ID_FIELD),
							String.valueOf(prodComp.getId()), Store.YES));
		}
		if (prodComp.getUuid() != null) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.UUID_FIELD),
					String.valueOf(prodComp.getUuid()), Store.YES));
		}
		if (prodComp.getCode() != null) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.CODE_FIELD),
							String.valueOf(prodComp.getCode()), Store.YES));
		}
		if (prodComp.getBrand() != null) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.BRAND_FIELD),
					JSON.toJSONString(prodComp.getBrand()), Store.YES));
		}
		if (prodComp.getKindid() != null) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.KINDID_FIELD),
					String.valueOf(prodComp.getKindid()), Store.YES));
		}
		return document;
	}

	/**
	 * 将DeputyOrderSimpleInfo转换为Document
	 * 
	 * @param depOrder
	 * @return
	 */
	public static Document toDocument(DeputyOrderSimpleInfo depOrder) {
		if (depOrder == null || depOrder.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(DeputyOrderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		if (null != depOrder.getId()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ID_FIELD),
					String.valueOf(depOrder.getId()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getCode())) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CODE_FIELD),
							String.valueOf(depOrder.getCode()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getSalecode())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.SALECODE_FIELD),
							String.valueOf(depOrder.getSalecode()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getSalepocode())) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.SALEPCODE_FIELD),
					String.valueOf(depOrder.getSalepocode()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getCustomer())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CUSTOMER_FIELD),
					String.valueOf(depOrder.getCustomer()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getLegalrepresent())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.LEGALREPRESENT_FIELD),
					String.valueOf(depOrder.getLegalrepresent()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getVenduser())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSER_FIELD),
					String.valueOf(depOrder.getVenduser()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getStatuscode())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.STATUSCOE_FIELD),
					String.valueOf(depOrder.getStatuscode()), Store.YES));
		}
		if (null != depOrder.getEnuu()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ENUU_FIELD),
							String.valueOf(depOrder.getEnuu()), Store.YES));
		}
		if (null != depOrder.getTervenduu()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDUU_FEILD),
					String.valueOf(depOrder.getTervenduu()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getCompanyname())) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.COMPANYNAME_FIELD),
					String.valueOf(depOrder.getCompanyname()), Store.YES));
		}
		if (!StringUtils.isEmpty(depOrder.getTervendor())) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDOR_FIELD),
					String.valueOf(depOrder.getTervendor()), Store.YES));
		}
		if (null != depOrder.getVenduseruu()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSERUU_FIELD),
					String.valueOf(depOrder.getVenduseruu()), Store.YES));
		}
		if (null != depOrder.getEntrystatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ENTRYSTATUS_FIELD),
					String.valueOf(depOrder.getEntrystatus()), Store.YES));
		}
		if (null != depOrder.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.DATE_FIELD),
					Long.valueOf(depOrder.getDate().getTime()), Store.YES));
		}
		if (null != depOrder.getDownloadstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.DOWNLOADSTATUS_FIELD),
					String.valueOf(depOrder.getDownloadstatus()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ID_FIELD), depOrder.getId()));
		return document;
	}

	/**
	 * 将PurcahseTenderSimplInfo转换为Document
	 * 
	 * @param tender
	 * @return
	 */
	public static Document toDocument(PurchaseTenderSimpleInfo tender) {
		if (tender == null || tender.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseTenderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ID_FIELD),
				String.valueOf(tender.getId()), Store.YES));
		if (null != tender.getCode()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CODE_FIELD),
							tender.getCode(), Store.YES));
		}
		if (null != tender.getCurrency()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CURRENCY_FIELD),
					tender.getCurrency(), Store.YES));
		}
		if (null != tender.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.STATUS_FIELD),
					tender.getStatus(), Store.YES));
		}
		if (null != tender.getIsPublish()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ISPUBLISH_FIELD),
					String.valueOf(tender.getIsPublish()), Store.YES));
		}
		if (null != tender.getAuditStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.AUDITSTATUS_FIELD),
					String.valueOf(tender.getAuditStatus()), Store.YES));
		}
		if (null != tender.getIfOpen()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.IFOPEN_FIELD),
					String.valueOf(tender.getIfOpen()), Store.YES));
		}
		if (null != tender.getDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.DATE_FIELD),
							Long.valueOf(tender.getDate().getTime()), Store.YES));
		}
		if (null != tender.getEndDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ENDDATE_FIELD),
					Long.valueOf(tender.getEndDate().getTime()), Store.YES));
		}
		if (null != tender.getPublishDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.PUBLISHDATE_FIELD),
					Long.valueOf(tender.getPublishDate().getTime()), Store.YES));
		}
		if (null != tender.getCertificate()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CERTIFICATE_FIELD),
					String.valueOf(tender.getCertificate()), Store.YES));
		}
		if (null != tender.getUser()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.USER_FIELD),
							tender.getUser(), Store.YES));
		}
		if (null != tender.getUserTel()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.USERTEL_FIELD),
					tender.getUserTel(), Store.YES));
		}
		if (null != tender.getTitle()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.TITLE_FIELD),
					tender.getTitle(), Store.YES));
		}
		if (null != tender.getShipAddress()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.SHIPADDRESS_FIELD),
					tender.getShipAddress(), Store.YES));
		}
		if (null != tender.getPayment()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.PAYMENT_FIELD),
					tender.getPayment(), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(tender.getEnterprise()), Store.YES));
		if (null != tender.getTenderProds()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.TENDERPROD_FIELD),
					JSONObject.toJSONString(tender.getTenderProds()), Store.YES));
		}
		if (null != tender.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.OVERDUE_FIELD),
					String.valueOf(tender.getOverdue()), Store.YES));
		}
		if (null != tender.getResult()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.RESULT_FIELD),
					String.valueOf(tender.getResult()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ID_FIELD), tender.getId()));
		return document;
	}

	/**
	 * 将ErpSaleTenderSimpleInfo转换为Document
	 * 
	 * @param tender
	 * @return
	 */
	public static Document toDocument(ErpSaleTenderSimpleInfo tender) {
		if (tender == null || tender.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ErpSaleTenderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.ID_FIELD),
				String.valueOf(tender.getId()), Store.YES));
		if (null != tender.getCode()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.CODE_FIELD),
							tender.getCode(), Store.YES));
		}
		if (null != tender.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.STATUS_FIELD),
					tender.getStatus(), Store.YES));
		}
		if (null != tender.getIfOpen()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.IFOPEN_FIELD),
					String.valueOf(tender.getIfOpen()), Store.YES));
		}
		if (null != tender.getIsPublish()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.ISPUBLISH_FIELD),
					String.valueOf(tender.getIsPublish()), Store.YES));
		}
		if (null != tender.getAuditStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.AUDITSTATUS_FIELD),
					String.valueOf(tender.getAuditStatus()), Store.YES));
		}
		if (null != tender.getDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.DATE_FIELD),
							Long.valueOf(tender.getDate().getTime()), Store.YES));
		}
		if (null != tender.getEndDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.ENDDATE_FIELD),
							Long.valueOf(tender.getEndDate().getTime()), Store.YES));
		}
		if (null != tender.getPublishDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.PUBLISHDATE_FIELD),
					Long.valueOf(tender.getPublishDate().getTime()), Store.YES));
		}
		if (null != tender.getUser()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.USER_FIELD),
							tender.getUser(), Store.YES));
		}
		if (null != tender.getUserTel()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.USERTEL_FIELD),
					tender.getUserTel(), Store.YES));
		}
		if (null != tender.getTitle()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.TITLE_FIELD),
							tender.getTitle(), Store.YES));
		}
		if (null != tender.getShipAddress()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.SHIPADDRESS_FIELD),
					tender.getShipAddress(), Store.YES));
		}
		if (null != tender.getPayment()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.PAYMENT_FIELD),
							tender.getPayment(), Store.YES));
		}
		document.add(new StringField(
				ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.ENTERPRISE_FIELD),
				JSON.toJSONString(tender.getEnterprise()), Store.YES));
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.VEND_FIELD),
				JSON.toJSONString(tender.getVendor()), Store.YES));
		if (null != tender.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.OVERDUE_FIELD),
					String.valueOf(tender.getOverdue()), Store.YES));
		}
		if (null != tender.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.OVERDUE_FIELD),
					String.valueOf(tender.getOverdue()), Store.YES));
		}
		if (null != tender.getResult()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.RESULT_FIELD),
					String.valueOf(tender.getResult()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ErpSaleTenderSimpleInfo.ID_FIELD), tender.getId()));
		return document;
	}

	/**
	 * 将SaleTenderSimpleInfo转换为Document
	 *
	 * @param saleTender
	 * @return
	 */
	public static Document toDocument(B2BSaleTenderSimpleInfo saleTender) {
		if (saleTender == null || saleTender.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(B2BSaleTenderSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ID_FIELD),
				String.valueOf(saleTender.getId()), Store.YES));
		if (null != saleTender.getCode()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.CODE_FIELD),
							saleTender.getCode(), Store.YES));
		}
		if (null != saleTender.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.STATUS_FIELD),
					saleTender.getStatus(), Store.YES));
		}
		if (null != saleTender.getIfOpen()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.IFOPEN_FIELD),
					String.valueOf(saleTender.getIfOpen()), Store.YES));
		}
		if (null != saleTender.getIsPublish()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ISPUBLISH_FIELD),
					String.valueOf(saleTender.getIsPublish()), Store.YES));
		}
		if (null != saleTender.getAuditStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.AUDITSTATUS_FIELD),
					String.valueOf(saleTender.getAuditStatus()), Store.YES));
		}
		if (null != saleTender.getDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.DATE_FIELD),
							Long.valueOf(saleTender.getDate().getTime()), Store.YES));
		}
		if (null != saleTender.getEndDate()) {
			document.add(
					new LongField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ENDDATE_FIELD),
							Long.valueOf(saleTender.getEndDate().getTime()), Store.YES));
		}
		if (null != saleTender.getPublishDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.PUBLISHDATE_FIELD),
					Long.valueOf(saleTender.getPublishDate().getTime()), Store.YES));
		}
		if (null != saleTender.getUser()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.USERNAME_FIELD),
							saleTender.getUser(), Store.YES));
		}
		if (null != saleTender.getUserTel()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.USERTEL_FIELD),
					saleTender.getUserTel(), Store.YES));
		}
		if (null != saleTender.getTitle()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.TITLE_FIELD),
							saleTender.getTitle(), Store.YES));
		}
		if (null != saleTender.getShipAddress()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.SHIPADDRESS_FIELD),
					saleTender.getShipAddress(), Store.YES));
		}
		if (null != saleTender.getPayment()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.PAYMENT_FIELD),
							saleTender.getPayment(), Store.YES));
		}
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ENTERPRISE_FIELD),
						JSON.toJSONString(saleTender.getEnterprise()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.VEND_FIELD),
				JSON.toJSONString(saleTender.getVendor()), Store.YES));
		if (null != saleTender.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.OVERDUE_FIELD),
					String.valueOf(saleTender.getOverdue()), Store.YES));
		}
		if (null != saleTender.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.OVERDUE_FIELD),
					String.valueOf(saleTender.getOverdue()), Store.YES));
		}
		if (null != saleTender.getResult()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.RESULT_FIELD),
					String.valueOf(saleTender.getResult()), Store.YES));
		}
		if (null != saleTender.getRecorder()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.RECORDER_FIELD),
					JSON.toJSONString(saleTender.getRecorder()), Store.YES));
		}

		if (null != saleTender.getVendUser()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.USER_FIELD),
							JSON.toJSONString(saleTender.getVendUser()), Store.YES));
		}

		if (null != saleTender.getSaleTenderItems()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ITEM_FIELD),
							JSON.toJSONString(saleTender.getSaleTenderItems()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, B2BSaleTenderSimpleInfo.ID_FIELD), saleTender.getId()));
		return document;
	}

	/**
	 * 将SaleTenderQuestionSimpleInfo转换为Document
	 *
	 * @param saleTenderQuestionSimpleInfo
	 * @return
	 */
	public static Document toDocument(SaleTenderQuestionSimpleInfo saleTenderQuestionSimpleInfo) {
		if (saleTenderQuestionSimpleInfo == null || saleTenderQuestionSimpleInfo.getId() == null
				|| saleTenderQuestionSimpleInfo.getVendUU() == null
				|| saleTenderQuestionSimpleInfo.getVendor() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleTenderQuestionSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.ID_FIELD),
						String.valueOf(saleTenderQuestionSimpleInfo.getId()), Store.YES));
		if (null != saleTenderQuestionSimpleInfo.getCode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.CODE_FIELD),
					saleTenderQuestionSimpleInfo.getCode(), Store.YES));
		}
		if (null != saleTenderQuestionSimpleInfo.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.STATUS_FIELD),
					String.valueOf(saleTenderQuestionSimpleInfo.getStatus()), Store.YES));
		}
		if (null != saleTenderQuestionSimpleInfo.getInDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.DATE_FIELD),
					Long.valueOf(saleTenderQuestionSimpleInfo.getInDate().getTime()), Store.YES));
		}
		if (null != saleTenderQuestionSimpleInfo.getReplyDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.REPLYDATE_FIELD),
					Long.valueOf(saleTenderQuestionSimpleInfo.getReplyDate().getTime()), Store.YES));
		}
		if (null != saleTenderQuestionSimpleInfo.getTopic()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.TOPIC_FIELD),
					saleTenderQuestionSimpleInfo.getTopic(), Store.YES));
		}
		if (null != saleTenderQuestionSimpleInfo.getContent()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.CONTENT_FIELD),
					saleTenderQuestionSimpleInfo.getContent(), Store.YES));
		}
		document.add(
				new TextField(ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.VEND_FIELD),
						JSON.toJSONString(saleTenderQuestionSimpleInfo.getVendor()), Store.YES));
		if (null != saleTenderQuestionSimpleInfo.getAnwser()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.ANSWER_FIELD),
					JSON.toJSONString(saleTenderQuestionSimpleInfo.getAnwser()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, SaleTenderQuestionSimpleInfo.ID_FIELD),
				saleTenderQuestionSimpleInfo.getId()));
		return document;
	}

	/**
	 * 将PagingReleaseDetailSimpleInfo 转换成Document
	 * 
	 * @param pagingReleaseDetail
	 * @return
	 */
	public static Document toDocument(PagingReleaseDetailSimpleInfo pagingReleaseDetail) {
		if (pagingReleaseDetail == null || pagingReleaseDetail.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PagingReleaseDetailSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.ID_FIELD),
						String.valueOf(pagingReleaseDetail.getId()), Store.YES));
		if (null != pagingReleaseDetail.getUserUU()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.USERUU_FIELD),
					String.valueOf(pagingReleaseDetail.getUserUU()), Store.YES));
		}
		if (null != pagingReleaseDetail.getUserName()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.USERNAME_FIELD),
					String.valueOf(pagingReleaseDetail.getUserName()), Store.YES));
		}
		if (null != pagingReleaseDetail.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.STATUS_FIELD),
					String.valueOf(pagingReleaseDetail.getStatus()), Store.YES));
		}
		if (null != pagingReleaseDetail.getReadStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.READSTATUS_FIELD),
					String.valueOf(pagingReleaseDetail.getReadStatus()), Store.YES));
		}
		if (null != pagingReleaseDetail.getPushStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.PUSHSTATUS_FIELD),
					String.valueOf(pagingReleaseDetail.getPushStatus()), Store.YES));
		}
		if (null != pagingReleaseDetail.getTotalStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.TOTALSTATUS_FIELD),
					String.valueOf(pagingReleaseDetail.getTotalStatus()), Store.YES));
		}
		if (null != pagingReleaseDetail.getEnterprise()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.VEND_FIELD),
					JSON.toJSONString(pagingReleaseDetail.getEnterprise()), Store.YES));
		}
		if (null != pagingReleaseDetail.getPagingRelease()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.MAIN_FIELD),
					JSONObject.toJSONString(pagingReleaseDetail.getPagingRelease()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.ID_FIELD),
				pagingReleaseDetail.getId()));

		return document;
	}

	/**
	 * 将VendorSimpleInfo 转换成Document
	 * 
	 * @param vendorSimpleInfo
	 * @return
	 */
	public static Document toDocument(VendorSimpleInfo vendorSimpleInfo) {
		if (vendorSimpleInfo == null || vendorSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(VendorSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ID_FIELD),
				String.valueOf(vendorSimpleInfo.getId()), Store.YES));
		if (null != vendorSimpleInfo.getStatus()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.STATUS_FIELD),
					String.valueOf(vendorSimpleInfo.getStatus()), Store.YES));
		}
		if (null != vendorSimpleInfo.getEnterprise()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ENTERPRISE_FIELD),
							JSON.toJSONString(vendorSimpleInfo.getEnterprise()), Store.YES));
		}
		if (null != vendorSimpleInfo.getVend()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VEND_FIELD),
					JSON.toJSONString(vendorSimpleInfo.getVend()), Store.YES));
		}
		if (null != vendorSimpleInfo.getMyUser()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.MYUSER_FIELD),
					JSON.toJSONString(vendorSimpleInfo.getMyUser()), Store.YES));
		}
		if (null != vendorSimpleInfo.getVendUser()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VENDUSER_FIELD),
							JSON.toJSONString(vendorSimpleInfo.getVendUser()), Store.YES));
		}
		if (null != vendorSimpleInfo.getCustswitch()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.CUSTSWITCH_FIELD),
							JSON.toJSONString(vendorSimpleInfo.getCustswitch()), Store.YES));
		}
		if (null != vendorSimpleInfo.getVendswitch()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VENDSWITCH_FIELD),
							JSON.toJSONString(vendorSimpleInfo.getVendswitch()), Store.YES));
		}
		if (null != vendorSimpleInfo.getServicerswitch()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.SERVICERSWITCH_FIELD),
					JSON.toJSONString(vendorSimpleInfo.getServicerswitch()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ID_FIELD), vendorSimpleInfo.getId()));

		return document;
	}

	/**
	 * 将CustmerSimpleInfo 转换成Document
	 * 
	 * @param custmerSimpleInfo
	 * @return
	 */
	public static Document toDocument(CustmerSimpleInfo custmerSimpleInfo) {
		if (custmerSimpleInfo == null || custmerSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(CustmerSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.ID_FIELD),
				String.valueOf(custmerSimpleInfo.getId()), Store.YES));
		if (null != custmerSimpleInfo.getStatus()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.STATUS_FIELD),
					String.valueOf(custmerSimpleInfo.getStatus()), Store.YES));
		}
		if (null != custmerSimpleInfo.getEnterprise()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.ENTERPRISE_FIELD),
							JSON.toJSONString(custmerSimpleInfo.getEnterprise()), Store.YES));
		}
		if (null != custmerSimpleInfo.getVend()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.VEND_FIELD),
					JSON.toJSONString(custmerSimpleInfo.getVend()), Store.YES));
		}
		if (null != custmerSimpleInfo.getMyUser()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.MYUSER_FIELD),
					JSON.toJSONString(custmerSimpleInfo.getMyUser()), Store.YES));
		}
		if (null != custmerSimpleInfo.getVendUser()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.VENDUSER_FIELD),
							JSON.toJSONString(custmerSimpleInfo.getVendUser()), Store.YES));
		}
		if (null != custmerSimpleInfo.getCustswitch()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.CUSTSWITCH_FIELD),
							JSON.toJSONString(custmerSimpleInfo.getCustswitch()), Store.YES));
		}
		if (null != custmerSimpleInfo.getVendswitch()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.VENDSWITCH_FIELD),
							JSON.toJSONString(custmerSimpleInfo.getVendswitch()), Store.YES));
		}
		if (null != custmerSimpleInfo.getServicerswitch()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.SERVICERSWITCH_FIELD),
					JSON.toJSONString(custmerSimpleInfo.getServicerswitch()), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, CustmerSimpleInfo.ID_FIELD), custmerSimpleInfo.getId()));

		return document;
	}

	/**
	 * 将ProductBrandSimpleInfo 转换成Document
	 * 
	 * @param productBrandSimpleInfo
	 * @return
	 */
	public static Document toDocument(ProductBrandSimpleInfo productBrandSimpleInfo) {
		if (productBrandSimpleInfo == null || productBrandSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProductBrandSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.ID_FIELD),
				String.valueOf(productBrandSimpleInfo.getId()), Store.YES));
		if (null != productBrandSimpleInfo.getUuid()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.UUID_FIELD),
							String.valueOf(productBrandSimpleInfo.getUuid()), Store.YES));
		}
		if (null != productBrandSimpleInfo.getNameCn()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMECN_FIELD),
							productBrandSimpleInfo.getNameCn(), Store.YES));
		}
		if (null != productBrandSimpleInfo.getNameEn()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMEEN_FIELD),
							productBrandSimpleInfo.getNameEn(), Store.YES));
		}
		if (null != productBrandSimpleInfo.getVendor()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.VENDOR_FIELD),
							productBrandSimpleInfo.getVendor(), Store.YES));
		}

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.ID_FIELD),
				productBrandSimpleInfo.getId()));

		return document;
	}

	/**
	 * 将UserSpaceDetailSimpleInfo转成document
	 * 
	 * @param userSpaceDetailSimpleInfo
	 * @return
	 */
	public static Document toDocument(UserSpaceDetailSimpleInfo userSpaceDetailSimpleInfo) {
		if (userSpaceDetailSimpleInfo == null || userSpaceDetailSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(UserSpaceDetailSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.ID_FIELD),
				String.valueOf(userSpaceDetailSimpleInfo.getId()), Store.YES));
		if (null != userSpaceDetailSimpleInfo.getName()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.NAME_FIELD),
							String.valueOf(userSpaceDetailSimpleInfo.getName()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getShortname()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.SHORTNAME_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getShortname()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getIndustry()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.INDUSTRY_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getIndustry()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getAdminname()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.ADMINNAME_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getAdminname()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getBusinesscode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.BUSINESSCODE_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getBusinesscode()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getSearchstatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.SEARCHSTATUS_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getSearchstatus()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.STATUS_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getStatus()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getProfession()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.PROFESSION_FIELD),
					userSpaceDetailSimpleInfo.getProfession(), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getTags()) {
			document.add(
					new TextField(ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.TAGS_FIELD),
							userSpaceDetailSimpleInfo.getTags(), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.STATUS_FIELD),
					String.valueOf(userSpaceDetailSimpleInfo.getStatus()), Store.YES));
		}
		if (null != userSpaceDetailSimpleInfo.getUu()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.UU_FIELD),
							String.valueOf(userSpaceDetailSimpleInfo.getUu()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.ID_FIELD),
				userSpaceDetailSimpleInfo.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, UserSpaceDetailSimpleInfo.STATUS_FIELD),
				userSpaceDetailSimpleInfo.getStatus()));

		return document;
	}

	/**
	 * 将purcInquirySimpleInfo转成document
	 * 
	 * @param purcInquirySimpleInfo
	 * @return
	 */
	public static Document toDocument(PurcInquirySimpleInfo purcInquirySimpleInfo) {
		if (purcInquirySimpleInfo == null || purcInquirySimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcInquirySimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.ID_FIELD),
				String.valueOf(purcInquirySimpleInfo.getId()), Store.YES));
		if (null != purcInquirySimpleInfo.getCode()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.CODE_FIELD),
							String.valueOf(purcInquirySimpleInfo.getCode()), Store.YES));
		}
		if (null != purcInquirySimpleInfo.getEnteryStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.ENTERYSTATUS_FIELD),
					String.valueOf(purcInquirySimpleInfo.getEnteryStatus()), Store.YES));
		}
		if (null != purcInquirySimpleInfo.getIsOpen()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.ISOPEN_FIELD),
							String.valueOf(purcInquirySimpleInfo.getIsOpen()), Store.YES));
		}
		if (null != purcInquirySimpleInfo.getRecorderUU()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.RECORDERUU_FIELD),
					String.valueOf(purcInquirySimpleInfo.getRecorderUU()), Store.YES));
		}
		if (null != purcInquirySimpleInfo.getEnterprise()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.ENTERPRISE_FIELD),
					JSONObject.toJSONString(purcInquirySimpleInfo.getEnterprise()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurcInquirySimpleInfo.ID_FIELD),
				purcInquirySimpleInfo.getId()));

		return document;
	}

	/**
	 * 将PurchaseInquiryItemSimpleInfo转换成Document
	 * 
	 * @param inquiryItem
	 * @return
	 */
	public static Document toDocument(PurcInquiryItemSimpleInfo2 inquiryItem) {
		if (inquiryItem == null || inquiryItem.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcInquiryItemSimpleInfo2.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.ID_FIELD),
						String.valueOf(inquiryItem.getId()), Store.YES));
		if (null != inquiryItem.getOverdue()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.OVERDUE_FIELD),
					String.valueOf(inquiryItem.getOverdue()), Store.YES));
		}
		if (inquiryItem.getInquiry() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.INQUIRY_FIELD),
					JSONObject.toJSONString(inquiryItem.getInquiry()), Store.YES));
		}
		if (inquiryItem.getProduct() != null) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.PRODUCT_FIELD),
					JSONObject.toJSONString(inquiryItem.getProduct()), Store.YES));
		}
		if (null != inquiryItem.getIsOpen()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.ISOPEN_FIELD),
					String.valueOf(inquiryItem.getIsOpen()), Store.YES));
		}
		if (null != inquiryItem.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.STATUS_FIELD),
					String.valueOf(inquiryItem.getStatus()), Store.YES));
		}
		if (null != inquiryItem.getAgreed()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.AGREED_FIELD),
					String.valueOf(inquiryItem.getAgreed()), Store.YES));
		}
		if (null != inquiryItem.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.DATE_FIELD),
					inquiryItem.getDate().getTime(), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.ID_FIELD),
				inquiryItem.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, PurcInquiryItemSimpleInfo2.OVERDUE_FIELD),
				inquiryItem.getOverdue()));
		return document;
	}

	/**
	 * 将InvitationRecordSimpleInfo转换成Document
	 * 
	 * @param invitation
	 * @return
	 */
	public static Document toDocument(InvitationRecordSimpleInfo invitation) {
		if (invitation == null || invitation.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(InvitationRecordSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(
				new StringField(ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.ID_FIELD),
						String.valueOf(invitation.getId()), Store.YES));
		if (null != invitation.getEnuu()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.ENUU_FIELD),
					String.valueOf(invitation.getEnuu()), Store.YES));
		}
		if (null != invitation.getUser()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.USERUU_FIELD),
					JSONObject.toJSONString(invitation.getUser()), Store.YES));
		}
		if (null != invitation.getActive()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.ACTIVE_FIELD),
					String.valueOf(invitation.getActive()), Store.YES));
		}
		if (null != invitation.getVendname()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.VENDNAME_FIELD),
					String.valueOf(invitation.getVendname()), Store.YES));
		}
		if (null != invitation.getVendusername()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.VENDUSERNAME_FIELD),
					String.valueOf(invitation.getVendusername()), Store.YES));
		}
		if (null != invitation.getVenduseremail()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.VENDUSEREMAIL_FIELD),
					String.valueOf(invitation.getVenduseremail()), Store.YES));
		}
		if (null != invitation.getVendusertel()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.VENDUSERTEL_FIELD),
					String.valueOf(invitation.getVendusertel()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.DATE_FIELD),
				invitation.getDate().getTime()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, InvitationRecordSimpleInfo.ID_FIELD),
				invitation.getId()));
		return document;
	}

	/**
	 * 将CartSimpleInfo转换成Document
	 *
	 * @param cartSimpleInfo
	 * @return
	 */
	public static Document toDocument(CartSimpleInfo cartSimpleInfo) {
		if (cartSimpleInfo == null || cartSimpleInfo.getId() == null ||
				cartSimpleInfo.getUser() == null || cartSimpleInfo.getUser().getUserUU() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(CartSimpleInfo.class);
		Document document = new Document();
		document.add(new TextField(
				ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.USERUU_FIELD),
				JSONObject.toJSONString(cartSimpleInfo.getUser()), Store.YES));
		if (null != cartSimpleInfo.getDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.DATE_FIELD),
					cartSimpleInfo.getDate().getTime(), Store.YES));
		}
		if (null != cartSimpleInfo.getAuditor()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.AUDITOR_FIELD),
					String.valueOf(cartSimpleInfo.getAuditor()), Store.YES));
		}
		if (null != cartSimpleInfo.getCode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.CODE_FIELD),
					String.valueOf(cartSimpleInfo.getCode()), Store.YES));
		}
		if (null != cartSimpleInfo.getCurrency()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.CURRENCY_FIELD),
					String.valueOf(cartSimpleInfo.getCurrency()), Store.YES));
		}
		if (null != cartSimpleInfo.getEnUU()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.ENUU_FIELD),
					String.valueOf(cartSimpleInfo.getEnUU()), Store.YES));
		}
		if (null != cartSimpleInfo.getId()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.ID_FIELD),
					String.valueOf(cartSimpleInfo.getId()), Store.YES));
		}
		if (null != cartSimpleInfo.getPayments()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.PAYMENTS_FIELD),
					String.valueOf(cartSimpleInfo.getPayments()), Store.YES));
		}
		if (null != cartSimpleInfo.getRate()) {
			document.add(new FloatDocValuesField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.RATE_FIELD),
					Float.valueOf(cartSimpleInfo.getRate())));
		}
		if (null != cartSimpleInfo.getReceiveCode()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.RECEIVECODE_FIELD),
					String.valueOf(cartSimpleInfo.getReceiveCode()), Store.YES));
		}
		if (null != cartSimpleInfo.getReceiveName()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.RECEIVENAME_FIELD),
					String.valueOf(cartSimpleInfo.getReceiveName()), Store.YES));
		}
		if (null != cartSimpleInfo.getRecorder()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.RECORDER_FIELD),
					String.valueOf(cartSimpleInfo.getRecorder()), Store.YES));
		}
		if (null != cartSimpleInfo.getRemark()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.REMARK_FIELD),
					String.valueOf(cartSimpleInfo.getRemark()), Store.YES));
		}
		if (null != cartSimpleInfo.getShipAddress()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.SHIPADDRESS_FIELD),
					String.valueOf(cartSimpleInfo.getShipAddress()), Store.YES));
		}
		if (null != cartSimpleInfo.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.STATUS_FIELD),
					String.valueOf(cartSimpleInfo.getStatus()), Store.YES));
		}
		if (null != cartSimpleInfo.getVenduser()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.VENDUSER_FIELD),
					String.valueOf(cartSimpleInfo.getVenduser()), Store.YES));
		}
		if (null != cartSimpleInfo.getVendusertel()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.VENDUSERTEL_FIELD),
					String.valueOf(cartSimpleInfo.getVendusertel()), Store.YES));
		}
		if (null != cartSimpleInfo.getVendUserUU()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.VENDUSERUU_FIELD),
					String.valueOf(cartSimpleInfo.getVendUserUU()), Store.YES));
		}
		if (null != cartSimpleInfo.getEnterprise()) {
			document.add(
					new StringField(ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.ENTERPRISE_FIELD),
							JSONObject.toJSONString(cartSimpleInfo.getEnterprise()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, CartSimpleInfo.ID_FIELD),
				cartSimpleInfo.getId()));
		return document;
	}

	/**
	 * 将KindSimpleInfo转换成Document
	 *
	 * @author hejq
	 * @param kindSimpleInfo
	 * @return
	 */
	public static Document toDocument(KindSimpleInfo kindSimpleInfo) {
		if (kindSimpleInfo == null || kindSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(KindSimpleInfo.class);
		Document document = new Document();
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, KindSimpleInfo.ID_FIELD),
				String.valueOf(kindSimpleInfo.getId()), Store.YES));
		if (null != kindSimpleInfo.getNameCn()) {
			document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, KindSimpleInfo.NAMECN_FIELD),
					String.valueOf(kindSimpleInfo.getNameCn()), Store.YES));
		}
		if (null != kindSimpleInfo.getNameEn()) {
			document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, KindSimpleInfo.NAMEEN_FIELD),
					String.valueOf(kindSimpleInfo.getNameEn()), Store.YES));
		}
		// 排序字段
		document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, KindSimpleInfo.ID_FIELD),
				kindSimpleInfo.getId()));
		return document;
	}

	/**
	 * 将PurchaseApBillOutSimpleInfo转换成Document
	 *
	 * @author huangct
	 * @param purchaseApBillOutSimpleInfo
	 * @return
	 */
	public static Document toDocument(PurchaseApBillOutSimpleInfo purchaseApBillOutSimpleInfo) {
		if (purchaseApBillOutSimpleInfo == null || purchaseApBillOutSimpleInfo.getId() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseApBillOutSimpleInfo.class);
		Document document = new Document();
		document.add(new StringField(ClassAndTableNameUtils
				.combineField(tableName, PurchaseApBillOutSimpleInfo.ID_FIELD),
				String.valueOf(purchaseApBillOutSimpleInfo.getId()), Store.YES));

		if (null != purchaseApBillOutSimpleInfo.getAmount()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.AMOUNT_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getAmount()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getAuditDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.AUDITDATE_FIELD),
					Long.valueOf(purchaseApBillOutSimpleInfo.getAuditDate().getTime()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getCheckStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.CHECKSTATUS_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getCheckStatus()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getCode()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.CODE_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getCode()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getCurrency()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.CURRENCY_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getCurrency()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getCustName()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.CUSTNAME_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getCustName()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getCustUu()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.CUSTUU_FIELD),
					Long.valueOf(purchaseApBillOutSimpleInfo.getCustUu()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getItems()) {
			document.add(new TextField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.ITEMS_FIELD),
					JSONObject.toJSONString(purchaseApBillOutSimpleInfo.getItems()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getDiffer()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.DIFFER_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getDiffer()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getPayAmount()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.PAYAMOUNT_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getPayAmount()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getPrint()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.PRINT_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getPrint()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getRate()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.RATE_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getRate()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getRecordDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.DATE_FIELD),
					Long.valueOf(purchaseApBillOutSimpleInfo.getRecordDate().getTime()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getRecorder()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.RECORDER_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getRecorder()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getRemark()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.REMARK_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getRemark()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getResDate()) {
			document.add(new LongField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.RESDATE_FIELD),
					Long.valueOf(purchaseApBillOutSimpleInfo.getResDate().getTime()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getResMan()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.RESMAN_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getResMan()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getStatus()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.STATUS_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getStatus()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getTaxSum()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.TAXSUM_FIELD),
					String.valueOf(purchaseApBillOutSimpleInfo.getTaxSum()), Store.YES));
		}
		if (null != purchaseApBillOutSimpleInfo.getEnUu()) {
			document.add(new StringField(
					ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.ENUU_FIELD),
					purchaseApBillOutSimpleInfo.getEnUu().toString(), Store.YES));
		}
		//TODO

		// 排序字段
		document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.ID_FIELD),
				purchaseApBillOutSimpleInfo.getId()));
		document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, PurchaseApBillOutSimpleInfo.DATE_FIELD),
				purchaseApBillOutSimpleInfo.getRecordDate().getTime()));
		return document;
	}

	/**
	 * 将VendorPerformanceAssessSimpleInfo转换成Document
	 *
	 * @param vpaSimpleInfo
	 * @return
	 */
	public static Document toDocument(VendorPerformanceAssessSimpleInfo vpaSimpleInfo) {
		if (vpaSimpleInfo == null || vpaSimpleInfo.getId() == null || vpaSimpleInfo.getVpaId() == null
				|| vpaSimpleInfo.getVpaCode() == null || vpaSimpleInfo.getEnUU() == null
				|| vpaSimpleInfo.getVpaVeuu() == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(VendorPerformanceAssessSimpleInfo.class);
		Document document = new Document();
		// 不能用LongField，否则后续实时更新索引时，方法updateDocument(new Term("", ""),
		// doc)无法根据id进行更新
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.ID_FIELD),
				String.valueOf(vpaSimpleInfo.getId()), Store.YES));
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.VPAID_FIELD),
				String.valueOf(vpaSimpleInfo.getVpaId()), Store.YES));
		document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.CODE_FIELD),
				vpaSimpleInfo.getVpaCode(), Store.YES));
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.ENTERPRISE_FIELD),
				String.valueOf(vpaSimpleInfo.getEnUU()), Store.YES));
		document.add(new LongField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.DATE_FIELD),
				vpaSimpleInfo.getVpaApplydate().getTime(), Store.YES));
		document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.VPAENUU_FIELD),
				String.valueOf(vpaSimpleInfo.getVpaVeuu()), Store.YES));

		// 排序字段
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.ID_FIELD),
				vpaSimpleInfo.getId()));
		document.add(new NumericDocValuesField(
				ClassAndTableNameUtils.combineField(tableName, VendorPerformanceAssessSimpleInfo.DATE_FIELD),
				vpaSimpleInfo.getVpaApplydate().getTime()));
		return document;
	}

    /**
     * 将ProductUsersSimpleInfo转换成Document
     *
     * @author hejq
     * @param productUsersSimpleInfo
     * @return
     */
    public static Document toDocument(ProductUsersSimpleInfo productUsersSimpleInfo) {
        if (productUsersSimpleInfo == null || productUsersSimpleInfo.getId() == null) {
            return null;
        }
        Table_name tableName = ClassAndTableNameUtils.toTableName(ProductUsersSimpleInfo.class);
        Document document = new Document();
        document.add(new StringField(ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.ID_FIELD),
                String.valueOf(productUsersSimpleInfo.getId()), Store.YES));
        if (null != productUsersSimpleInfo.getProduct()) {
            document.add(new TextField(ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.PRODUCT_FIELD),
                    JSON.toJSONString(productUsersSimpleInfo.getProduct()), Store.YES));
        }

        if (null != productUsersSimpleInfo.getEnuu()) {
            document.add(new StringField(
                    ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.ENUU_FIELD),
                    productUsersSimpleInfo.getEnuu().toString(), Store.YES));
        }

        if (null != productUsersSimpleInfo.getUseruu()) {
            document.add(new StringField(
                    ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.USERUU_FIELD),
                    productUsersSimpleInfo.getUseruu().toString(), Store.YES));
        }

        if (!StringUtils.isEmpty(productUsersSimpleInfo.getDate())) {
            document.add(
                    new LongField(ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.DATE_FIELD),
                            productUsersSimpleInfo.getDate().getTime(), Store.YES));
        }

        // 排序字段
        document.add(new NumericDocValuesField(ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.ID_FIELD),
                productUsersSimpleInfo.getId()));
        document.add(new NumericDocValuesField(
                ClassAndTableNameUtils.combineField(tableName, ProductUsersSimpleInfo.DATE_FIELD),
                productUsersSimpleInfo.getDate().getTime()));
        return document;
    }

}
