Пример #1
0
  @Override
  public void verifyAllRedFormulaCaclVerifyMulForcast(int spaceNum, int forcastSpaceNum) {

    // 1.获取开始期和结束期范围内的预测数据
    List<BaseEntity> forcasts =
        getBaseDao()
            .find(
                " from RedFormulaCaclMulForcast a where a.verified = false and a.spaceNum = ? and a.forcastSpaceNum = ?",
                new Integer[] {spaceNum, forcastSpaceNum});

    for (int i = 0; i < forcasts.size(); i++) {
      RedFormulaCaclMulForcast forcast = (RedFormulaCaclMulForcast) forcasts.get(i);
      int targetSsqIndex = forcast.getTargetSsqIndex();

      SsqRecord record = ssqRecordDao.findSsqRecordBySsqIndex(targetSsqIndex);
      if (record == null) {
        return;
      }

      String careNums = forcast.getCareNums();
      String killNums = forcast.getKillNums();
      String selectNums = forcast.getSelectNums();

      Map<String, String> coldHotMap = new HashMap<String, String>();

      coldHotMap.put(String.valueOf(record.getR1()), null);
      coldHotMap.put(String.valueOf(record.getR2()), null);
      coldHotMap.put(String.valueOf(record.getR3()), null);
      coldHotMap.put(String.valueOf(record.getR4()), null);
      coldHotMap.put(String.valueOf(record.getR5()), null);
      coldHotMap.put(String.valueOf(record.getR6()), null);

      String careNumsResult = "";
      String killNumsResult_right = "";
      String killNumsResult_error = "";
      String selectNumsResult = "";

      if (StringUtils.hasLength(careNums)) {
        String[] strs = careNums.split(",");
        for (int j = 0; j < strs.length; j++) {
          if (coldHotMap.containsKey(strs[j])) {
            careNumsResult = careNumsResult + strs[j] + ",";
          }
        }
      }

      if (StringUtils.hasLength(killNums)) {
        String[] strs = killNums.split(",");
        for (int j = 0; j < strs.length; j++) {
          if (coldHotMap.containsKey(strs[j])) {
            killNumsResult_error = killNumsResult_error + strs[j] + ",";
          } else {
            killNumsResult_right = killNumsResult_right + strs[j] + ",";
          }
        }
      }

      if (StringUtils.hasLength(selectNums)) {
        String[] strs = selectNums.split(",");
        for (int j = 0; j < strs.length; j++) {
          if (coldHotMap.containsKey(strs[j])) {
            selectNumsResult = selectNumsResult + strs[j] + ",";
          }
        }
      }

      forcast.setCareNumsResult(careNumsResult);

      String tmp = "";
      if (StringUtils.hasLength(killNumsResult_right)) {
        tmp = tmp + "杀对:" + killNumsResult_right;
      }
      if (StringUtils.hasLength(killNumsResult_error)) {
        tmp = tmp + "  杀错:" + killNumsResult_error;
      }
      forcast.setKillNumsResult(tmp);

      forcast.setSelectNumsResult(selectNumsResult);

      writeKillErrorFormula(forcast);
      writeSelectRightFormula(forcast);

      forcast.setVerified(true);

      // 修改保存
      getBaseDao().update(forcast);
    }
  }
Пример #2
0
  @Override
  public void verifyAllRedFormula() throws Exception {

    // 删除所有RedFormulaCaclVerify
    //		getBaseDao().deleteByHql("delete from RedFormulaCaclVerify");

    List<RedFormula> redFormulaes = getFormulaDao().findRedFormulasByHql("from RedFormula");

    // 获取还未验证过的红球公式计算值
    List<BaseEntity> redFormulaCacles =
        getFormulaDao()
            .find(
                "from RedFormulaCacl where ssqIndex > ( select max(ssqIndex) from RedFormulaCaclVerify ) ");

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

    for (int i = 0; i < redFormulaCacles.size(); i++) {

      RedFormulaCaclVerify caclVerify = new RedFormulaCaclVerify();

      RedFormulaCacl redFormulaCacl = (RedFormulaCacl) redFormulaCacles.get(i);

      caclVerify.setSsqIndex(redFormulaCacl.getSsqIndex());

      int targetSsqIndex = redFormulaCacl.getTargetSsqIndex();

      caclVerify.setTargetSsqIndex(targetSsqIndex);

      // 获取目标期的双色球开奖记录
      SsqRecord targetSsqRecord = ssqRecordDao.findSsqRecordBySsqIndex(targetSsqIndex);

      if (targetSsqRecord == null) {
        continue;
      }

      Map<Integer, String> redMap = new HashMap<Integer, String>();
      redMap.put(targetSsqRecord.getR1(), null);
      redMap.put(targetSsqRecord.getR2(), null);
      redMap.put(targetSsqRecord.getR3(), null);
      redMap.put(targetSsqRecord.getR4(), null);
      redMap.put(targetSsqRecord.getR5(), null);
      redMap.put(targetSsqRecord.getR6(), null);

      for (int j = 0; j < redFormulaes.size(); j++) {
        RedFormula redFormula = redFormulaes.get(j);

        String formulaName = redFormula.getName();

        // 获取计算值
        formulaName = formulaName.substring(0, 1).toUpperCase() + formulaName.substring(1);

        // 根据公式名称反射赋值到RedFormulaCacl对应字段
        String methodName = "get" + formulaName + "Value";
        Method method = null;
        if (methodMap1.get(methodName) == null) {
          method = RedFormulaCacl.class.getMethod(methodName);
          methodMap1.put(methodName, method);
        } else {
          method = methodMap1.get(methodName);
        }

        int result = ((Integer) method.invoke(redFormulaCacl)).intValue();

        boolean killRight = false;
        if (!redMap.containsKey(result)) {
          killRight = true;
        }

        methodName = "setKill" + formulaName + "Right";
        Method method1 = null;
        if (methodMap2.get(methodName) == null) {
          method1 = RedFormulaCaclVerify.class.getMethod(methodName, boolean.class);
          methodMap2.put(methodName, method1);
        } else {
          method1 = methodMap2.get(methodName);
        }
        method1.invoke(caclVerify, killRight);
      }
      caclVerifies.add(caclVerify);
    }

    getBaseDao().batchAddBaseEntityes(caclVerifies);
  }