AccountHeadMapperEx.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.jsh.erp.datasource.mappers.AccountHeadMapperEx">
  4. <resultMap extends="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap" id="ResultMapEx" type="com.jsh.erp.datasource.entities.AccountHeadVo4ListEx">
  5. <result column="OrganName" jdbcType="VARCHAR" property="organName" />
  6. <result column="HandsPersonName" jdbcType="VARCHAR" property="handsPersonName" />
  7. <result column="userName" jdbcType="VARCHAR" property="userName" />
  8. <result column="AccountName" jdbcType="VARCHAR" property="accountName" />
  9. </resultMap>
  10. <select id="selectByConditionAccountHead" parameterType="com.jsh.erp.datasource.entities.AccountHeadExample" resultMap="ResultMapEx">
  11. select distinct ah.*, s.supplier OrganName, p.Name HandsPersonName, u.username userName, a.Name AccountName
  12. from jsh_account_head ah
  13. left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
  14. left join jsh_depot_head dh on dh.id=ai.bill_id and ifnull(dh.delete_flag,'0') !='1'
  15. left join jsh_supplier s on ah.organ_id=s.id and ifnull(s.delete_Flag,'0') !='1'
  16. left join jsh_user u on ah.creator=u.id and ifnull(u.delete_flag,'0') !='1'
  17. left join jsh_person p on ah.hands_person_id=p.id and ifnull(p.delete_Flag,'0') !='1'
  18. left join jsh_account a on ah.account_id=a.id and ifnull(a.delete_Flag,'0') !='1'
  19. where 1=1
  20. <if test="billNo != null">
  21. <bind name="bindBillNo" value="'%'+billNo+'%'"/>
  22. and ah.bill_no like #{bindBillNo}
  23. </if>
  24. <if test="type != null">
  25. and ah.type=#{type}
  26. </if>
  27. <if test="beginTime != null">
  28. and ah.bill_time &gt;= #{beginTime}
  29. </if>
  30. <if test="endTime != null">
  31. and ah.bill_time &lt;= #{endTime}
  32. </if>
  33. <if test="organId != null">
  34. and ah.organ_id=#{organId}
  35. </if>
  36. <if test="handsPersonId != null">
  37. and ah.hands_person_id=#{handsPersonId}
  38. </if>
  39. <if test="creator != null">
  40. and ah.creator=#{creator}
  41. </if>
  42. <if test="creatorArray != null">
  43. and ah.creator in (
  44. <foreach collection="creatorArray" item="creator" separator=",">
  45. #{creator}
  46. </foreach>
  47. )
  48. </if>
  49. <if test="accountId != null">
  50. and ah.account_id=#{accountId}
  51. </if>
  52. <if test="status != null and status != ''">
  53. and ah.status=#{status}
  54. </if>
  55. <if test="remark != null and remark !=''">
  56. <bind name="bindRemark" value="'%'+remark+'%'"/>
  57. and ah.remark like #{bindRemark}
  58. </if>
  59. <if test="number != null and number !=''">
  60. <if test="number == 'QiChu'">
  61. and ai.bill_id is null
  62. </if>
  63. <if test="number != 'QiChu'">
  64. <bind name="bindNumber" value="'%'+number+'%'"/>
  65. and dh.number like #{bindNumber}
  66. </if>
  67. </if>
  68. <if test="inOutItemId != null">
  69. and ai.in_out_item_id=#{inOutItemId}
  70. </if>
  71. and ifnull(ah.delete_flag,'0') !='1'
  72. order by ah.id desc
  73. </select>
  74. <select id="getDetailByNumber" parameterType="com.jsh.erp.datasource.entities.AccountHeadExample" resultMap="ResultMapEx">
  75. select ah.*, s.supplier OrganName, p.Name HandsPersonName, a.Name AccountName
  76. from jsh_account_head ah
  77. left join jsh_supplier s on ah.organ_id=s.id and ifnull(s.delete_Flag,'0') !='1'
  78. left join jsh_person p on ah.hands_person_id=p.id and ifnull(p.delete_Flag,'0') !='1'
  79. left join jsh_account a on ah.account_id=a.id and ifnull(a.delete_Flag,'0') !='1'
  80. where 1=1
  81. <if test="billNo != null">
  82. and ah.bill_no = #{billNo}
  83. </if>
  84. and ifnull(ah.delete_flag,'0') !='1'
  85. </select>
  86. <update id="batchDeleteAccountHeadByIds">
  87. update jsh_account_head
  88. set delete_flag='1'
  89. where 1=1
  90. and id in (
  91. <foreach collection="ids" item="id" separator=",">
  92. #{id}
  93. </foreach>
  94. )
  95. </update>
  96. <select id="getAccountHeadListByAccountIds" resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
  97. select
  98. <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
  99. from jsh_account_head
  100. where 1=1
  101. and account_id in (
  102. <foreach collection="accountIds" item="accountId" separator=",">
  103. #{accountId}
  104. </foreach>
  105. )
  106. and ifnull(delete_flag,'0') !='1'
  107. </select>
  108. <select id="getAccountHeadListByOrganIds" resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
  109. select
  110. <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
  111. from jsh_account_head
  112. where 1=1
  113. and organ_id in (
  114. <foreach collection="organIds" item="organId" separator=",">
  115. #{organId}
  116. </foreach>
  117. )
  118. and ifnull(delete_flag,'0') !='1'
  119. </select>
  120. <select id="getAccountHeadListByHandsPersonIds" resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
  121. select
  122. <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
  123. from jsh_account_head
  124. where 1=1
  125. and hands_person_id in (
  126. <foreach collection="handsPersonIds" item="handsPersonId" separator=",">
  127. #{handsPersonId}
  128. </foreach>
  129. )
  130. and ifnull(delete_flag,'0') !='1'
  131. </select>
  132. <select id="getFinancialBillNoByBillIdList" resultType="com.jsh.erp.datasource.entities.AccountItem">
  133. select ai.bill_id from jsh_account_head ah
  134. left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
  135. where 1=1
  136. <if test="idList.size()>0">
  137. and ai.bill_id in
  138. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  139. #{item}
  140. </foreach>
  141. </if>
  142. and ifnull(ah.delete_flag,'0') !='1'
  143. </select>
  144. <select id="getFinancialBillNoByBillId" resultType="com.jsh.erp.datasource.entities.AccountHead">
  145. select ah.bill_no from jsh_account_head ah
  146. left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
  147. where ai.bill_id=#{billId}
  148. and ifnull(ah.delete_flag,'0') !='1'
  149. </select>
  150. <select id="getFinancialAllPriceByOrganId" resultType="java.math.BigDecimal">
  151. select ifnull(sum(ah.total_price),0) allPrice from jsh_account_head ah
  152. where ah.organ_id=#{organId}
  153. and ah.type = '收预付款'
  154. and ifnull(ah.delete_flag,'0') !='1'
  155. </select>
  156. </mapper>