package com.swfarm.biz.chain.bo.flytexpressapi;

import java.io.ByteArrayOutputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.log4j.Logger;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "PackageInfo")
public class PackageInfo {

	Logger logger = Logger.getLogger(PackageInfo.class);

	@XmlElement(name = "PkgEnName")
	private String pkgEnName;

	@XmlElement(name = "PkgCnName")
	private String pkgCnName;

	@XmlElement(name = "Num")
	private Integer num;

	@XmlElement(name = "CurrencyType")
	private String currencyType;

	@XmlElement(name = "UnitPrice")
	private String unitPrice;

	@XmlElement(name = "RealPrice")
	private String realPrice;

	@XmlElement(name = "ProducingArea")
	private String producingArea;

	@XmlElement(name = "ItemId")
	private String itemId;

	@XmlElement(name = "Freight")
	private String freight;

	@XmlElement(name = "BatteryType")
	private String batteryType;

	@XmlElement(name = "HaikwanCode")
	private String haikwanCode;

	public String getPkgEnName() {
		return pkgEnName;
	}

	public void setPkgEnName(String pkgEnName) {
		this.pkgEnName = pkgEnName;
	}

	public String getPkgCnName() {
		return pkgCnName;
	}

	public void setPkgCnName(String pkgCnName) {
		this.pkgCnName = pkgCnName;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public String getCurrencyType() {
		return currencyType;
	}

	public void setCurrencyType(String currencyType) {
		this.currencyType = currencyType;
	}

	public String getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(String unitPrice) {
		this.unitPrice = unitPrice;
	}

	public String getRealPrice() {
		return realPrice;
	}

	public void setRealPrice(String realPrice) {
		this.realPrice = realPrice;
	}

	public String getProducingArea() {
		return producingArea;
	}

	public void setProducingArea(String producingArea) {
		this.producingArea = producingArea;
	}

	public String getHaikwanCode() {
		return haikwanCode;
	}

	public void setHaikwanCode(String haikwanCode) {
		this.haikwanCode = haikwanCode;
	}

	public String build() {
		String result = "";
		try {
			JAXBContext context = JAXBContext.newInstance(this.getClass());
			Marshaller marshaller = context.createMarshaller();
			marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");// //编码格式
			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);// 是否格式化生成的xml串
			marshaller.setProperty(Marshaller.JAXB_FRAGMENT, false);// 是否省略xm头声明信息
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			marshaller.marshal(this, output);
			result = new String(output.toByteArray(), "UTF-8");
		} catch (Exception e) {
			logger.warn(e.getMessage(), e);
		}
		return result;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public String getItemId() {
		return itemId;
	}

	public void setFreight(String freight) {
		this.freight = freight;
	}

	public String getFreight() {
		return freight;
	}

	public void setBatteryType(String batteryType) {
		this.batteryType = batteryType;
	}

	public String getBatteryType() {
		return batteryType;
	}

}
