DaZsdaDAOImpl.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. package com.huimv.da.dao;
  2. import java.sql.SQLException;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.springframework.orm.ibatis.SqlMapClientCallback;
  7. import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
  8. import com.huimv.busi.base.dto.ResponseBean;
  9. import com.huimv.busi.da.dto.DaZsdaDTO;
  10. import com.huimv.busi.xt.constant.XtSqlMapConstant;
  11. import com.huimv.da.dataobject.DaZsda;
  12. import com.huimv.da.dataobject.DaZsdaExample;
  13. import com.huimv.web.base.PageBean;
  14. import com.ibatis.sqlmap.client.SqlMapExecutor;
  15. public class DaZsdaDAOImpl extends SqlMapClientDaoSupport implements DaZsdaDAO {
  16. /**
  17. * This method was generated by Apache iBATIS ibator. This method
  18. * corresponds to the database table da_zsda
  19. *
  20. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  21. */
  22. public DaZsdaDAOImpl() {
  23. super();
  24. }
  25. /**
  26. * This method was generated by Apache iBATIS ibator. This method
  27. * corresponds to the database table da_zsda
  28. *
  29. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  30. */
  31. public int countByExample(DaZsdaExample example) {
  32. Integer count = (Integer) getSqlMapClientTemplate().queryForObject("da_zsda.ibatorgenerated_countByExample",
  33. example);
  34. return count;
  35. }
  36. /**
  37. * This method was generated by Apache iBATIS ibator. This method
  38. * corresponds to the database table da_zsda
  39. *
  40. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  41. */
  42. public int deleteByExample(DaZsdaExample example) {
  43. int rows = getSqlMapClientTemplate().delete("da_zsda.ibatorgenerated_deleteByExample", example);
  44. return rows;
  45. }
  46. /**
  47. * This method was generated by Apache iBATIS ibator. This method
  48. * corresponds to the database table da_zsda
  49. *
  50. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  51. */
  52. public int deleteByPrimaryKey(Integer id) {
  53. DaZsda key = new DaZsda();
  54. key.setId(id);
  55. int rows = getSqlMapClientTemplate().delete("da_zsda.ibatorgenerated_deleteByPrimaryKey", key);
  56. return rows;
  57. }
  58. /**
  59. * This method was generated by Apache iBATIS ibator. This method
  60. * corresponds to the database table da_zsda
  61. *
  62. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  63. */
  64. public void insert(DaZsda record) {
  65. getSqlMapClientTemplate().insert("da_zsda.ibatorgenerated_insert", record);
  66. }
  67. /**
  68. * This method was generated by Apache iBATIS ibator. This method
  69. * corresponds to the database table da_zsda
  70. *
  71. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  72. */
  73. public void insertSelective(DaZsda record) {
  74. getSqlMapClientTemplate().insert("da_zsda.ibatorgenerated_insertSelective", record);
  75. }
  76. /**
  77. * This method was generated by Apache iBATIS ibator. This method
  78. * corresponds to the database table da_zsda
  79. *
  80. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  81. */
  82. @SuppressWarnings("unchecked")
  83. public List<DaZsda> selectByExample(DaZsdaExample example) {
  84. List<DaZsda> list = getSqlMapClientTemplate().queryForList("da_zsda.ibatorgenerated_selectByExample", example);
  85. return list;
  86. }
  87. /**
  88. * This method was generated by Apache iBATIS ibator. This method
  89. * corresponds to the database table da_zsda
  90. *
  91. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  92. */
  93. public DaZsda selectByPrimaryKey(Integer id) {
  94. DaZsda key = new DaZsda();
  95. key.setId(id);
  96. DaZsda record = (DaZsda) getSqlMapClientTemplate().queryForObject("da_zsda.ibatorgenerated_selectByPrimaryKey",
  97. key);
  98. return record;
  99. }
  100. /**
  101. * This method was generated by Apache iBATIS ibator. This method
  102. * corresponds to the database table da_zsda
  103. *
  104. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  105. */
  106. public int updateByExampleSelective(DaZsda record, DaZsdaExample example) {
  107. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  108. int rows = getSqlMapClientTemplate().update("da_zsda.ibatorgenerated_updateByExampleSelective", parms);
  109. return rows;
  110. }
  111. /**
  112. * This method was generated by Apache iBATIS ibator. This method
  113. * corresponds to the database table da_zsda
  114. *
  115. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  116. */
  117. public int updateByExample(DaZsda record, DaZsdaExample example) {
  118. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  119. int rows = getSqlMapClientTemplate().update("da_zsda.ibatorgenerated_updateByExample", parms);
  120. return rows;
  121. }
  122. /**
  123. * This method was generated by Apache iBATIS ibator. This method
  124. * corresponds to the database table da_zsda
  125. *
  126. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  127. */
  128. public int updateByPrimaryKeySelective(DaZsda record) {
  129. int rows = getSqlMapClientTemplate().update("da_zsda.ibatorgenerated_updateByPrimaryKeySelective", record);
  130. return rows;
  131. }
  132. /**
  133. * This method was generated by Apache iBATIS ibator. This method
  134. * corresponds to the database table da_zsda
  135. *
  136. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  137. */
  138. public int updateByPrimaryKey(DaZsda record) {
  139. int rows = getSqlMapClientTemplate().update("da_zsda.ibatorgenerated_updateByPrimaryKey", record);
  140. return rows;
  141. }
  142. /**
  143. * This class was generated by Apache iBATIS ibator. This class corresponds
  144. * to the database table da_zsda
  145. *
  146. * @ibatorgenerated Fri May 23 16:56:30 CST 2014
  147. */
  148. private static class UpdateByExampleParms extends DaZsdaExample {
  149. private Object record;
  150. public UpdateByExampleParms(Object record, DaZsdaExample example) {
  151. super(example);
  152. this.record = record;
  153. }
  154. @SuppressWarnings("unused")
  155. public Object getRecord() {
  156. return record;
  157. }
  158. }
  159. public DaZsda selectZsdaByParam(DaZsda daZsda) {
  160. DaZsda record = (DaZsda) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_SELECT_ZSDA_BY_PARAM,
  161. daZsda);
  162. return record;
  163. }
  164. public int countZsdaByParam(DaZsda daZsda) {
  165. Integer count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_ZSDA_BY_PARAM,
  166. daZsda);
  167. return count;
  168. }
  169. /**
  170. * 根据参数获取猪舍档案
  171. *
  172. * @return
  173. * @throws Exception
  174. */
  175. @SuppressWarnings("unchecked")
  176. public ResponseBean getZsdaByParam(Map<String, Object> paramMap, PageBean pageBean) throws Exception {
  177. ResponseBean rb = new ResponseBean();
  178. List<DaZsda> zsdaList = new ArrayList<DaZsda>();
  179. int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_ZSDA_BY_PARAM,
  180. paramMap);
  181. if (null != pageBean) {
  182. int startRecord = pageBean.getCurrentPageFirstRecord();
  183. int endRecord = pageBean.getPageSize();
  184. paramMap.put("startRecord", startRecord);
  185. paramMap.put("endRecord", endRecord);
  186. zsdaList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSDA_BY_PARAM, paramMap);
  187. pageBean.setRecordCount(count);
  188. } else {
  189. paramMap.put("startRecord", 0);
  190. paramMap.put("endRecord", count);
  191. zsdaList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSDA_BY_PARAM, paramMap);
  192. }
  193. rb.setResult(zsdaList);
  194. rb.setReturnCode(count);
  195. return rb;
  196. }
  197. @SuppressWarnings("unchecked")
  198. public List<DaZsda> selectZSMCdaByParam(Map<String, Object> paramMap, PageBean pageBean) {
  199. List<DaZsda> zsdaList = new ArrayList<DaZsda>();
  200. int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_ZSDA_BY_PARAM,
  201. paramMap);
  202. if (null != pageBean) {
  203. int startRecord = pageBean.getCurrentPageFirstRecord();
  204. int endRecord = pageBean.getPageSize();
  205. paramMap.put("startRecord", startRecord);
  206. paramMap.put("endRecord", endRecord);
  207. zsdaList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSMCDA_BY_PARAM, paramMap);
  208. pageBean.setRecordCount(count);
  209. } else {
  210. paramMap.put("startRecord", 0);
  211. paramMap.put("endRecord", count);
  212. zsdaList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSMCDA_BY_PARAM, paramMap);
  213. }
  214. return zsdaList;
  215. }
  216. /**
  217. * 根据参数获取猪舍档案
  218. *
  219. * @return
  220. * @throws Exception
  221. */
  222. public DaZsda getZsdaById(Map<String, Object> paramMap) throws Exception {
  223. DaZsda zsdaList = new DaZsda();
  224. int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_ZSDA_BY_PARAM,
  225. paramMap);
  226. paramMap.put("startRecord", 0);
  227. paramMap.put("endRecord", count);
  228. zsdaList = (DaZsda) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_SELECT_ZSDA_BY_PARAM,
  229. paramMap);
  230. return zsdaList;
  231. }
  232. /**
  233. * 根据参数获取猪舍档案
  234. *
  235. * @return
  236. * @throws Exception
  237. */
  238. public DaZsda getZsdaByJqid(Map<String, Object> paramMap) throws Exception {
  239. DaZsda zsda = (DaZsda) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_SELECT_ZSMCDA_BY_JQID,
  240. paramMap);
  241. return zsda;
  242. }
  243. @SuppressWarnings("unchecked")
  244. public List<DaZsda> getZsdaListByParam(Map<String, Object> paramMap) {
  245. List<DaZsda> list = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_MCLIST_BY_PARAM,
  246. paramMap);
  247. return list;
  248. }
  249. /**
  250. * 获取临时排序的猪舍列表
  251. */
  252. public String getZsidListByParam(Map<String, Object> paramMap) {
  253. String zsids = (String) getSqlMapClientTemplate()
  254. .queryForObject(XtSqlMapConstant.SQLMAP_SELECT_ZSLIST_ZSID_BY_PARAM, paramMap);
  255. return zsids;
  256. }
  257. /**
  258. * 获取猪舍列表
  259. */
  260. public List<DaZsda> getZsxxListByParam(Map<String, Object> paramMap) {
  261. @SuppressWarnings("unchecked")
  262. List<DaZsda> zsxxList = getSqlMapClientTemplate()
  263. .queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSLIST_ZSXX_BY_PARAM, paramMap);
  264. return zsxxList;
  265. }
  266. public List<DaZsdaDTO> getZsdtoByXlh(Map<String, Object> paramMap) {
  267. @SuppressWarnings("unchecked")
  268. List<DaZsdaDTO> zsxxList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_ZSDADTO_BY_XLH,
  269. paramMap);
  270. return zsxxList;
  271. }
  272. public int countZs(Map<String, Object> paramMap) {
  273. int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_ZSID_FROM_DAZSDA,
  274. paramMap);
  275. return count;
  276. }
  277. /**
  278. * 获取临时排序的猪舍列表 只有普通舍和测定舍
  279. */
  280. public String getPtZsidListByParam(Map<String, Object> paramMap) {
  281. String zsids = (String) getSqlMapClientTemplate()
  282. .queryForObject(XtSqlMapConstant.SQLMAP_SELECT_PTZSLIST_ZSID_BY_PARAM, paramMap);
  283. return zsids;
  284. }
  285. /**
  286. * 批量更新猪舍区域
  287. *
  288. * @param paramMapList
  289. * @param zsdaExList
  290. */
  291. public void updateZsqyByParam(List<DaZsda> paramMapList) {
  292. HpDaZsdaSqlMapClientCallback hpDaZsdaSqlMapClientCallback = new HpDaZsdaSqlMapClientCallback();
  293. hpDaZsdaSqlMapClientCallback.setZsdaList(paramMapList);
  294. getSqlMapClientTemplate().execute(hpDaZsdaSqlMapClientCallback);// 。每次执行CRUD操作时,都会调用execute,该方法负责创建并关闭session。
  295. }
  296. // 回调
  297. public class HpDaZsdaSqlMapClientCallback implements SqlMapClientCallback {
  298. private List<DaZsda> zsdaList;
  299. public void setZsdaList(List<DaZsda> zsdaList) {
  300. this.zsdaList = zsdaList;
  301. }
  302. public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { // 回调接口
  303. executor.startBatch(); // // 开始批处理
  304. for (int i = 0; i < zsdaList.size(); i++) {
  305. DaZsda zsda = new DaZsda();
  306. zsda = zsdaList.get(i);
  307. // 更新
  308. executor.update("da_zsda.ibatorgenerated_updateByPrimaryKeySelective", zsda);
  309. }
  310. executor.executeBatch(); /// 执行批处理
  311. return null;
  312. }
  313. }
  314. public String selectDqlqfromzsdaAndJqdaByJqid(String jqid) {
  315. String dqlq = (String) getSqlMapClientTemplate()
  316. .queryForObject(XtSqlMapConstant.SQLMAP_SELECT_DQLQ_FROM_ZSDA_AND_JQDA_BY_JQID, jqid);
  317. return dqlq;
  318. }
  319. public List<DaZsda> selectZsxxByDgds(Map<String, Object> paramMap) {
  320. List<DaZsda> zsxxList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_DSXX_BY_DGDS, paramMap);
  321. return zsxxList;
  322. }
  323. public List<DaZsda> selectZsxxByLxds(Map<String, Object> paramMap) {
  324. List<DaZsda> zsxxList = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_DSXX_BY_LXDS, paramMap);
  325. return zsxxList;
  326. }
  327. }