ExamManualLedgerMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.keao.edu.user.dao.ExamManualLedgerDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamManualLedger" id="ExamManualLedger">
  9. <result column="id_" property="id" />
  10. <result column="organ_id_" property="organId"/>
  11. <result column="target_organ_id_" property="targetOrganId"/>
  12. <result column="examination_basic_id_" property="examinationBasicId" />
  13. <result column="trans_direction_" property="transDirection" />
  14. <result column="amount_" property="amount" />
  15. <result column="trans_time_" property="transTime" />
  16. <result column="memo_" property="memo" />
  17. <result column="operator_user_id_" property="operatorUserId" />
  18. <result column="tenant_id_" property="tenantId" />
  19. <result column="create_time_" property="createTime" />
  20. <association property="organization" columnPrefix="organ_" resultMap="com.keao.edu.user.dao.OrganizationDao.Organization"/>
  21. <association property="operator" columnPrefix="user_" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  22. </resultMap>
  23. <!-- 根据主键查询一条记录 -->
  24. <select id="get" resultMap="ExamManualLedger" >
  25. SELECT * FROM exam_manual_ledger WHERE id_ = #{id}
  26. </select>
  27. <!-- 全查询 -->
  28. <select id="findAll" resultMap="ExamManualLedger">
  29. SELECT * FROM exam_manual_ledger ORDER BY id_
  30. </select>
  31. <!-- 向数据库增加一条记录 -->
  32. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamManualLedger" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  33. <!--
  34. <selectKey resultClass="int" keyProperty="id" >
  35. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  36. </selectKey>
  37. -->
  38. INSERT INTO exam_manual_ledger (organ_id_,target_organ_id_,examination_basic_id_,trans_direction_,amount_,trans_time_,memo_,operator_user_id_,tenant_id_,create_time_)
  39. VALUES(#{organId},#{targetOrganId},#{examinationBasicId},#{transDirection},#{amount},#{transTime},#{memo},#{operatorUserId},#{tenantId},NOW())
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.keao.edu.user.entity.ExamManualLedger">
  43. UPDATE exam_manual_ledger
  44. <set>
  45. <if test="organId!=null">
  46. organ_id_=#{organId},
  47. </if>
  48. <if test="targetOrganId!=null">
  49. target_organ_id_=#{targetOrganId},
  50. </if>
  51. <if test="examinationBasicId != null">
  52. examination_basic_id_ = #{examinationBasicId},
  53. </if>
  54. <if test="transDirection != null">
  55. trans_direction_ = #{transDirection},
  56. </if>
  57. <if test="amount != null">
  58. amount_ = #{amount},
  59. </if>
  60. <if test="transTime != null">
  61. trans_time_ = #{transTime},
  62. </if>
  63. <if test="memo != null">
  64. memo_ = #{memo},
  65. </if>
  66. <if test="operatorUserId != null">
  67. operator_user_id_ = #{operatorUserId},
  68. </if>
  69. </set> WHERE id_ = #{id}
  70. </update>
  71. <!-- 根据主键删除一条记录 -->
  72. <delete id="delete" >
  73. DELETE FROM exam_manual_ledger WHERE id_ = #{id}
  74. </delete>
  75. <!-- 分页查询 -->
  76. <select id="queryPage" resultMap="ExamManualLedger" parameterType="map">
  77. SELECT * FROM exam_manual_ledger
  78. WHERE examination_basic_id_=#{examId}
  79. ORDER BY id_
  80. <include refid="global.limit"/>
  81. </select>
  82. <!-- 查询当前表的总记录数 -->
  83. <select id="queryCount" resultType="int">
  84. SELECT COUNT(*) FROM exam_manual_ledger
  85. WHERE examination_basic_id_=#{examId}
  86. </select>
  87. <sql id="queryExamManualLedgersCondition">
  88. <where>
  89. examination_basic_id_=#{examId}
  90. <if test="organId!=null and organId!=0">
  91. AND organ_id_=#{organId}
  92. </if>
  93. </where>
  94. </sql>
  95. <select id="queryExamManualLedgers" resultMap="ExamManualLedger" parameterType="map">
  96. SELECT
  97. eml.*,
  98. CASE WHEN o.name_ IS NOT NULL THEN o.name_ ELSE '其他' END organ_name_,
  99. su.real_name_ user_real_name_
  100. FROM
  101. exam_manual_ledger eml
  102. LEFT JOIN organization o ON eml.target_organ_id_ = o.id_
  103. LEFT JOIN sys_user su ON eml.operator_user_id_ = su.id_
  104. <include refid="queryExamManualLedgersCondition"/>
  105. ORDER BY id_
  106. <include refid="global.limit"/>
  107. </select>
  108. <select id="countExamManualLedgers" resultType="int">
  109. SELECT COUNT(*) FROM exam_manual_ledger
  110. <include refid="queryExamManualLedgersCondition"/>
  111. </select>
  112. <select id="getExamManualLedgerStatistics" resultType="com.keao.edu.user.dto.ExamManualLedgerStatisticsDto">
  113. SELECT
  114. COUNT( id_ ) expenditureNum,
  115. SUM( amount_ ) expenditureFee
  116. FROM
  117. exam_manual_ledger
  118. WHERE
  119. examination_basic_id_ = #{examId}
  120. <if test="organId!=null and organId!=0">
  121. AND organ_id_=#{organId}
  122. </if>
  123. AND trans_direction_ = 'EXPENDITURE'
  124. </select>
  125. <select id="getExamOrganManualLedgers" resultMap="ExamManualLedger">
  126. SELECT
  127. *
  128. FROM
  129. exam_manual_ledger
  130. WHERE
  131. examination_basic_id_ = #{examId}
  132. AND organ_id_ = #{organId}
  133. AND DATE_FORMAT( trans_time_, '%Y-%m-%d' ) IN
  134. <foreach collection="days" item="day" separator="," open="(" close=")">
  135. #{day}
  136. </foreach>
  137. </select>
  138. </mapper>