SjlrGzdaDAOImpl.java 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. package com.huimv.sjlr.dao;
  2. import java.sql.SQLException;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.orm.ibatis.SqlMapClientCallback;
  6. import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
  7. import com.huimv.busi.xt.constant.XtSqlMapConstant;
  8. import com.huimv.sjlr.dataobject.SjlrGzda;
  9. import com.huimv.sjlr.dataobject.SjlrGzdaExample;
  10. import com.ibatis.sqlmap.client.SqlMapExecutor;
  11. public class SjlrGzdaDAOImpl extends SqlMapClientDaoSupport implements SjlrGzdaDAO {
  12. /**
  13. * This method was generated by Apache iBATIS ibator.
  14. * This method corresponds to the database table sjlr_gzda
  15. *
  16. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  17. */
  18. public SjlrGzdaDAOImpl() {
  19. super();
  20. }
  21. /**
  22. * This method was generated by Apache iBATIS ibator.
  23. * This method corresponds to the database table sjlr_gzda
  24. *
  25. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  26. */
  27. public int countByExample(SjlrGzdaExample example) {
  28. Integer count = (Integer) getSqlMapClientTemplate().queryForObject("sjlr_gzda.ibatorgenerated_countByExample", example);
  29. return count;
  30. }
  31. /**
  32. * This method was generated by Apache iBATIS ibator.
  33. * This method corresponds to the database table sjlr_gzda
  34. *
  35. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  36. */
  37. public int deleteByExample(SjlrGzdaExample example) {
  38. int rows = getSqlMapClientTemplate().delete("sjlr_gzda.ibatorgenerated_deleteByExample", example);
  39. return rows;
  40. }
  41. /**
  42. * This method was generated by Apache iBATIS ibator.
  43. * This method corresponds to the database table sjlr_gzda
  44. *
  45. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  46. */
  47. public int deleteByPrimaryKey(Integer id) {
  48. SjlrGzda key = new SjlrGzda();
  49. key.setId(id);
  50. int rows = getSqlMapClientTemplate().delete("sjlr_gzda.ibatorgenerated_deleteByPrimaryKey", key);
  51. return rows;
  52. }
  53. /**
  54. * This method was generated by Apache iBATIS ibator.
  55. * This method corresponds to the database table sjlr_gzda
  56. *
  57. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  58. */
  59. public void insert(SjlrGzda record) {
  60. getSqlMapClientTemplate().insert("sjlr_gzda.ibatorgenerated_insert", record);
  61. }
  62. /**
  63. * This method was generated by Apache iBATIS ibator.
  64. * This method corresponds to the database table sjlr_gzda
  65. *
  66. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  67. */
  68. public void insertSelective(SjlrGzda record) {
  69. getSqlMapClientTemplate().insert("sjlr_gzda.ibatorgenerated_insertSelective", record);
  70. }
  71. /**
  72. * This method was generated by Apache iBATIS ibator.
  73. * This method corresponds to the database table sjlr_gzda
  74. *
  75. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  76. */
  77. @SuppressWarnings("unchecked")
  78. public List<SjlrGzda> selectByExample(SjlrGzdaExample example) {
  79. List<SjlrGzda> list = getSqlMapClientTemplate().queryForList("sjlr_gzda.ibatorgenerated_selectByExample", example);
  80. return list;
  81. }
  82. /**
  83. * This method was generated by Apache iBATIS ibator.
  84. * This method corresponds to the database table sjlr_gzda
  85. *
  86. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  87. */
  88. public SjlrGzda selectByPrimaryKey(Integer id) {
  89. SjlrGzda key = new SjlrGzda();
  90. key.setId(id);
  91. SjlrGzda record = (SjlrGzda) getSqlMapClientTemplate().queryForObject("sjlr_gzda.ibatorgenerated_selectByPrimaryKey", key);
  92. return record;
  93. }
  94. /**
  95. * This method was generated by Apache iBATIS ibator.
  96. * This method corresponds to the database table sjlr_gzda
  97. *
  98. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  99. */
  100. public int updateByExampleSelective(SjlrGzda record, SjlrGzdaExample example) {
  101. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  102. int rows = getSqlMapClientTemplate().update("sjlr_gzda.ibatorgenerated_updateByExampleSelective", parms);
  103. return rows;
  104. }
  105. /**
  106. * This method was generated by Apache iBATIS ibator.
  107. * This method corresponds to the database table sjlr_gzda
  108. *
  109. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  110. */
  111. public int updateByExample(SjlrGzda record, SjlrGzdaExample example) {
  112. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  113. int rows = getSqlMapClientTemplate().update("sjlr_gzda.ibatorgenerated_updateByExample", parms);
  114. return rows;
  115. }
  116. /**
  117. * This method was generated by Apache iBATIS ibator.
  118. * This method corresponds to the database table sjlr_gzda
  119. *
  120. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  121. */
  122. public int updateByPrimaryKeySelective(SjlrGzda record) {
  123. int rows = getSqlMapClientTemplate().update("sjlr_gzda.ibatorgenerated_updateByPrimaryKeySelective", record);
  124. return rows;
  125. }
  126. /**
  127. * This method was generated by Apache iBATIS ibator.
  128. * This method corresponds to the database table sjlr_gzda
  129. *
  130. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  131. */
  132. public int updateByPrimaryKey(SjlrGzda record) {
  133. int rows = getSqlMapClientTemplate().update("sjlr_gzda.ibatorgenerated_updateByPrimaryKey", record);
  134. return rows;
  135. }
  136. /**
  137. * This class was generated by Apache iBATIS ibator.
  138. * This class corresponds to the database table sjlr_gzda
  139. *
  140. * @ibatorgenerated Wed Mar 08 10:40:08 CST 2017
  141. */
  142. private static class UpdateByExampleParms extends SjlrGzdaExample {
  143. private Object record;
  144. public UpdateByExampleParms(Object record, SjlrGzdaExample example) {
  145. super(example);
  146. this.record = record;
  147. }
  148. public Object getRecord() {
  149. return record;
  150. }
  151. }
  152. /**
  153. * 获取公猪档案列表
  154. * @param parmaMap
  155. * @return
  156. */
  157. public List<SjlrGzda> getGzdaListByParam(Map<String, Object> paramMap) {
  158. @SuppressWarnings("unchecked")
  159. List<SjlrGzda> gzdaList = (List<SjlrGzda>)getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_SJLR_GZDA_BY_PARAM, paramMap);
  160. return gzdaList;
  161. }
  162. // /**
  163. // * 批量更新公猪档案
  164. // */
  165. // public void updateGzdaByExample(List<SjlrGzda> paramMapList) {
  166. // HpSjlrGzdaSqlMapClientCallback hpSjlrGzdaSqlMapClientCallback = new HpSjlrGzdaSqlMapClientCallback();
  167. // hpSjlrGzdaSqlMapClientCallback.setParamMapList(paramMapList);
  168. // getSqlMapClientTemplate().execute(hpSjlrGzdaSqlMapClientCallback);
  169. // }
  170. //
  171. // /**
  172. // * 回调
  173. // */
  174. // private class HpSjlrGzdaSqlMapClientCallback implements SqlMapClientCallback {
  175. // private List<SjlrGzda> paramMapList;
  176. //
  177. // public void setParamMapList(List<SjlrGzda> paramMapList) {
  178. // this.paramMapList = paramMapList;
  179. // }
  180. //
  181. // @Override
  182. // public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
  183. // executor.startBatch();
  184. // for (SjlrGzda sjlrGzda : paramMapList) {
  185. // executor.update("sjlr_gzda.ibatorgenerated_updateByExampleSelective", sjlrGzda);
  186. // }
  187. // executor.executeBatch();
  188. // return null;
  189. // }
  190. // }
  191. public void updatGzdaByParam(List<SjlrGzda> paramMapList,List<SjlrGzdaExample> gzdaExList) {
  192. HpSjlrGzdaSqlMapClientCallback hpSjlrGzdaSqlMapClientCallback = new HpSjlrGzdaSqlMapClientCallback();
  193. hpSjlrGzdaSqlMapClientCallback.setgzdaList(paramMapList);
  194. hpSjlrGzdaSqlMapClientCallback.setgzdaExList(gzdaExList);
  195. getSqlMapClientTemplate().execute(hpSjlrGzdaSqlMapClientCallback);
  196. }
  197. //回调
  198. public class HpSjlrGzdaSqlMapClientCallback implements SqlMapClientCallback {
  199. private List<SjlrGzda> sjlrGzdaList ;
  200. private List<SjlrGzdaExample> gzdaExList ;
  201. public void setgzdaList(List<SjlrGzda> sjlrGzdaList) {
  202. this.sjlrGzdaList=sjlrGzdaList;
  203. }
  204. public void setgzdaExList(List<SjlrGzdaExample> sjlrGzdaExList) {
  205. this.gzdaExList=sjlrGzdaExList;
  206. }
  207. public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
  208. executor.startBatch();
  209. for (int i=0;i<sjlrGzdaList.size();i++) {
  210. SjlrGzda sjlrGzda=new SjlrGzda();
  211. sjlrGzda=sjlrGzdaList.get(i);
  212. SjlrGzdaExample sjlrGzdaExample=new SjlrGzdaExample();
  213. sjlrGzdaExample= gzdaExList.get(i);
  214. //更新
  215. UpdateByExampleParms parms = new UpdateByExampleParms(sjlrGzda, sjlrGzdaExample);
  216. executor.update("sjlr_gzda.ibatorgenerated_updateByExampleSelective", parms);
  217. }
  218. executor.executeBatch();
  219. return null;
  220. }
  221. }
  222. @Override
  223. public List<SjlrGzda> selectpzjgByParam(Map<String, Object> paramMap) {
  224. @SuppressWarnings("unchecked")
  225. List<SjlrGzda> gzdaList = (List<SjlrGzda>)getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_SJLR_GZDAPZJG_BY_PARAM, paramMap);
  226. return gzdaList;
  227. }
  228. }