@RequestMapping(value = "timeseries", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Response timeseries(@RequestParam String clusterName, @RequestParam String status) { Response response = new Response(); response.setSuccess(true); int level = SessionUtils.getLevel(); ApplicationContext applicationContext = ApplicationContextRegistry.getApplicationContext(); JdbcTemplate jdbcTemplate = applicationContext.getBean(JdbcTemplate.class); String query = null; if (level != 1) { // 일반 사용자의 경우 자기것만 보여줘야 함 if ("ALL".equals(status)) { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE USERNAME = '******' AND START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } else if ("SUCCESS".equals(status)) { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, 'SUCCESS' as type, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE USERNAME = '******' AND STATUS = 'SUCCESS' AND START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } else { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, 'FAILED' as type, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE USERNAME = '******' AND STATUS <> 'SUCCESS' AND START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } } else { if ("ALL".equals(status)) { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } else if ("SUCCESS".equals(status)) { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, 'SUCCESS' as type, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE STATUS = 'SUCCESS' AND START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } else { query = "select (@row:=@row+1) as num, count(*) as sum, DATE_FORMAT(MAX(START_DATE),'%Y-%m-%d %H') as time, 'FAILED' as type, START_DATE from FL_WORKFLOW_HISTORY, (SELECT @row := 0) r WHERE AND STATUS <> 'SUCCESS' AND START_DATE > DATE_ADD(now(), INTERVAL -7 DAY) GROUP BY DATE_FORMAT(START_DATE,'%Y-%m-%d %H') ORDER BY START_DATE asc"; } } List<Map<String, Object>> list = jdbcTemplate.queryForList(MessageFormatter.format(query, clusterName).getMessage()); response.getList().addAll(list); return response; }
/** * Workflow Monitoring History 목록을 조회한다. * * @param clusterName 클러스터명 * @param startDate 시작 날짜 * @param endDate 마지막 날짜 * @param status 워크플로우 작업 상태 * @param workflowName 워크플로우명 * @param jobType 워크플로우 작업 타입 * @param page 페이지 * @param start 시작 페이지 * @param limit 조회 제한 개수 * @param node 히스토리 목록이 속한 상위 노드 정보 * @return Workflow History List */ @RequestMapping(value = "/workflows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Response getWorkflows( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "") String startDate, @RequestParam(defaultValue = "") String endDate, @RequestParam(defaultValue = "") String status, @RequestParam(defaultValue = "") String workflowName, @RequestParam(defaultValue = "") String jobType, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "0") int start, @RequestParam(defaultValue = "16") int limit, @RequestParam(defaultValue = "") String node) { Response response = new Response(); EngineService engineService = getEngineService(clusterName); WorkflowHistoryRemoteService workflowHistoryRemoteService = engineService.getWorkflowHistoryRemoteService(); int level = SessionUtils.getLevel(); String username = level == 1 ? "" : SessionUtils.getUsername(); ArrayList<Map> arrayList = new ArrayList<>(); List<WorkflowHistory> workflowHistories = workflowHistoryRemoteService.selectByCondition( startDate, endDate, start, limit, username, workflowName, status, ""); for (WorkflowHistory workflowHistory : workflowHistories) { Map map = getNodeForWorkflow(workflowHistory, node); arrayList.add(map); } int total = workflowHistoryRemoteService.selectTotalCountByUsername( startDate, endDate, start, limit, username, workflowName, status, ""); response.setTotal(total); response.setLimit(arrayList.size()); response.getList().addAll(arrayList); response.setSuccess(true); return response; }
/** * 현재 세션의 사용자 등급 정보를 가져온다. * * @return level */ private int getSessionUserLevel() { return SessionUtils.getLevel(); }