CommunityServiceDaoImpl.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. package com.java110.community.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.community.dao.ICommunityServiceDao;
  7. import com.java110.core.base.dao.BaseServiceDao;
  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("communityServiceDaoImpl")
  18. //@Transactional
  19. public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunityServiceDao {
  20. private static Logger logger = LoggerFactory.getLogger(CommunityServiceDaoImpl.class);
  21. /**
  22. * 小区信息封装
  23. *
  24. * @param businessCommunityInfo 小区信息 封装
  25. * @throws DAOException
  26. */
  27. @Override
  28. public void saveBusinessCommunityInfo(Map businessCommunityInfo) throws DAOException {
  29. businessCommunityInfo.put("month", DateUtil.getCurrentMonth());
  30. // 查询business_user 数据是否已经存在
  31. logger.debug("保存小区信息 入参 businessCommunityInfo : {}", businessCommunityInfo);
  32. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityInfo", businessCommunityInfo);
  33. if (saveFlag < 1) {
  34. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区数据失败:" + JSONObject.toJSONString(businessCommunityInfo));
  35. }
  36. }
  37. /**
  38. * 小区属性信息分装
  39. *
  40. * @param businessCommunityAttr 小区属性信息封装
  41. * @throws DAOException
  42. */
  43. @Override
  44. public void saveBusinessCommunityAttr(Map businessCommunityAttr) throws DAOException {
  45. businessCommunityAttr.put("month", DateUtil.getCurrentMonth());
  46. // 查询business_user 数据是否已经存在
  47. logger.debug("保存小区属性信息 入参 businessCommunityAttr : {}", businessCommunityAttr);
  48. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityAttr", businessCommunityAttr);
  49. if (saveFlag < 1) {
  50. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区属性数据失败:" + JSONObject.toJSONString(businessCommunityAttr));
  51. }
  52. }
  53. /**
  54. * 保存小区照片信息
  55. *
  56. * @param businessCommunityPhoto 小区照片
  57. * @throws DAOException
  58. */
  59. @Override
  60. public void saveBusinessCommunityPhoto(Map businessCommunityPhoto) throws DAOException {
  61. businessCommunityPhoto.put("month", DateUtil.getCurrentMonth());
  62. logger.debug("保存小区照片信息 入参 businessCommunityPhoto : {}", businessCommunityPhoto);
  63. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityPhoto", businessCommunityPhoto);
  64. if (saveFlag < 1) {
  65. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区照片数据失败:" + JSONObject.toJSONString(businessCommunityPhoto));
  66. }
  67. }
  68. /**
  69. * 保存小区证件信息
  70. *
  71. * @param businessCommunityCerdentials 小区证件
  72. * @throws DAOException
  73. */
  74. @Override
  75. public void saveBusinessCommunityCerdentials(Map businessCommunityCerdentials) throws DAOException {
  76. businessCommunityCerdentials.put("month", DateUtil.getCurrentMonth());
  77. logger.debug("保存小区证件信息 入参 businessCommunityCerdentials : {}", businessCommunityCerdentials);
  78. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityCerdentials", businessCommunityCerdentials);
  79. if (saveFlag < 1) {
  80. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区证件数据失败:" + JSONObject.toJSONString(businessCommunityCerdentials));
  81. }
  82. }
  83. /**
  84. * 查询小区信息
  85. *
  86. * @param info bId 信息
  87. * @return 小区信息
  88. * @throws DAOException
  89. */
  90. @Override
  91. public Map getBusinessCommunityInfo(Map info) throws DAOException {
  92. logger.debug("查询小区信息 入参 info : {}", info);
  93. List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityInfo", info);
  94. if (businessCommunityInfos == null) {
  95. return null;
  96. }
  97. if (businessCommunityInfos.size() > 1) {
  98. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "根据条件查询有多条数据,数据异常,请检查:businessCommunityInfos," + JSONObject.toJSONString(info));
  99. }
  100. return businessCommunityInfos.get(0);
  101. }
  102. /**
  103. * 查询小区属性
  104. *
  105. * @param info bId 信息
  106. * @return 小区属性
  107. * @throws DAOException
  108. */
  109. @Override
  110. public List<Map> getBusinessCommunityAttrs(Map info) throws DAOException {
  111. logger.debug("查询小区属性信息 入参 info : {}", info);
  112. List<Map> businessCommunityAttrs = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityAttrs", info);
  113. return businessCommunityAttrs;
  114. }
  115. /**
  116. * 查询小区照片
  117. *
  118. * @param info bId 信息
  119. * @return
  120. * @throws DAOException
  121. */
  122. @Override
  123. public List<Map> getBusinessCommunityPhoto(Map info) throws DAOException {
  124. logger.debug("查询小区照片信息 入参 info : {}", info);
  125. List<Map> businessCommunityPhotos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityPhoto", info);
  126. return businessCommunityPhotos;
  127. }
  128. /**
  129. * 查询小区证件
  130. *
  131. * @param info bId 信息
  132. * @return
  133. * @throws DAOException
  134. */
  135. @Override
  136. public List<Map> getBusinessCommunityCerdentials(Map info) throws DAOException {
  137. logger.debug("查询小区证件信息 入参 info : {}", info);
  138. List<Map> businessCommunityCerdentialses = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityCerdentials", info);
  139. return businessCommunityCerdentialses;
  140. }
  141. /**
  142. * 保存小区信息 到 instance
  143. *
  144. * @param info bId 信息
  145. * @throws DAOException
  146. */
  147. @Override
  148. public void saveCommunityInfoInstance(Map info) throws DAOException {
  149. logger.debug("保存小区信息Instance 入参 info : {}", info);
  150. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityInfoInstance", info);
  151. if (saveFlag < 1) {
  152. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区信息Instance数据失败:" + JSONObject.toJSONString(info));
  153. }
  154. }
  155. @Override
  156. public void saveCommunityAttrsInstance(Map info) throws DAOException {
  157. logger.debug("保存小区属性信息Instance 入参 info : {}", info);
  158. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityAttrsInstance", info);
  159. if (saveFlag < 1) {
  160. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区属性信息Instance数据失败:" + JSONObject.toJSONString(info));
  161. }
  162. }
  163. @Override
  164. public void saveCommunityPhotoInstance(Map info) throws DAOException {
  165. logger.debug("保存小区照片信息Instance 入参 info : {}", info);
  166. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityPhotoInstance", info);
  167. if (saveFlag < 1) {
  168. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区照片信息Instance数据失败:" + JSONObject.toJSONString(info));
  169. }
  170. }
  171. /**
  172. * 查询小区信息(instance)
  173. *
  174. * @param info bId 信息
  175. * @return
  176. * @throws DAOException
  177. */
  178. @Override
  179. public Map getCommunityInfo(Map info) throws DAOException {
  180. logger.debug("查询小区信息 入参 info : {}", info);
  181. List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityInfo", info);
  182. if (businessCommunityInfos == null || businessCommunityInfos.size() == 0) {
  183. return null;
  184. }
  185. if (businessCommunityInfos.size() > 1) {
  186. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "根据条件查询有多条数据,数据异常,请检查:getCommunityInfo," + JSONObject.toJSONString(info));
  187. }
  188. return businessCommunityInfos.get(0);
  189. }
  190. /**
  191. * 小区属性查询(instance)
  192. *
  193. * @param info bId 信息
  194. * @return
  195. * @throws DAOException
  196. */
  197. @Override
  198. public List<Map> getCommunityAttrs(Map info) throws DAOException {
  199. logger.debug("查询小区属性信息 入参 info : {}", info);
  200. List<Map> communityAttrs = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityAttrs", info);
  201. return communityAttrs;
  202. }
  203. /**
  204. * 小区照片查询(instance)
  205. *
  206. * @param info bId 信息
  207. * @return
  208. * @throws DAOException
  209. */
  210. @Override
  211. public List<Map> getCommunityPhoto(Map info) throws DAOException {
  212. logger.debug("查询小区照片信息 入参 info : {}", info);
  213. List<Map> communityPhotos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityPhoto", info);
  214. return communityPhotos;
  215. }
  216. /**
  217. * 修改小区信息
  218. *
  219. * @param info 修改信息
  220. * @throws DAOException
  221. */
  222. @Override
  223. public void updateCommunityInfoInstance(Map info) throws DAOException {
  224. logger.debug("修改小区信息Instance 入参 info : {}", info);
  225. int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityInfoInstance", info);
  226. if (saveFlag < 1) {
  227. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区信息Instance数据失败:" + JSONObject.toJSONString(info));
  228. }
  229. }
  230. /**
  231. * 修改小区属性信息(instance)
  232. *
  233. * @param info 修改信息
  234. * @throws DAOException
  235. */
  236. @Override
  237. public void updateCommunityAttrInstance(Map info) throws DAOException {
  238. logger.debug("修改小区属性信息Instance 入参 info : {}", info);
  239. int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityAttrInstance", info);
  240. if (saveFlag < 1) {
  241. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区属性信息Instance数据失败:" + JSONObject.toJSONString(info));
  242. }
  243. }
  244. /**
  245. * 修改 小区照片信息
  246. *
  247. * @param info 修改信息
  248. * @throws DAOException
  249. */
  250. @Override
  251. public void updateCommunityPhotoInstance(Map info) throws DAOException {
  252. logger.debug("修改小区照片信息Instance 入参 info : {}", info);
  253. int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityPhotoInstance", info);
  254. if (saveFlag < 1) {
  255. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区照片信息Instance数据失败:" + JSONObject.toJSONString(info));
  256. }
  257. }
  258. /**
  259. * 小区成员加入信息
  260. *
  261. * @param businessCommunityMember 小区成员信息 封装
  262. * @throws DAOException 操作数据库异常
  263. */
  264. public void saveBusinessCommunityMember(Map businessCommunityMember) throws DAOException {
  265. logger.debug("小区成员加入 入参 businessCommunityMember : {}", businessCommunityMember);
  266. businessCommunityMember.put("month", DateUtil.getCurrentMonth());
  267. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveBusinessCommunityMember", businessCommunityMember);
  268. if (saveFlag < 1) {
  269. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "小区成员加入失败:" + JSONObject.toJSONString(businessCommunityMember));
  270. }
  271. }
  272. /**
  273. * 成员加入 保存信息至instance
  274. *
  275. * @param info
  276. * @throws DAOException
  277. */
  278. @Override
  279. public void saveCommunityMemberInstance(Map info) throws DAOException {
  280. logger.debug("小区成员加入Instance 入参 info : {}", info);
  281. int saveFlag = sqlSessionTemplate.insert("communityServiceDaoImpl.saveCommunityMemberInstance", info);
  282. if (saveFlag < 1) {
  283. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存小区照片信息Instance数据失败:" + JSONObject.toJSONString(info));
  284. }
  285. }
  286. /**
  287. * 查询小区成员加入信息(business过程)
  288. * 根据bId 查询小区信息
  289. *
  290. * @param info bId 信息
  291. * @return 小区信息
  292. * @throws DAOException
  293. */
  294. public Map getBusinessCommunityMember(Map info) throws DAOException {
  295. logger.debug("查询小区成员加入信息 入参 info : {}", info);
  296. List<Map> businessCommunityMembers = sqlSessionTemplate.selectList("communityServiceDaoImpl.getBusinessCommunityMember", info);
  297. if (businessCommunityMembers == null || businessCommunityMembers.size() == 0) {
  298. return null;
  299. }
  300. if (businessCommunityMembers.size() > 1) {
  301. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "根据条件查询有多条数据,数据异常,请检查:businessCommunityMember," + JSONObject.toJSONString(info));
  302. }
  303. return businessCommunityMembers.get(0);
  304. }
  305. /**
  306. * 查询小区成员加入信息(instance过程)
  307. * 根据bId 查询小区信息
  308. *
  309. * @param info bId 信息
  310. * @return 小区信息
  311. * @throws DAOException
  312. */
  313. public Map getCommunityMember(Map info) throws DAOException {
  314. logger.debug("查询小区成员加入信息 入参 info : {}", info);
  315. List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityMember", info);
  316. if (memberCommunitys == null || memberCommunitys.size() == 0) {
  317. return null;
  318. }
  319. if (memberCommunitys.size() > 1) {
  320. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "根据条件查询有多条数据,数据异常,请检查:getCommunityMember," + JSONObject.toJSONString(info));
  321. }
  322. return memberCommunitys.get(0);
  323. }
  324. /**
  325. * 修改小区成员加入信息
  326. *
  327. * @param info 修改信息
  328. * @throws DAOException
  329. */
  330. public void updateCommunityMemberInstance(Map info) throws DAOException {
  331. logger.debug("修改小区成员加入信息Instance 入参 info : {}", info);
  332. int saveFlag = sqlSessionTemplate.update("communityServiceDaoImpl.updateCommunityMemberInstance", info);
  333. if (saveFlag < 1) {
  334. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区成员加入信息Instance数据失败:" + JSONObject.toJSONString(info));
  335. }
  336. }
  337. /**
  338. * @param info bId 信息
  339. * @return
  340. * @throws DAOException
  341. */
  342. @Override
  343. public List<Map> getCommunityMembers(Map info) throws DAOException {
  344. logger.debug("查询小区成员加入信息 入参 info : {}", info);
  345. List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityMember", info);
  346. return memberCommunitys;
  347. }
  348. @Override
  349. public int getCommunityMemberCount(Map info) {
  350. logger.debug("查询小区成员加入信息 入参 info : {}", info);
  351. List<Map> memberCommunitys = sqlSessionTemplate.selectList("communityServiceDaoImpl.getCommunityMemberCount", info);
  352. if (memberCommunitys.size() < 1) {
  353. return 0;
  354. }
  355. return Integer.parseInt(memberCommunitys.get(0).get("count").toString()); }
  356. }