Beispiel #1
0
  private void addEmployeePlans(
      List<EmployeePlan> employeePlans,
      Integer year,
      Integer month,
      Employee employee,
      JsonNode jsonNode) {
    final Map<JsonStringNode, JsonNode> fields = jsonNode.getFields();

    JsonStringNode field;

    for (Map.Entry<JsonStringNode, TSEnum> entry : PLAN_TYPE_MAP.entrySet()) {
      field = entry.getKey();

      final EmployeePlan employeePlan =
          createEmployeePlanIfNeed(
              year, month, employee, dictionaryItemService.find(entry.getValue().getId()));

      if (fields.containsKey(field)) {
        employeePlan.setValue(JsonUtil.getFloatNumberValue(jsonNode, field.getText()));

        employeePlans.add(employeePlan);
      }
    }

    // KSS APLANATS-850 Удалять будем только существующие записи с value=0.
    // Удаление будет вызвано в методе
    // com.aplana.timesheet.service.EmployeePlanService.mergeProjectPlans

  }
Beispiel #2
0
  private void addEmployeeProjectPlans(
      List<EmployeeProjectPlan> employeeProjectPlans,
      Integer year,
      Integer month,
      Employee employee,
      JsonNode jsonNode) {
    // employeeProjectPlanService.remove(employee, year, month); KSS APLANATS-850 Удалять будем
    // только существующие записи с value=0. Удаление будет вызвано в методе
    // com.aplana.timesheet.service.EmployeeProjectPlanService.mergeEmployeeProjectPlans

    if (jsonNode.getFields().containsKey(PROJECTS_PLANS_FIELD)) {
      for (JsonNode node : jsonNode.getArrayNode(PROJECTS_PLANS)) {
        employeeProjectPlans.add(createEmployeeProjectPlanIfNeed(year, month, employee, node));
      }
    }
  }
Beispiel #3
0
 public List<DictionaryItem> getVacationTypes(List<Vacation> vacations) {
   List<DictionaryItem> result = new ArrayList<DictionaryItem>();
   for (Vacation vacation : vacations) {
     if (!result.contains(vacation.getType())) {
       result.add(vacation.getType());
     }
   }
   // отсортируем
   Collections.sort(
       result,
       new Comparator() {
         @Override
         public int compare(Object type1, Object type2) {
           Integer typeId1 = ((DictionaryItem) type1).getId();
           Integer typeId2 = ((DictionaryItem) type2).getId();
           return typeId1.compareTo(typeId2);
         }
       });
   return result;
 }
Beispiel #4
0
 public List<VacationInYear> getSummaryDaysCountByYearAndType(
     List<DictionaryItem> vacationTypes,
     int firstYear,
     int lastYear,
     Map<Vacation, Integer> calDays,
     Map<Vacation, Integer> workDays) {
   List<VacationInYear> result = new ArrayList<VacationInYear>();
   for (DictionaryItem vacationType : vacationTypes) {
     for (int year = firstYear; year <= lastYear; year++) {
       Map<Vacation, Integer> calDaysForYearByType =
           getDaysForYearByType(calDays, year, vacationType);
       Map<Vacation, Integer> workDaysForYearByType =
           getDaysForYearByType(workDays, year, vacationType);
       int summaryCalDays = getSummaryDaysCount(calDaysForYearByType);
       int summaryWorkDays = getSummaryDaysCount(workDaysForYearByType);
       result.add(
           new VacationInYear(vacationType.getValue(), year, summaryCalDays, summaryWorkDays));
     }
   }
   return result;
 }
Beispiel #5
0
 public String getVacationListByRegionJSON(
     Date dateFrom, Date dateTo, List<Vacation> vacationList) {
   List<Region> regionList = regionService.getRegions();
   List<Employee> employeeList = new ArrayList<Employee>();
   for (Vacation vacation : vacationList) {
     Employee employee = vacation.getEmployee();
     if (!(employeeList.contains(employee))) {
       employeeList.add(employee);
     }
   }
   final JsonArrayNodeBuilder result = anArrayBuilder();
   // для каждого проекта смотрим сотрудников у которых есть отпуск
   for (Region region : regionList) {
     JsonArrayNodeBuilder employeeNode = anArrayBuilder();
     boolean hasEmployees = false;
     for (Employee employee : employeeList) {
       if (employee.getRegion().getId().equals(region.getId())) {
         JsonArrayNodeBuilder vacationNode = createVacationsNode(employee, vacationList);
         hasEmployees = true;
         employeeNode.withElement(
             anObjectBuilder()
                 .withField("employee", aStringBuilder(employee.getName()))
                 .withField("vacations", vacationNode));
       }
     }
     if (hasEmployees) {
       result.withElement(
           anObjectBuilder()
               .withField("region_id", aStringBuilder(region.getId().toString()))
               .withField("region_name", aStringBuilder(region.getName()))
               .withField("employeeList", employeeNode)
               .withField("holidays", getHolidayInRegion(dateFrom, dateTo, region)));
     }
   }
   return JsonUtil.format(result);
 }