1 package ecar.servlet.servico;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import java.util.Date;
6
7 import javax.servlet.ServletException;
8 import javax.servlet.http.HttpServlet;
9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11
12 import org.apache.log4j.Logger;
13
14 import comum.util.Data;
15
16 import ecar.dao.ServicoDao;
17 import ecar.exception.ECARException;
18 import ecar.pojo.ItemEstruturaIett;
19
20
21 public class ApuracaoReprogramacaoReducaoPontosCriticos extends HttpServlet {
22 private static final long serialVersionUID = 3723440142007156805L;
23 private Logger logger = Logger.getLogger(this.getClass());
24
25 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
26 logger.info("request :: GET:: Classe:: " + this.getClass().getName() );
27 execute(request,response);
28 }
29
30 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
31 logger.info("request :: POST:: Classe:: " + this.getClass().getName() );
32 execute(request,response);
33
34 }
35
36
37 private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
38
39 String codIett = request.getParameter("codIett");
40 String dataBase = request.getParameter("dataBase");
41
42 ServicoDao servicoDao = new ServicoDao(request);
43
44 try{
45
46 ItemEstruturaIett itemEstrutura = (ItemEstruturaIett)servicoDao.buscar(ItemEstruturaIett.class, Long.valueOf(codIett) );
47 double apuracaoRepReducao = servicoDao.apuracaoReprogramacaoReducaoPontosCriticos(itemEstrutura, Data.parseDate(dataBase));
48
49 response.setContentType("text/html");
50
51 PrintWriter output = response.getWriter();
52 output.println(apuracaoRepReducao);
53
54 } catch (IOException e) {
55 this.logger.error(e);
56 throw new ServletException(e);
57 } catch (ECARException e) {
58 this.logger.error(e);
59 throw new ServletException(e);
60 } catch (Exception e) {
61 this.logger.error(e);
62 throw new ServletException(e);
63 }
64 }
65
66
67 }