FinancialExpenditureMapper.xml 9.5 KB

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