StorageLocationMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. b.name as materialName
  20. from
  21. tld_storage_location a
  22. left join tld_material_type b on a.storage_location_type = b.tld_id
  23. <trim prefix="WHERE" prefixOverrides="and |or">
  24. <if test="storageLocationCode != null and storageLocationCode != ''">
  25. and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
  26. </if>
  27. <if test="storageLocationName != null and storageLocationName != ''">
  28. and a.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  29. </if>
  30. <if test="storageLocationType != null and storageLocationType != ''">
  31. and a.storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
  32. </if>
  33. <if test="isNotDisable != null and isNotDisable != ''">
  34. and a.is_not_disable = #{isNotDisable}
  35. </if>
  36. <if test="id != null and id != ''">
  37. and a.id = #{id}
  38. </if>
  39. </trim>
  40. order by a.id desc
  41. </select>
  42. <!-- 新增库位信息 -->
  43. <insert id="addStorage">
  44. insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time)
  45. values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},DATE_FORMAT(NOW(), '%Y-%m-%d'))
  46. </insert>
  47. <!-- 删除库位信息 -->
  48. <delete id="delStorage">
  49. delete from tld_storage_location where id = #{id}
  50. </delete>
  51. <!-- 修改库位信息 -->
  52. <update id="updateStorage">
  53. update tld_storage_location
  54. <set>
  55. <trim suffixOverrides=",">
  56. <if test="storageLocationCode != null and storageLocationCode != ''">
  57. storage_location_code = #{storageLocationCode},
  58. </if>
  59. <if test="storageLocationName != null and storageLocationName != ''">
  60. storage_location_name = #{storageLocationName},
  61. </if>
  62. <if test="warehouseWhere != null and warehouseWhere != ''">
  63. warehouse_where = #{warehouseWhere},
  64. </if>
  65. <if test="storageLocationType != null and storageLocationType != ''">
  66. storage_location_type = #{storageLocationType},
  67. </if>
  68. <if test="storageLocationCapacity != null and storageLocationCapacity != ''">
  69. storage_location_capacity = #{storageLocationCapacity},
  70. </if>
  71. <if test="isNotDisable != null and isNotDisable != ''">
  72. is_not_disable = #{isNotDisable},
  73. </if>
  74. </trim>
  75. </set>
  76. where id = #{id}
  77. </update>
  78. <!-- 导出数据查询 -->
  79. <select id="export" resultType="java.util.LinkedHashMap">
  80. select
  81. storage_location_code,
  82. storage_location_name,
  83. warehouse_where,
  84. storage_location_type,
  85. storage_location_capacity,
  86. case is_not_disable when '1' then '是' when '0' then '不是' END as isNotDisable,
  87. create_time
  88. from tld_storage_location
  89. <trim prefix="WHERE" prefixOverrides="and |or">
  90. <if test="storageLocationCode != null and storageLocationCode != ''">
  91. and storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
  92. </if>
  93. <if test="storageLocationName != null and storageLocationName != ''">
  94. and storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  95. </if>
  96. <if test="storageLocationType != null and storageLocationType != ''">
  97. and storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
  98. </if>
  99. <if test="isNotDisable != null and isNotDisable != ''">
  100. and is_not_disable = #{isNotDisable}
  101. </if>
  102. <if test="id != null and id != ''">
  103. and id = #{id}
  104. </if>
  105. </trim>
  106. order by a.id desc
  107. </select>
  108. <!-- 查询编号是否存在 -->
  109. <select id="getStorageCount" resultType="int">
  110. select count(*) from tld_storage_location where storage_location_code = #{storageLocationCode}
  111. </select>
  112. </mapper>