예제 #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

  }
예제 #2
0
  private EmployeePlan createEmployeePlanIfNeed(
      Integer year, Integer month, Employee employee, DictionaryItem dictionaryItem) {
    EmployeePlan employeePlan = employeePlanService.tryFind(employee, year, month, dictionaryItem);

    if (employeePlan == null) {
      employeePlan = new EmployeePlan();

      employeePlan.setType(dictionaryItem);
      employeePlan.setEmployee(employee);
      employeePlan.setYear(year);
      employeePlan.setMonth(month);
    }

    return employeePlan;
  }