깜놀하는 해므찌로

Egov Spring Controller 파이차트 상세보기 컨트롤러 예시 본문

IT

Egov Spring Controller 파이차트 상세보기 컨트롤러 예시

agnusdei1207 2022. 7. 16. 11:07
반응형
SMALL
/* 차트 클릭 시 상세보기 */
	@SuppressWarnings("unchecked")
	@RequestMapping("/mgr/statistics/{proc}Point.do")   
	public String eatPoint(@ModelAttribute("searchVO") Mgr0117VO searchVO, ModelMap model, @PathVariable String proc) throws Exception {
		
		/* 결과 값 저장 변수 */
		ArrayList<String> resultInfo = new ArrayList<>();
		 
		/* 날짜 값 셋팅 */
		String year = DateUtils.getNowDate("yyyy");
		searchVO.setSchEtc05(year + "." + searchVO.getSchEtc05().split("_")[0].replace("/", "."));  
		
		/* 변수 선언 */
		int divnCnt = 0; 
		String stringDivnCnt = ""; 
		String userSeq = ""; 
		String info = "";    
		  
		/* 식대 */
		if("eat".equals(proc)){ 
			/* 식사인원, 가격, 그룹 수, 그룹 내 인원 수 조회 */          
			List<Mgr0117VO> circleList = (List<Mgr0117VO>)cmmnService.selectList(searchVO, PROGRAM_ID + ".eatPointClickSelectList"); 
			  
			for (int i = 0; i < circleList.size(); i++) {  
				divnCnt = circleList.get(i).getUserSeq().split(",").length; 
				stringDivnCnt += "," + divnCnt;
				userSeq += "," + circleList.get(i).getUserSeq(); 
				info += "," + circleList.get(i).getPrice();
			}          
			     
			String[] arrUserSeq = userSeq.split(","); // 사용자 SEQ
			String[] arrDivnCnt = stringDivnCnt.split(","); // 그룹 수
			String[] arrPrice = info.split(","); // 가격
			  
			/* 이름 조회 */ 
			String userName = "";                   
			for(int i = 1; i < arrUserSeq.length; i++){
				searchVO.setSchEtc06(arrUserSeq[i]); 
				LoginVO loginVO = (LoginVO)cmmnService.selectContents(searchVO, PROGRAM_ID + ".findNameSelectContents"); 
				userName += "," + loginVO.getName();
			}   
			
			/* 조회 결과 배열에 담기 */ 
			String[] arrUserName = userName.split(","); // 사용자 이름 저장
			String[] resultUserName = new String[arrDivnCnt.length]; // 이름 배열 : 그룹 수 만큼 길이로 설정    
			String[] resultPrice = new String[arrDivnCnt.length]; // 가격 배열 : 그룹 수 만큼 길이로 설정
			
			int savePoint = 0; // 마지막 인덱스 저장      
			int idx = 0;  
			for(int i = 1; i < arrDivnCnt.length; i++){ // 그룹 수 만큼 반복
				int	cutLength = Integer.parseInt(arrDivnCnt[i]); // 그륩별 식사 인원수  
				String groupNames = "";
				String str = "";  
				 
				if(idx == 0){ // 최초 첫번째 바퀴부터 
					for(int j = 1; j <= cutLength; j++){ // 이름 꺼내기
						if(j == cutLength){
							str = ""; 
						}else{              
							str = ","; 
						}                   
						groupNames += arrUserName[j] + str; // 이름 문자열 구분값     
						savePoint = j;        
					}              
				}else{ // 두번째 바퀴부터                    
					for(int j = savePoint; j < savePoint + cutLength; j++){ // 마지막 인덱스 < 마지막 인덱스 + 그룹별 식사 인원수
						if(j == savePoint + cutLength - 1){
							str = "";   
						}else{               
							str = ","; 
						}    
						groupNames += arrUserName[j+1] + str; // 마지막 인덱스 중복 방지  + 1
					}           
					/* 마지막 인덱스 + 그룹 내 인원 수 */
					savePoint = savePoint + cutLength;             
				}    
				
				resultUserName[idx] = groupNames; // 추출된 이름 배열에 담기  
				resultPrice[idx] = arrPrice[i]; // 추출된 가격 배열에 담기
				idx++;
			} 
			for(int i = 0; i < resultUserName.length -1; i++){
				resultInfo.add(resultUserName[i]+ "_" +resultPrice[i]);
			}     
			     
		}else if("overTime".equals(proc)){ /* 초과근무 차트 */    
			/* 날짜 값 schEtc05 */ 
			List<Mgr0118VO> circleList = (List<Mgr0118VO>)cmmnService.selectList(searchVO, PROGRAM_ID + ".overTimePointClickSelectList"); 
			String[] resultUserName = new String[circleList.size()];
			String[] arrOverTime = new String[circleList.size()];  
			            
			/* 이름 조회 schEtc06 */      
			for(int i = 0; i < circleList.size(); i++){
				searchVO.setSchEtc06(circleList.get(i).getEmplySeq()); 
				LoginVO loginVO = (LoginVO)cmmnService.selectContents(searchVO, PROGRAM_ID + ".findNameSelectContents"); 
				resultUserName[i] = loginVO.getName();
				arrOverTime[i] = circleList.get(i).getCol1();
			}   
			/* 최종 결과 저장 */    
			for(int i = 0; i < circleList.size(); i++){   
				resultInfo.add(resultUserName[i] + "_" + arrOverTime[i]);   
			}  
			
		} 
		model.addAttribute("resultInfo", resultInfo);     
		model.addAttribute("proc", proc);     
		return folderPath + "circleChart";
	}
반응형
LIST