FinancialExpenditureMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true"
  53. keyColumn="id"
  54. keyProperty="id">
  55. INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
  56. organ_id_,cooperation_organ_id_,apply_user_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_)
  57. VALUES
  58. <foreach collection="financialExpenditures" item="item" separator=",">
  59. (#{item.batchNo},#{item.financialProcessNo},#{item.dingtalkProcessNo},#{item.organId},
  60. #{item.cooperationOrganId},#{item.applyUser},#{item.amount},
  61. #{item.itemDetail},#{item.paymentTime},#{item.cause},now(),now(),
  62. #{item.feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  63. #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  64. </foreach>
  65. </insert>
  66. <!-- 根据主键查询一条记录 -->
  67. <update id="update" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure">
  68. UPDATE financial_expenditure
  69. <set>
  70. <if test="feeProject != null">
  71. fee_project_ = #{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  72. </if>
  73. <if test="type != null">
  74. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  75. </if>
  76. <if test="batchNo != null">
  77. batch_no_ = #{batchNo},
  78. </if>
  79. <if test="financialProcessNo != null">
  80. financial_process_no_ = #{financialProcessNo},
  81. </if>
  82. <if test="dingtalkProcessNo != null">
  83. dingtalk_process_no_ = #{dingtalkProcessNo},
  84. </if>
  85. <if test="organId != null">
  86. organ_id_ = #{organId},
  87. </if>
  88. <if test="cooperationOrganId != null">
  89. cooperation_organ_id_ = #{cooperationOrganId},
  90. </if>
  91. <if test="applyUser != null">
  92. apply_user_ = #{applyUser},
  93. </if>
  94. <if test="amount != null">
  95. amount_ = #{amount},
  96. </if>
  97. <if test="itemDetail != null">
  98. item_detail_ = #{itemDetail},
  99. </if>
  100. <if test="paymentTime != null">
  101. payment_time_ = #{paymentTime},
  102. </if>
  103. <if test="cause != null">
  104. cause_ = #{cause},
  105. </if>
  106. update_time_ = NOW()
  107. </set>
  108. WHERE id_ = #{id}
  109. </update>
  110. <!-- 根据主键删除一条记录 -->
  111. <update id="delete">
  112. UPDATE financial_expenditure
  113. SET del_flag_ = 1
  114. WHERE id_ = #{id}
  115. </update>
  116. <update id="batchDel">
  117. UPDATE financial_expenditure
  118. SET del_flag_ = 1
  119. WHERE FIND_IN_SET(id_, #{ids})
  120. </update>
  121. <sql id="queryPageSql">
  122. <where>
  123. fe.del_flag_ = 0
  124. <if test="batchNo != null and batchNo != ''">
  125. AND fe.batch_no_ = #{batchNo}
  126. </if>
  127. <if test="feeProject != null">
  128. AND fe.fee_project_ = #{feeProject}
  129. </if>
  130. <if test="type != null">
  131. AND fe.type_ = #{type}
  132. </if>
  133. <if test="financialProcessNo != null and financialProcessNo != ''">
  134. AND fe.financial_process_no_ = #{financialProcessNo}
  135. </if>
  136. <if test="dingtalkProcessNo != null and dingtalkProcessNo != ''">
  137. AND fe.dingtalk_process_no_ = #{dingtalkProcessNo}
  138. </if>
  139. <if test="search != null and search != ''">
  140. AND (fe.id_ LIKE CONCAT('%',#{search},'%') OR fe.financial_process_no_ LIKE CONCAT('%',#{search},'%')
  141. OR fe.dingtalk_process_no_ LIKE CONCAT('%',#{search},'%') OR fe.apply_user_ LIKE
  142. CONCAT('%',#{search},'%'))
  143. </if>
  144. <if test="organId != null and organId != ''">
  145. AND FIND_IN_SET(fe.organ_id_,#{organId})
  146. </if>
  147. <if test="cooperationOrganId != null">
  148. AND fe.cooperation_organ_id_ = #{cooperationOrganId}
  149. </if>
  150. <if test="startTime != null and startTime != ''">
  151. AND DATE_FORMAT(fe.payment_time_,'%Y-%m-%d') &gt;= #{startTime}
  152. </if>
  153. <if test="endTime != null and endTime != ''">
  154. AND DATE_FORMAT(fe.payment_time_,'%Y-%m-%d') &lt;= #{endTime}
  155. </if>
  156. </where>
  157. </sql>
  158. <!-- 分页查询 -->
  159. <select id="queryPage" resultMap="FinancialExpenditure" parameterType="map">
  160. SELECT fe.*,o.name_ organ_name_,co.name_ cooperation_name_,su.real_name_
  161. FROM financial_expenditure fe
  162. LEFT JOIN organization o ON o.id_ = fe.organ_id_
  163. LEFT JOIN cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
  164. <include refid="queryPageSql"/>
  165. <include refid="global.limit"/>
  166. </select>
  167. <!-- 查询当前表的总记录数 -->
  168. <select id="queryCount" resultType="int">
  169. SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
  170. <include refid="queryPageSql"/>
  171. </select>
  172. <resultMap type="com.ym.mec.biz.dal.dto.FinancialExpenditureDto" id="FinancialExpenditureDto"
  173. extends="FinancialExpenditure">
  174. <result column="organ_name_" property="organName"/>
  175. <result column="cooperation_name_" property="cooperationName"/>
  176. </resultMap>
  177. <select id="findFinancialExpenditureCount" resultType="java.lang.Integer">
  178. SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
  179. <include refid="queryPageSql"/>
  180. </select>
  181. <select id="queryFinancialExpenditurePage" resultMap="FinancialExpenditureDto">
  182. SELECT fe.*,o.name_ organ_name_,co.name_ cooperation_name_
  183. FROM financial_expenditure fe
  184. LEFT JOIN organization o ON o.id_ = fe.organ_id_
  185. LEFT JOIN cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
  186. <include refid="queryPageSql"/>
  187. ORDER BY fe.id_ DESC
  188. <include refid="global.limit"/>
  189. </select>
  190. <!-- 统计合作单位的支出 -->
  191. <select id="getCooperationExpenditure" resultMap="FinancialExpenditure"><![CDATA[
  192. SELECT organ_id_, cooperation_organ_id_, type_, SUM(amount_) amount_
  193. FROM financial_expenditure
  194. WHERE payment_time_ >= #{startTime}
  195. AND payment_time_ <= #{endTime}
  196. AND del_flag_ = 0
  197. GROUP BY organ_id_, cooperation_organ_id_, type_
  198. ]]></select>
  199. <select id="countBydingTalk" resultType="java.lang.String">
  200. SELECT dingtalk_process_no_ FROM financial_expenditure WHERE del_flag_ = 0 AND dingtalk_process_no_ IN
  201. <foreach collection="collect" separator="," open="(" close=")" item="item">
  202. #{item}
  203. </foreach>
  204. GROUP BY dingtalk_process_no_
  205. </select>
  206. <resultMap id="PWorkOrderInfo" type="com.ym.mec.biz.dal.dto.PWorkOrderInfo">
  207. <result property="id" column="id"/>
  208. <result property="classify" column="classify"/>
  209. <result property="isEnd" column="is_end"/>
  210. <result property="isDenied" column="is_denied"/>
  211. <result property="isCancel" column="is_cancel"/>
  212. <result property="creator" column="mec_user_id"/>
  213. <result property="process" column="process"/>
  214. <result property="title" column="title"/>
  215. <result property="deptId" column="dept_id"/>
  216. </resultMap>
  217. <select id="getWorkOrderInfo" resultMap="PWorkOrderInfo">
  218. SELECT woi.*,su.mec_user_id FROM mec_dev_api.p_work_order_info woi
  219. LEFT JOIN mec_dev_api.p_work_order_circulation_history woch ON woi.id = woch.work_order
  220. LEFT JOIN mec_dev_api.p_process_info pi ON pi.id = woi.classify
  221. LEFT JOIN mec_dev_api.sys_user su ON su.user_id = woi.creator
  222. WHERE woi.is_end = 1 AND woi.is_denied = 0 AND woi.is_cancel = 0
  223. AND woch.`status` != 0 AND woi.id = #{workOrderId} AND pi.fee_type = 1 LIMIT 1
  224. </select>
  225. <select id="getFormStructure" resultType="java.lang.String">
  226. SELECT form_structure FROM mec_dev_api.p_work_order_tpl_data WHERE work_order = #{workOrderId}
  227. </select>
  228. <select id="getFormData" resultType="java.lang.String">
  229. SELECT form_data FROM mec_dev_api.p_work_order_tpl_data WHERE work_order = #{workOrderId}
  230. </select>
  231. <select id="getTplInfo" resultType="java.lang.String">
  232. SELECT form_structure FROM mec_dev_api.p_tpl_info WHERE id = #{tplInfoId}
  233. </select>
  234. <select id="findByBatchNoAndProcessNo" resultType="integer">
  235. SELECT id_ FROM financial_expenditure WHERE batch_no_ = #{workOrderId} AND financial_process_no_ = #{workOrderId} LIMIT 1
  236. </select>
  237. <select id="getDeptId" resultType="java.lang.Integer">
  238. SELECT organ_id FROM mec_dev_api.sys_dept WHERE dept_id = #{deptId}
  239. </select>
  240. </mapper>