Esempio n. 1
0
  /**
   * 生成所有红球公式计算值正确性多期统计表
   *
   * @param spaceNum
   * @throws Exception
   */
  @Override
  public void writeAllRedFormulaCaclVerifyMulStats(int spaceNum) throws Exception {

    List<BaseEntity> mulStatsList = new ArrayList<BaseEntity>();

    // 取出所有红球公式
    List<RedFormula> redFormulaes = getFormulaDao().findRedFormulasByHql("from RedFormula");

    // 1.删除所有的红球公式计算值正确性多期统计表
    //		getSsqRecordDao()
    //				.deleteByHql(
    //						"delete from RedFormulaCaclMulStats a where a.spaceNum = ?",
    //						new Integer[] { spaceNum });

    // 2.取出所有红球公式计算值正确性单期统计信息
    int maxFromSsqIndex =
        ssqRecordDao.getFunctionIntValue(
            "select max(fromSsqIndex) from RedFormulaCaclMulStats  where spaceNum = ? ",
            new Object[] {spaceNum});

    List<BaseEntity> statses =
        getBaseDao()
            .find(
                "from RedFormulaCaclVerify where targetSsqIndex > ? order by targetSsqIndex",
                new Object[] {maxFromSsqIndex});

    // 计算多期统计总记录数
    int mulCount = statses.size() - spaceNum + 1;

    for (int i = 0; i < mulCount; i++) {

      List<RedFormulaCaclVerify> tmp = new ArrayList<RedFormulaCaclVerify>();

      for (int j = i, index = 0; index < spaceNum; index++, j++) {
        tmp.add((RedFormulaCaclVerify) statses.get(j));
      }

      // 生成一条红球公式计算值正确性多期统计表信息
      RedFormulaCaclMulStats mulStats = buildARedFormulaCaclMulStats(tmp, redFormulaes);

      mulStatsList.add(mulStats);
    }

    getSsqRecordDao().batchAddBaseEntityes(mulStatsList);
  }
Esempio n. 2
0
  /**
   * 生成所有红球公式计算值正确性多期预测表
   *
   * @param spaceNum
   * @throws Exception
   */
  @Override
  public void writeAllRedFormulaCaclVerifyMulForcast(int spaceNum, int forcastSpaceNum)
      throws Exception {

    List<BaseEntity> forcastList = new ArrayList<BaseEntity>();

    // 取出所有红球公式
    List<RedFormula> redFormulaes = getFormulaDao().findRedFormulasByHql("from RedFormula");

    String str =
        " select max(fromSsqIndex) from RedFormulaCaclMulForcast where spaceNum = ? and forcastSpaceNum = ?";
    int maxFromSsqIndex =
        ssqRecordDao.getFunctionIntValue(str, new Object[] {spaceNum, forcastSpaceNum});

    // 2.取出所有红球公式计算值正确性单期统计信息
    String hql =
        "from RedFormulaCaclMulStats a where a.fromSsqIndex>=2007001 and a.fromSsqIndex > ? and a.spaceNum = ? order by a.fromSsqIndex";

    List<BaseEntity> records = getBaseDao().find(hql, new Integer[] {maxFromSsqIndex, spaceNum});

    int forcastCount = records.size() - forcastSpaceNum + 1;

    for (int i = 0; i < forcastCount; i++) {
      int count = 0;

      List<RedFormulaCaclMulStats> tmp = new ArrayList<RedFormulaCaclMulStats>();

      for (int j = i; count < forcastSpaceNum; j++, count++) {
        tmp.add((RedFormulaCaclMulStats) records.get(j));
      }

      RedFormulaCaclMulForcast forcast =
          buildARedFormulaCaclMulForcast(tmp, redFormulaes, forcastSpaceNum);

      forcastList.add(forcast);
    }

    // 批量保存预测数据
    getBaseDao().batchAddBaseEntityes(forcastList);
  }
