StatementMapper.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.web.work.mapper.StatementMapper">
  6. <sql id="selectStatementVo">
  7. SELECT
  8. s.id,
  9. s.company_id,
  10. s.num,
  11. s.channel,
  12. s.invoice,
  13. s.state,
  14. s.audit,
  15. s.give,
  16. s.batch_name,
  17. s.file_name,
  18. s.msg,
  19. s.service_company,
  20. s.create_time,
  21. s.generate_time,
  22. s.submit_time,
  23. s.audit_time,
  24. s.give_time,
  25. ( SELECT COUNT( d.id ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS peoples,
  26. ( SELECT SUM( d.money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS money,
  27. ( SELECT SUM( d.real_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS real_money,
  28. ( SELECT SUM( d.service_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS service_money,
  29. p.project_name,
  30. c.company_name
  31. FROM
  32. tb_statement s
  33. LEFT JOIN tb_project p ON p.id = s.project_id
  34. LEFT JOIN tb_company c ON c.id = s.company_id
  35. </sql>
  36. <select id="selectList" resultType="com.ruoyi.web.work.domain.Statement">
  37. <include refid="selectStatementVo"/>
  38. <where>
  39. <if test="companyId != null "> and s.company_id = #{companyId}</if>
  40. <if test="batchName != null and batchName != ''"> and s.batch_name like concat('%', #{batchName}, '%')</if>
  41. <if test="num != null and num != ''"> and s.num like concat('%', #{num}, '%')</if>
  42. <if test="projectId != null "> and s.project_id = #{projectId}</if>
  43. <if test="state != null "> and s.state = #{state}</if>
  44. <if test="give != null "> and s.give = #{give}</if>
  45. <if test="dateBegin != null and dateBegin != ''"> AND s.give_time BETWEEN #{dateBegin} AND #{dateEnd} + INTERVAL 1 DAY</if>
  46. <choose>
  47. <when test="auditors">
  48. <if test="audit == null "> and s.audit <![CDATA[ >= ]]> 1</if>
  49. <if test="audit != null "> and s.audit=#{audit} and s.audit <![CDATA[ >= ]]> 1</if>
  50. </when>
  51. <otherwise>
  52. <if test="audit != null "> and s.audit = #{audit}</if>
  53. </otherwise>
  54. </choose>
  55. </where>
  56. </select>
  57. <select id="selectPayList" resultType="com.ruoyi.web.work.domain.Statement">
  58. <include refid="selectStatementVo"/>
  59. <where>
  60. <if test="num != null and num != ''"> and s.num like concat('%', #{num}, '%')</if>
  61. <choose>
  62. <when test="give != null">and s.give=#{give} and s.give <![CDATA[ >= ]]> 1</when>
  63. <otherwise>and s.give <![CDATA[ >= ]]> 1</otherwise>
  64. </choose>
  65. <if test="dateBegin != null and dateBegin != ''"> AND s.give_time BETWEEN #{dateBegin} AND #{dateEnd} + INTERVAL 1 DAY</if>
  66. </where>
  67. </select>
  68. <select id="calculate" resultType="com.ruoyi.web.work.domain.Statement">
  69. SELECT
  70. s.id,
  71. s.audit,
  72. s.give,
  73. s.company_id,
  74. ( SELECT SUM( d.money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS money,
  75. ( SELECT SUM( d.real_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS realMoney,
  76. ( SELECT SUM( d.service_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS serviceMoney,
  77. ( SELECT COUNT( d.id ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS peoples
  78. FROM
  79. tb_statement s
  80. WHERE
  81. s.id =#{id}
  82. </select>
  83. </mapper>