FinancialExpenditureMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.FinancialExpenditureDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.FinancialExpenditure" id="FinancialExpenditure">
  9. <result column="id_" property="id"/>
  10. <result column="batch_no_" property="batchNo"/>
  11. <result column="financial_process_no_" property="financialProcessNo"/>
  12. <result column="dingtalk_process_no_" property="dingtalkProcessNo"/>
  13. <result column="organ_id_" property="organId"/>
  14. <result column="cooperation_organ_id_" property="cooperationOrganId"/>
  15. <result column="apply_user_id_" property="applyUserId"/>
  16. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. <result column="fee_project_" property="feeProject" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  18. <result column="amount_" property="amount"/>
  19. <result column="item_detail_" property="itemDetail"/>
  20. <result column="payment_time_" property="paymentTime"/>
  21. <result column="del_flag_" property="delFlag"/>
  22. <result column="cause_" property="cause"/>
  23. <result column="create_time_" property="createTime"/>
  24. <result column="update_time_" property="updateTime"/>
  25. </resultMap>
  26. <!-- 根据主键查询一条记录 -->
  27. <select id="get" resultMap="FinancialExpenditure">
  28. SELECT * FROM financial_expenditure WHERE id_ = #{id}
  29. </select>
  30. <!-- 全查询 -->
  31. <select id="findAll" resultMap="FinancialExpenditure">
  32. SELECT * FROM financial_expenditure WHERE del_flag_ = 0 ORDER BY id_
  33. </select>
  34. <!-- 向数据库增加一条记录 -->
  35. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true" keyColumn="id"
  36. keyProperty="id">
  37. INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
  38. organ_id_,cooperation_organ_id_,apply_user_id_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_)
  39. VALUES(#{batchNo},#{financialProcessNo},#{dingtalkProcessNo},#{organId},#{cooperationOrganId},#{applyUserId},#{amount},
  40. #{itemDetail},#{paymentTime},#{cause},now(),now(),#{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  41. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  42. </insert>
  43. <insert id="batchInsert">
  44. INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
  45. organ_id_,cooperation_organ_id_,apply_user_id_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_)
  46. VALUES
  47. <foreach collection="financialExpenditures" item="item" separator=",">
  48. (#{item.batchNo},#{item.financialProcessNo},#{item.dingtalkProcessNo},#{item.organId},
  49. #{item.cooperationOrganId},#{item.applyUserId},#{item.amount},
  50. #{item.itemDetail},#{item.paymentTime},#{item.cause},now(),now(),
  51. #{item.feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  52. #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  53. </foreach>
  54. </insert>
  55. <!-- 根据主键查询一条记录 -->
  56. <update id="update" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure">
  57. UPDATE financial_expenditure
  58. <set>
  59. <if test="feeProject != null">
  60. fee_project_ = #{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  61. </if>
  62. <if test="type != null">
  63. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  64. </if>
  65. <if test="batchNo != null">
  66. batch_no_ = #{batchNo},
  67. </if>
  68. <if test="financialProcessNo != null">
  69. financial_process_no_ = #{financialProcessNo},
  70. </if>
  71. <if test="dingtalkProcessNo != null">
  72. dingtalk_process_no_ = #{dingtalkProcessNo},
  73. </if>
  74. <if test="organId != null">
  75. organ_id_ = #{organId},
  76. </if>
  77. <if test="cooperationOrganId != null">
  78. cooperation_organ_id_ = #{cooperationOrganId},
  79. </if>
  80. <if test="applyUserId != null">
  81. apply_user_id_ = #{applyUserId},
  82. </if>
  83. <if test="amount != null">
  84. amount_ = #{amount},
  85. </if>
  86. <if test="itemDetail != null">
  87. item_detail_ = #{itemDetail},
  88. </if>
  89. <if test="paymentTime != null">
  90. payment_time_ = #{paymentTime},
  91. </if>
  92. <if test="cause != null">
  93. cause_ = #{cause},
  94. </if>
  95. update_time_ = NOW()
  96. </set>
  97. WHERE id_ = #{id}
  98. </update>
  99. <!-- 根据主键删除一条记录 -->
  100. <update id="delete">
  101. UPDATE financial_expenditure SET del_flag_ = 1 WHERE id_ = #{id}
  102. </update>
  103. <update id="batchDel">
  104. UPDATE financial_expenditure SET del_flag_ = 1 WHERE FIND_IN_SET(id_,#{ids})
  105. </update>
  106. <sql id="queryPageSql">
  107. <where>
  108. fe.del_flag_ = 0
  109. <if test="batchNo != null and batchNo != ''">
  110. AND fe.batch_no_ = #{batchNo}
  111. </if>
  112. <if test="feeProject != null">
  113. AND fe.fee_project_ = #{feeProject}
  114. </if>
  115. <if test="type != null">
  116. AND fe.type_ = #{type}
  117. </if>
  118. <if test="financialProcessNo != null and financialProcessNo != ''">
  119. AND fe.financial_process_no_ = #{financialProcessNo}
  120. </if>
  121. <if test="dingtalkProcessNo != null and dingtalkProcessNo != ''">
  122. AND fe.dingtalk_process_no_ = #{dingtalkProcessNo}
  123. </if>
  124. <if test="search != null and search != ''">
  125. AND (fe.batch_no_ LIKE CONCAT('%',#{search},'%') OR fe.financial_process_no_ LIKE CONCAT('%',#{search},'%')
  126. OR fe.dingtalk_process_no_ LIKE CONCAT('%',#{search},'%') OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  127. </if>
  128. <if test="organId != null">
  129. AND fe.organ_id_ = #{organId}
  130. </if>
  131. <if test="cooperationOrganId != null">
  132. AND fe.cooperation_organ_id_ = #{cooperationOrganId}
  133. </if>
  134. <if test="applyUserId != null">
  135. AND fe.apply_user_id_ = #{applyUserId}
  136. </if>
  137. <if test="startTime != null and startTime != ''">
  138. AND DATE_FORMAT(fe.payment_time_,'%Y%m%d') &gt;= #{startTime}
  139. </if>
  140. <if test="endTime != null and endTime != ''">
  141. AND DATE_FORMAT(fe.payment_time_,'%Y%m%d') &lt;= #{endTime}
  142. </if>
  143. </where>
  144. </sql>
  145. <!-- 分页查询 -->
  146. <select id="queryPage" resultMap="FinancialExpenditure" parameterType="map">
  147. SELECT fe.*,o.name_ organ_name_,co.name_ cooperation_name_,su.real_name_
  148. FROM financial_expenditure fe
  149. LEFT JOIN organization o ON o.id_ = fe.organ_id_
  150. LEFT JOIN sys_user su ON su.id_ = fe.apply_user_id_
  151. LEFT JOIN cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
  152. <include refid="queryPageSql"/>
  153. <include refid="global.limit"/>
  154. </select>
  155. <!-- 查询当前表的总记录数 -->
  156. <select id="queryCount" resultType="int">
  157. SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
  158. LEFT JOIN sys_user su ON su.id_ = fe.apply_user_id_
  159. <include refid="queryPageSql"/>
  160. </select>
  161. <resultMap type="com.ym.mec.biz.dal.dto.FinancialExpenditureDto" id="FinancialExpenditureDto" extends="FinancialExpenditure">
  162. <result column="organ_name_" property="organName"/>
  163. <result column="cooperation_name_" property="cooperationName"/>
  164. <result column="real_name_" property="realName"/>
  165. </resultMap>
  166. <select id="findFinancialExpenditureCount" resultType="java.lang.Integer">
  167. SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
  168. LEFT JOIN sys_user su ON su.id_ = fe.apply_user_id_
  169. <include refid="queryPageSql"/>
  170. </select>
  171. <select id="queryFinancialExpenditurePage" resultMap="FinancialExpenditureDto">
  172. SELECT fe.*,o.name_ organ_name_,co.name_ cooperation_name_,su.real_name_
  173. FROM financial_expenditure fe
  174. LEFT JOIN organization o ON o.id_ = fe.organ_id_
  175. LEFT JOIN sys_user su ON su.id_ = fe.apply_user_id_
  176. LEFT JOIN cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
  177. <include refid="queryPageSql"/>
  178. <include refid="global.limit"/>
  179. </select>
  180. <!-- 统计合作单位的支出 -->
  181. <select id="getCooperationExpenditure" resultMap="FinancialExpenditure">
  182. SELECT organ_id_,cooperation_organ_id_, type_, SUM(amount_) amount_ FROM financial_expenditure WHERE del_flag_ =0
  183. GROUP BY organ_id_,cooperation_organ_id_,type_
  184. </select>
  185. <select id="countBydingTalk" resultType="java.lang.String">
  186. SELECT dingtalk_process_no_ FROM financial_expenditure WHERE dingtalk_process_no_ IN
  187. <foreach collection="collect" separator="," open="(" close=")" item="item">
  188. #{item}
  189. </foreach>
  190. GROUP BY dingtalk_process_no_
  191. </select>
  192. </mapper>