SjSscssjDAOImpl.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. package com.huimv.sj.dao;
  2. import java.sql.SQLException;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.springframework.orm.ibatis.SqlMapClientCallback;
  8. import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
  9. import org.springframework.util.StringUtils;
  10. import com.huimv.busi.base.dto.ResponseBean;
  11. import com.huimv.busi.da.dto.DaSlxxDTO;
  12. import com.huimv.busi.xt.constant.XtSqlMapConstant;
  13. import com.huimv.busi.xt.utils.DynamicDataSourceHolder;
  14. import com.huimv.sj.dataobject.SjSscssj;
  15. import com.huimv.sj.dataobject.SjSscssjExample;
  16. import com.huimv.web.base.PageBean;
  17. import com.ibatis.sqlmap.client.SqlMapExecutor;
  18. public class SjSscssjDAOImpl extends SqlMapClientDaoSupport implements SjSscssjDAO {
  19. /**
  20. * This method was generated by Apache iBATIS ibator.
  21. * This method corresponds to the database table sj_sscssj
  22. *
  23. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  24. */
  25. public SjSscssjDAOImpl() {
  26. super();
  27. }
  28. /**
  29. * This method was generated by Apache iBATIS ibator.
  30. * This method corresponds to the database table sj_sscssj
  31. *
  32. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  33. */
  34. public int countByExample(SjSscssjExample example) {
  35. Integer count = (Integer) getSqlMapClientTemplate().queryForObject("sj_sscssj.ibatorgenerated_countByExample", example);
  36. return count;
  37. }
  38. /**
  39. * This method was generated by Apache iBATIS ibator.
  40. * This method corresponds to the database table sj_sscssj
  41. *
  42. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  43. */
  44. public int deleteByExample(SjSscssjExample example) {
  45. int rows = getSqlMapClientTemplate().delete("sj_sscssj.ibatorgenerated_deleteByExample", example);
  46. return rows;
  47. }
  48. /**
  49. * This method was generated by Apache iBATIS ibator.
  50. * This method corresponds to the database table sj_sscssj
  51. *
  52. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  53. */
  54. public int deleteByPrimaryKey(Integer id) {
  55. SjSscssj key = new SjSscssj();
  56. key.setId(id);
  57. int rows = getSqlMapClientTemplate().delete("sj_sscssj.ibatorgenerated_deleteByPrimaryKey", key);
  58. return rows;
  59. }
  60. /**
  61. * This method was generated by Apache iBATIS ibator.
  62. * This method corresponds to the database table sj_sscssj
  63. *
  64. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  65. */
  66. public void insert(SjSscssj record) {
  67. getSqlMapClientTemplate().insert("sj_sscssj.ibatorgenerated_insert", record);
  68. }
  69. /**
  70. * This method was generated by Apache iBATIS ibator.
  71. * This method corresponds to the database table sj_sscssj
  72. *
  73. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  74. */
  75. public void insertSelective(SjSscssj record) {
  76. getSqlMapClientTemplate().insert("sj_sscssj.ibatorgenerated_insertSelective", record);
  77. }
  78. /**
  79. * This method was generated by Apache iBATIS ibator.
  80. * This method corresponds to the database table sj_sscssj
  81. *
  82. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  83. */
  84. @SuppressWarnings("unchecked")
  85. public List<SjSscssj> selectByExample(SjSscssjExample example) {
  86. List<SjSscssj> list = getSqlMapClientTemplate().queryForList("sj_sscssj.ibatorgenerated_selectByExample", example);
  87. return list;
  88. }
  89. /**
  90. * This method was generated by Apache iBATIS ibator.
  91. * This method corresponds to the database table sj_sscssj
  92. *
  93. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  94. */
  95. public SjSscssj selectByPrimaryKey(Integer id) {
  96. SjSscssj key = new SjSscssj();
  97. key.setId(id);
  98. SjSscssj record = (SjSscssj) getSqlMapClientTemplate().queryForObject("sj_sscssj.ibatorgenerated_selectByPrimaryKey", key);
  99. return record;
  100. }
  101. /**
  102. * This method was generated by Apache iBATIS ibator.
  103. * This method corresponds to the database table sj_sscssj
  104. *
  105. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  106. */
  107. public int updateByExampleSelective(SjSscssj record, SjSscssjExample example) {
  108. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  109. int rows = getSqlMapClientTemplate().update("sj_sscssj.ibatorgenerated_updateByExampleSelective", parms);
  110. return rows;
  111. }
  112. /**
  113. * This method was generated by Apache iBATIS ibator.
  114. * This method corresponds to the database table sj_sscssj
  115. *
  116. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  117. */
  118. public int updateByExample(SjSscssj record, SjSscssjExample example) {
  119. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  120. int rows = getSqlMapClientTemplate().update("sj_sscssj.ibatorgenerated_updateByExample", parms);
  121. return rows;
  122. }
  123. /**
  124. * This method was generated by Apache iBATIS ibator.
  125. * This method corresponds to the database table sj_sscssj
  126. *
  127. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  128. */
  129. public int updateByPrimaryKeySelective(SjSscssj record) {
  130. int rows = getSqlMapClientTemplate().update("sj_sscssj.ibatorgenerated_updateByPrimaryKeySelective", record);
  131. return rows;
  132. }
  133. /**
  134. * This method was generated by Apache iBATIS ibator.
  135. * This method corresponds to the database table sj_sscssj
  136. *
  137. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  138. */
  139. public int updateByPrimaryKey(SjSscssj record) {
  140. int rows = getSqlMapClientTemplate().update("sj_sscssj.ibatorgenerated_updateByPrimaryKey", record);
  141. return rows;
  142. }
  143. /**
  144. * This class was generated by Apache iBATIS ibator.
  145. * This class corresponds to the database table sj_sscssj
  146. *
  147. * @ibatorgenerated Thu Jun 19 15:59:45 CST 2014
  148. */
  149. private static class UpdateByExampleParms extends SjSscssjExample {
  150. private Object record;
  151. public UpdateByExampleParms(Object record, SjSscssjExample example) {
  152. super(example);
  153. this.record = record;
  154. }
  155. @SuppressWarnings("unused")
  156. public Object getRecord() {
  157. return record;
  158. }
  159. }
  160. /**
  161. * 得到指定条件采食记录的最大时间
  162. */
  163. public Date selectMaxSscssjTimeByParam(Map<String, Object> searchParam) {
  164. Date date = (Date) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_SELECT_MAX_SSCSSJ_TIME_BY_PARAM, searchParam);
  165. return date;
  166. }
  167. /**
  168. * 插入动物访问记录
  169. */
  170. public void insertSscssjByParam(List<Map<String, Object>> paramMapList) {
  171. SscssjSqlMapClientCallback sscssjSqlMapClientCallback = new SscssjSqlMapClientCallback();
  172. sscssjSqlMapClientCallback.setParamMapList(paramMapList);
  173. getSqlMapClientTemplate().execute(sscssjSqlMapClientCallback);
  174. }
  175. /**
  176. * 插入数据的回调类
  177. */
  178. private class SscssjSqlMapClientCallback implements SqlMapClientCallback {
  179. private List<Map<String, Object>> paramMapList;
  180. public void setParamMapList(List<Map<String, Object>> paramMapList) {
  181. this.paramMapList = paramMapList;
  182. }
  183. @Override
  184. public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
  185. executor.startBatch();
  186. String dqlq = "";
  187. String jqid = "";
  188. for (Map<String, Object> paramMap : paramMapList) {
  189. jqid = (String) paramMap.get("jqid");
  190. dqlq = (String) executor.queryForObject(XtSqlMapConstant.SQLMAP_SELECT_DQLQ_FROM_ZSDA_AND_JQDA_BY_JQID, jqid);
  191. if (StringUtils.hasText(dqlq)) {
  192. paramMap.put("dqlq", dqlq);
  193. executor.insert(XtSqlMapConstant.SQLMAP_INSERT_SSCSSJ_BY_PARAM, paramMap);
  194. }
  195. }
  196. executor.executeBatch();
  197. return null;
  198. }
  199. }
  200. /**
  201. * 上料维护
  202. * @param example
  203. * @return
  204. */
  205. public int countSlwhByExample(SjSscssjExample example) {
  206. Integer count = (Integer) getSqlMapClientTemplate().queryForObject("sj_sscssj.ibatorgenerated_countSlwhByExample", example);
  207. return count;
  208. }
  209. /**
  210. * 上料维护信息查询
  211. * @param example
  212. * @return
  213. */
  214. @SuppressWarnings("unchecked")
  215. public List<SjSscssj> selectSlwhByExample(SjSscssjExample example) {
  216. List<SjSscssj> list = getSqlMapClientTemplate().queryForList("sj_sscssj.ibatorgenerated_selectSlwhByExample", example);
  217. return list;
  218. }
  219. /**
  220. * 上料信息参数查询
  221. */
  222. @SuppressWarnings("unchecked")
  223. public ResponseBean selectDaSlxxByParam(Map<String, Object> paramMap, PageBean pageBean) throws Exception {
  224. ResponseBean rb = new ResponseBean();
  225. List<DaSlxxDTO> daSlxxDTOs = new ArrayList<DaSlxxDTO>();
  226. int count = (Integer) getSqlMapClientTemplate().queryForObject(XtSqlMapConstant.SQLMAP_COUNT_SLXX_BY_PARAM, paramMap);
  227. if(null != pageBean) {
  228. int startRecord = pageBean.getCurrentPageFirstRecord();
  229. int endRecord = pageBean.getPageSize();
  230. paramMap.put("startRecord", startRecord);
  231. paramMap.put("endRecord", endRecord);
  232. pageBean.setRecordCount(count);
  233. } else {
  234. paramMap.put("startRecord", 0);
  235. paramMap.put("endRecord", count);
  236. }
  237. daSlxxDTOs = (List<DaSlxxDTO>) getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_SLXX_BY_PARAM, paramMap);
  238. rb.setResult(daSlxxDTOs);
  239. rb.setReturnCode(count);
  240. return rb;
  241. }
  242. @Override
  243. public void callPrcSlxx(Map<String, Object> searchParam) {
  244. // TODO Auto-generated method stub
  245. getSqlMapClientTemplate().update(XtSqlMapConstant.SQLMAP_PRC_SLXX, searchParam);
  246. }
  247. @SuppressWarnings("unchecked")
  248. public List<SjSscssj> selectHkcsCgqidByParam(Map<String, Object> searchParam) {
  249. DynamicDataSourceHolder.setRouteKey("");
  250. List<SjSscssj> list = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_HKCS_CGQID_BY_PARAM, searchParam);
  251. return list;
  252. }
  253. @SuppressWarnings("unchecked")
  254. public List<SjSscssj> selectQccsByParam(Map<String, Object> searchParam) {
  255. DynamicDataSourceHolder.setRouteKey("");
  256. List<SjSscssj> list = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_QCHKCS_BY_PARAM, searchParam);
  257. DynamicDataSourceHolder.removeRouteKey();
  258. return list;
  259. }
  260. @SuppressWarnings("unchecked")
  261. public List<SjSscssj> selectDqcsByParam(Map<String, Object> searchParam) {
  262. DynamicDataSourceHolder.setRouteKey("");
  263. List<SjSscssj> list = getSqlMapClientTemplate().queryForList(XtSqlMapConstant.SQLMAP_SELECT_DQHKCS_BY_PARAM, searchParam);
  264. DynamicDataSourceHolder.removeRouteKey();
  265. return list;
  266. }
  267. }