コード例 #1
0
ファイル: Data2DbSima.java プロジェクト: songjiavc/collect
 /**
  * @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
ファイル: Data2DbSima.java プロジェクト: songjiavc/collect
 /**
  * @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;
 }