Package org.sis.ancmessaging.domain

Examples of org.sis.ancmessaging.domain.ReportDetail


        reportDao.saveDetail(reportDetail);
    }

    @Override
    public ReportDetail generateDetail(Report report) {
        ReportDetail reportDetail = reportDao.generateReport(report);
        return reportDetail;
    }
View Full Code Here


  @RequestMapping(value = "create", method = RequestMethod.POST)
  public String createReport(HttpServletRequest request, Model model) {
    int year = Integer.parseInt(request.getParameter("year"));
    Report report = getReportObject(year);
    ReportDetail reportDetail = reportService.generateDetail(report);
    report.getReportDetails().add(reportDetail);
    reportDetail.setReport(report);
    reportService.save(report);
    //reportService.saveDetail(reportDetail);
    return "redirect:/admin/report?response=true";
  }
View Full Code Here

  @RequestMapping(value = "show", method = RequestMethod.GET)
  public
  @ResponseBody
  String showReport(@RequestParam("year") int year) {
    Report report = getReportObject(year);
    ReportDetail reportDetail = reportService.generateDetail(report);
    int colSize = report.getToQuarter() - report.getFromQuarter() + 2;

    String template = "<table border='1' cellspacing='0'><tr><td colspan=\"" + colSize + "\"><b>Delivery</b></td></tr>";
    String line1 = "<td>Home: </td><td>" + reportDetail.getQ1HomeDelivery() + "</td>";
    String line2 = "<td>HC: </td><td>" + reportDetail.getQ1HcDelivery() + "</td>";
    String line3 = "<td>HP: </td><td>" + reportDetail.getQ1HpDelivery() + "</td>";
    String line4 = "<td>Referred: </td><td>" + reportDetail.getQ1ReferredDelivery() + "</td>";
    String line5 = "<td>Unknown: </td><td>" + reportDetail.getQ1UnknownDelivery() + "</td>";
    String middle = "<tr><td colspan=\"" + colSize + "\"><b>Reminders</b></td></tr>";
    String line6 = "<td>First: </td><td>" + reportDetail.getQ1FirstReminder() + "</td>";
    String line7 = "<td>Second: </td><td>" + reportDetail.getQ1SecondReminder() + "</td>";
    String line8 = "<td><b>EDD: </b></td><td>" + reportDetail.getQ1Edd() + "</td>";

    for (int i = report.getFromQuarter(); i <= report.getToQuarter(); i++) {
      switch (i) {
        case 2:
          line1 += "<td>" + reportDetail.getQ2HomeDelivery() + "</td>";
          line2 += "<td>" + reportDetail.getQ2HcDelivery() + "</td>";
          line3 += "<td>" + reportDetail.getQ2HpDelivery() + "</td>";
          line4 += "<td>" + reportDetail.getQ2ReferredDelivery() + "</td>";
          line5 += "<td>" + reportDetail.getQ2UnknownDelivery() + "</td>";
          line6 += "<td>" + reportDetail.getQ2FirstReminder() + "</td>";
          line7 += "<td>" + reportDetail.getQ2SecondReminder() + "</td>";
          line8 += "<td>" + reportDetail.getQ2Edd() + "</td>";
          break;
        case 3:
          line1 += "<td>" + reportDetail.getQ3HomeDelivery() + "</td>";
          line2 += "<td>" + reportDetail.getQ3HcDelivery() + "</td>";
          line3 += "<td>" + reportDetail.getQ3HpDelivery() + "</td>";
          line4 += "<td>" + reportDetail.getQ3ReferredDelivery() + "</td>";
          line5 += "<td>" + reportDetail.getQ3UnknownDelivery() + "</td>";
          line6 += "<td>" + reportDetail.getQ3FirstReminder() + "</td>";
          line7 += "<td>" + reportDetail.getQ3SecondReminder() + "</td>";
          line8 += "<td>" + reportDetail.getQ3Edd() + "</td>";
          break;
        case 4:
          line1 += "<td>" + reportDetail.getQ4HomeDelivery() + "</td>";
          line2 += "<td>" + reportDetail.getQ4HcDelivery() + "</td>";
          line3 += "<td>" + reportDetail.getQ4HpDelivery() + "</td>";
          line4 += "<td>" + reportDetail.getQ4ReferredDelivery() + "</td>";
          line5 += "<td>" + reportDetail.getQ4UnknownDelivery() + "</td>";
          line6 += "<td>" + reportDetail.getQ4FirstReminder() + "</td>";
          line7 += "<td>" + reportDetail.getQ4SecondReminder() + "</td>";
          line8 += "<td>" + reportDetail.getQ4Edd() + "</td>";
          break;
      }
    }

    line1 = "<tr>" + line1 + "</tr>";
View Full Code Here

  }

  @Override
  public ReportDetail generateReport(Report report) {
    DateTime begin, end;
    ReportDetail reportDetail = new ReportDetail();
    for (int i = report.getFromQuarter(); i <= report.getToQuarter(); i++) {
      int endMonth = i * 3;
      int beginMonth = endMonth - 2;
      int year = report.getYear();
      int endDate = getTotalDaysOfMonth(year, endMonth);

      begin = new DateTime(year, beginMonth, 1, 0, 0);
      end = new DateTime(year, endMonth, endDate, 0, 0);

      long count = (Long) getSession().createCriteria(Reminder.class)
          .add(Restrictions.between("reminderSentOn", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("reminderType", "MONTHLY"))
          .setProjection(Projections.rowCount()).uniqueResult();
      int c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1FirstReminder(c);
          break;
        case 2:
          reportDetail.setQ2FirstReminder(c);
          break;
        case 3:
          reportDetail.setQ3FirstReminder(c);
          break;
        case 4:
          reportDetail.setQ4FirstReminder(c);
          break;
      }

      count = (Long) getSession().createCriteria(Reminder.class)
          .add(Restrictions.between("reminderSentOn", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("reminderType", "WEEKLY"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1SecondReminder(c);
          break;
        case 2:
          reportDetail.setQ2SecondReminder(c);
          break;
        case 3:
          reportDetail.setQ3SecondReminder(c);
          break;
        case 4:
          reportDetail.setQ4SecondReminder(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("arrivalTime", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("outcome", "Delivered at Home"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1HomeDelivery(c);
          break;
        case 2:
          reportDetail.setQ2HomeDelivery(c);
          break;
        case 3:
          reportDetail.setQ3HomeDelivery(c);
          break;
        case 4:
          reportDetail.setQ4HomeDelivery(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("arrivalTime", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("outcome", "Delivered at HP"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1HpDelivery(c);
          break;
        case 2:
          reportDetail.setQ2HpDelivery(c);
          break;
        case 3:
          reportDetail.setQ3HpDelivery(c);
          break;
        case 4:
          reportDetail.setQ4HpDelivery(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("arrivalTime", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("outcome", "Delivered at HC"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1HcDelivery(c);
          break;
        case 2:
          reportDetail.setQ2HcDelivery(c);
          break;
        case 3:
          reportDetail.setQ3HcDelivery(c);
          break;
        case 4:
          reportDetail.setQ4HcDelivery(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("arrivalTime", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("outcome", "Referred"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1ReferredDelivery(c);
          break;
        case 2:
          reportDetail.setQ2ReferredDelivery(c);
          break;
        case 3:
          reportDetail.setQ3ReferredDelivery(c);
          break;
        case 4:
          reportDetail.setQ4ReferredDelivery(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("arrivalTime", begin.toDate(), end.toDate()))
          .add(Restrictions.eq("outcome", "Unknown"))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1UnknownDelivery(c);
          break;
        case 2:
          reportDetail.setQ2UnknownDelivery(c);
          break;
        case 3:
          reportDetail.setQ3UnknownDelivery(c);
          break;
        case 4:
          reportDetail.setQ4UnknownDelivery(c);
          break;
      }

      count = (Long) getSession().createCriteria(Mother.class)
          .add(Restrictions.between("edd", begin.toDate(), end.toDate()))
          .setProjection(Projections.rowCount()).uniqueResult();
      c = (int) count;
      switch (i) {
        case 1:
          reportDetail.setQ1Edd(c);
          break;
        case 2:
          reportDetail.setQ2Edd(c);
          break;
        case 3:
          reportDetail.setQ3Edd(c);
          break;
        case 4:
          reportDetail.setQ4Edd(c);
          break;
      }
    }

    return reportDetail;
View Full Code Here

TOP

Related Classes of org.sis.ancmessaging.domain.ReportDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.