package nc.bs.pu.wgpt.pubitf;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nc.bs.pu.wgpt.bp.WuYeWgptBP;
import nc.net.servlet.SapToNcEsbJsonServlet;

/**
 * @Description: 【网购平台->NC】新增/修改采购发票
 * 
 * @author 谢文如 【碧桂园-物业板块-网购平台接口】
 * @date 2019-3-6
 * @version with NCC
 */
@SuppressWarnings("restriction")
public class WGInvoiceInfoServlet extends SapToNcEsbJsonServlet {

	@Override
	public void  execFunction(HttpServletRequest request, HttpServletResponse response) {
		WuYeWgptBP bp = new WuYeWgptBP();
		String jsondata = bp.writeInvoiceInfo(request);
		sendResponse(response, jsondata);
	}

	/**
	 * 发送响应信息
	 * @param response
	 * @param esb
	 */
	private void sendResponse(final HttpServletResponse response, String jsondata) {
		PrintWriter out = null;
		try {
			response.setHeader("Content-type", "application/json;charset=UTF-8");
			out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
			out.write(jsondata);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

}
