AllocationQueryMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kcim.dao.mapper.AllocationQueryMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kcim.dao.model.AllocationQuery" id="allocationQueryMap">
  6. <result property="id" column="id"/>
  7. <result property="dateYear" column="date_year"/>
  8. <result property="dateMonth" column="date_month"/>
  9. <result property="hospId" column="hosp_id"/>
  10. <result property="responsibilityCode" column="responsibility_code"/>
  11. <result property="responsibilityName" column="responsibility_name"/>
  12. <result property="originId" column="origin_id"/>
  13. <result property="originType" column="origin_type"/>
  14. <result property="amount" column="amount"/>
  15. <result property="accountingCode" column="accounting_code"/>
  16. <result property="accountingName" column="accounting_name"/>
  17. <result property="targetResponsibilityCode" column="target_responsibility_code"/>
  18. <result property="targetResponsibilityName" column="target_responsibility_code"/>
  19. <result property="shareLevelId" column="share_level_id"/>
  20. <result property="createTime" column="create_time"/>
  21. <result property="deleteTime" column="delete_time"/>
  22. </resultMap>
  23. <select id="getTotalMoney" resultType="java.math.BigDecimal">
  24. select sum(amount)
  25. from cost_allocation_query
  26. where date_year = #{dateYear}
  27. and date_month = #{month}
  28. and hosp_id = #{hospId}
  29. and delete_time = 0
  30. </select>
  31. <select id="getRespCodeAndName" resultType="com.kcim.vo.CodeAndNameVO">
  32. select responsibility_code as code, responsibility_name as name
  33. from cost_allocation_query
  34. where date_year = #{dateYear}
  35. and date_month = #{month}
  36. and hosp_id = #{hospId}
  37. and delete_time = 0
  38. </select>
  39. <select id="getAccountCodeAndName" resultType="com.kcim.vo.CodeAndNameVO">
  40. select accounting_code as code, accounting_name as name
  41. from cost_allocation_query
  42. where date_year = #{dateYear}
  43. and date_month = #{month}
  44. and hosp_id = #{hospId}
  45. and delete_time = 0
  46. </select>
  47. <select id="getCountByRespAndAccounts" resultType="java.math.BigDecimal">
  48. select IFNULL(sum(amount), 0)
  49. from cost_allocation_query
  50. where date_year = #{dateYear}
  51. and date_month = #{month}
  52. and hosp_id = #{hospId}
  53. and responsibility_code = #{code}
  54. and accounting_code in
  55. <foreach collection="accountCodes" item="item" open="(" separator="," close=")">
  56. #{item}
  57. </foreach>
  58. and delete_time = 0
  59. </select>
  60. <select id="getTotalByAccountAndResps" resultType="java.math.BigDecimal">
  61. select IFNULL(sum(amount), 0)
  62. from cost_allocation_query
  63. where date_year = #{dateYear}
  64. and date_month = #{month}
  65. and hosp_id = #{hospId}
  66. and accounting_code = #{code}
  67. and responsibility_code in
  68. <foreach collection="respCodes" item="item" open="(" separator="," close=")">
  69. #{item}
  70. </foreach>
  71. and delete_time = 0
  72. </select>
  73. <select id="getTotalByAccountAndRespCode" resultType="java.math.BigDecimal">
  74. select IFNULL(sum(amount), 0)
  75. from cost_allocation_query
  76. where date_year = #{dateYear}
  77. and date_month = #{month}
  78. and hosp_id = #{hospId}
  79. and accounting_code = #{accountCode}
  80. and responsibility_code = #{responsibilityCode}
  81. and delete_time = 0
  82. </select>
  83. <select id="getAcountAccounts" resultType="com.kcim.dao.model.AllocationQuery">
  84. SELECT
  85. accounting_code,
  86. IFNULL( sum( amount ), 0 ) AS amount
  87. FROM
  88. cost_allocation_query
  89. WHERE
  90. date_year = #{dateYear}
  91. AND date_month = #{month}
  92. AND hosp_id = #{hospId}
  93. AND delete_time = 0
  94. GROUP BY
  95. accounting_code
  96. </select>
  97. <select id="getRespAcountAccounts" resultType="com.kcim.dao.model.AllocationQuery">
  98. SELECT
  99. responsibility_code,
  100. accounting_code,
  101. IFNULL( sum( amount ), 0 ) AS amount
  102. FROM
  103. cost_allocation_query
  104. WHERE
  105. date_year = #{dateYear}
  106. AND date_month = #{month}
  107. AND hosp_id = #{hospId}
  108. AND delete_time = 0
  109. GROUP BY
  110. responsibility_code,
  111. accounting_code
  112. </select>
  113. <select id="getRespOriginAcountAccounts" resultType="com.kcim.dao.model.AllocationQuery">
  114. SELECT
  115. responsibility_code,
  116. origin_type,
  117. accounting_code,
  118. IFNULL( sum( amount ), 0 ) AS amount
  119. FROM
  120. cost_allocation_query
  121. WHERE
  122. date_year = #{dateYear}
  123. AND date_month = #{month}
  124. AND hosp_id = #{hospId}
  125. AND delete_time = 0
  126. GROUP BY
  127. responsibility_code,
  128. origin_type,
  129. accounting_code
  130. </select>
  131. </mapper>