650472e00dec5b8d65a50c6c715647e8533849a4.svn-base 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.chinacreator.process.dao;
  2. import java.sql.SQLException;
  3. import java.util.List;
  4. import javax.annotation.PostConstruct;
  5. import org.springframework.cache.annotation.Cacheable;
  6. import org.springframework.stereotype.Component;
  7. import com.chinacreator.common.dao.CacheableDao;
  8. import com.chinacreator.common.support.cache.annotation.CacheName;
  9. import com.chinacreator.process.bean.OrderConfigBean;
  10. import com.chinacreator.process.util.DataSource;
  11. import com.frameworkset.common.poolman.PreparedDBUtil;
  12. @Component
  13. @CacheName("OrderConfigBean")
  14. public class OrderConfigDao extends CacheableDao{
  15. @SuppressWarnings("unchecked")
  16. @PostConstruct
  17. public void loadCache() throws SQLException {
  18. PreparedDBUtil pdb = new PreparedDBUtil();
  19. String sql = "select * from TB_CHANNELORDER_CONFIG where status = 0 ";
  20. List<OrderConfigBean> orderConfigBeans = pdb.executeSelectForList(DataSource.SDK, sql, OrderConfigBean.class);
  21. for(OrderConfigBean orderConfigBean : orderConfigBeans) {
  22. addCache("OrderConfigBean", orderConfigBean.getVacproductid(), orderConfigBean);
  23. }
  24. }
  25. @Cacheable(value="OrderConfigBean", key="#vacproductid")
  26. public OrderConfigBean findByProductid(String vacproductid){
  27. PreparedDBUtil pdb = new PreparedDBUtil();
  28. String sql = "select * from TB_CHANNELORDER_CONFIG where vacproductid = ? and status = 0";
  29. try {
  30. pdb.preparedSelect(DataSource.SDK, sql);
  31. pdb.setString(1, vacproductid);
  32. return (OrderConfigBean) pdb.executePreparedForObject(OrderConfigBean.class);
  33. } catch (SQLException e) {
  34. e.printStackTrace();
  35. }
  36. return null;
  37. }
  38. }