MaterialInitialStockMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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.jsh.erp.datasource.mappers.MaterialInitialStockMapper">
  4. <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.MaterialInitialStock">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="material_id" jdbcType="BIGINT" property="materialId" />
  7. <result column="depot_id" jdbcType="BIGINT" property="depotId" />
  8. <result column="number" jdbcType="DECIMAL" property="number" />
  9. <result column="low_safe_stock" jdbcType="DECIMAL" property="lowSafeStock" />
  10. <result column="high_safe_stock" jdbcType="DECIMAL" property="highSafeStock" />
  11. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  12. <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
  13. </resultMap>
  14. <sql id="Example_Where_Clause">
  15. <where>
  16. <foreach collection="oredCriteria" item="criteria" separator="or">
  17. <if test="criteria.valid">
  18. <trim prefix="(" prefixOverrides="and" suffix=")">
  19. <foreach collection="criteria.criteria" item="criterion">
  20. <choose>
  21. <when test="criterion.noValue">
  22. and ${criterion.condition}
  23. </when>
  24. <when test="criterion.singleValue">
  25. and ${criterion.condition} #{criterion.value}
  26. </when>
  27. <when test="criterion.betweenValue">
  28. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  29. </when>
  30. <when test="criterion.listValue">
  31. and ${criterion.condition}
  32. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  33. #{listItem}
  34. </foreach>
  35. </when>
  36. </choose>
  37. </foreach>
  38. </trim>
  39. </if>
  40. </foreach>
  41. </where>
  42. </sql>
  43. <sql id="Update_By_Example_Where_Clause">
  44. <where>
  45. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  46. <if test="criteria.valid">
  47. <trim prefix="(" prefixOverrides="and" suffix=")">
  48. <foreach collection="criteria.criteria" item="criterion">
  49. <choose>
  50. <when test="criterion.noValue">
  51. and ${criterion.condition}
  52. </when>
  53. <when test="criterion.singleValue">
  54. and ${criterion.condition} #{criterion.value}
  55. </when>
  56. <when test="criterion.betweenValue">
  57. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  58. </when>
  59. <when test="criterion.listValue">
  60. and ${criterion.condition}
  61. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  62. #{listItem}
  63. </foreach>
  64. </when>
  65. </choose>
  66. </foreach>
  67. </trim>
  68. </if>
  69. </foreach>
  70. </where>
  71. </sql>
  72. <sql id="Base_Column_List">
  73. id, material_id, depot_id, number, low_safe_stock, high_safe_stock, tenant_id, delete_flag, position
  74. </sql>
  75. <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStockExample" resultType="com.jsh.erp.datasource.entities.MaterialInitialStock">
  76. select
  77. <if test="distinct">
  78. distinct
  79. </if>
  80. <include refid="Base_Column_List" />
  81. from jsh_material_initial_stock
  82. <if test="_parameter != null">
  83. <include refid="Example_Where_Clause" />
  84. </if>
  85. <if test="orderByClause != null">
  86. order by ${orderByClause}
  87. </if>
  88. </select>
  89. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  90. select
  91. <include refid="Base_Column_List" />
  92. from jsh_material_initial_stock
  93. where id = #{id,jdbcType=BIGINT}
  94. </select>
  95. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  96. delete from jsh_material_initial_stock
  97. where id = #{id,jdbcType=BIGINT}
  98. </delete>
  99. <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStockExample">
  100. delete from jsh_material_initial_stock
  101. <if test="_parameter != null">
  102. <include refid="Example_Where_Clause" />
  103. </if>
  104. </delete>
  105. <insert id="insert" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
  106. insert into jsh_material_initial_stock (id, material_id, depot_id,
  107. number, low_safe_stock, high_safe_stock,
  108. tenant_id, delete_flag)
  109. values (#{id,jdbcType=BIGINT}, #{materialId,jdbcType=BIGINT}, #{depotId,jdbcType=BIGINT},
  110. #{number,jdbcType=DECIMAL}, #{lowSafeStock,jdbcType=DECIMAL}, #{highSafeStock,jdbcType=DECIMAL},
  111. #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
  112. </insert>
  113. <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
  114. insert into jsh_material_initial_stock
  115. <trim prefix="(" suffix=")" suffixOverrides=",">
  116. <if test="id != null">
  117. id,
  118. </if>
  119. <if test="materialId != null">
  120. material_id,
  121. </if>
  122. <if test="depotId != null">
  123. depot_id,
  124. </if>
  125. <if test="number != null">
  126. number,
  127. </if>
  128. <if test="lowSafeStock != null">
  129. low_safe_stock,
  130. </if>
  131. <if test="highSafeStock != null">
  132. high_safe_stock,
  133. </if>
  134. <if test="tenantId != null">
  135. tenant_id,
  136. </if>
  137. <if test="deleteFlag != null">
  138. delete_flag,
  139. </if>
  140. <if test="position != null">
  141. position,
  142. </if>
  143. </trim>
  144. <trim prefix="values (" suffix=")" suffixOverrides=",">
  145. <if test="id != null">
  146. #{id,jdbcType=BIGINT},
  147. </if>
  148. <if test="materialId != null">
  149. #{materialId,jdbcType=BIGINT},
  150. </if>
  151. <if test="depotId != null">
  152. #{depotId,jdbcType=BIGINT},
  153. </if>
  154. <if test="number != null">
  155. #{number,jdbcType=DECIMAL},
  156. </if>
  157. <if test="lowSafeStock != null">
  158. #{lowSafeStock,jdbcType=DECIMAL},
  159. </if>
  160. <if test="highSafeStock != null">
  161. #{highSafeStock,jdbcType=DECIMAL},
  162. </if>
  163. <if test="tenantId != null">
  164. #{tenantId,jdbcType=BIGINT},
  165. </if>
  166. <if test="deleteFlag != null">
  167. #{deleteFlag,jdbcType=VARCHAR},
  168. </if>
  169. <if test="position != null">
  170. #{position,jdbcType=VARCHAR},
  171. </if>
  172. </trim>
  173. </insert>
  174. <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStockExample" resultType="java.lang.Long">
  175. select count(*) from jsh_material_initial_stock
  176. <if test="_parameter != null">
  177. <include refid="Example_Where_Clause" />
  178. </if>
  179. </select>
  180. <update id="updateByExampleSelective" parameterType="map">
  181. update jsh_material_initial_stock
  182. <set>
  183. <if test="record.id != null">
  184. id = #{record.id,jdbcType=BIGINT},
  185. </if>
  186. <if test="record.materialId != null">
  187. material_id = #{record.materialId,jdbcType=BIGINT},
  188. </if>
  189. <if test="record.depotId != null">
  190. depot_id = #{record.depotId,jdbcType=BIGINT},
  191. </if>
  192. <if test="record.number != null">
  193. number = #{record.number,jdbcType=DECIMAL},
  194. </if>
  195. <if test="record.lowSafeStock != null">
  196. low_safe_stock = #{record.lowSafeStock,jdbcType=DECIMAL},
  197. </if>
  198. <if test="record.highSafeStock != null">
  199. high_safe_stock = #{record.highSafeStock,jdbcType=DECIMAL},
  200. </if>
  201. <if test="record.tenantId != null">
  202. tenant_id = #{record.tenantId,jdbcType=BIGINT},
  203. </if>
  204. <if test="record.deleteFlag != null">
  205. delete_flag = #{record.deleteFlag,jdbcType=VARCHAR},
  206. </if>
  207. </set>
  208. <if test="_parameter != null">
  209. <include refid="Update_By_Example_Where_Clause" />
  210. </if>
  211. </update>
  212. <update id="updateByExample" parameterType="map">
  213. update jsh_material_initial_stock
  214. set id = #{record.id,jdbcType=BIGINT},
  215. material_id = #{record.materialId,jdbcType=BIGINT},
  216. depot_id = #{record.depotId,jdbcType=BIGINT},
  217. number = #{record.number,jdbcType=DECIMAL},
  218. low_safe_stock = #{record.lowSafeStock,jdbcType=DECIMAL},
  219. high_safe_stock = #{record.highSafeStock,jdbcType=DECIMAL},
  220. tenant_id = #{record.tenantId,jdbcType=BIGINT},
  221. delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
  222. <if test="_parameter != null">
  223. <include refid="Update_By_Example_Where_Clause" />
  224. </if>
  225. </update>
  226. <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
  227. update jsh_material_initial_stock
  228. <set>
  229. <if test="materialId != null">
  230. material_id = #{materialId,jdbcType=BIGINT},
  231. </if>
  232. <if test="depotId != null">
  233. depot_id = #{depotId,jdbcType=BIGINT},
  234. </if>
  235. <if test="number != null">
  236. number = #{number,jdbcType=DECIMAL},
  237. </if>
  238. <if test="lowSafeStock != null">
  239. low_safe_stock = #{lowSafeStock,jdbcType=DECIMAL},
  240. </if>
  241. <if test="highSafeStock != null">
  242. high_safe_stock = #{highSafeStock,jdbcType=DECIMAL},
  243. </if>
  244. <if test="tenantId != null">
  245. tenant_id = #{tenantId,jdbcType=BIGINT},
  246. </if>
  247. <if test="deleteFlag != null">
  248. delete_flag = #{deleteFlag,jdbcType=VARCHAR},
  249. </if>
  250. </set>
  251. where id = #{id,jdbcType=BIGINT}
  252. </update>
  253. <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
  254. update jsh_material_initial_stock
  255. set material_id = #{materialId,jdbcType=BIGINT},
  256. depot_id = #{depotId,jdbcType=BIGINT},
  257. number = #{number,jdbcType=DECIMAL},
  258. low_safe_stock = #{lowSafeStock,jdbcType=DECIMAL},
  259. high_safe_stock = #{highSafeStock,jdbcType=DECIMAL},
  260. tenant_id = #{tenantId,jdbcType=BIGINT},
  261. delete_flag = #{deleteFlag,jdbcType=VARCHAR}
  262. where id = #{id,jdbcType=BIGINT}
  263. </update>
  264. <select id="selectPosition" resultType="String" parameterType="java.lang.Long">
  265. SELECT DISTINCT position FROM jsh_material_initial_stock WHERE depot_id = #{depotId} AND position IS NOT NULL AND position != "" AND ifnull(delete_Flag,'0') !='1'
  266. </select>
  267. <select id="selectMaterialIdByPosition" resultType="String">
  268. SELECT DISTINCT material_id FROM jsh_material_initial_stock WHERE position LIKE CONCAT('%',#{position},'%') AND ifnull(delete_Flag,'0') !='1'
  269. </select>
  270. </mapper>