Package main

Source Code of main.StatOpened

/**
*
*/
package main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import cputils.DataItem;
import cputils.XmlUtils;

/**
* @author zhengweiwei
* @date 2014年8月4日
*/
public class StatOpened {

  public static void main(String[] args) {
    everyPos("ssq");
  }

  public static List<String> everyPos(String type) {
    List<String> resList = new ArrayList<String>();
    XmlUtils utils = new XmlUtils();
    int bMax = 33, bSize = 6, aMax = 16;
    if ("dlt".equals(type)) {
      bMax = 35;
      bSize = 5;
      aMax = 12;
    }
    Map<Integer, Map<Integer, Integer>> posMap = new HashMap<Integer, Map<Integer, Integer>>();
   
    Map<Integer, Integer> dataMap1 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap2 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap3 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap4 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap5 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap6 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> dataMap7 = new HashMap<Integer, Integer>();
   
    Map<Integer, Integer> first2 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> first3 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> first4 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> first5 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> first6 = new HashMap<Integer, Integer>();
    Map<Integer, Integer> first7 = new HashMap<Integer, Integer>();
    for (int i = 1; i <= bMax; i++) {
      first2.put(i, 0);
      first3.put(i, 0);
      first4.put(i, 0);
      first5.put(i, 0);
      dataMap1.put(i, 0);
      dataMap2.put(i, 0);
      dataMap3.put(i, 0);
      dataMap4.put(i, 0);
      dataMap5.put(i, 0);
      if (bSize == 6) {
        dataMap6.put(i, 0);
        first6.put(i, 0);
      }
    }
    for (int i = 1; i <= aMax; i++) {
      if (bSize == 5) {
        dataMap6.put(i, 0);
        first6.put(i, 0);
      }
      dataMap7.put(i, 0);
      first7.put(i, 0);
    }
    List<DataItem> list = null;
    try {
      list = utils.list(type);
      System.out.println("all size:"+list.size());
      for (DataItem item : list) {
        String[] codeArr = item.getOpencode().split(" ");
        Integer[] intCodeArr = new Integer[codeArr.length];
        for (int i = 0; i < codeArr.length; i++) {
          intCodeArr[i] = Integer.parseInt(codeArr[i]);
        }
       
        addMapData(dataMap1,intCodeArr[0]);
        addMapData(dataMap2,intCodeArr[1]);
        addMapData(dataMap3,intCodeArr[2]);
        addMapData(dataMap4,intCodeArr[3]);
        addMapData(dataMap5,intCodeArr[4]);
        addMapData(dataMap6,intCodeArr[5]);
        addMapData(dataMap7,intCodeArr[6]);
       
        addMapData(first2,intCodeArr[0]);
        addMapData(first2,intCodeArr[1]);
       
        addMapData(first3,intCodeArr[0]);
        addMapData(first3,intCodeArr[1]);
        addMapData(first3,intCodeArr[2]);
       
        addMapData(first4,intCodeArr[0]);
        addMapData(first4,intCodeArr[1]);
        addMapData(first4,intCodeArr[2]);
        addMapData(first4,intCodeArr[3]);
       
        addMapData(first5,intCodeArr[0]);
        addMapData(first5,intCodeArr[1]);
        addMapData(first5,intCodeArr[2]);
        addMapData(first5,intCodeArr[3]);
        addMapData(first5,intCodeArr[4]);
       
        if (bSize == 6) {
          addMapData(first6,intCodeArr[0]);
          addMapData(first6,intCodeArr[1]);
          addMapData(first6,intCodeArr[2]);
          addMapData(first6,intCodeArr[3]);
          addMapData(first6,intCodeArr[4]);
          addMapData(first6,intCodeArr[5]);
        }
       
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    posMap.put(1, XmlUtils.makeSortedMap(dataMap1));
    posMap.put(2, XmlUtils.makeSortedMap(dataMap2));
    posMap.put(3, XmlUtils.makeSortedMap(dataMap3));
    posMap.put(4, XmlUtils.makeSortedMap(dataMap4));
    posMap.put(5, XmlUtils.makeSortedMap(dataMap5));
    posMap.put(6, XmlUtils.makeSortedMap(dataMap6));
    posMap.put(7, XmlUtils.makeSortedMap(dataMap7));
    System.out.println("/*****************every position**********************/");
    for (Entry<Integer, Map<Integer, Integer>> tem : posMap.entrySet()) {
      System.out.println(tem.getKey() + ": " + tem.getValue());
    }
    //First two
    System.out.println("/*****************first2 3 4 5 6 7 position**********************/");
    System.out.println("first2:"+XmlUtils.makeSortedMap(first2));
    System.out.println("first3:"+XmlUtils.makeSortedMap(first3));
    System.out.println("first4:"+XmlUtils.makeSortedMap(first4));
    System.out.println("first5:"+XmlUtils.makeSortedMap(first5));
    System.out.println("first6:"+XmlUtils.makeSortedMap(first6));
    System.out.println("first7:"+XmlUtils.makeSortedMap(first7));
   
    System.out.println("/*****************all position**********************/");
    try {
      Map<String, Map<Integer, Integer>> all = utils.stat(type);
      for (Entry<String, Map<Integer, Integer>> tem : all.entrySet()) {
        System.out.println(tem.getKey() + ": " + tem.getValue());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return resList;
  }
  private static void addMapData(Map<Integer, Integer> dataMap,Integer key){
    dataMap.put(key, addCount(dataMap,key));
  }
  private static int addCount(Map<Integer, Integer> dataMap,Integer key){
    return (dataMap.get(key)!=null?dataMap.get(key):0) + 1;
  }
}
TOP

Related Classes of main.StatOpened

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.