OwnerServiceDaoImpl.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. package com.java110.user.dao.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.common.constant.ResponseConstant;
  4. import com.java110.common.exception.DAOException;
  5. import com.java110.common.util.DateUtil;
  6. import com.java110.core.base.dao.BaseServiceDao;
  7. import com.java110.user.dao.IOwnerServiceDao;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.stereotype.Service;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * 业主服务 与数据库交互
  15. * Created by wuxw on 2017/4/5.
  16. */
  17. @Service("ownerServiceDaoImpl")
  18. //@Transactional
  19. public class OwnerServiceDaoImpl extends BaseServiceDao implements IOwnerServiceDao {
  20. private static Logger logger = LoggerFactory.getLogger(OwnerServiceDaoImpl.class);
  21. /**
  22. * 业主信息封装
  23. *
  24. * @param businessOwnerInfo 业主信息 封装
  25. * @throws DAOException DAO异常
  26. */
  27. @Override
  28. public void saveBusinessOwnerInfo(Map businessOwnerInfo) throws DAOException {
  29. businessOwnerInfo.put("month", DateUtil.getCurrentMonth());
  30. // 查询business_user 数据是否已经存在
  31. logger.debug("保存业主信息 入参 businessOwnerInfo : {}", businessOwnerInfo);
  32. int saveFlag = sqlSessionTemplate.insert("ownerServiceDaoImpl.saveBusinessOwnerInfo", businessOwnerInfo);
  33. if (saveFlag < 1) {
  34. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存业主数据失败:" + JSONObject.toJSONString(businessOwnerInfo));
  35. }
  36. }
  37. /**
  38. * 查询业主信息
  39. *
  40. * @param info bId 信息
  41. * @return 业主信息
  42. * @throws DAOException DAO异常
  43. */
  44. @Override
  45. public List<Map> getBusinessOwnerInfo(Map info) throws DAOException {
  46. logger.debug("查询业主信息 入参 info : {}", info);
  47. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.getBusinessOwnerInfo", info);
  48. return businessOwnerInfos;
  49. }
  50. /**
  51. * 保存业主信息 到 instance
  52. *
  53. * @param info bId 信息
  54. * @throws DAOException DAO异常
  55. */
  56. @Override
  57. public void saveOwnerInfoInstance(Map info) throws DAOException {
  58. logger.debug("保存业主信息Instance 入参 info : {}", info);
  59. int saveFlag = sqlSessionTemplate.insert("ownerServiceDaoImpl.saveOwnerInfoInstance", info);
  60. if (saveFlag < 1) {
  61. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存业主信息Instance数据失败:" + JSONObject.toJSONString(info));
  62. }
  63. }
  64. /**
  65. * 查询业主信息(instance)
  66. *
  67. * @param info bId 信息
  68. * @return List<Map>
  69. * @throws DAOException DAO异常
  70. */
  71. @Override
  72. public List<Map> getOwnerInfo(Map info) throws DAOException {
  73. logger.debug("查询业主信息 入参 info : {}", info);
  74. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.getOwnerInfo", info);
  75. return businessOwnerInfos;
  76. }
  77. /**
  78. * 修改业主信息
  79. *
  80. * @param info 修改信息
  81. * @throws DAOException DAO异常
  82. */
  83. @Override
  84. public void updateOwnerInfoInstance(Map info) throws DAOException {
  85. logger.debug("修改业主信息Instance 入参 info : {}", info);
  86. int saveFlag = sqlSessionTemplate.update("ownerServiceDaoImpl.updateOwnerInfoInstance", info);
  87. if (saveFlag < 1) {
  88. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改业主信息Instance数据失败:" + JSONObject.toJSONString(info));
  89. }
  90. }
  91. /**
  92. * 查询业主数量
  93. *
  94. * @param info 业主信息
  95. * @return 业主数量
  96. */
  97. @Override
  98. public int queryOwnersCount(Map info) {
  99. logger.debug("查询业主数据 入参 info : {}", info);
  100. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryOwnersCount", info);
  101. if (businessOwnerInfos.size() < 1) {
  102. return 0;
  103. }
  104. return Integer.parseInt(businessOwnerInfos.get(0).get("count").toString());
  105. }
  106. /**
  107. * 查询业主数量
  108. *
  109. * @param info 业主信息
  110. * @return 业主数量
  111. */
  112. @Override
  113. public int queryOwnersCountByCondition(Map info) {
  114. logger.debug("查询业主数据 入参 info : {}", info);
  115. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryOwnersCountByCondition", info);
  116. if (businessOwnerInfos.size() < 1) {
  117. return 0;
  118. }
  119. return Integer.parseInt(businessOwnerInfos.get(0).get("count").toString());
  120. }
  121. /**
  122. * 查询业主信息(instance)
  123. *
  124. * @param info bId 信息
  125. * @return List<Map>
  126. * @throws DAOException DAO异常
  127. */
  128. @Override
  129. public List<Map> getOwnerInfoByCondition(Map info) throws DAOException {
  130. logger.debug("查询业主信息 入参 info : {}", info);
  131. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.getOwnerInfoByCondition", info);
  132. return businessOwnerInfos;
  133. }
  134. @Override
  135. public int queryNoEnterRoomOwnerCount(Map info) {
  136. logger.debug("查询业主数据 入参 info : {}", info);
  137. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryNoEnterRoomOwnerCount", info);
  138. if (businessOwnerInfos.size() < 1) {
  139. return 0;
  140. }
  141. return Integer.parseInt(businessOwnerInfos.get(0).get("count").toString());
  142. }
  143. @Override
  144. public List<Map> queryOwnersByRoom(Map info) throws DAOException {
  145. logger.debug("queryOwnersByRoom 入参 info : {}", info);
  146. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryOwnersByRoom", info);
  147. return businessOwnerInfos;
  148. }
  149. @Override
  150. public List<Map> queryOwnersByParkingSpace(Map info) throws DAOException {
  151. logger.debug("queryOwnersByParkingSpace 入参 info : {}", info);
  152. List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryOwnersByParkingSpace", info);
  153. return businessOwnerInfos; }
  154. }