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;
/**
 * 【网购平台->NC】新加的方法，采购平台协同库存采购入库/退库
 * @author 符耀铭
 * @time 2019-7-15
 */
public class WGPurchaseinInfoServlet extends SapToNcEsbJsonServlet {

	@Override
	public void execFunction(HttpServletRequest request,HttpServletResponse response) {
		WuYeWgptBP bp = new WuYeWgptBP();
		String jsondata = bp.writePurchaseinInfo(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();
			}
		}
	}
}
