示例#1
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;
 }
示例#2
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;
 }
示例#3
0
 /**
  * @param issueNumber
  * @return 根据期数获取期号
  */
 private String getIssueCodeByIssueNumber(String issueNumber) {
   if (issueNumber != null && issueNumber.length() > 2) {
     return issueNumber.substring(issueNumber.length() - 2, issueNumber.length());
   } else {
     LogUtil.error("获取期号错误!", "sima");
     return null;
   }
 }
示例#4
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;
 }
示例#5
0
 /**
  * @Description: 在源库中查找最新的期号
  *
  * @author [email protected]
  * @date Feb 15, 2016 3:29:13 PM
  * @return
  */
 public boolean hasRecordByIssueNumber(String issueNumber, String tbName) {
   Connection srcConn = ConnectSrcDb.getSrcConnection();
   boolean flag = false;
   int count = 0;
   PreparedStatement pstmt = null;
   String sql =
       "SELECT count(*) count FROM " + tbName + " where issue_number = '" + issueNumber + "'";
   try {
     pstmt = (PreparedStatement) srcConn.prepareStatement(sql);
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) {
       count = rs.getInt(1);
     }
     if (count > 0) {
       flag = true;
     }
     if (rs != null && !rs.isClosed()) {
       rs.close();
     }
   } catch (SQLException e) {
     LogUtil.error(e.getMessage(), "sima");
   }
   return flag;
 }