Example #1
0
 /**
  * @param status
  * @throws SQLException 更新胆码表状态内容
  */
 private void updateDanMaStatus(Fast3SiMa fast3SiMa) throws SQLException {
   Connection conn = ConnectSrcDb.getSrcConnection();
   String sql =
       "UPDATE "
           + App.simaTbName
           + " SET DROWN_ISSUE_NUMBER=?,DROWN_NUMBER=?,status = ?,DROWN_CYCLE=?  where ID = ?";
   // System.out.println(sql);
   PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(sql);
   pstmt.setString(1, fast3SiMa.getDrownIssueNumber());
   pstmt.setString(2, fast3SiMa.getDrownNumber());
   pstmt.setString(3, fast3SiMa.getStatus());
   pstmt.setInt(4, fast3SiMa.getDrownCycle());
   pstmt.setInt(5, fast3SiMa.getId());
   pstmt.executeUpdate();
 }
Example #2
0
 /**
  * @Description: 在源库中查找最新的预测计划,并保证期号在预测范围内,否则报错
  *
  * @author [email protected]
  * @date Feb 15, 2016 3:29:13 PM
  * @return
  */
 public Fast3SiMa getSiMaYuceRecordByIssueCode(String issueNumber) {
   Connection srcConn = ConnectSrcDb.getSrcConnection();
   PreparedStatement pstmt = null;
   Fast3SiMa data = null;
   String sql =
       "SELECT ID,YUCE_ISSUE_START,YUCE_ISSUE_STOP,DROWN_PLAN,DROWN_CYCLE,DROWN_ISSUE_NUMBER  FROM "
           + App.simaTbName
           + " WHERE "
           + issueNumber
           + " BETWEEN YUCE_ISSUE_START AND YUCE_ISSUE_STOP   ORDER BY ID DESC LIMIT 1";
   try {
     pstmt = (PreparedStatement) srcConn.prepareStatement(sql);
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) {
       data = new Fast3SiMa();
       data.setId(rs.getInt(1));
       data.setYuceIssueStart(rs.getString(2));
       data.setYuceIssueStop(rs.getString(3));
       data.setDrownPlan(rs.getString(4));
       data.setDrownCycle(rs.getInt(5));
       data.setDrownIssueNumber(rs.getString(6));
     }
     if (rs != null && !rs.isClosed()) {
       rs.close();
     }
   } catch (SQLException e) {
     LogUtil.error(e.getMessage(), "sima");
   }
   return data;
 }
Example #3
0
 /**
  * 代码入库主方法
  *
  * @param issueCode
  */
 public void execSima(String issueNumber, Fast3SiMa fast3SiMa) throws SQLException {
   // 获取即将预测的20数据
   List<SrcDataBean> noList =
       this.getYucePool(issueNumber.substring(issueNumber.length() - 2, issueNumber.length()));
   // 计算出现次数最多的数组
   List<Fast3Count> fast3CountList = this.getTimesForNumber(noList); // 计算胆码
   Collections.sort(fast3CountList);
   // 插入新纪录时需要判断
   if (fast3SiMa == null || fast3SiMa.getDrownCycle() > 0) { // drowncycle = 0说明是新生成的记录,无需再一次生成
     insertData2Db(issueNumber, fast3CountList);
   }
 }
Example #4
0
 /**
  * @param number
  * @param fast3DanMa
  * @return 判断中出状态
  */
 private String judgeDownStatus(SrcDataBean number, Fast3SiMa fast3SiMa) {
   String status = "1"; // 假设中出
   int[] numArr = {number.getNo1(), number.getNo2(), number.getNo3()};
   String drownPlan = fast3SiMa.getDrownPlan();
   for (int i = 0; i < numArr.length; i++) {
     if (drownPlan.indexOf(Integer.toString(numArr[i])) >= 0) {
       continue;
     } else {
       status = "0"; // 没中
       break;
     }
   }
   // System.out.println("status="+status);
   return status;
 }
Example #5
0
 public void execDrawnSima(String issueNumber) throws SQLException {
   // 获取开奖信息
   SrcDataBean srcDataBean = this.getRecordByIssueNumber(issueNumber);
   // 获取预测计划
   Fast3SiMa fast3SiMa = getSiMaYuceRecordByIssueCode(issueNumber);
   // 判断中出情况
   if (fast3SiMa != null) {
     if (!issueNumber.equals(fast3SiMa.getDrownIssueNumber())) { // 避免反复执行该段代码,有时重启程序时可能有的问题
       String status = judgeDownStatus(srcDataBean, fast3SiMa);
       // 将状态结果入库,并判断是否需要生成新的计划
       if (status == "1") { // 预测结果中出
         fast3SiMa.setDrownCycle(fast3SiMa.getDrownCycle() + 1);
         fast3SiMa.setDrownIssueNumber(issueNumber);
         fast3SiMa.setDrownNumber(
             Integer.toString(srcDataBean.getNo1())
                 + Integer.toString(srcDataBean.getNo2())
                 + Integer.toString(srcDataBean.getNo3()));
         fast3SiMa.setStatus(status);
         // 更新结果内容
         this.updateDanMaStatus(fast3SiMa);
         // 中出后立即启动新的预测计划
         execSima(issueNumber, fast3SiMa);
       } else {
         fast3SiMa.setDrownCycle(fast3SiMa.getDrownCycle() + 1);
         fast3SiMa.setDrownIssueNumber(issueNumber);
         fast3SiMa.setDrownNumber(
             Integer.toString(srcDataBean.getNo1())
                 + Integer.toString(srcDataBean.getNo2())
                 + Integer.toString(srcDataBean.getNo3()));
         fast3SiMa.setStatus(status);
         this.updateDanMaStatus(fast3SiMa);
         if (fast3SiMa.getDrownCycle() == 3) {
           execSima(issueNumber, fast3SiMa);
         }
       }
     }
   } else {
     execSima(issueNumber, fast3SiMa);
   }
 }