 package com.connor.erp.materialquery;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
import java.util.Map.Entry;

import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.input.SAXBuilder;

import com.teamcenter.rac.appearanceconfiguration.ApprAttrPanel.listListener;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
 public class StockReadXMLStr {
   public static void xmlElements(File xmlFilePath, Map<String, List<String[]>> map) {
/*  36 */     SAXBuilder sb = new SAXBuilder();
     try {
/*  39 */       Document doc = sb.build(xmlFilePath);
/*  41 */       Element root = doc.getRootElement();
///*  42 */       loadElements(root.getChildren(), map);
/*  43 */     } catch (JDOMException e) {
/*  44 */       e.printStackTrace();
/*  45 */     } catch (IOException e) {
/*  46 */       e.printStackTrace();
     } 
   }
   
   public static void loadElements(Map<String, Object> inprocessInfoMap, Map<String, List<String[]>> map) {
/*  51 */     int inprocessInfoMapSize = inprocessInfoMap.size();
/*  52 */     if (inprocessInfoMapSize == 0)
       return; 
			  for(Entry<String, Object> entry:inprocessInfoMap.entrySet()) {
				  /*  62 */         List<String[]> list = (List)new ArrayList<String>();
				  JSONObject jsonObject = JSONObject.fromObject(entry.getValue());
				  /*  59 */       String segment1_value = entry.getKey();
				  /*  60 */       String name_value = jsonObject.getString("itemName");
				  JSONObject jsonObject2 = jsonObject.getJSONObject("itemQty");
				  JSONArray jsonArray = jsonObject2.getJSONArray("ORG_NHL");
				  if(!jsonArray.isEmpty()) {
					  for(int i=0;i<jsonArray.size();i++) {
						  List<Quantity> quantityList = (List<Quantity>)JSONArray.toList(jsonArray,Quantity.class);
						  for(Quantity q:quantityList) {
							  /*  87 */                     String[] tableData = new String[5];
							  /*  88 */                     tableData[0] = segment1_value;
							  /*  89 */                     tableData[1] = name_value;
							  /*  90 */                     tableData[2] = "主组织";					  
							  /*  90 */                     tableData[3] = q.getSubInv();					  
							  /*  90 */                     tableData[4] = q.getQty();	
							  list.add(tableData);
							  
						  }
					  }
				  }
				  jsonArray = jsonObject2.getJSONArray("ORG_NSC");
				  if(!jsonArray.isEmpty()) {
					  for(int i=0;i<jsonArray.size();i++) {
						  List<Quantity> quantityList = (List<Quantity>)JSONArray.toList(jsonArray,Quantity.class);
						  for(Quantity q:quantityList) {
							  /*  87 */                     String[] tableData = new String[5];
							  /*  88 */                     tableData[0] = segment1_value;
							  /*  89 */                     tableData[1] = name_value;
							  /*  90 */                     tableData[2] = "生产组织";					  
							  /*  90 */                     tableData[3] = q.getSubInv();					  
							  /*  90 */                     tableData[4] = q.getQty();	
							  list.add(tableData);
							  
						  }
					  }
				  }
				  jsonArray = jsonObject2.getJSONArray("ORG_NBJ");
				  if(!jsonArray.isEmpty()) {
					  for(int i=0;i<jsonArray.size();i++) {
						  List<Quantity> quantityList = (List<Quantity>)JSONArray.toList(jsonArray,Quantity.class);
						  for(Quantity q:quantityList) {
							  /*  87 */                     String[] tableData = new String[5];
							  /*  88 */                     tableData[0] = segment1_value;
							  /*  89 */                     tableData[1] = name_value;
							  /*  90 */                     tableData[2] = "备件组织";					  
							  /*  90 */                     tableData[3] = q.getSubInv();					  
							  /*  90 */                     tableData[4] = q.getQty();	
							  list.add(tableData);
							  
						  }
					  }
				  }
				  jsonArray = jsonObject2.getJSONArray("ORG_NSC");
				  if(!jsonArray.isEmpty()) {
					  for(int i=0;i<jsonArray.size();i++) {
						  List<Quantity> quantityList = (List<Quantity>)JSONArray.toList(jsonArray,Quantity.class);
						  for(Quantity q:quantityList) {
							  /*  87 */                     String[] tableData = new String[5];
							  /*  88 */                     tableData[0] = segment1_value;
							  /*  89 */                     tableData[1] = name_value;
							  /*  90 */                     tableData[2] = "非生产组织";					  
							  /*  90 */                     tableData[3] = q.getSubInv();					  
							  /*  90 */                     tableData[4] = q.getQty();	
							  list.add(tableData);
							  
						  }
					  }
				  }
/* 192 */         map.put(segment1_value, list);
//       } 
//     } 
   }
   }
 }

