FeeServiceDaoImpl.java 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. package com.java110.fee.dao.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.core.base.dao.BaseServiceDao;
  4. import com.java110.fee.dao.IFeeServiceDao;
  5. import com.java110.utils.constant.ResponseConstant;
  6. import com.java110.utils.exception.DAOException;
  7. import com.java110.utils.util.DateUtil;
  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("feeServiceDaoImpl")
  18. //@Transactional
  19. public class FeeServiceDaoImpl extends BaseServiceDao implements IFeeServiceDao {
  20. private static Logger logger = LoggerFactory.getLogger(FeeServiceDaoImpl.class);
  21. /**
  22. * 费用信息封装
  23. *
  24. * @param businessFeeInfo 费用信息 封装
  25. * @throws DAOException DAO异常
  26. */
  27. @Override
  28. public void saveBusinessFeeInfo(Map businessFeeInfo) throws DAOException {
  29. businessFeeInfo.put("month", DateUtil.getCurrentMonth());
  30. // 查询business_user 数据是否已经存在
  31. logger.debug("保存费用信息 入参 businessFeeInfo : {}", businessFeeInfo);
  32. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.saveBusinessFeeInfo", businessFeeInfo);
  33. if (saveFlag < 1) {
  34. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存费用数据失败:" + JSONObject.toJSONString(businessFeeInfo));
  35. }
  36. }
  37. /**
  38. * 查询费用信息
  39. *
  40. * @param info bId 信息
  41. * @return 费用信息
  42. * @throws DAOException DAO异常
  43. */
  44. @Override
  45. public List<Map> getBusinessFeeInfo(Map info) throws DAOException {
  46. logger.debug("查询费用信息 入参 info : {}", info);
  47. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.getBusinessFeeInfo", info);
  48. return businessFeeInfos;
  49. }
  50. /**
  51. * 保存费用信息 到 instance
  52. *
  53. * @param info bId 信息
  54. * @throws DAOException DAO异常
  55. */
  56. @Override
  57. public void saveFeeInfoInstance(Map info) throws DAOException {
  58. logger.debug("保存费用信息Instance 入参 info : {}", info);
  59. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.saveFeeInfoInstance", 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> getFeeInfo(Map info) throws DAOException {
  73. logger.debug("查询费用信息 入参 info : {}", info);
  74. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.getFeeInfo", info);
  75. return businessFeeInfos;
  76. }
  77. /**
  78. * 修改费用信息
  79. *
  80. * @param info 修改信息
  81. * @throws DAOException DAO异常
  82. */
  83. @Override
  84. public void updateFeeInfoInstance(Map info) throws DAOException {
  85. logger.debug("修改费用信息Instance 入参 info : {}", info);
  86. int saveFlag = sqlSessionTemplate.update("feeServiceDaoImpl.updateFeeInfoInstance", 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 queryFeesCount(Map info) {
  99. logger.debug("查询费用数据 入参 info : {}", info);
  100. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryFeesCount", info);
  101. if (businessFeeInfos.size() < 1) {
  102. return 0;
  103. }
  104. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  105. }
  106. @Override
  107. public int queryFeeByAttrCount(Map info) {
  108. logger.debug("查询费用数据 入参 info : {}", info);
  109. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryFeeByAttrCount", info);
  110. if (businessFeeInfos.size() < 1) {
  111. return 0;
  112. }
  113. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  114. }
  115. @Override
  116. public List<Map> queryFeeByAttr(Map info) throws DAOException {
  117. logger.debug("查询费用信息 入参 info : {}", info);
  118. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryFeeByAttr", info);
  119. return businessFeeInfos;
  120. }
  121. /**
  122. * 查询费用账期
  123. *
  124. * @param info 费用信息
  125. * @return 费用数量
  126. */
  127. @Override
  128. public int queryBillCount(Map info) {
  129. logger.debug("查询费用数据 入参 info : {}", info);
  130. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryBillCount", info);
  131. if (businessFeeInfos.size() < 1) {
  132. return 0;
  133. }
  134. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  135. }
  136. /**
  137. * 查询账期
  138. *
  139. * @param info bId 信息
  140. * @return List<Map>
  141. * @throws DAOException DAO异常
  142. */
  143. @Override
  144. public List<Map> queryBills(Map info) throws DAOException {
  145. logger.debug("查询费用信息 入参 info : {}", info);
  146. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryBills", info);
  147. return businessFeeInfos;
  148. }
  149. /**
  150. * 查询账单欠费总数
  151. *
  152. * @param info 费用信息
  153. * @return 费用数量
  154. */
  155. @Override
  156. public int queryBillOweFeeCount(Map info) {
  157. logger.debug("查询费用数据 入参 info : {}", info);
  158. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryBillOweFeeCount", info);
  159. if (businessFeeInfos.size() < 1) {
  160. return 0;
  161. }
  162. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  163. }
  164. /**
  165. * 查询账单欠费
  166. *
  167. * @param info bId 信息
  168. * @return List<Map>
  169. * @throws DAOException DAO异常
  170. */
  171. @Override
  172. public List<Map> queryBillOweFees(Map info) throws DAOException {
  173. logger.debug("查询费用信息 入参 info : {}", info);
  174. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.queryBillOweFees", info);
  175. return businessFeeInfos;
  176. }
  177. /**
  178. * 保存欠费
  179. *
  180. * @param info bId 信息
  181. * @return List<Map>
  182. * @throws DAOException DAO异常
  183. */
  184. @Override
  185. public int insertBillOweFees(Map info) throws DAOException {
  186. logger.debug("保存欠费费用信息 入参 info : {}", info);
  187. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.insertBillOweFees", info);
  188. return saveFlag;
  189. }
  190. /**
  191. * 保存欠费
  192. *
  193. * @param info bId 信息
  194. * @return List<Map>
  195. * @throws DAOException DAO异常
  196. */
  197. @Override
  198. public int updateBillOweFees(Map info) throws DAOException {
  199. logger.debug("保存欠费费用信息 入参 info : {}", info);
  200. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.updateBillOweFees", info);
  201. return saveFlag;
  202. }
  203. /**
  204. * 保存欠费
  205. *
  206. * @param info bId 信息
  207. * @return List<Map>
  208. * @throws DAOException DAO异常
  209. */
  210. @Override
  211. public int insertBill(Map info) throws DAOException {
  212. logger.debug("保存欠费费用信息 入参 info : {}", info);
  213. sqlSessionTemplate.update("feeServiceDaoImpl.updateBill", info);
  214. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.insertBill", info);
  215. return saveFlag;
  216. }
  217. /**
  218. * 批量保存费用
  219. *
  220. * @param info
  221. * @return
  222. */
  223. @Override
  224. public int insertFees(Map info) {
  225. int saveFlag = sqlSessionTemplate.insert("feeServiceDaoImpl.insertFees", info);
  226. return saveFlag;
  227. }
  228. @Override
  229. public int computeBillOweFeeCount(Map beanCovertMap) {
  230. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeBillOweFeeCount", beanCovertMap);
  231. if (businessFeeInfos.size() < 1) {
  232. return 0;
  233. }
  234. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  235. }
  236. @Override
  237. public List<Map> computeBillOweFee(Map beanCovertMap) {
  238. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeBillOweFee", beanCovertMap);
  239. return businessFeeInfos;
  240. }
  241. @Override
  242. public int computeEveryOweFeeCount(Map beanCovertMap) {
  243. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeEveryOweFeeCount", beanCovertMap);
  244. if (businessFeeInfos.size() < 1) {
  245. return 0;
  246. }
  247. return Integer.parseInt(businessFeeInfos.get(0).get("count").toString());
  248. }
  249. @Override
  250. public List<Map> computeEveryOweFee(Map beanCovertMap) {
  251. List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeEveryOweFee", beanCovertMap);
  252. return businessFeeInfos;
  253. }
  254. @Override
  255. public int deleteFeesByBatch(Map info) {
  256. logger.debug("修改费用信息Instance 入参 info : {}", info);
  257. int saveFlag = sqlSessionTemplate.update("feeServiceDaoImpl.deleteFeesByBatch", info);
  258. return saveFlag;
  259. }
  260. }