package nc.bs.uap.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;

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