예제 #1
0
  private void saveRestingHour() {

    if (currentCrew != null) {
      EntryTime entryTime = new EntryTime();

      entryTime.setEntryDate(getDate(currentDate));
      entryTime.setCrewId(currentCrew.getId());
      entryTime.setComments(txtComments.getText());
      entryTime.setOnPort(chkOnPort.isSelected());
      entryTime.setSchedule(timeSheet.getSchedule());
      entryTime.setWorkIn24Hours(timeSheet.getTotalWork());
      entryTime.setRestIn24Hours(timeSheet.getTotalRest());

      if (entryTimeDao.addUpdateEntry(entryTime) > 0) {

        if (errorReportEntry != null) new ReportDAO().addErrorReportEntry(errorReportEntry);

        NotificationManager.showNotification(
            "<html>Resting hours has been saved for<br/>"
                + CalendarUtil.format("MMM dd, yyyy", getDate(currentDate))
                + "</html>");
      }
    }
  }
예제 #2
0
  @Override
  public void changed(float totalRest, float totalWork) {
    txtHoursOfRest24Hrs.setText(Float.toString(totalRest));
    txtHoursOfWork24Hrs.setText(Float.toString(totalWork));

    Calendar cal = Calendar.getInstance();
    cal.setTime(currentDate);

    int month = cal.get(Calendar.MONTH);

    StringBuilder sb = new StringBuilder();
    sb.append("<html><ul>");

    if (currentCrew != null) {

      try {

        EntryTime time = new EntryTime();
        time.setSchedule(timeSheet.getSchedule());

        double totalWorkHours = 24 - time.getTotalRestHours();

        errorReportEntry = new ErrorReportEntry();
        errorReportEntry.setEntryDate(getDate(currentDate));
        errorReportEntry.setCrew(currentCrew);

        errorReportEntry.setRestIn24hours(time.getTotalRestHours());
        errorReportEntry.setWorkIn24hours(totalWorkHours);

        if (time.getTotalRestHours() < 10) {
          sb.append("<li>Total period of REST > 10 Hours</li>");

          errorReportEntry.setRestGreater10hrs(true);
        }

        if (totalWorkHours > 14) {
          sb.append("<li>Total period of WORK &lt; 14 Hours</li>");

          errorReportEntry.setWorkLess14hrs(true);
        }

        errorReport = new ErrorReport(currentCrew, null, month, cal.get(Calendar.YEAR));
        errorReport.generateReport();

        if (errorReport.getEntryTimeList().size() >= cal.get(Calendar.DAY_OF_MONTH) - 1) {
          errorReport
              .getEntryTimeList()
              .get(cal.get(Calendar.DAY_OF_MONTH) - 1)
              .setSchedule(timeSheet.getSchedule());
          errorReport.refresh();
        }

        if (errorReport.getContainMoreThan2RestPeriods(cal.get(Calendar.DAY_OF_MONTH)) == true) {
          sb.append("<li>Total number of REST periods are more than 2</li>");

          errorReportEntry.setTotalRestPeriods(
              errorReport.getRestPeriodCounter(cal.get(Calendar.DAY_OF_MONTH)));
        }

        if (!errorReport.contain6HourContinuousRest(cal.get(Calendar.DAY_OF_MONTH))) {
          sb.append("<li>At least one period of rest must be of 6 hours in length</li>");

          errorReportEntry.setOneRestPeriod6hrs(true);
        }

        double restHoursIn24Hours = errorReport.get24HourRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (restHoursIn24Hours < 10) {
          sb.append("<li>Any 24-hour Total Period of REST &gt; 10 Hours</li>");

          errorReportEntry.setAnyRest24hours(restHoursIn24Hours);

          errorReportEntry.setTotalRest24hrsGreater10hrs(true);
        }

        double restHoursIn7Days = errorReport.get7DayRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (restHoursIn7Days < 77) {
          sb.append("<li>Any 7-days Total Period of REST &gt; 77 Hours</li>");

          errorReportEntry.setRest7days(restHoursIn7Days);

          errorReportEntry.setTotalRest7daysGreater77hrs(true);
        }

        double last3DayTotalRestHours =
            errorReport.getLast3DayTotalRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (last3DayTotalRestHours < 36) {
          sb.append("<li>Rest hours in last 3 days are &lt; 36 Hours</li>");
        }
        errorReportEntry.setRestHour3daysGreater36hrs(last3DayTotalRestHours);

      } catch (Exception e) {
      }
    }

    sb.append("</ul></html>");

    lblNonConformities.setText(sb.toString());
    lblNonConformities.repaint();
  }