FreezeMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. <mapper namespace="com.dk.mdm.mapper.mst.FreezeMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. freeze_id, freeze_no, cus_id, org_id, staff_id, freeze_status, freeze_date, auto_unfreeze_date, sum_quantity, remarks, make_staff, make_time, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.common.model.response.mst.FreezeResponse">
  11. <id column="freeze_id" property="freezeId"/>
  12. <result column="freeze_no" property="freezeNo"/>
  13. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  14. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  15. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  16. <result column="freeze_status" property="freezeStatus"/>
  17. <result column="freeze_date" property="freezeDate" typeHandler="TimestampTypeHandler"/>
  18. <result column="auto_unfreeze_date" property="autoUnfreezeDate" typeHandler="TimestampTypeHandler"/>
  19. <result column="sum_quantity" property="sumQuantity"/>
  20. <result column="remarks" property="remarks"/>
  21. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  22. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  23. <result column="flg_valid" property="flgValid"/>
  24. <result column="cp_id" property="cpId"/>
  25. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  26. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  27. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  28. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  29. <result column="op_app_code" property="opAppCode"/>
  30. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  31. <result column="op_db_user" property="opDbUser"/>
  32. </resultMap>
  33. <!-- 通用条件列 -->
  34. <sql id="Condition">
  35. <where>
  36. <if test="freezeNo != null and freezeNo != ''">
  37. AND freeze_no = #{freezeNo}
  38. </if>
  39. <if test="cusId != null and cusId != ''">
  40. AND cus_id = #{cusId}
  41. </if>
  42. <if test="orgId != null and orgId != ''">
  43. AND org_id = #{orgId}
  44. </if>
  45. <if test="staffId != null and staffId != ''">
  46. AND staff_id = #{staffId}
  47. </if>
  48. <if test="freezeStatus != null and freezeStatus != ''">
  49. AND freeze_status = #{freezeStatus}
  50. </if>
  51. <if test="freezeDate != null">
  52. AND freeze_date = #{freezeDate}
  53. </if>
  54. <if test="autoUnfreezeDate != null">
  55. AND auto_unfreeze_date = #{autoUnfreezeDate}
  56. </if>
  57. <if test="sumQuantity != null">
  58. AND sum_quantity = #{sumQuantity}
  59. </if>
  60. <if test="remarks != null and remarks != ''">
  61. AND remarks = #{remarks}
  62. </if>
  63. <if test="makeStaff != null and makeStaff != ''">
  64. AND make_staff = #{makeStaff}
  65. </if>
  66. <if test="makeTime != null">
  67. AND make_time = #{makeTime}
  68. </if>
  69. <if test="flgValid != null">
  70. AND flg_valid = #{flgValid}
  71. </if>
  72. <if test="cpId != null">
  73. AND cp_id = #{cpId}
  74. </if>
  75. <if test="opCreateTime != null">
  76. AND op_create_time = #{opCreateTime}
  77. </if>
  78. <if test="opCreateUserId != null and opCreateUserId != ''">
  79. AND op_create_user_id = #{opCreateUserId}
  80. </if>
  81. <if test="opUpdateTime != null">
  82. AND op_update_time = #{opUpdateTime}
  83. </if>
  84. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  85. AND op_update_user_id = #{opUpdateUserId}
  86. </if>
  87. <if test="opAppCode != null and opAppCode != ''">
  88. AND op_app_code = #{opAppCode}
  89. </if>
  90. <if test="opTimestamp != null">
  91. AND op_timestamp = #{opTimestamp}
  92. </if>
  93. <if test="opDbUser != null and opDbUser != ''">
  94. AND op_db_user = #{opDbUser}
  95. </if>
  96. </where>
  97. </sql>
  98. <sql id="idsForeach">
  99. <!-- 根据主键freezeId批量操作 -->
  100. WHERE freeze_id in
  101. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  102. #{item}
  103. </foreach>
  104. </sql>
  105. <!-- 查询表t_psi_freeze,(条件查询+分页)列表 -->
  106. <select id="selectByCond" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM t_psi_freeze
  110. <include refid="Condition"/>
  111. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  112. limit #{end} offset #{start}
  113. </if>
  114. </select>
  115. <!-- 查询表t_psi_freeze,(条件查询)个数 -->
  116. <select id="countByCond" resultType="Long">
  117. SELECT
  118. count(1)
  119. FROM t_psi_freeze
  120. <include refid="Condition"/>
  121. </select>
  122. <!-- 根据主键查询表t_psi_freeze的一行数据 -->
  123. <select id="selectById" resultMap="BaseResultMap">
  124. SELECT
  125. <include refid="Base_Column_List"/>
  126. FROM t_psi_freeze
  127. WHERE freeze_id = #{freezeId}::uuid
  128. </select>
  129. <!-- 根据主键锁定表t_psi_freeze的一行数据 -->
  130. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  131. SELECT
  132. <include refid="Base_Column_List"/>
  133. FROM t_psi_freeze
  134. WHERE freeze_id = #{freezeId}
  135. for update
  136. </select>
  137. <!-- 根据主键锁定表t_psi_freeze的多行数据 -->
  138. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  139. SELECT
  140. <include refid="Base_Column_List"/>
  141. FROM t_psi_freeze
  142. <include refid="idsForeach"/>
  143. for update
  144. </select>
  145. <insert id="insertBatch">
  146. insert into t_psi_freeze
  147. (
  148. <trim suffixOverrides=",">
  149. freeze_no,
  150. cus_id,
  151. org_id,
  152. staff_id,
  153. freeze_status,
  154. freeze_date,
  155. auto_unfreeze_date,
  156. sum_quantity,
  157. remarks,
  158. make_staff,
  159. make_time,
  160. cp_id,
  161. op_app_code,
  162. </trim>
  163. )
  164. values
  165. <foreach collection="list" index="index" item="item" separator=",">
  166. (
  167. <trim suffixOverrides=",">
  168. #{item.freezeNo},
  169. #{item.cusId}::uuid,
  170. #{item.orgId}::uuid,
  171. #{item.staffId}::uuid,
  172. #{item.freezeStatus},
  173. #{item.freezeDate},
  174. #{item.autoUnfreezeDate},
  175. #{item.sumQuantity},
  176. #{item.remarks},
  177. #{item.makeStaff}::uuid,
  178. #{item.makeTime},
  179. #{item.cpId},
  180. #{item.opAppCode},
  181. </trim>
  182. )
  183. </foreach>
  184. </insert>
  185. </mapper>