minwook
10
2018-09-14 22:42:57
2
92

매소드 변수값 가져오기?


  @Override 
 public int ExceluploadForNetSalesReport(String filePath) throws Exception {


  int result = 1;
  
  setCurrentState("A");
  
  String[] columnNameList = ExcelReadOption.getColumnNameList(EXCEL_READ_TYPE.EXCEL_NET_SALES_REPORT);
  ExcelReadOption excelReadOption = ExcelReadOption.getExcelReadOption(filePath, columnNameList, EXCEL_READ_TYPE.EXCEL_NET_SALES_REPORT);
       
        List<Map<String,String>> excelContent = ExcelRead.read(excelReadOption);
       
        if (logger.isDebugEnabled())
   logger.debug("==========> Excel Data Read End.");


        int insertDbCnt = 1;       
        int totalSize = excelContent.size() + (excelContent.size()/10);
       
        totalRowCount = totalSize;       
       
        List<NetSalesReport> netSalesReportList = new ArrayList<NetSalesReport>();
       
        loop : for(Map<String,String> map : excelContent){


         setCurrentState("B");
         int eight = map.get(columnNameList[2]).length();
         String med = map.get(columnNameList[2]);
         if( eight != 8 || med.contains("MED") == false){           
          return result = 5; 
         }         
         else if( eight != 0 ){
          break loop;
         }
         
         successRowCount++;
         currentStateCount++;
         insertDbCnt++;
         
        }       
       
        for(Map<String,String> map : excelContent){


         setCurrentState("B");
         
         if(    map.get(columnNameList[0]) != null
          && map.get(columnNameList[1]) != null
          && map.get(columnNameList[2]) != null          
          && map.get(columnNameList[7]) != null
          ) {
          
          if(    !map.get(columnNameList[0]).trim().equals("")
           && !map.get(columnNameList[1]).trim().equals("")
           && !map.get(columnNameList[2]).trim().equals("")
           && !map.get(columnNameList[7]).trim().equals("")){
          
           NetSalesReport netSalesReport = new NetSalesReport();          
              
           netSalesReport.setAccountCd(map.get(columnNameList[0]));
           netSalesReport.setCountryCd(map.get(columnNameList[1]));
           netSalesReport.setMedicineCd(map.get(columnNameList[2]));
              
              int iSalesVolumn = 0;
              Double dNetSalesPrice = 0.0;
              Double dNetSales = 0.0;
              
              Double dInvenOnHand = 0.0;
              Double dSampleVials = 0.0;
              Double dDamagedWastedVials = 0.0;      
              Double dExchangeRate = 0.0;
              
              Double ChargebacksRebates = 0.0;
              Double dGovernmentClawback = 0.0;
              
              try{
               if( map.get(columnNameList[3]) != null && !map.get(columnNameList[3]).trim().equals("")){
                iSalesVolumn = Double.valueOf(map.get(columnNameList[3])).intValue();  
               }
               
               if( map.get(columnNameList[4]) != null && !map.get(columnNameList[4]).trim().equals("")){
                dNetSalesPrice = Double.valueOf(map.get(columnNameList[4]));   
               }
               if( map.get(columnNameList[5]) != null && !map.get(columnNameList[5]).trim().equals("")){
                dNetSales = Double.valueOf(map.get(columnNameList[5]));
               }
               if( map.get(columnNameList[8]) != null && !map.get(columnNameList[8]).trim().equals("")){
                dInvenOnHand = Double.valueOf(map.get(columnNameList[8]));         
               }
               if( map.get(columnNameList[9]) != null && !map.get(columnNameList[9]).trim().equals("")){
                dSampleVials = Double.valueOf(map.get(columnNameList[9]));
               }
               if( map.get(columnNameList[10]) != null && !map.get(columnNameList[10]).trim().equals("")){
                dDamagedWastedVials = Double.valueOf(map.get(columnNameList[10]));  
               }
                  if( map.get(columnNameList[11]) != null && !map.get(columnNameList[11]).trim().equals("")){
                   dExchangeRate = Double.valueOf(map.get(columnNameList[11]));
                  }
                  
                  if( map.get(columnNameList[12]) != null && !map.get(columnNameList[12]).trim().equals("")){
                   ChargebacksRebates = Double.valueOf(map.get(columnNameList[12]));
                  }
                  if( map.get(columnNameList[13]) != null && !map.get(columnNameList[13]).trim().equals("")){
                   dGovernmentClawback = Double.valueOf(map.get(columnNameList[13]));
                  }
               
              }catch(Exception ex){
               result = 2;
               break;
              }
              
              netSalesReport.setSalesVolume(iSalesVolumn);
              netSalesReport.setNetSalesPrice(dNetSalesPrice.longValue());
              netSalesReport.setNetSales(dNetSales.longValue());
              
              netSalesReport.setCurrencyCd(map.get(columnNameList[6]));
              netSalesReport.setSalesDate(map.get(columnNameList[7]));
              
              netSalesReport.setInvenOnHand(String.valueOf(dInvenOnHand));
              netSalesReport.setSampleVials(String.valueOf(dSampleVials));
              netSalesReport.setDamagedWastedVials(String.valueOf(dDamagedWastedVials));
              netSalesReport.setExchangeRate(String.valueOf(dExchangeRate));
              
              netSalesReport.setChargebacksRebates(String.valueOf(ChargebacksRebates));
              netSalesReport.setGovernmentClawback(String.valueOf(dGovernmentClawback));         
              
              netSalesReportList.add(netSalesReport);
          }
         }


         successRowCount++;
         currentStateCount++;
         insertDbCnt++;
        }
  
   if (logger.isDebugEnabled()){
    logger.debug("==========> Excel Line. : "+String.valueOf(insertDbCnt));
    logger.debug("==========> Data Insert Start. : "+netSalesReportList.size());    
      }


      if( netSalesReportList.size() > 0  && result == 1){
       try{
           successRowCount++;
            currentStateCount++;
            netSalesReportService.addNetSalesReportList(netSalesReportList);
       }catch( Exception e){
        e.printStackTrace();
        result = 4;
       }
      }else{
       result = 3;
      }
 
      if (logger.isDebugEnabled())
    logger.debug("==========> Data Insert End. result:" + result);  
 
  setCurrentState("C");  
  
  return result;
 }

--------------------------------------------------------------------------------------------------------------------

스프링 엑셀업로드 impl입니다.

netSalesReportList.size() ←이거를 Controller에서 출력하려면 어떻게 해야하죠..?

Controller에서 netSalesReportList.size() 에 해당되는 갯수를 메세지창을 띄워 보여주려고 합니다.



0
0
  • 답변 2

  • 야쿠르트
    424
    2018-09-14 22:51:35

    int netSalesReportListSize 라는 변수 선언하고

    자바빈을 만든다음

    	public int getNetSalesReportListSize() {
    		return netSalesReportListSize;
    	}
    
    
    	public void setNetSalesReportListSize(int netSalesReportListSize) {
    		this.netSalesReportListSize = netSalesReportListSize;
    	}
    	

      logger.debug("==========> Data Insert Start. : "+netSalesReportList.size());    

    위 위치에 setNetSalesReportListSize(netSalesReportList.size());



    1
  • 더미
    10k
    2018-09-14 22:52:04

    리턴해주면 되죠...

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.