StorageLocationMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.tld.mapper.StorageLocationMapper">
  5. <sql id="field">
  6. id,storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time
  7. </sql>
  8. <!-- 查询库位信息 -->
  9. <select id="getStorage" resultType="com.tld.model.StorageLocation">
  10. select
  11. a.id,
  12. a.storage_location_code,
  13. a.storage_location_name,
  14. a.warehouse_where,
  15. a.storage_location_type,
  16. a.is_not_disable,
  17. a.storage_location_capacity,
  18. a.create_time,
  19. a.is_product,
  20. a.storage_location_type as materialName,
  21. c.name as wareHouseName,
  22. c.tld_id as tldId,
  23. a.modify_time as modifyTime,
  24. f.user_name as modifyUser
  25. from tld_storage_location a
  26. /*left join tld_material_type b on a.storage_location_type = b.tld_id*/
  27. left join tld_warehouse c on a.warehouse_where = c.tld_id
  28. left join tld_user f on a.modify_user = f.id
  29. <trim prefix="WHERE" prefixOverrides="and |or">
  30. <if test="storageLocationCode != null and storageLocationCode != ''">
  31. and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
  32. </if>
  33. <if test="storageLocationName != null and storageLocationName != ''">
  34. and a.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  35. </if>
  36. <if test="storageLocationType != null and storageLocationType != ''">
  37. and a.storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
  38. </if>
  39. <if test="modifyUser != null and modifyUser != ''">
  40. and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
  41. </if>
  42. <if test="isNotDisable != null and isNotDisable != ''">
  43. and a.is_not_disable = #{isNotDisable}
  44. </if>
  45. <if test="warehouseWhere != null and warehouseWhere != ''">
  46. and a.warehouse_where = #{warehouseWhere}
  47. </if>
  48. <if test="id != null and id != ''">
  49. and a.id = #{id}
  50. </if>
  51. <if test="isProduct != null and isProduct != ''">
  52. and a.is_product = #{isProduct}
  53. </if>
  54. </trim>
  55. order by a.id desc
  56. </select>
  57. <!-- 新增库位信息 -->
  58. <insert id="addStorage">
  59. delete from tld_storage_location where storage_location_code = #{storageLocationCode};
  60. insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time,is_product,modify_user,modify_time)
  61. values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},NOW(),#{isProduct},#{modifyUser},NOW())
  62. </insert>
  63. <!-- 删除库位信息 -->
  64. <delete id="delStorage">
  65. delete from tld_storage_location where id = #{id}
  66. </delete>
  67. <!-- 修改库位信息 -->
  68. <update id="updateStorage">
  69. update tld_storage_location
  70. <set>
  71. <trim suffixOverrides=",">
  72. <if test="storageLocationCode != null">
  73. storage_location_code = #{storageLocationCode},
  74. </if>
  75. <if test="storageLocationName != null">
  76. storage_location_name = #{storageLocationName},
  77. </if>
  78. <if test="warehouseWhere != null">
  79. warehouse_where = #{warehouseWhere},
  80. </if>
  81. <if test="storageLocationType != null">
  82. storage_location_type = #{storageLocationType},
  83. </if>
  84. <if test="storageLocationCapacity != null">
  85. storage_location_capacity = #{storageLocationCapacity},
  86. </if>
  87. <if test="isNotDisable != null">
  88. is_not_disable = #{isNotDisable},
  89. </if>
  90. <if test="isProduct != null">
  91. is_product = #{isProduct},
  92. </if>
  93. modify_user = #{modifyUser},modify_time=now(),
  94. </trim>
  95. </set>
  96. where id = #{id}
  97. </update>
  98. <!-- 导出数据查询 -->
  99. <select id="export" resultType="java.util.LinkedHashMap">
  100. select
  101. a.storage_location_code,
  102. a.storage_location_name,
  103. b.name,
  104. if(a.storage_location_type = '', null , a.storage_location_type) as storageLocationType,
  105. if(a.is_not_disable = '1', '是' , '否') as isNotDisable,
  106. if(a.is_product = '1', '是' , '否') as isProduct
  107. from tld_storage_location a
  108. left join tld_warehouse b on a.warehouse_where = b.tld_id
  109. left join tld_user f on a.modify_user = f.id
  110. <trim prefix="WHERE" prefixOverrides="and |or">
  111. <if test="storageLocationCode != null and storageLocationCode != ''">
  112. and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
  113. </if>
  114. <if test="storageLocationName != null and storageLocationName != ''">
  115. and a.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  116. </if>
  117. <if test="storageLocationType != null and storageLocationType != ''">
  118. and a.storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
  119. </if>
  120. <if test="modifyUser != null and modifyUser != ''">
  121. and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
  122. </if>
  123. <if test="isNotDisable != null and isNotDisable != ''">
  124. and a.is_not_disable = #{isNotDisable}
  125. </if>
  126. <if test="isProduct != null and isProduct != ''">
  127. and a.is_product = #{isProduct}
  128. </if>
  129. <if test="warehouseWhere != null and warehouseWhere != ''">
  130. and a.warehouse_where = #{warehouseWhere}
  131. </if>
  132. <if test="id != null and id != ''">
  133. and a.id = #{id}
  134. </if>
  135. </trim>
  136. order by a.id desc
  137. </select>
  138. <!-- 查询编号是否存在 -->
  139. <select id="getStorageCount" resultType="int">
  140. select count(*) from tld_storage_location where storage_location_code = #{storageLocationCode}
  141. </select>
  142. <!-- 仓库id -->
  143. <select id="getWarehouseWhere" resultType="String">
  144. select tld_id from tld_warehouse where name = #{value}
  145. </select>
  146. </mapper>