| | |
| | | |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.mapper.DepartmentMapper; |
| | | import kr.wisestone.owl.repository.UserDepartmentRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.CommonUtil; |
| | | import kr.wisestone.owl.web.condition.DepartmentCondition; |
| | | import kr.wisestone.owl.web.condition.UserCondition; |
| | | import kr.wisestone.owl.web.form.DepartmentForm; |
| | | import kr.wisestone.owl.web.form.UserDepartmentForm; |
| | | import org.jsoup.Jsoup; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private DepartmentRepository departmentRepository; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | |
| | | @Autowired |
| | | private DepartmentMapper departmentMapper; |
| | | |
| | | @Autowired |
| | | private DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | private WorkflowDepartmentService workflowDepartmentService; |
| | | |
| | | @Autowired |
| | | private ProjectRoleDepartmentService projectRoleDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueDepartmentService issueDepartmentService; |
| | | |
| | | @Autowired |
| | | private ProjectRoleService projectRoleService; |
| | | |
| | | @Autowired |
| | | private IssueTypeService issueTypeService; |
| | | |
| | | @Autowired |
| | | private WorkspaceService workspaceService; |
| | |
| | | } |
| | | |
| | | for (Long id : departmentForm.getRemoveIds()) { |
| | | if (!this.departmentService.countInDepartment(id)) { |
| | | this.departmentRepository.deleteById(id); |
| | | } else { |
| | | if (this.departmentService.countInDepartment(id)) { |
| | | // 사용자가 부서에 속해 있는지 체크 |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE)); |
| | | |
| | | } else if (this.workflowDepartmentService.usingDepartment(id)) { |
| | | // 워크플로우에서 해당 부서를 사용하고 있는지 체크 |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_WORKFLOW)); |
| | | |
| | | } else if (this.projectRoleDepartmentService.usingDepartment(id)) { |
| | | // 프로젝트의 담당부서인지 체크 |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_PROJECT)); |
| | | |
| | | } else if (this.issueDepartmentService.usingDepartment(id)) { |
| | | // 이슈의 담당부서로 되어있는지 체크 |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_ISSUE)); |
| | | |
| | | } else { |
| | | this.departmentRepository.deleteById(id); |
| | | } |
| | | } |
| | | this.departmentRepository.flush(); |
| | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, departmentVos); |
| | | } |
| | | |
| | | // 워크플로우에 속해있는 부서 목록 조회 |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public void findWorkflowDepartment(Map<String, Object> resJsonData, DepartmentCondition departmentCondition) { |
| | | List<DepartmentVo> departmentVos = findWorkflowDepartment(departmentCondition.getIssueTypeId()); |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, departmentVos); |
| | | } |
| | | |
| | | // 워크플로우에 속해있는 부서 목록 조회 |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<DepartmentVo> findWorkflowDepartment(Long issueTypeId) { |
| | | List<WorkflowDepartment> workflowDepartmentList = this.findWorkflowDepartmentByIssueTypeId(issueTypeId); |
| | | List<DepartmentVo> departmentVos = Lists.newArrayList(); |
| | | |
| | | if(workflowDepartmentList != null && workflowDepartmentList.size()>0){ |
| | | for(WorkflowDepartment workflowDepartment : workflowDepartmentList){ |
| | | DepartmentVo departmentVo = ConvertUtil.copyProperties(workflowDepartment.getDepartment(), DepartmentVo.class); |
| | | departmentVo.setByName(departmentVo.getDepartmentName()); |
| | | departmentVos.add(departmentVo); |
| | | } |
| | | } |
| | | return departmentVos; |
| | | } |
| | | |
| | | // 이슈 유형(워크플로우)에 있는 담당부서 조회 |
| | | private List<WorkflowDepartment> findWorkflowDepartmentByIssueTypeId(Long issueTypeId) { |
| | | Long workflowId = this.getWorkflowId(issueTypeId); |
| | | return this.workflowDepartmentService.find(workflowId); |
| | | } |
| | | |
| | | private Long getWorkflowId(Long issueTypeId) { |
| | | IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); |
| | | return issueType.getWorkflow().getId(); |
| | | } |
| | | |
| | | // 부서 목록을 엑셀로 다운로드 한다. |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public boolean countInDepartment(Long id) { |
| | | return this.departmentMapper.countInDepartment(id) > 0; |
| | | boolean result = false; |
| | | List<UserDepartment> usingDepartments = this.userDepartmentService.findByDepartmentId(id); |
| | | if(usingDepartments != null && usingDepartments.size() > 0){ |
| | | result = true; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // DepartmentVos 데이터를 엑셀에서 표시할 수 있는 데이터로 변경한다. |