WarehouseMapper.xml 7.4 KB

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