예제 #1
0
 /**
  * @Description: 在源库中查找最新的期号
  *
  * @author songjia
  * @date Feb 15, 2016 3:29:13 PM
  * @return
  */
 public SrcDataBean getRecordByIssueNumber(String issueNumber) {
   Connection srcConn = ConnectSrcDb.getSrcConnection();
   PreparedStatement pstmt = null;
   SrcDataBean srcDataBean = null;
   String sql =
       "SELECT issue_number,no1,no2,no3 FROM "
           + App.srcNumberTbName
           + " WHERE ISSUE_NUMBER = '"
           + issueNumber
           + "'";
   try {
     pstmt = (PreparedStatement) srcConn.prepareStatement(sql);
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) {
       srcDataBean = new SrcDataBean();
       srcDataBean.setIssueId(rs.getString(1));
       srcDataBean.setNo1(rs.getInt(2));
       srcDataBean.setNo2(rs.getInt(3));
       srcDataBean.setNo3(rs.getInt(4));
     }
     if (rs != null && !rs.isClosed()) {
       rs.close();
     }
   } catch (SQLException e) {
     LogUtil.error(e.getMessage(), "sima");
   }
   return srcDataBean;
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * @Description: 根据期号在源数据库中获取记录
  *
  * @author [email protected]
  * @date Feb 15, 2016 4:24:40 PM
  * @param issueId
  * @return
  */
 public List<SrcDataBean> getYucePool(String issueCode) {
   Connection srcConn = ConnectSrcDb.getSrcConnection();
   List<SrcDataBean> srcList = new ArrayList<SrcDataBean>();
   PreparedStatement pstmt = null;
   String startDay = DateUtil.getNextNDay(-7);
   // System.out.println("开始日期"+startDay);
   String endDay = DateUtil.getNextNDay(-1);
   // System.out.println("结束日期"+endDay);
   String code1 = DateUtil.getNextIssueCodeByCurrentIssue(issueCode);
   String code2 = DateUtil.getNextIssueCodeByCurrentIssue(code1);
   String code3 = DateUtil.getNextIssueCodeByCurrentIssue(code2);
   String sql =
       "SELECT issue_number,no1,no2,no3 FROM "
           + App.srcNumberTbName
           + " WHERE substr(ISSUE_NUMBER,1,6) between '"
           + startDay
           + "' and '"
           + endDay
           + "' AND substr(ISSUE_NUMBER,8) IN ('"
           + code1
           + "','"
           + code2
           + "','"
           + code3
           + "') ORDER BY ISSUE_NUMBER DESC";
   // System.out.println(sql);
   try {
     pstmt = (PreparedStatement) srcConn.prepareStatement(sql);
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) {
       SrcDataBean srcDataBean = new SrcDataBean();
       srcDataBean.setIssueId(rs.getString(1));
       srcDataBean.setNo1(rs.getInt(2));
       srcDataBean.setNo2(rs.getInt(3));
       srcDataBean.setNo3(rs.getInt(4));
       srcList.add(srcDataBean);
     }
     if (rs != null && !rs.isClosed()) {
       rs.close();
     }
   } catch (SQLException e) {
     e.printStackTrace();
     LogUtil.error(e.getMessage(), "sima/");
   }
   // System.out.println(srcList.size());
   return srcList;
 }
예제 #4
0
 /**
  * 通过最近20天数据统计出现次数
  *
  * @param noList
  * @return
  */
 public List<Fast3Count> getTimesForNumber(List<SrcDataBean> noList) {
   List<Fast3Count> fast3CountList =
       new ArrayList<Fast3Count>(); // 一维0 代表最近7期出现次数,1为最近14期出现次数,2为最近20天出现次数
   int[] arr3 = {0, 0, 0, 0, 0, 0};
   int[] arr5 = {0, 0, 0, 0, 0, 0};
   int[] arr7 = {0, 0, 0, 0, 0, 0};
   int i = 0;
   for (SrcDataBean no : noList) {
     int[] temp = {no.getNo1(), no.getNo2(), no.getNo3()};
     Integer[] numIntArr = getUniqueArr(temp);
     if (i < 9) {
       for (int j = 0; j < numIntArr.length; j++) {
         arr3[numIntArr[j] - 1]++;
       }
     }
     if (i < 15) {
       for (int j = 0; j < numIntArr.length; j++) {
         arr5[numIntArr[j] - 1]++;
       }
     }
     if (i < 21) {
       for (int j = 0; j < numIntArr.length; j++) {
         arr7[numIntArr[j] - 1]++;
       }
     }
     i++;
   }
   for (int j = 0; j < 6; j++) {
     Fast3Count fast3Count = new Fast3Count();
     fast3Count.setNumber(j + 1);
     fast3Count.setCount7(arr3[j]);
     fast3Count.setCount14(arr5[j]);
     fast3Count.setCount20(arr7[j]);
     fast3CountList.add(fast3Count);
   }
   return fast3CountList;
 }
예제 #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);
   }
 }