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

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.lucene.document.Document;

import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.uas.search.b2b.exception.SearchException;
import com.uas.search.b2b.service.SearchService.Table_name;
import com.uas.search.console.b2b.model.BrandSimpleInfo;
import com.uas.search.console.b2b.model.DeputyOrderSimpleInfo;
import com.uas.search.console.b2b.model.EnterpriseSearchSimpleInfo;
import com.uas.search.console.b2b.model.EnterpriseSimpleInfo;
import com.uas.search.console.b2b.model.MakeAcceptItemSimpleInfo;
import com.uas.search.console.b2b.model.MakeAcceptSimpleInfo;
import com.uas.search.console.b2b.model.MakeChangesSimpleInfo;
import com.uas.search.console.b2b.model.MakeOrderChangeItemSimpleInfo;
import com.uas.search.console.b2b.model.MakeOrderSimpleInfo;
import com.uas.search.console.b2b.model.MakeReturnItemSimpleInfo;
import com.uas.search.console.b2b.model.MakeReturnSimpleInfo;
import com.uas.search.console.b2b.model.PagingReleaseDetailSimpleInfo;
import com.uas.search.console.b2b.model.PagingReleaseSimpleInfo;
import com.uas.search.console.b2b.model.ProdSimpleInfo;
import com.uas.search.console.b2b.model.ProductBrandSimpleInfo;
import com.uas.search.console.b2b.model.ProductComponentSimpleInfo;
import com.uas.search.console.b2b.model.ProductSimpleInfo;
import com.uas.search.console.b2b.model.PurcProofingapprovalSimpleInfo;
import com.uas.search.console.b2b.model.PurcProofingsendSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseAcceptItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseAcceptSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseApBillItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseApCheckItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseApCheckSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseApbillSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseBadInItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseBadinSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseBadoutItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseBadoutSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseChangesSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseForecastItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseForecastSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseInquiryItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseInquiryMouldItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseInquiryMouldSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseInquirySimpleInfo;
import com.uas.search.console.b2b.model.PurchaseMrbSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseNoticeSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseOrderChangeItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseOrderItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseOrderSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseProofingItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseProofingSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseReturnItemSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseReturnSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseTenderProdSimpleInfo;
import com.uas.search.console.b2b.model.PurchaseTenderSimpleInfo;
import com.uas.search.console.b2b.model.SaleARCheckItemSimpleInfo;
import com.uas.search.console.b2b.model.SaleArcheckSimpleInfo;
import com.uas.search.console.b2b.model.SaleQuotationItemSimpleInfo;
import com.uas.search.console.b2b.model.SaleQuotationSimpleInfo;
import com.uas.search.console.b2b.model.SaleSendItemSimpleInfo;
import com.uas.search.console.b2b.model.SaleSendSimpleInfo;
import com.uas.search.console.b2b.model.UserSimpleInfo;
import com.uas.search.console.b2b.model.VendorSimpleInfo;

/**
 * 将Document转换为对象的工具类
 * 
 * @author sunyj
 * @since 2016年11月9日 下午3:31:06
 */

public class DocumentToObjectUtils {

