/**
 *
 */
package com.foc.offline;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.io.IOUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.foc.flightdynamics.bean.FlightDynamicsBean;

/**
 * 
 * @team BBDTEK IT Team
 * @author renmb
 * @version 1.0
 * @time  2017年1月3日
 */
public class PageNumTestMain {

    /**
     * 
     * @author renmb
     * @time  2017年1月3日
     * @param args
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    public static void main(String[] args) throws FileNotFoundException, IOException {
        // TODO Auto-generated method stub
        String text = IOUtils.toString(new FileInputStream("C:\\Users\\owner\\Desktop\\120221.dynamics.json"));
        JSONObject result = JSON.parseObject(text);
        JSONObject dataJson = (JSONObject) result.get("data");
        JSONArray  jsonArray = (JSONArray) dataJson.get("apiResp");
        
//        Set<String> sets = new HashSet<>();

        
        List<FlightDynamicsBean> flightDynamicsBeans = JSONObject.parseArray(jsonArray.toJSONString(),
                FlightDynamicsBean.class);
        if (flightDynamicsBeans != null) {
            int index=0;
            int size = flightDynamicsBeans.size();
            for (FlightDynamicsBean flightDynamicsBean : flightDynamicsBeans) {
                try {
                    index++; 
                    System.out.print("【DYNAMIC】第【"+index+"/"+size+"】条【"+flightDynamicsBean.getFlightNo()+"】"
                            + "【"+flightDynamicsBean.getDatopChn()+"】"
                                    + "【"+flightDynamicsBean.getDepStn()+"】"
                                            + "【"+flightDynamicsBean.getArrStn()+"】"
                                                    + "【"+flightDynamicsBean.getStatus()+"】"
                    + "【"+flightDynamicsBean.getSta()+"】"
                    + "【"+flightDynamicsBean.getStd()+"】");
                    System.out.println("【正常】");
                } catch (Exception e) {
                    // TODO: handle exception
                    
                    System.out.println("【异常】");
                }
            }
        }
        System.out.println("总条数："+jsonArray.size());
    }

}
