GoodsMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.GoodsMapper">
  5. <sql id="field">
  6. id,item_number,type,min_accommodate,accommodate_num,max_accommodate,supplier,storage_location,input_type,user_department,low_reserves,high_reserves,grade,packing_type,unit,name
  7. </sql>
  8. <!-- 查询货品信息 -->
  9. <select id="getStorage" resultType="com.tld.model.Goods">
  10. select
  11. a.id,
  12. a.item_number,
  13. a.type,
  14. a.min_accommodate,
  15. a.accommodate_num,
  16. a.max_accommodate,
  17. a.supplier,
  18. a.storage_location,
  19. a.input_type,
  20. a.user_department,
  21. a.low_reserves,
  22. a.high_reserves,
  23. a.grade,
  24. a. packing_type,
  25. a. unit,
  26. a.name,
  27. b.name as userDepartmentName,
  28. c.storage_location_name as storageLocationName
  29. from tld_goods a
  30. left join tld_department b on a.user_department = b.code
  31. left join tld_storage_location c on a.storage_location = c.id
  32. <trim prefix="WHERE" prefixOverrides="and |or">
  33. <if test="itemNumber != null and itemNumber != ''">
  34. and a.item_number = #{itemNumber}
  35. </if>
  36. <if test="id != null and id != ''">
  37. and a.id = #{id}
  38. </if>
  39. </trim>
  40. </select>
  41. <!-- 新增货品信息 -->
  42. <insert id="addGoods">
  43. insert into tld_goods(item_number,type,min_accommodate,accommodate_num,max_accommodate,supplier,storage_location,input_type,user_department,low_reserves,high_reserves,grade,packing_type,unit,name)
  44. values(#{itemNumber},#{type},#{minAccommodate},#{accommodateNum},#{maxAccommodate},#{supplier},#{storageLocation},#{inputType},#{userDepartment},#{lowReserves},#{highReserves},#{grade},#{packingType},#{unit},#{name})
  45. </insert>
  46. <!-- 删除货品信息 -->
  47. <delete id="delGoods">
  48. delete from tld_goods where id = #{id}
  49. </delete>
  50. <!-- 修改货品信息 -->
  51. <update id="updateGoods">
  52. update tld_goods
  53. <set>
  54. <trim suffixOverrides=",">
  55. <if test="itemNumber != null">
  56. item_number = #{itemNumber},
  57. </if>
  58. <if test="type != null">
  59. type = #{type},
  60. </if>
  61. <if test="minAccommodate != null">
  62. min_accommodate = #{minAccommodate},
  63. </if>
  64. <if test="accommodateNum != null">
  65. accommodate_num = #{accommodateNum},
  66. </if>
  67. <if test="maxAccommodate != null">
  68. max_accommodate = #{maxAccommodate},
  69. </if>
  70. <if test="supplier != null">
  71. supplier = #{supplier},
  72. </if>
  73. <if test="storageLocation != null">
  74. storage_location = #{storageLocation},
  75. </if>
  76. <if test="inputType != null">
  77. input_type = #{inputType},
  78. </if>
  79. <if test="userDepartment != null">
  80. user_department = #{userDepartment},
  81. </if>
  82. <if test="lowReserves != null">
  83. low_reserves = #{lowReserves},
  84. </if>
  85. <if test="highReserves != null">
  86. high_reserves = #{highReserves},
  87. </if>
  88. <if test="grade != null">
  89. grade = #{grade},
  90. </if>
  91. <if test="packingType != null">
  92. packing_type = #{packingType},
  93. </if>
  94. <if test="unit != null">
  95. unit = #{unit},
  96. </if>
  97. <if test="name != null">
  98. name = #{name},
  99. </if>
  100. </trim>
  101. </set>
  102. where id = #{id}
  103. </update>
  104. <!-- 导出数据查询 -->
  105. <select id="export" resultType="java.util.LinkedHashMap">
  106. select
  107. a.item_number,
  108. a.name,
  109. a.type,
  110. a.min_accommodate,
  111. a.accommodate_num,
  112. a.max_accommodate,
  113. a.supplier,
  114. c.storage_location_name,
  115. a.input_type,
  116. b.name,
  117. a.low_reserves,
  118. a.high_reserves,
  119. a.grade,
  120. a.packing_type,
  121. a.unit
  122. from tld_goods a
  123. left join tld_department b on a.user_department = b.code
  124. left join tld_storage_location c on a.storage_location = c.id
  125. <trim prefix="WHERE" prefixOverrides="and |or">
  126. <if test="itemNumber != null and itemNumber != ''">
  127. and item_number = #{itemNumber}
  128. </if>
  129. <if test="id != null and id != ''">
  130. and id = #{id}
  131. </if>
  132. </trim>
  133. </select>
  134. </mapper>