	/**
	 * 将Document转换为对象
	 * 
	 * @param <T>
	 * 
	 * @param document
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static <T> T toObject(Document document, Class<T> clazz) {
		if (clazz == null) {
			return null;
		}
		if (clazz == PurchaseOrderSimpleInfo.class) {
			return (T) toPurchaseOrder(document);
		} else if (clazz == MakeOrderSimpleInfo.class) {
			return (T) toMakeOrder(document);
		} else if (clazz == PurchaseAcceptSimpleInfo.class) {
			return (T) toPurchaseAccept(document);
		} else if (clazz == SaleQuotationSimpleInfo.class) {
			return (T) toSaleQuotation(document);
		} else if (clazz == PurchaseApbillSimpleInfo.class) {
			return (T) toPurchaseApbill(document);
		} else if (clazz == PurchaseBadinSimpleInfo.class) {
			return (T) toPurchaseBadin(document);
		} else if (clazz == PurchaseBadoutSimpleInfo.class) {
			return (T) toPurchaseBadout(document);
		} else if (clazz == PurchaseForecastSimpleInfo.class) {
			return (T) toPurchaseForecast(document);
		} else if (clazz == PurchaseMrbSimpleInfo.class) {
			return (T) toPurchaseMrb(document);
		} else if (clazz == PurchaseChangesSimpleInfo.class) {
			return (T) toPurchaseChanges(document);
		} else if (clazz == PurchaseReturnSimpleInfo.class) {
			return (T) toPurchaseReturn(document);
		} else if (clazz == MakeAcceptSimpleInfo.class) {
			return (T) toMakeAccept(document);
		} else if (clazz == MakeOrderChangeItemSimpleInfo.class) {
			return (T) toMakeChangeItem(document);
		} else if (clazz == MakeReturnSimpleInfo.class) {
			return (T) toMakeReturn(document);
		} else if (clazz == SaleSendSimpleInfo.class) {
			return (T) toSaleSend(document);
		} else if (clazz == PurchaseNoticeSimpleInfo.class) {
			return (T) toPurchaseNotice(document);
		} else if (clazz == PurcProofingapprovalSimpleInfo.class) {
			return (T) toPurcProofingapproval(document);
		} else if (clazz == PurcProofingsendSimpleInfo.class) {
			return (T) toPurcProofingsend(document);
		} else if (clazz == SaleArcheckSimpleInfo.class) {
			return (T) toSaleArcheck(document);
		} else if (clazz == PurchaseApCheckSimpleInfo.class) {
			return (T) toPurcApcheck(document);
		} else if (clazz == PurchaseInquiryItemSimpleInfo.class) {
			return (T) toInquiryItem(document);
		} else if (clazz == PurchaseProofingItemSimpleInfo.class) {
			return (T) toPurchaseProofingItem(document);
		} else if (clazz == PurchaseInquiryMouldSimpleInfo.class) {
			return (T) toPurchaseInquiryMould(document);
		} else if (clazz == ProdSimpleInfo.class) {
			return (T) toProd(document);
		} else if (clazz == EnterpriseSearchSimpleInfo.class) {
			return (T) toEnterprise(document);
		} else if (clazz == ProductComponentSimpleInfo.class) {
			return (T) toProdComponent(document);
		} else if (clazz == DeputyOrderSimpleInfo.class) {
			return (T) toDeputyOrder(document);
		} else if (clazz == PurchaseTenderSimpleInfo.class) {
			return (T) toPurchaseTenderSimpleInfo(document);
		} else if (clazz == PagingReleaseDetailSimpleInfo.class) {
			return (T) toPagingReleaseDetailSimpleInfo(document);
		} else if (clazz == VendorSimpleInfo.class) {
			return (T) toVendorSimpleInfo(document);
		} else if (clazz == ProductBrandSimpleInfo.class) {
			return (T) toProductBrandSimpleInfo(document);
		}

		// TODO 其他表
		else {
			throw new SearchException("不支持将Document转为类型：" + clazz.getName());
		}
	}

	private static DeputyOrderSimpleInfo toDeputyOrder(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(DeputyOrderSimpleInfo.class);
		DeputyOrderSimpleInfo depOrder = new DeputyOrderSimpleInfo();
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ID_FIELD))) {
			depOrder.setId(Long.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ID_FIELD))));
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ENUU_FIELD))) {
			depOrder.setEnuu(Long.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.ENUU_FIELD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDUU_FEILD))) {
			depOrder.setTervenduu(Long.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDUU_FEILD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSERUU_FIELD))) {
			depOrder.setVenduseruu(Long.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSERUU_FIELD))));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CODE_FIELD)))) {
			depOrder.setCode(
					document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CODE_FIELD)));
		}
		if (!StringUtils.isEmpty(document
				.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.COMPANYNAME_FIELD)))) {
			depOrder.setCompanyname(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.COMPANYNAME_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CUSTOMER_FIELD)))) {
			depOrder.setCustomer(
					document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.CUSTOMER_FIELD)));
		}
		if (!StringUtils.isEmpty(document
				.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.LEGALREPRESENT_FIELD)))) {
			depOrder.setLegalrepresent(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.LEGALREPRESENT_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDOR_FIELD)))) {
			depOrder.setTervendor(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.TERVENDOR_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSER_FIELD)))) {
			depOrder.setVenduser(
					document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.VENDUSER_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.STATUSCOE_FIELD)))) {
			depOrder.setStatuscode(Integer.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, DeputyOrderSimpleInfo.STATUSCOE_FIELD))));
		}
		return depOrder;
	}

	private static ProductComponentSimpleInfo toProdComponent(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProductComponentSimpleInfo.class);
		ProductComponentSimpleInfo prodComp = new ProductComponentSimpleInfo();
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.ID_FIELD))) {
			prodComp.setId(Long.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.ID_FIELD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.KINDID_FIELD))) {
			prodComp.setKindid(Long.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.KINDID_FIELD))));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.CODE_FIELD)))) {
			prodComp.setCode(document
					.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.CODE_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.UUID_FIELD)))) {
			prodComp.setUuid(document
					.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.UUID_FIELD)));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.BRAND_FIELD)))) {
			prodComp.setBrand(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, ProductComponentSimpleInfo.BRAND_FIELD)),
					BrandSimpleInfo.class));
		}
		return prodComp;
	}

	private static PurchaseProofingItemSimpleInfo toPurchaseProofingItem(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseProofingItemSimpleInfo.class);
		PurchaseProofingItemSimpleInfo purcProofingItem = new PurchaseProofingItemSimpleInfo();
		purcProofingItem.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.ID_FIELD))));
		purcProofingItem.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		purcProofingItem.setStatus(Short.valueOf(document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.STATUS_FIELD))));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseProofingItemSimpleInfo.PROOFING_FIELD))) {
			purcProofingItem
					.setProofing(
							JSONObject.parseObject(
									document.get(ClassAndTableNameUtils.combineField(tableName,
											PurchaseProofingItemSimpleInfo.PROOFING_FIELD)),
									PurchaseProofingSimpleInfo.class));
		}
		return purcProofingItem;
	}

	/**
	 * 将Document转换成PurchaseInquiryItemSimpleInfo
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseInquiryItemSimpleInfo toInquiryItem(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseInquiryItemSimpleInfo.class);
		PurchaseInquiryItemSimpleInfo purcInquiryItem = new PurchaseInquiryItemSimpleInfo();
		purcInquiryItem.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.ID_FIELD))));
		purcInquiryItem.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.PRODUCT_FIELD))) {
			purcInquiryItem
					.setProduct(
							JSONObject
									.parseObject(
											document.get(ClassAndTableNameUtils.combineField(tableName,
													PurchaseInquiryItemSimpleInfo.PRODUCT_FIELD)),
											ProductSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.SENDSTATUS_FIELD))) {
			purcInquiryItem.setSendStatus(Short.valueOf(document.get(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.SENDSTATUS_FIELD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.STATUS_FIELD))) {
			purcInquiryItem.setStatus(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.STATUS_FIELD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.OVERDUE_FIELD))) {
			purcInquiryItem.setOverdue(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.OVERDUE_FIELD))));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryItemSimpleInfo.INQUIRY_FIELD))) {
			purcInquiryItem
					.setInquiry(
							JSONObject.parseObject(
									document.get(ClassAndTableNameUtils.combineField(tableName,
											PurchaseInquiryItemSimpleInfo.INQUIRY_FIELD)),
									PurchaseInquirySimpleInfo.class));
		}
		return purcInquiryItem;
	}

	/**
	 * 将Document转换成SaleQuotation
	 * 
	 * @param document
	 * @return
	 */
	private static SaleQuotationSimpleInfo toSaleQuotation(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleQuotationSimpleInfo.class);
		SaleQuotationSimpleInfo saleQuotation = new SaleQuotationSimpleInfo();
		saleQuotation.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ID_FIELD))));
		saleQuotation.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.CODE_FIELD)));
		saleQuotation.setStatus(Short.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.STATUS_FIELD))));
		saleQuotation.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.DATE_FIELD)))));
		saleQuotation.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		saleQuotation.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ITEMS_FIELD))) {
			saleQuotation.setSaleQuotationItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, SaleQuotationSimpleInfo.ITEMS_FIELD)),
					SaleQuotationItemSimpleInfo.class));
		}
		return saleQuotation;
	}

	/**
	 * 将Document转换成PurcApcheck
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseApCheckSimpleInfo toPurcApcheck(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseApCheckSimpleInfo.class);
		PurchaseApCheckSimpleInfo purcApcheck = new PurchaseApCheckSimpleInfo();
		purcApcheck.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ID_FIELD))));
		purcApcheck.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.CODE_FIELD)));
		String statusString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.STATUS_FIELD));
		if (!StringUtils.isEmpty(statusString)) {
			purcApcheck.setStatus(Short.valueOf(statusString));
		}
		String checkstatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.CHECKSTATUS_FIELD));
		if (!StringUtils.isEmpty(checkstatus)) {
			purcApcheck.setCheckstatus(checkstatus);
		}
		purcApcheck.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.DATE_FIELD)))));
		purcApcheck.setEnterprise(JSONObject.parseObject(
				document.get(
						ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purcApcheck.setVendor(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ITEMS_FIELD))) {
			purcApcheck.setItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApCheckSimpleInfo.ITEMS_FIELD)),
					PurchaseApCheckItemSimpleInfo.class));
		}
		return purcApcheck;
	}

	/**
	 * 将Document转换成SaleArcheck
	 * 
	 * @param document
	 * @return
	 */
	private static SaleArcheckSimpleInfo toSaleArcheck(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleArcheckSimpleInfo.class);
		SaleArcheckSimpleInfo saleArcheck = new SaleArcheckSimpleInfo();
		saleArcheck.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ID_FIELD))));
		saleArcheck.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.CODE_FIELD)));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.STATUS_FIELD))) {
			saleArcheck.setStatus(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.STATUS_FIELD))));
		}
		saleArcheck.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.DATE_FIELD)))));
		saleArcheck.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		saleArcheck.setVendor(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ITEMS_FIELD))) {
			saleArcheck.setItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, SaleArcheckSimpleInfo.ITEMS_FIELD)),
					SaleARCheckItemSimpleInfo.class));
		}
		return saleArcheck;
	}

	/**
	 * 将Document转换成PurcProofingsend
	 * 
	 * @param document
	 * @return
	 */
	private static PurcProofingsendSimpleInfo toPurcProofingsend(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcProofingsendSimpleInfo.class);
		PurcProofingsendSimpleInfo purcProofingsend = new PurcProofingsendSimpleInfo();
		purcProofingsend.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ID_FIELD))));
		String code = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.CODE_FIELD));
		if (!StringUtils.isEmpty(code)) {
			purcProofingsend.setCode(code);
		}
		String brand = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.BRAND_FIELD));
		if (!StringUtils.isEmpty(brand)) {
			purcProofingsend.setBrand(brand);
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purcProofingsend.setDate(new Date(Long.valueOf(dateString)));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ITEMS_FIELD))) {
			purcProofingsend.setProofingItem(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PurcProofingsendSimpleInfo.ITEMS_FIELD)),
					PurchaseProofingItemSimpleInfo.class));
		}
		return purcProofingsend;
	}

	/**
	 * 将Document转换成PurcProofingapproval
	 * 
	 * @param document
	 * @return
	 */
	private static PurcProofingapprovalSimpleInfo toPurcProofingapproval(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurcProofingapprovalSimpleInfo.class);
		PurcProofingapprovalSimpleInfo purcProofingapproval = new PurcProofingapprovalSimpleInfo();
		purcProofingapproval.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.ID_FIELD))));
		purcProofingapproval.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		purcProofingapproval.setCode(document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.CODE_FIELD)));
		String prodcode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODCODE_FIELD));
		if (!StringUtils.isEmpty(prodcode)) {
			purcProofingapproval.setProdCode(prodcode);
		}
		String proddetail = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODDETAIL_FIELD));
		if (!StringUtils.isEmpty(proddetail)) {
			purcProofingapproval.setProdDetail(proddetail);
		}
		String pscode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PSCODE_FIELD));
		if (!StringUtils.isEmpty(pscode)) {
			purcProofingapproval.setPscode(pscode);
		}
		String sscode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.SSCODE_FIELD));
		if (!StringUtils.isEmpty(sscode)) {
			purcProofingapproval.setSscode(sscode);
		}
		String prodspec = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.PRODSPEC_FIELD));
		if (!StringUtils.isEmpty(prodspec)) {
			purcProofingapproval.setProdSpec(prodspec);
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purcProofingapproval.setDate(new Date(Long.valueOf(dateString)));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurcProofingapprovalSimpleInfo.ENTERPRISE_FIELD))) {
			purcProofingapproval
					.setEnterprise(
							JSONObject.parseObject(
									document.get(ClassAndTableNameUtils.combineField(tableName,
											PurcProofingapprovalSimpleInfo.ENTERPRISE_FIELD)),
									EnterpriseSimpleInfo.class));
		}
		return purcProofingapproval;
	}

	/**
	 * 将Document转换成PurchaseNotice
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseNoticeSimpleInfo toPurchaseNotice(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseNoticeSimpleInfo.class);
		PurchaseNoticeSimpleInfo purchaseNotice = new PurchaseNoticeSimpleInfo();
		purchaseNotice.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ID_FIELD))));
		purchaseNotice.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.DATE_FIELD)))));
		purchaseNotice.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchaseNotice.setWaiting(Short.valueOf(document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ISWAITING_FIELD))));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.END_FIELD))) {
			purchaseNotice.setEnd(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.END_FIELD))));
		}
		purchaseNotice.setStatus(Short.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.STATUS_FIELD))));
		purchaseNotice.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ORDERITEMS_FIELD))) {
			purchaseNotice.setOrderItem(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PurchaseNoticeSimpleInfo.ORDERITEMS_FIELD)),
					PurchaseOrderItemSimpleInfo.class));
		}
		return purchaseNotice;
	}

	/**
	 * 将Document转换成SaleSend
	 * 
	 * @param document
	 * @return
	 */
	private static SaleSendSimpleInfo toSaleSend(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(SaleSendSimpleInfo.class);
		SaleSendSimpleInfo saleSend = new SaleSendSimpleInfo();
		saleSend.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ID_FIELD))));
		saleSend.setCode(document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.CODE_FIELD)));
		String dateString = document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			saleSend.setDate(new Date(Long.valueOf(dateString)));
		}
		saleSend.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		if (document.get(SaleSendSimpleInfo.STATUS_FIELD) != null) {
			saleSend.setVerifystatus(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.STATUS_FIELD))));
		}
		saleSend.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ITEMS_FIELD))) {
			saleSend.setSendItems(
					toSet(document.get(ClassAndTableNameUtils.combineField(tableName, SaleSendSimpleInfo.ITEMS_FIELD)),
							SaleSendItemSimpleInfo.class));
		}
		return saleSend;
	}

	/**
	 * 将Document转换成MakeReturn
	 * 
	 * @param document
	 * @return
	 */
	private static MakeReturnSimpleInfo toMakeReturn(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeReturnSimpleInfo.class);
		MakeReturnSimpleInfo makeReturn = new MakeReturnSimpleInfo();
		makeReturn.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ID_FIELD))));
		makeReturn
				.setCode(document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.CODE_FIELD)));
		makeReturn.setSendCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.SENDCODE_FIELD)));
		makeReturn.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, (MakeReturnSimpleInfo.DATE_FIELD))))));
		makeReturn.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		makeReturn.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ITEMS_FIELD))) {
			makeReturn.setReturnItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, MakeReturnSimpleInfo.ITEMS_FIELD)),
					MakeReturnItemSimpleInfo.class));

		}
		return makeReturn;
	}

	/**
	 * 将Document转换成makeOrderChangeItem
	 * 
	 * @param document
	 * @return
	 */
	private static MakeOrderChangeItemSimpleInfo toMakeChangeItem(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeOrderChangeItemSimpleInfo.class);
		MakeOrderChangeItemSimpleInfo makeChangeItem = new MakeOrderChangeItemSimpleInfo();
		makeChangeItem.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.ID_FIELD))));
		makeChangeItem.setOrderCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.CODE_FIELD)));
		makeChangeItem.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.PRODUCT_FIELD))) {
			makeChangeItem
					.setProduct(
							JSONObject
									.parseObject(
											document.get(ClassAndTableNameUtils.combineField(tableName,
													MakeOrderChangeItemSimpleInfo.PRODUCT_FIELD)),
											ProductSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.MAKE_FIELD))) {
			makeChangeItem.setMakeChanges(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, MakeOrderChangeItemSimpleInfo.MAKE_FIELD)),
					MakeChangesSimpleInfo.class));
		}
		return makeChangeItem;
	}

	/**
	 * 将Document转换成MakeAccept
	 * 
	 * @param document
	 * @return
	 */
	private static MakeAcceptSimpleInfo toMakeAccept(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeAcceptSimpleInfo.class);
		MakeAcceptSimpleInfo makeAccept = new MakeAcceptSimpleInfo();
		makeAccept.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ID_FIELD))));
		makeAccept
				.setCode(document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.CODE_FIELD)));
		makeAccept.setSendCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.SENDCODE_FIELD)));
		makeAccept.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.DATE_FIELD)))));
		makeAccept.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		makeAccept.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ITEMS_FIELD))) {
			makeAccept.setAcceptItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, MakeAcceptSimpleInfo.ITEMS_FIELD)),
					MakeAcceptItemSimpleInfo.class));
		}
		return makeAccept;
	}

	/**
	 * 将Document转换成PurchaseReturn
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseReturnSimpleInfo toPurchaseReturn(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseReturnSimpleInfo.class);
		PurchaseReturnSimpleInfo purcReturn = new PurchaseReturnSimpleInfo();
		purcReturn.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ID_FIELD))));
		purcReturn.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.CODE_FIELD)));
		String sendcode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.SENDCODE_FIELD));
		if (!StringUtils.isEmpty(sendcode)) {
			purcReturn.setSendCode(sendcode);
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purcReturn.setDate(new Date(Long.valueOf(dateString)));
		}
		purcReturn.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purcReturn.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ITEMS_FIELD))) {
			purcReturn.setReturnItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseReturnSimpleInfo.ITEMS_FIELD)),
					PurchaseReturnItemSimpleInfo.class));
		}
		return purcReturn;
	}

	/**
	 * 将Document转换成PurchaseChanges
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseChangesSimpleInfo toPurchaseChanges(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseChangesSimpleInfo.class);
		PurchaseChangesSimpleInfo purcChanges = new PurchaseChangesSimpleInfo();
		purcChanges.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ID_FIELD))));
		purcChanges.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.CODE_FIELD)));
		purcChanges.setOrderCode(document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ORDERCODE_FIELD)));
		purcChanges.setStatus(Short.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.STATUS_FIELD))));
		purcChanges.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.DATE_FIELD)))));
		purcChanges.setEnterprise(JSONObject.parseObject(
				document.get(
						ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purcChanges.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ITEMS_FIELD))) {
			purcChanges.setOrderChangeItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseChangesSimpleInfo.ITEMS_FIELD)),
					PurchaseOrderChangeItemSimpleInfo.class));
		}
		return purcChanges;
	}

	/**
	 * 将Document转换成PurchaseMrb
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseMrbSimpleInfo toPurchaseMrb(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseMrbSimpleInfo.class);
		PurchaseMrbSimpleInfo purcMrb = new PurchaseMrbSimpleInfo();
		purcMrb.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ID_FIELD))));
		purcMrb.setCode(document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.CODE_FIELD)));
		purcMrb.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.DATE_FIELD)))));
		purcMrb.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purcMrb.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ITEMS_FIELD))) {
			purcMrb.setOrderItem(JSONObject.parseObject(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.ITEMS_FIELD)),
					PurchaseOrderItemSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.BADITEMS_FIELD))) {
			purcMrb.setBadIn(JSONObject.parseObject(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseMrbSimpleInfo.BADITEMS_FIELD)),
					PurchaseBadinSimpleInfo.class));
		}
		return purcMrb;
	}

	/**
	 * 将Document转换为PurchaseOrder对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseOrderSimpleInfo toPurchaseOrder(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseOrderSimpleInfo.class);
		PurchaseOrderSimpleInfo purchaseOrder = new PurchaseOrderSimpleInfo();
		purchaseOrder.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ID_FIELD))));
		purchaseOrder.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.CODE_FIELD)));
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.REPLY_FIELD)))) {
			purchaseOrder.setReply(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.REPLY_FIELD))));
		}
		if (!StringUtils.isEmpty(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.END_FIELD)))) {
			purchaseOrder.setEnd(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.END_FIELD))));
		}
		purchaseOrder.setStatus(Short.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.STATUS_FIELD))));
		purchaseOrder.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.DATE_FIELD)))));
		purchaseOrder.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchaseOrder.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ITEMS_FIELD))) {
			purchaseOrder.setOrderItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseOrderSimpleInfo.ITEMS_FIELD)),
					PurchaseOrderItemSimpleInfo.class));
		}
		return purchaseOrder;
	}

	/**
	 * 将Document转换为MakeOrder对象
	 * 
	 * @param document
	 * @return
	 */
	private static MakeOrderSimpleInfo toMakeOrder(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(MakeOrderSimpleInfo.class);
		MakeOrderSimpleInfo makeOrder = new MakeOrderSimpleInfo();
		makeOrder.setId(Long
				.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.ID_FIELD))));
		makeOrder.setCode(document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.CODE_FIELD)));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.END_FIELD))) {
			makeOrder.setEnd(Short.valueOf(
					document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.END_FIELD))));
		}
		makeOrder.setStatus(Short.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.STATUS_FIELD))));
		makeOrder.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.DATE_FIELD)))));
		makeOrder.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		makeOrder.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.PRODUCT_FIELD))) {
			makeOrder.setProduct(JSONObject.parseObject(
					document.get(ClassAndTableNameUtils.combineField(tableName, MakeOrderSimpleInfo.PRODUCT_FIELD)),
					ProductSimpleInfo.class));
		}
		return makeOrder;
	}

	/**
	 * 将Document转换为PurchaseAccept对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseAcceptSimpleInfo toPurchaseAccept(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseAcceptSimpleInfo.class);
		PurchaseAcceptSimpleInfo purchaseAccept = new PurchaseAcceptSimpleInfo();
		purchaseAccept.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ID_FIELD))));
		purchaseAccept.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.CODE_FIELD)));
		String sendCode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.SENDCODE_FIELD));
		if (!StringUtils.isEmpty(sendCode)) {
			purchaseAccept.setSendCode(sendCode);
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purchaseAccept.setDate(new Date(Long.valueOf(dateString)));
		}
		purchaseAccept.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchaseAccept.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ITEMS_FIELD))) {
			purchaseAccept.setAcceptItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseAcceptSimpleInfo.ITEMS_FIELD)),
					PurchaseAcceptItemSimpleInfo.class));
		}
		return purchaseAccept;
	}

	/**
	 * 将Document转换为PurchaseApbill对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseApbillSimpleInfo toPurchaseApbill(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseApbillSimpleInfo.class);
		PurchaseApbillSimpleInfo purchApbill = new PurchaseApbillSimpleInfo();
		purchApbill.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ID_FIELD))));
		purchApbill.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.CODE_FIELD)));
		purchApbill.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.DATE_FIELD)))));
		purchApbill.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchApbill.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ITEMS_FIELD))) {
			purchApbill.setItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseApbillSimpleInfo.ITEMS_FIELD)),
					PurchaseApBillItemSimpleInfo.class));
		}
		return purchApbill;
	}

	/**
	 * 将Document转换成PurchaseBadin对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseBadinSimpleInfo toPurchaseBadin(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseBadinSimpleInfo.class);
		PurchaseBadinSimpleInfo purchBadin = new PurchaseBadinSimpleInfo();
		purchBadin.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ID_FIELD))));
		purchBadin.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.CODE_FIELD)));
		String sendcode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.SENDCODE_FIELD));
		if (!StringUtils.isEmpty(sendcode)) {
			purchBadin.setSendCode(sendcode);
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purchBadin.setDate(new Date(Long.valueOf(dateString)));
		}
		purchBadin.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchBadin.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ITEMS_FIELD))) {
			purchBadin.setBadInItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadinSimpleInfo.ITEMS_FIELD)),
					PurchaseBadInItemSimpleInfo.class));
		}
		return purchBadin;
	}

	/**
	 * 将Document转换成PurchaseBadout对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseBadoutSimpleInfo toPurchaseBadout(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseBadoutSimpleInfo.class);
		PurchaseBadoutSimpleInfo purchaseBadout = new PurchaseBadoutSimpleInfo();
		purchaseBadout.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ID_FIELD))));
		purchaseBadout.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.CODE_FIELD)));
		String sendcode = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.SENDCODE_FIELD));
		if (!StringUtils.isEmpty(sendcode)) {
			purchaseBadout.setSendCode(sendcode);

		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purchaseBadout.setDate(new Date(Long.valueOf(dateString)));
		}
		purchaseBadout.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		purchaseBadout.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ITEMS_FIELD))) {
			purchaseBadout.setBadOutItems(toSet(
					document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseBadoutSimpleInfo.ITEMS_FIELD)),
					PurchaseBadoutItemSimpleInfo.class));
		}
		return purchaseBadout;
	}

	/**
	 * 将Document转换成PurchaseForecastSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseForecastSimpleInfo toPurchaseForecast(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseForecastSimpleInfo.class);
		PurchaseForecastSimpleInfo purchaseForecast = new PurchaseForecastSimpleInfo();
		purchaseForecast.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ID_FIELD))));
		purchaseForecast.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.CODE_FIELD)));
		purchaseForecast.setDate(new Date(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.DATE_FIELD)))));
		purchaseForecast.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ITEMS_FIELD))) {
			purchaseForecast.setForecastItems(toSet(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PurchaseForecastSimpleInfo.ITEMS_FIELD)),
					PurchaseForecastItemSimpleInfo.class));
		}
		return purchaseForecast;
	}

	/**
	 * 将Document转换成PurchaseInquiryMouldSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseInquiryMouldSimpleInfo toPurchaseInquiryMould(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseInquiryMouldSimpleInfo.class);
		PurchaseInquiryMouldSimpleInfo purchaseInquiryMould = new PurchaseInquiryMouldSimpleInfo();
		purchaseInquiryMould.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ID_FIELD))));
		purchaseInquiryMould.setCode(document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.CODE_FIELD)));
		if (document.get(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.STATUS_FIELD)) != null) {
			purchaseInquiryMould.setStatus(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.STATUS_FIELD))));
		}
		if (document.get(ClassAndTableNameUtils.combineField(tableName,
				PurchaseInquiryMouldSimpleInfo.ADOPTSTATUS_FIELD)) != null) {
			purchaseInquiryMould.setAdoptstatus(Short.valueOf(document.get(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ADOPTSTATUS_FIELD))));
		}
		if (document.get(ClassAndTableNameUtils.combineField(tableName,
				PurchaseInquiryMouldSimpleInfo.SENDSTATUS_FIELD)) != null) {
			purchaseInquiryMould.setSendstatus(Short.valueOf(document.get(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.SENDSTATUS_FIELD))));
		}
		if (document.get(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.OVERDUE_FIELD)) != null) {
			purchaseInquiryMould.setOverdue(Short.valueOf(document.get(
					ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.OVERDUE_FIELD))));
		}
		if (document.get(
				ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.VALID_FIELD)) != null) {
			purchaseInquiryMould.setValid(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.VALID_FIELD))));
		}
		String dateString = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.DATE_FIELD));
		if (!StringUtils.isEmpty(dateString)) {
			purchaseInquiryMould.setDate(new Date(Long.valueOf(dateString)));
		}
		String endDate = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ENDDATE_FIELD));
		if (!StringUtils.isEmpty(endDate)) {
			purchaseInquiryMould.setEndDate(new Date(Long.valueOf(endDate)));
		}
		purchaseInquiryMould
				.setEnterprise(
						JSONObject
								.parseObject(
										document.get(ClassAndTableNameUtils.combineField(tableName,
												PurchaseInquiryMouldSimpleInfo.ENTERPRISE_FIELD)),
										EnterpriseSimpleInfo.class));
		purchaseInquiryMould.setVend(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.VEND_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ITEMS_FIELD))) {
			purchaseInquiryMould.setMouldItems(toSet(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PurchaseInquiryMouldSimpleInfo.ITEMS_FIELD)),
					PurchaseInquiryMouldItemSimpleInfo.class));
		}
		return purchaseInquiryMould;
	}

	/**
	 * 将Document转换成ProdSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static ProdSimpleInfo toProd(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProdSimpleInfo.class);
		ProdSimpleInfo prodSimpleInfo = new ProdSimpleInfo();
		prodSimpleInfo.setId(
				Long.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ID_FIELD))));
		prodSimpleInfo
				.setProdCode(document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.CODE_FIELD)));
		String title = document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.TITLE_FIELD));
		if (null != title) {
			prodSimpleInfo.setProdTitle(title);
		}
		String spec = document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.SPEC_FIELD));
		if (null != spec) {
			prodSimpleInfo.setProdSpec(spec);
		}
		String brand = document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.BRAND_FIELD));
		if (null != brand) {
			prodSimpleInfo.setBrand(brand);
		}
		prodSimpleInfo.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, ProdSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		return prodSimpleInfo;
	}

	/**
	 * 将Document转换成EnterpriseSearchSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static EnterpriseSearchSimpleInfo toEnterprise(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(EnterpriseSearchSimpleInfo.class);
		EnterpriseSearchSimpleInfo enterprise = new EnterpriseSearchSimpleInfo();
		enterprise.setEnuu(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ID_FIELD))));
		enterprise.setEnName(
				document.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.NAME_FIELD)));
		String shortName = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SHORTNAME_FIELD));
		if (null != shortName) {
			enterprise.setEnShortname(shortName);
		}
		String address = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ADDRESS_FIELD));
		if (null != address) {
			enterprise.setEnAddress(address);
		}
		String adminuu = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ADMINUU_FIELD));
		if (null != adminuu) {
			enterprise.setEnAdminuu(Long.valueOf(adminuu));
		}
		String area = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.AREA_FIELD));
		if (null != area) {
			enterprise.setEnArea(area);
		}
		String enCorporation = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.CORPORATION_FIELD));
		if (null != enCorporation) {
			enterprise.setEnCorporation(enCorporation);
		}
		String enDate = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.DATE_FIELD));
		if (null != enDate) {
			enterprise.setEnDate(new Date(Long.valueOf(enDate)));
		}
		String enDeliverAddr = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.DELIVERYADDR_FIELD));
		if (null != enDeliverAddr) {
			enterprise.setEnDeliverAddr(enDeliverAddr);
		}
		String enEmail = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.EMAIL_FIELD));
		if (null != enEmail) {
			enterprise.setEnEmail(enEmail);
		}
		String enFax = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.FAX_FIELD));
		if (null != enFax) {
			enterprise.setEnFax(enFax);
		}
		String enRegistercapital = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.REGISTERCAPITAL_FIELD));
		if (null != enRegistercapital) {
			enterprise.setEnRegistercapital(enRegistercapital);
		}
		String enSaasSendStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASSENDSTATUS_FIELD));
		if (null != enSaasSendStatus) {
			enterprise.setEnSaasSendStatus(Short.valueOf(enSaasSendStatus));
		}
		String enSaasStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASSTATUS_FIELD));
		if (null != enSaasStatus) {
			enterprise.setEnSaasStatus(Short.valueOf(enSaasStatus));
		}
		String enSaasUrl = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SAASURL_FIELD));
		if (null != enSaasUrl) {
			enterprise.setEnSaasUrl(enSaasUrl);
		}
		String enStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.STATUS_FIELD));
		if (null != enStatus) {
			enterprise.setEnStatus(Short.valueOf(enStatus));
		}
		String enSendStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.SENDSTATUS_FIELD));
		if (null != enSendStatus) {
			enterprise.setEnSendStatus(Short.valueOf(enSendStatus));
		}
		String enTaxcode = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TAXCODE_FIELD));
		if (null != enTaxcode) {
			enterprise.setEnTaxcode(enTaxcode);
		}
		String enBussinessCode = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.BUSSINESSCODE_FIELD));
		if (null != enBussinessCode) {
			enterprise.setEnBussinessCode(enBussinessCode);
		}
		String enIndustry = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.INDUSTRY_FIELD));
		if (null != enIndustry) {
			enterprise.setEnIndustry(enIndustry);
		}
		String enIsErp = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.ISERP_FIELD));
		if (null != enIsErp) {
			enterprise.setEnIsErp(Short.valueOf(enIsErp));
		}
		String enUrl = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.URL_FIELD));
		if (null != enUrl) {
			enterprise.setEnUrl(enUrl);
		}
		String enType = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TYPE_FIELD));
		if (null != enType) {
			enterprise.setEnType(enType);
		}
		String enTel = document
				.get(ClassAndTableNameUtils.combineField(tableName, EnterpriseSearchSimpleInfo.TEL_FIELD));
		if (null != enTel) {
			enterprise.setEnTel(enTel);
		}
		return enterprise;
	}

	/**
	 * 将Document转换成PurchaseTenderSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static PurchaseTenderSimpleInfo toPurchaseTenderSimpleInfo(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PurchaseTenderSimpleInfo.class);
		PurchaseTenderSimpleInfo purchasetender = new PurchaseTenderSimpleInfo();
		purchasetender.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ID_FIELD))));
		purchasetender.setCode(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CODE_FIELD)));
		String title = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.TITLE_FIELD));
		if (title != null) {
			purchasetender.setTitle(title);
		}
		String status = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.STATUS_FIELD));
		if (status != null) {
			purchasetender.setStatus(status);
		}
		String date = document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.DATE_FIELD));
		if (date != null) {
			purchasetender.setDate(new Date(Long.valueOf(date)));
		}
		String endDate = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ENDDATE_FIELD));
		if (endDate != null) {
			purchasetender.setEndDate(new Date(Long.valueOf(endDate)));
		}
		String publishDate = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.PUBLISHDATE_FIELD));
		if (publishDate != null) {
			purchasetender.setPublishDate(new Date(Long.valueOf(publishDate)));
		}
		String payment = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.PAYMENT_FIELD));
		if (payment != null) {
			purchasetender.setPayment(payment);
		}
		String shipAddress = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.SHIPADDRESS_FIELD));
		if (shipAddress != null) {
			purchasetender.setShipAddress(shipAddress);
		}
		String user = document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.USER_FIELD));
		if (user != null) {
			purchasetender.setUser(user);
		}
		String userTel = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.USERTEL_FIELD));
		if (userTel != null) {
			purchasetender.setUserTel(userTel);
		}
		String currency = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CURRENCY_FIELD));
		if (currency != null) {
			purchasetender.setCurrency(currency);
		}
		String certificate = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.CERTIFICATE_FIELD));
		if (certificate != null) {
			purchasetender.setCertificate(certificate);
		}
		String isPublish = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ISPUBLISH_FIELD));
		if (isPublish != null) {
			purchasetender.setIsPublish(Short.valueOf(isPublish));
		}
		String ifOpen = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.IFOPEN_FIELD));
		if (ifOpen != null) {
			purchasetender.setIfOpen(Short.valueOf(ifOpen));
		}
		purchasetender.setEnterprise(JSONObject.parseObject(
				document.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.ENTERPRISE_FIELD)),
				EnterpriseSimpleInfo.class));
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.TENDERPROD_FIELD))) {
			purchasetender.setTenderProds(toSet(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.TENDERPROD_FIELD)),
					PurchaseTenderProdSimpleInfo.class));
		}
		String overdue = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.OVERDUE_FIELD));
		if (overdue != null) {
			purchasetender.setOverdue(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.OVERDUE_FIELD))));
		}
		String result = document
				.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.RESULT_FIELD));
		if (result != null) {
			purchasetender.setResult(Short.valueOf(document
					.get(ClassAndTableNameUtils.combineField(tableName, PurchaseTenderSimpleInfo.RESULT_FIELD))));
		}
		return purchasetender;
	}

	/**
	 * 将Document转换成PagingReleaseDetailSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static PagingReleaseDetailSimpleInfo toPagingReleaseDetailSimpleInfo(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(PagingReleaseDetailSimpleInfo.class);
		PagingReleaseDetailSimpleInfo pagingReleaseDetail = new PagingReleaseDetailSimpleInfo();
		pagingReleaseDetail.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.ID_FIELD))));
		String userName = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.USERNAME_FIELD));
		if (userName != null) {
			pagingReleaseDetail.setUserName(userName);
		}
		String userUU = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.USERUU_FIELD));
		if (userUU != null) {
			pagingReleaseDetail.setUserUU(userUU);
		}
		String status = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.STATUS_FIELD));
		if (status != null) {
			pagingReleaseDetail.setStatus(Short.valueOf(status));
		}
		String readStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.READSTATUS_FIELD));
		if (readStatus != null) {
			pagingReleaseDetail.setReadStatus(Short.valueOf(readStatus));
		}
		String pushStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.PUSHSTATUS_FIELD));
		if (pushStatus != null) {
			pagingReleaseDetail.setPushStatus(Short.valueOf(pushStatus));
		}
		String totalStatus = document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.TOTALSTATUS_FIELD));
		if (totalStatus != null) {
			pagingReleaseDetail.setTotalStatus(Short.valueOf(totalStatus));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.VEND_FIELD))) {
			pagingReleaseDetail.setEnterprise(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.VEND_FIELD)),
					EnterpriseSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.MAIN_FIELD))) {
			pagingReleaseDetail.setPagingRelease(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, PagingReleaseDetailSimpleInfo.MAIN_FIELD)),
					PagingReleaseSimpleInfo.class));
		}
		return pagingReleaseDetail;
	}

	/**
	 * 将Document转换成VendorSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static VendorSimpleInfo toVendorSimpleInfo(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(VendorSimpleInfo.class);
		VendorSimpleInfo vendorSimpleInfo = new VendorSimpleInfo();
		vendorSimpleInfo.setId(
				Long.valueOf(document.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ID_FIELD))));
		String status = document
				.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.STATUS_FIELD));
		if (status != null) {
			vendorSimpleInfo.setStatus(status);
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ENTERPRISE_FIELD))) {
			vendorSimpleInfo.setEnterprise(JSONObject.parseObject(
					document.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.ENTERPRISE_FIELD)),
					EnterpriseSimpleInfo.class));
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VEND_FIELD))) {
			vendorSimpleInfo.setVend(JSONObject.parseObject(
					document.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VEND_FIELD)),
					EnterpriseSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.MYUSER_FIELD))) {
			vendorSimpleInfo.setMyUser(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.MYUSER_FIELD)),
					UserSimpleInfo.class));
		}
		if (null != document
				.get(ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VENDUSER_FIELD))) {
			vendorSimpleInfo.setVendUser(JSONObject.parseObject(
					document.get(
							ClassAndTableNameUtils.combineField(tableName, VendorSimpleInfo.VENDUSER_FIELD)),
					UserSimpleInfo.class));
		}
		return vendorSimpleInfo;
	}

	/**
	 * 将Document转换成ProdctBrandSimpleInfo对象
	 * 
	 * @param document
	 * @return
	 */
	private static ProductBrandSimpleInfo toProductBrandSimpleInfo(Document document) {
		if (document == null) {
			return null;
		}
		Table_name tableName = ClassAndTableNameUtils.toTableName(ProductBrandSimpleInfo.class);
		ProductBrandSimpleInfo productBrandSimpleInfo = new ProductBrandSimpleInfo();
		productBrandSimpleInfo.setId(Long.valueOf(
				document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.ID_FIELD))));
		String uuid = document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.UUID_FIELD));
		if (uuid != null) {
			productBrandSimpleInfo.setUuid(uuid);
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMECN_FIELD))) {
			productBrandSimpleInfo.setNameCn(
					document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMECN_FIELD)));
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMEEN_FIELD))) {
			productBrandSimpleInfo.setNameEn(
					document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.NAMEEN_FIELD)));
		}
		if (null != document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.VENDOR_FIELD))) {
			productBrandSimpleInfo.setVendor(
					document.get(ClassAndTableNameUtils.combineField(tableName, ProductBrandSimpleInfo.VENDOR_FIELD)));
		}

		return productBrandSimpleInfo;
	}

	/**
	 * 将json字符串转为Set<T>对象
	 * 
	 * @param <T>
	 * 
	 * @param jsonString
	 *            索引中存储的json数据
	 * @return Set<T>对象
	 */
	private static <T> Set<T> toSet(String jsonString, Class<T> clazz) {
		if (StringUtils.isEmpty(jsonString)) {
			return null;
		}
		Set<T> set = new HashSet<>();
		set.addAll(JSONObject.parseArray(jsonString, clazz));
		return set;
	}

}
