CostCostingGroupMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.imed.costaccount.mapper.CostCostingGroupMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.imed.costaccount.model.CostCostingGroup" id="costCostingGroupMap">
  6. <result property="id" column="id"/>
  7. <result property="departmentCode" column="department_code"/>
  8. <result property="departmentName" column="department_name"/>
  9. <result property="responsibilityCode" column="responsibility_code"/>
  10. <result property="responsibilityName" column="responsibility_name"/>
  11. <result property="otherResponsibilityCode" column="other_responsibility_code"/>
  12. <result property="otherResponsibilityName" column="other_responsibility_name"/>
  13. <result property="productCode" column="product_code"/>
  14. <result property="productName" column="product_name"/>
  15. <result property="accountCode" column="account_code"/>
  16. <result property="accountName" column="account_name"/>
  17. <result property="amount" column="amount"/>
  18. <result property="hospId" column="hosp_id"/>
  19. <result property="fileId" column="file_id"/>
  20. <result property="afterCostGroup" column="after_cost_group"/>
  21. <result property="dateYear" column="date_year"/>
  22. <result property="dateMonth" column="date_month"/>
  23. <result property="createTime" column="create_time"/>
  24. <result property="deleteTime" column="delete_time"/>
  25. </resultMap>
  26. <select id="queryStartAllocation" resultType="com.imed.costaccount.model.vo.CostingGroupStartVO">
  27. select
  28. ccg.id as id,
  29. ccg.date_year as year,
  30. ccg.date_month as month,
  31. ccg.amount as amount,
  32. ccg.department_code as departCode,
  33. sd.department_name as departName,
  34. ccg.responsibility_code as responsibilityCode,
  35. cr.responsibility_name as responsibilityName,
  36. ccg.account_code as accountCode,
  37. ccg.account_name as accountName,
  38. ccg.product_code as productCode,
  39. cp.product_name as productName,
  40. ccg.file_id as fileId
  41. from cost_costing_group ccg
  42. left join sys_department sd
  43. on ccg.hosp_id = sd.hosp_id and ccg.department_code = sd.department_code
  44. left join cost_responsibility cr
  45. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  46. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  47. left join cost_product cp
  48. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  49. where ccg.delete_time = 0
  50. and ccg.date_year = #{year}
  51. and ccg.date_month = #{month}
  52. and ccg.hosp_id = #{hospId}
  53. <if test="responsibilityCode != null and responsibilityCode != ''">
  54. and ccg.responsibility_code = #{responsibilityCode}
  55. </if>
  56. <if test="accountCode != null and accountCode != ''">
  57. and ccg.account_code = #{accountCode}
  58. </if>
  59. and sd.delete_time = 0
  60. and cr.delete_time = 0
  61. and ca.delete_time = 0
  62. limit #{startIndex},#{pageSize}
  63. </select>
  64. <select id="queryStartAllocationCount" resultType="java.lang.Integer">
  65. select
  66. count(*)
  67. from cost_costing_group ccg
  68. left join sys_department sd
  69. on ccg.hosp_id = sd.hosp_id and ccg.department_code = sd.department_code
  70. left join cost_responsibility cr
  71. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  72. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  73. left join cost_product cp
  74. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  75. where ccg.delete_time = 0
  76. and ccg.date_year = #{year}
  77. and ccg.date_month = #{month}
  78. and ccg.hosp_id = #{hospId}
  79. <if test="responsibilityCode != null and responsibilityCode != ''">
  80. and ccg.responsibility_code = #{responsibilityCode}
  81. </if>
  82. <if test="accountCode != null and accountCode != ''">
  83. and ccg.account_code = #{accountCode}
  84. </if>
  85. and sd.delete_time = 0
  86. and cr.delete_time = 0
  87. and ca.delete_time = 0
  88. </select>
  89. <select id="queryStartAllocationTotalAmount" resultType="java.math.BigDecimal">
  90. select
  91. sum(ccg.amount)
  92. from cost_costing_group ccg
  93. left join cost_responsibility cr
  94. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  95. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  96. left join cost_product cp
  97. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  98. where ccg.delete_time = 0
  99. and ccg.date_year = #{year}
  100. and ccg.date_month = #{month}
  101. and ccg.hosp_id = #{hospId}
  102. <if test="responsibilityCode != null and responsibilityCode != ''">
  103. and ccg.responsibility_code = #{responsibilityCode}
  104. </if>
  105. <if test="accountCode != null and accountCode != ''">
  106. and ccg.account_code = #{accountCode}
  107. </if>
  108. and cr.delete_time = 0
  109. and ca.delete_time = 0
  110. </select>
  111. <select id="queryAllocation" resultType="com.imed.costaccount.model.vo.AllocationVO">
  112. select date_year as year,date_month as month,IFNULL(sum(amount),0) as amount,false as isAllocation
  113. from cost_costing_group
  114. where delete_time = 0
  115. <if test="year != null">
  116. and date_year = #{year}
  117. and date_month = #{month}
  118. </if>
  119. and hosp_id = #{hospId} group by date_year,date_month
  120. limit #{startIndex},#{pageSize}
  121. </select>
  122. <select id="queryAllocationCount" resultType="java.lang.Integer">
  123. select count(*) from (select count(*)
  124. from cost_costing_group
  125. where delete_time = 0
  126. <if test="year != null">
  127. and date_year = #{year}
  128. and date_month = #{month}
  129. </if>
  130. and hosp_id = #{hospId} group by date_year,date_month) t
  131. </select>
  132. </mapper>