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; }
/* * Возвращает HashMap со значениями для заполнения списков сотрудников, * проектов, пресейлов, проектных задач, типов и категорий активности на * форме приложения. */ private Map<String, Object> getListsToMAV() { Map<String, Object> result = new HashMap<String, Object>(); List<DictionaryItem> typesOfActivity = dictionaryItemService.getTypesOfActivity(); result.put("actTypeList", typesOfActivity); String typesOfActivityJson = getDictionaryItemsInJson(typesOfActivity); result.put("actTypeJson", typesOfActivityJson); String workplacesJson = getDictionaryItemsInJson(dictionaryItemService.getWorkplaces()); result.put("workplaceJson", workplacesJson); result.put( "overtimeCauseJson", getDictionaryItemsInJson(dictionaryItemService.getOvertimeCauses())); result.put( "unfinishedDayCauseJson", getDictionaryItemsInJson(dictionaryItemService.getUnfinishedDayCauses())); result.put("overtimeThreshold", propertyProvider.getOvertimeThreshold()); List<Division> divisions = divisionService.getDivisions(); result.put("divisionList", divisions); result.put( "employeeListJson", employeeHelper.getEmployeeListJson(divisions, employeeService.isShowAll(request))); List<DictionaryItem> categoryOfActivity = dictionaryItemService.getCategoryOfActivity(); result.put("actCategoryList", categoryOfActivity); String actCategoryListJson = getDictionaryItemsInJson(categoryOfActivity); result.put("actCategoryListJson", actCategoryListJson); result.put("availableActCategoriesJson", getAvailableActCategoriesJson()); result.put("projectListJson", projectService.getProjectListJson(divisions)); result.put("projectTaskListJson", getProjectTaskListJson(projectService.getProjectsWithCq())); List<ProjectRole> projectRoleList = projectRoleService.getProjectRoles(); for (int i = 0; i < projectRoleList.size(); i++) { if (projectRoleList .get(i) .getCode() .equals("ND")) { // Убираем из списка роль "Не определена" APLANATS-270 projectRoleList.remove(i); break; } } result.put("projectRoleList", projectRoleList); StringBuilder projectRoleListJson = new StringBuilder(); projectRoleListJson.append("["); for (ProjectRole item : projectRoleList) { projectRoleListJson.append("{id:'"); projectRoleListJson.append(item.getId().toString()); projectRoleListJson.append("', value:'"); projectRoleListJson.append(item.getName()); projectRoleListJson.append("'},"); } result.put( "projectRoleListJson", projectRoleListJson.toString().substring(0, (projectRoleListJson.toString().length() - 1)) + "]"); return result; }