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 public class ApuracaoConclusaoPontosCriticos extends HttpServlet {
21 private static final long serialVersionUID = 3723440142007156805L;
22 private Logger logger = Logger.getLogger(this.getClass());
23
24 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
25 logger.info("request :: GET:: Classe:: " + this.getClass().getName() );
26 execute(request,response);
27 }
28
29 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
30 logger.info("request :: POST:: Classe:: " + this.getClass().getName() );
31 execute(request,response);
32
33 }
34
35
36 private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
37
38 String codIett = request.getParameter("codIett");
39 String dataBase = request.getParameter("dataBase");
40
41 ServicoDao servicoDao = new ServicoDao(request);
42
43 try{
44
45 ItemEstruturaIett itemEstrutura = (ItemEstruturaIett)servicoDao.buscar(ItemEstruturaIett.class, Long.valueOf(codIett) );
46 double apuracaoConclusao = servicoDao.apuracaoConclusaoPontosCriticos(itemEstrutura, Data.parseDate(dataBase));
47
48 response.setContentType("text/html");
49
50 PrintWriter output = response.getWriter();
51 output.println(apuracaoConclusao);
52
53 } catch (IOException e) {
54 this.logger.error(e);
55 throw new ServletException(e);
56 } catch (ECARException e) {
57 this.logger.error(e);
58 throw new ServletException(e);
59 } catch (Exception e) {
60 this.logger.error(e);
61 throw new ServletException(e);
62 }
63 }
64
65
66 }