f2217cd2e5a8090e14e5cef5ffa03747d17ba331.svn-base 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.bean.NetOrderBean;
  3. import com.chinacreator.process.util.DataSource;
  4. import com.frameworkset.common.poolman.PreparedDBUtil;
  5. import com.frameworkset.common.poolman.SQLExecutor;
  6. import java.sql.SQLException;
  7. import java.util.List;
  8. import org.apache.commons.lang.math.NumberUtils;
  9. import org.apache.log4j.Logger;
  10. import org.springframework.stereotype.Component;
  11. @Component
  12. public class PreToOrderDao
  13. {
  14. private static Logger logger = Logger.getLogger(PreToOrderDao.class);
  15. @SuppressWarnings("unchecked")
  16. public List<NetOrderBean> queryNeedDo()
  17. {
  18. String sql = "select * from td_pre_order_relations where cpid ='tencent' and spid='101' and to_char(ordertime,'yyyymm')<to_char(sysdate,'yyyymm') and SYNCSTATUS=1";
  19. PreparedDBUtil pdb = new PreparedDBUtil();
  20. try {
  21. return pdb.executeSelectForList(DataSource.NET3G, sql, 0,500, NetOrderBean.class);
  22. } catch (Exception e) {
  23. logger.error("查询失败", e);
  24. }
  25. return null;
  26. }
  27. public long getSize() throws SQLException{
  28. String sql = "select count(1) from td_pre_order_relations where cpid ='tencent' and spid='101' and to_char(ordertime,'yyyymm')<to_char(sysdate,'yyyymm') and SYNCSTATUS=1 ";
  29. return NumberUtils.toLong(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql),0);
  30. }
  31. public void update(String id,String status) throws SQLException{
  32. String sql = "update td_pre_order_relations set SYNCSTATUS=? , SYNCTIME=sysdate where id =?";
  33. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, status,id);
  34. }
  35. // public Integer querysize() throws SQLException{
  36. // String sql = "select count(distinct userid) from td_pre_order_relations where cpid ='tencent' and spid='84' and status=0 and to_char(ordertime,'yyyymm')<to_char(sysdate,'yyyymm')";
  37. // return SQLExecutor.queryObjectBeanWithDBName(Integer.class,DataSource.NET3G, sql,null)/500+1;
  38. // }
  39. public static void main(String[] args) throws SQLException {
  40. PreToOrderDao dao = new PreToOrderDao();
  41. // List<String> list = dao.queryNeedDo(0);
  42. // System.out.println(list.size());
  43. // List<String> list2 = dao.queryNeedDo(1);
  44. // System.out.println(list2.size());
  45. // for (String string : list2) {
  46. // for (String str : list) {
  47. // if(string.equals(str)){
  48. // System.out.println(str);
  49. // }
  50. // }
  51. // }
  52. System.out.println(dao.getSize()/500);
  53. }
  54. }