Esempio n. 3
0
  private RedFormulaCaclMulForcast buildARedFormulaCaclMulForcast(
      List<RedFormulaCaclMulStats> records, List<RedFormula> redFormulaes, int forcastSpaceNum)
      throws Exception {

    RedFormulaCaclMulForcast forcast = new RedFormulaCaclMulForcast();

    int size = records.size();

    int fromSsqIndex = records.get(0).getFromSsqIndex();
    forcast.setFromSsqIndex(fromSsqIndex);

    int toSsqIndex = records.get(size - 1).getToSsqIndex();
    forcast.setToSsqIndex(toSsqIndex);

    int targetSsqIndex =
        ssqRecordDao.getFunctionIntValue(
            "select nextSsqIndex from SsqRecord a where a.ssqIndex = ? ",
            new Integer[] {toSsqIndex});

    forcast.setTargetSsqIndex(targetSsqIndex);

    forcast.setSpaceNum(records.get(0).getSpaceNum());
    forcast.setForcastSpaceNum(forcastSpaceNum);

    for (int j = 0; j < size; j++) {
      RedFormulaCaclMulStats stats = records.get(j);

      for (int i = 0; i < redFormulaes.size(); i++) {
        String formulaName = redFormulaes.get(i).getName();
        formulaName = formulaName.substring(0, 1).toUpperCase() + formulaName.substring(1);

        // 获取原记录数
        String getKillRightCountMethodName = "get" + formulaName + "KillRightCount";
        Method m1 = null;
        if (methodMap3.get(getKillRightCountMethodName) == null) {
          m1 = RedFormulaCaclMulStats.class.getMethod(getKillRightCountMethodName);
          methodMap3.put(getKillRightCountMethodName, m1);
        } else {
          m1 = methodMap3.get(getKillRightCountMethodName);
        }
        int count = ((Integer) m1.invoke(stats)).intValue();

        // 获取最大、最小值
        String getFormulaKillRightMaxCountMethodName = "get" + formulaName + "KillRightMaxCount";
        Method m2 = null;
        if (methodMap6.get(getFormulaKillRightMaxCountMethodName) == null) {
          m2 = RedFormulaCaclMulForcast.class.getMethod(getFormulaKillRightMaxCountMethodName);
          methodMap6.put(getFormulaKillRightMaxCountMethodName, m2);
        } else {
          m2 = methodMap6.get(getFormulaKillRightMaxCountMethodName);
        }
        int maxCount = ((Integer) m2.invoke(forcast)).intValue();

        String getFormulaKillRightMinCountMethodName = "get" + formulaName + "KillRightMinCount";
        Method m3 =
            getMethodInCache(
                getFormulaKillRightMinCountMethodName, RedFormulaCaclMulForcast.class, methodMap7);
        int minCount = ((Integer) m3.invoke(forcast)).intValue();

        // 设置最大、最小值
        String setFormulaKillRightMaxCountMethodName = "set" + formulaName + "KillRightMaxCount";
        Method m4 = null;
        if (methodMap8.get(setFormulaKillRightMaxCountMethodName) == null) {
          m4 =
              RedFormulaCaclMulForcast.class.getMethod(
                  setFormulaKillRightMaxCountMethodName, int.class);
          methodMap8.put(setFormulaKillRightMaxCountMethodName, m4);
        } else {
          m4 = methodMap8.get(setFormulaKillRightMaxCountMethodName);
        }
        m4.invoke(forcast, count > maxCount ? count : maxCount);

        String setFormulaKillRightMinCountMethodName = "set" + formulaName + "KillRightMinCount";
        Method m5 = null;
        if (methodMap9.get(setFormulaKillRightMinCountMethodName) == null) {
          m5 =
              RedFormulaCaclMulForcast.class.getMethod(
                  setFormulaKillRightMinCountMethodName, int.class);
          methodMap9.put(setFormulaKillRightMinCountMethodName, m5);
        } else {
          m5 = methodMap9.get(setFormulaKillRightMinCountMethodName);
        }
        m5.invoke(forcast, count < minCount ? count : minCount);
      }
    }

    RedFormulaCaclMulStats lastMulStats = records.get(size - 1);

    // 处理关注数
    dealCareNums(forcast, lastMulStats, redFormulaes);

    // 处理选择的和杀的
    dealKillAndSelectNums(forcast, lastMulStats, redFormulaes);

    return forcast;
  }