WarehousingMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.WarehousingMapper">
  5. <sql id="field">
  6. order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num
  7. </sql>
  8. <!-- 查询物料库位 -->
  9. <select id="getMaterialClass" resultType="com.tld.model.MaterialClass">
  10. select * from tld_material_class where wllb_code = #{wllbCode}
  11. </select>
  12. <!-- 根据物料分类查询库位 -->
  13. <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
  14. select
  15. a.id,
  16. a.storage_location_code
  17. from tld_material_class a
  18. join tld_material b on a.wllb_code = b.code
  19. join tld_inventory c on b.wllb_class = c.wllb_class
  20. where a.wllb_code = #{wllbCode}
  21. </select>
  22. <!-- 新增库位信息虚拟表 -->
  23. <insert id="addWarehousingVirtual">
  24. insert into tld_warehousing_virtual(unique_code,num,storage_location_code,wllb_code,supp_id,serial,type,produc_date,capacity,seq,user_id,storage_location_name)
  25. values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName})
  26. </insert>
  27. <!-- 查询总数量 -->
  28. <select id="getScanNum" resultType="java.util.Map">
  29. SELECT
  30. (ifnull(sum(a.num), 0) + ${num} + ifnull(c.amount, 0)) as scanNum,
  31. ifnull(b.storage_location_capacity, 0) as storageLocationCapacity
  32. FROM
  33. tld_warehousing_virtual a
  34. right join tld_storage_location b on a.storage_location_code = b.storage_location_code
  35. left join tld_inventory c on b.storage_location_code = c.storage_location_code
  36. where b.storage_location_code = #{storageLocationCode}
  37. </select>
  38. <!-- 查询 -->
  39. <select id="recommend" resultType="com.tld.model.StorageLocation">
  40. SELECT
  41. *
  42. FROM
  43. tld_storage_location
  44. WHERE
  45. #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%')
  46. </select>
  47. <!-- 查询是否是混合物料 -->
  48. <select id="getIsNotSisable" resultType="String">
  49. select is_not_disable from tld_material where code = #{wllbCode}
  50. </select>
  51. <!-- 查询混合库位 -->
  52. <select id="getIsNotSisableLocation" resultType="com.tld.model.StorageLocation">
  53. select * from tld_storage_location where is_not_disable = #{isNotDisable}
  54. </select>
  55. <!-- 删除虚拟表 -->
  56. <delete id="delWarehousingVirtual">
  57. delete from tld_warehousing_virtual where serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and supp_id = #{suppId}
  58. </delete>
  59. <!-- 查询虚拟表数据进行入库 -->
  60. <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
  61. select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
  62. </select>
  63. <!-- 查询采购单信息 -->
  64. <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  65. SELECT
  66. a.*,b.company_number,b.order_number,b.source_type,b.move_type,f.name as supplierName
  67. FROM
  68. tld_receive_goods a
  69. LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
  70. LEFT JOIN tld_material c on a.material_id = c.tld_id and c.code = #{wllbCode}
  71. LEFT JOIN tld_customer f on a.supplier_id = f.tld_id
  72. WHERE
  73. a.supplier_id = #{suppId} and IFNULL(a.warehousing_num, 0 ) <![CDATA[<]]> a.qualified_num
  74. ORDER BY
  75. a.arrival_time DESC
  76. </select>
  77. <!-- 修改采购单入库数量 -->
  78. <update id="updateReceiveGood">
  79. update tld_receive_goods
  80. set
  81. warehousing_num = (
  82. select a.result from (select (warehousing_num + ${warehousingNum}) as result from tld_receive_goods where id = #{id}) a
  83. )
  84. where id = #{id}
  85. </update>
  86. <!-- 查询物料类型 -->
  87. <select id="getWlClass" resultType="com.tld.model.WarehousingVirtual">
  88. select wllb_class,tld_id as materialId from tld_material where code = #{wllbCode}
  89. </select>
  90. <!-- 插入入库流水 -->
  91. <insert id="addStorage">
  92. insert into tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq)
  93. values
  94. <foreach collection="list" index="index" item="item" separator=",">
  95. (#{item.wllbCode},#{item.suppId},#{item.serial},#{item.producDate},#{item.producDate},#{item.num},#{item.seq},#{item.type},#{item.userId},#{item.departmentId},#{item.storageLocationCode},now())
  96. </foreach>
  97. </insert>
  98. <!-- 插入库存 -->
  99. <insert id="addInventory">
  100. insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq)
  101. values
  102. <foreach collection="list" index="index" item="item" separator=",">
  103. (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate}, now())
  104. </foreach>
  105. </insert>
  106. <!-- 删除临时表数据 -->
  107. <delete id="delVirtual">
  108. delete from tld_warehousing_virtual where unique_code = #{uniqueCode}
  109. </delete>
  110. <!-- 查询当天质检数量 -->
  111. <select id="getWarehousingCount" resultType="int">
  112. select count(*) from tld_return_gs_warehousing where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  113. </select>
  114. <!-- 存入为gs穿的信息 -->
  115. <insert id="addReturnWarehousing">
  116. insert into tld_return_gs_warehousing(storage_code,gs_ck,source_type,move_type,entry_number,wbs,material_id,warehousing_num,receive_goods_id,scrq,order_number)
  117. values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber});
  118. </insert>
  119. <!-- 入库回传 -->
  120. <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
  121. select * from tld_return_gs_warehousing where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
  122. </select>
  123. <!-- 查询入库流水 -->
  124. <select id="warehousingFlowing" resultType="com.tld.model.Storage">
  125. select
  126. a.id,
  127. b.name as materialName,
  128. a.wllb_code,
  129. h.name as supplierName,
  130. a.serial,
  131. a.produc_date,
  132. a.produc_batch,
  133. a.capacity,
  134. a.seq,
  135. a.type,
  136. c.user_name as userName,
  137. e.name as departmentName,
  138. g.storage_location_name as storageLocationName,
  139. a.scrq
  140. from tld_storage a
  141. left join tld_material b on a.wllb_code = b.code
  142. left join tld_user c on a.user_id = c.id
  143. left join tld_department e on a.department_id = e.tld_id
  144. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  145. left join tld_customer h on a.supplier_id = h.code
  146. <trim prefix="WHERE" prefixOverrides="and |or">
  147. <if test="wllbCode != null and wllbCode != ''">
  148. and a.wllb_code = #{wllbCode}
  149. </if>
  150. <if test="startTime != null and startTime != ''">
  151. and a.scrq <![CDATA[>=]]> #{startTime}
  152. </if>
  153. <if test="endTime != null and endTime != ''">
  154. and a.scrq <![CDATA[<=]]> #{endTime}
  155. </if>
  156. </trim>
  157. </select>
  158. <!-- 查询虚拟入库 -->
  159. <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
  160. select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
  161. </select>
  162. <!-- 查询导出内容 -->
  163. <select id="export" resultType="java.util.LinkedHashMap">
  164. select
  165. b.name as materialName,
  166. h.name as supplierName,
  167. a.serial,
  168. a.produc_date,
  169. a.produc_batch,
  170. a.capacity,
  171. a.seq,
  172. a.type,
  173. c.user_name as userName,
  174. e.name as departmentName,
  175. g.storage_location_name as storageLocationName,
  176. a.scrq
  177. from tld_storage a
  178. left join tld_material b on a.wllb_code = b.code
  179. left join tld_user c on a.user_id = c.id
  180. left join tld_department e on a.department_id = e.tld_id
  181. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  182. left join tld_customer h on a.supplier_id = h.code
  183. <trim prefix="WHERE" prefixOverrides="and |or">
  184. <if test="wllbCode != null and wllbCode != ''">
  185. and a.wllb_code = #{wllbCode}
  186. </if>
  187. <if test="startTime != null and startTime != ''">
  188. and a.scrq <![CDATA[>=]]> #{startTime}
  189. </if>
  190. <if test="endTime != null and endTime != ''">
  191. and a.scrq <![CDATA[<=]]> #{endTime}
  192. </if>
  193. </trim>
  194. </select>
  195. <!-- 查询是否扫描 -->
  196. <select id="getScanIsNot" resultType="java.util.Map">
  197. select
  198. (select count(*) from tld_inventory where supplier_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryCount,
  199. (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualCount
  200. from dual
  201. </select>
  202. <!-- 查询物料是否存在 -->
  203. <select id="getMateriaIsExist" resultType="int">
  204. select count(0) from tld_material where code = #{wllbCode}
  205. </select>
  206. <!-- 查询库存是否同物料同批次存在 -->
  207. <select id="getInventoryProduc" resultType="int">
  208. SELECT
  209. count(0)
  210. FROM
  211. tld_inventory a
  212. JOIN tld_material b ON a.material_id = b.tld_id
  213. WHERE a.produc_date = #{producDate} AND b.code = #{wllbCode} and a.storage_location_code = #{storageLocationCode}
  214. </select>
  215. </mapper>