FinancialExpenditureMapper.xml 12 KB

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