StorageLocationMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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="isNotDisable != null and isNotDisable != ''">
  40. and a.is_not_disable = #{isNotDisable}
  41. </if>
  42. <if test="warehouseWhere != null and warehouseWhere != ''">
  43. and a.warehouse_where = #{warehouseWhere}
  44. </if>
  45. <if test="id != null and id != ''">
  46. and a.id = #{id}
  47. </if>
  48. <if test="isProduct != null and isProduct != ''">
  49. and a.is_product = #{isProduct}
  50. </if>
  51. </trim>
  52. order by a.id desc
  53. </select>
  54. <!-- 新增库位信息 -->
  55. <insert id="addStorage">
  56. 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)
  57. values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},NOW(),#{isProduct},#{modifyUser},NOW())
  58. </insert>
  59. <!-- 删除库位信息 -->
  60. <delete id="delStorage">
  61. delete from tld_storage_location where id = #{id}
  62. </delete>
  63. <!-- 修改库位信息 -->
  64. <update id="updateStorage">
  65. update tld_storage_location
  66. <set>
  67. <trim suffixOverrides=",">
  68. <if test="storageLocationCode != null and">
  69. storage_location_code = #{storageLocationCode},
  70. </if>
  71. <if test="storageLocationName != null and">
  72. storage_location_name = #{storageLocationName},
  73. </if>
  74. <if test="warehouseWhere != null and warehouseWhere != ''">
  75. warehouse_where = #{warehouseWhere},
  76. </if>
  77. <if test="storageLocationType != null and">
  78. storage_location_type = #{storageLocationType},
  79. </if>
  80. <if test="storageLocationCapacity != null and">
  81. storage_location_capacity = #{storageLocationCapacity},
  82. </if>
  83. <if test="isNotDisable != null and">
  84. is_not_disable = #{isNotDisable},
  85. </if>
  86. <if test="isProduct != null and">
  87. is_product = #{isProduct},
  88. </if>
  89. modify_user = #{modifyUser},modify_time=now(),
  90. </trim>
  91. </set>
  92. where id = #{id}
  93. </update>
  94. <!-- 导出数据查询 -->
  95. <select id="export" resultType="java.util.LinkedHashMap">
  96. select
  97. storage_location_code,
  98. storage_location_name,
  99. warehouse_where,
  100. if(storage_location_type = '', '暂无' , storage_location_type) as storageLocationType,
  101. storage_location_capacity,
  102. case is_not_disable when '1' then '是' when '0' then '不是' END as isNotDisable,
  103. create_time
  104. from tld_storage_location
  105. <trim prefix="WHERE" prefixOverrides="and |or">
  106. <if test="storageLocationCode != null and storageLocationCode != ''">
  107. and storage_location_code like CONCAT(CONCAT('%', #
  108. </if>
  109. <if test="storageLocationName != null and storageLocationName != ''">
  110. and storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  111. </if>
  112. <if test="storageLocationType != null and storageLocationType != ''">
  113. and storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
  114. </if>
  115. <if test="isNotDisable != null and isNotDisable != ''">
  116. and is_not_disable = #{isNotDisable}
  117. </if>
  118. <if test="warehouseWhere != null and warehouseWhere != ''">
  119. and a.warehouse_where = #{warehouseWhere}
  120. </if>
  121. <if test="id != null and id != ''">
  122. and id = #{id}
  123. </if>
  124. </trim>
  125. order by id desc
  126. </select>
  127. <!-- 查询编号是否存在 -->
  128. <select id="getStorageCount" resultType="int">
  129. select count(*) from tld_storage_location where storage_location_code = #{storageLocationCode}
  130. </select>
  131. </mapper>