Пример #1
0
  @Transactional(propagation = Propagation.REQUIRES_NEW)
  public void savePlans(JsonRootNode rootNode, Integer year, Integer month) {
    final Calendar calendar = DateTimeUtil.getCalendar(year, month);

    if (DateUtils.truncatedCompareTo(new Date(), calendar.getTime(), Calendar.MONTH) > 0) {
      throw new IllegalArgumentException("Редактирование планов за предыдущий месяц запрещено");
    }

    final List<EmployeePlan> employeePlans = new ArrayList<EmployeePlan>();
    final List<EmployeeProjectPlan> employeeProjectPlans = new ArrayList<EmployeeProjectPlan>();

    processJsonDataItems(employeePlans, employeeProjectPlans, rootNode, year, month);

    employeePlanService.mergeProjectPlans(employeePlans);
    employeeProjectPlanService.mergeEmployeeProjectPlans(employeeProjectPlans);
  }
Пример #2
0
  private EmployeeProjectPlan createEmployeeProjectPlanIfNeed(
      Integer year, Integer month, Employee employee, JsonNode node) {
    final Project project = projectService.find(JsonUtil.getDecNumberValue(node, PROJECT_ID));

    EmployeeProjectPlan employeeProjectPlan =
        employeeProjectPlanService.tryFind(employee, year, month, project);

    if (employeeProjectPlan == null) {
      employeeProjectPlan = new EmployeeProjectPlan();

      employeeProjectPlan.setEmployee(employee);
      employeeProjectPlan.setProject(project);
      employeeProjectPlan.setYear(year);
      employeeProjectPlan.setMonth(month);
    }

    employeeProjectPlan.setValue(JsonUtil.getFloatNumberValue(node, _PLAN));

    return employeeProjectPlan;
  }