CostCostingGroupMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. ccg.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 cost_responsibility cr
  43. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  44. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  45. left join cost_product cp
  46. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  47. where ccg.delete_time = 0
  48. and ccg.date_year = #{year}
  49. and ccg.date_month = #{month}
  50. and ccg.hosp_id = #{hospId}
  51. <if test="responsibilityCode != null and responsibilityCode != ''">
  52. and ccg.responsibility_code = #{responsibilityCode}
  53. </if>
  54. <if test="accountCode != null and accountCode != ''">
  55. and ccg.account_code = #{accountCode}
  56. </if>
  57. and cr.delete_time = 0
  58. and ca.delete_time = 0
  59. limit #{startIndex},#{pageSize}
  60. </select>
  61. <select id="queryStartAllocationCount" resultType="java.lang.Integer">
  62. select
  63. count(*)
  64. from cost_costing_group ccg
  65. left join cost_responsibility cr
  66. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  67. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  68. left join cost_product cp
  69. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  70. where ccg.delete_time = 0
  71. and ccg.date_year = #{year}
  72. and ccg.date_month = #{month}
  73. and ccg.hosp_id = #{hospId}
  74. <if test="responsibilityCode != null and responsibilityCode != ''">
  75. and ccg.responsibility_code = #{responsibilityCode}
  76. </if>
  77. <if test="accountCode != null and accountCode != ''">
  78. and ccg.account_code = #{accountCode}
  79. </if>
  80. and cr.delete_time = 0
  81. and ca.delete_time = 0
  82. </select>
  83. <select id="queryStartAllocationTotalAmount" resultType="java.math.BigDecimal">
  84. select
  85. sum(ccg.amount)
  86. from cost_costing_group ccg
  87. left join cost_responsibility cr
  88. on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
  89. left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
  90. left join cost_product cp
  91. on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
  92. where ccg.delete_time = 0
  93. and ccg.date_year = #{year}
  94. and ccg.date_month = #{month}
  95. and ccg.hosp_id = #{hospId}
  96. <if test="responsibilityCode != null and responsibilityCode != ''">
  97. and ccg.responsibility_code = #{responsibilityCode}
  98. </if>
  99. <if test="accountCode != null and accountCode != ''">
  100. and ccg.account_code = #{accountCode}
  101. </if>
  102. and cr.delete_time = 0
  103. and ca.delete_time = 0
  104. </select>
  105. <select id="queryAllocation" resultType="com.imed.costaccount.model.vo.AllocationVO">
  106. select date_year as year,date_month as month,IFNULL(sum(amount),0) as amount,false as isAllocation
  107. from cost_costing_group
  108. where delete_time = 0
  109. <if test="year != null">
  110. and date_year = #{year}
  111. and date_month = #{month}
  112. </if>
  113. and hosp_id = #{hospId} group by date_year,date_month
  114. limit #{startIndex},#{pageSize}
  115. </select>
  116. <select id="queryAllocationCount" resultType="java.lang.Integer">
  117. select count(*) from (select count(*)
  118. from cost_costing_group
  119. where delete_time = 0
  120. <if test="year != null">
  121. and date_year = #{year}
  122. and date_month = #{month}
  123. </if>
  124. and hosp_id = #{hospId} group by date_year,date_month) t
  125. </select>
  126. </mapper>