WarehouseTransferMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.WarehouseTransferMapper">
  5. <!-- 查询移库单 -->
  6. <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
  7. select
  8. a.id,
  9. a.warehouse_transfer_id,
  10. a.entry_number,
  11. a.supply_warehouse_id,
  12. a.material_id,
  13. a.wbs,
  14. a.num,
  15. a.out_num,
  16. a.type,
  17. a.account_sleeve,
  18. b.warehouse_transfer_code,
  19. b.ask_goods_warehouse_id,
  20. b.document_time,
  21. b.warehouse_transfer_type,
  22. c.name as materialName,
  23. c.code as materialCode,
  24. c.part_type as partType,
  25. c.is_recommend as isRecommend,
  26. f.name as askGoodsWarehouseaName,
  27. e.name as supplyWarehouseName,
  28. ifnull(f.warehouse_type, 10) as askType,
  29. ifnull(e.warehouse_type, 10) as suppType
  30. from tld_warehouse_transfer a
  31. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  32. join tld_material c on a.material_id = c.tld_id
  33. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  34. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  35. <trim prefix="WHERE" prefixOverrides="and |or">
  36. <if test="type != null and type != ''">
  37. and a.type = #{type}
  38. </if>
  39. <if test="materialCode != null and materialCode != ''">
  40. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  41. </if>
  42. <if test="materialName != null and materialName != ''">
  43. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  44. </if>
  45. <if test="startTime != null and startTime != ''">
  46. and a.document_time <![CDATA[>=]]> #{startTime}
  47. </if>
  48. <if test="endTime != null and endTime != ''">
  49. and a.document_time <![CDATA[<=]]> #{endTime}
  50. </if>
  51. and (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
  52. </trim>
  53. </select>
  54. <!-- 物料库位选择 -->
  55. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  56. select
  57. a.storage_location_code,
  58. a.wllb_class,
  59. a.library_type,
  60. a.material_id,
  61. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  62. a.total,
  63. a.totime,
  64. a.hold,
  65. a.amount_lock,
  66. a.account_sleeve,
  67. a.wbs,
  68. a.supplier_id,
  69. a.serial,
  70. a.wllb_code,
  71. a.produc_date,
  72. a.scrq,
  73. b.storage_location_name as storageLocationName
  74. from tld_inventory a
  75. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  76. where a.material_id = #{materialId} and a.hold = '0' and a.account_sleeve = #{accountSleeve} and a.wbs = #{wbs} and b.warehouse_where = #{warehouseWhere}
  77. order by a.produc_date
  78. </select>
  79. <!-- 查询库存是否充足 -->
  80. <select id="getAsk" resultType="com.tld.model.AskGoods">
  81. SELECT
  82. ifnull(sum(a.num),0) as num
  83. FROM tld_ask_goods_vitrual a
  84. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  85. where a.storage_location_code = #{storageLocationCode} and a.serial = #{serial}
  86. </select>
  87. <!-- 查询移库单内容 -->
  88. <select id="getWarehouseTransferDetailed" resultType="com.tld.model.WarehouseTransfer">
  89. select
  90. a.id,
  91. a.warehouse_transfer_id,
  92. a.entry_number,
  93. a.supply_warehouse_id,
  94. a.material_id,
  95. a.wbs,
  96. a.measurement_id,
  97. a.num,
  98. a.out_num,
  99. a.type,
  100. a.account_sleeve,
  101. b.ask_goods_warehouse_id
  102. from tld_warehouse_transfer a
  103. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  104. where a.warehouse_transfer_id = #{askGoodsId} and a.material_id = #{materialId}
  105. </select>
  106. <!-- 修改出库数量 -->
  107. <update id="updateOutNum">
  108. update tld_warehouse_transfer
  109. set out_num = ifnull(out_num, 0) + #{num},type = #{typeVal} where material_id = #{materialId} and warehouse_transfer_id = #{askGoodsId}
  110. </update>
  111. <!-- 查询当天移库单条数 -->
  112. <select id="getReturnWarehouseTransferCount" resultType="int">
  113. select count(*) from tld_return_warehouse_transfer where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  114. </select>
  115. <!-- 新增返回gs移库信息 -->
  116. <insert id="addReturnGsWarehouseTransfer">
  117. insert into tld_return_warehouse_transfer_z(warehouse_transfer_id,entry_number,supply_warehouse_id,material_id,wbs,out_num)
  118. value(#{warehouseTransferId},#{entryNumber},#{supplyWarehouseId},#{materialId},#{wbs},#{outNum})
  119. </insert>
  120. <!-- 查询父表移库单申请 -->
  121. <select id="getWarehouseTransferDetailedF" resultType="com.tld.model.WarehouseTransfer">
  122. select
  123. warehouse_transfer_id,
  124. warehouse_transfer_code,
  125. ask_goods_warehouse_id,
  126. warehouse_transfer_type,
  127. document_time
  128. from tld_warehouse_transfer_f where warehouse_transfer_id = #{askGoodsId}
  129. </select>
  130. <!-- 查询移库单原始数据 -->
  131. <select id="getWarehouseTransfers" resultType="java.util.Map">
  132. select * from tld_warehouse_transfer where id = #{id}
  133. </select>
  134. <!-- 删除移库单原始数据 -->
  135. <delete id="delWarehouseTransfer">
  136. delete from tld_warehouse_transfer where id = #{id}
  137. </delete>
  138. <!-- 新增返回gs父表移库信息 -->
  139. <insert id="addReturnGsWarehouseTransferF">
  140. insert into tld_return_warehouse_transfer(warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq)
  141. value(#{warehouseTransferId},#{warehouseTransferCode},#{askGoodsWarehouseId},#{warehouseTransferType},now())
  142. </insert>
  143. <!-- 查询指定pda 指定物料扫描总数 -->
  144. <select id="getScanNum" resultType="integer">
  145. select if(sum(num) is null, 0, sum(num))
  146. from tld_warehousing_virtual
  147. where unique_code = #{uniqueCode} and warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{materialCode}
  148. </select>
  149. <!-- 查询指定pda 指定物料扫描总数 -->
  150. <select id="getScanNumWare" resultType="integer">
  151. select if(sum(num) is null, 0, sum(num))
  152. from tld_ask_goods_vitrual
  153. where unique_code = #{uniqueCode} and ask_goods_id = #{warehouseTransferId} and wllb_code = #{materialCode}
  154. </select>
  155. <!-- 查询指定送货单信息 -->
  156. <select id="getAsknInfo" resultType="com.tld.model.WarehouseTransfer">
  157. SELECT
  158. a.id,
  159. a.warehouse_transfer_id,
  160. a.entry_number,
  161. a.material_id,
  162. a.wbs,
  163. a.measurement_id,
  164. a.num,
  165. ifnull(a.out_num, 0) as out_num
  166. FROM
  167. tld_warehouse_transfer a
  168. join tld_material b on a.material_id = b.tld_id
  169. where a.warehouse_transfer_id = #{askGoodsId} and b.code = #{wllbCode}
  170. </select>
  171. <!-- 物料库位选择 -->
  172. <select id="getMaterialWarehouseTransfer" resultType="com.tld.model.Inventory">
  173. select
  174. a.storage_location_code,
  175. a.wllb_class,
  176. a.library_type,
  177. a.material_id,
  178. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  179. a.total,
  180. a.totime,
  181. a.hold,
  182. a.amount_lock,
  183. a.account_sleeve,
  184. a.wbs,
  185. a.supplier_id,
  186. a.serial,
  187. a.wllb_code,
  188. a.produc_date,
  189. a.scrq,
  190. b.storage_location_name as storageLocationName
  191. from tld_inventory a
  192. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  193. join tld_warehouse c on b.warehouse_where = c.tld_id
  194. where a.material_id = #{materialId} and a.account_sleeve = #{companyNumber} and a.hold = '0' and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2') and a.wbs = #{wbs}
  195. <if test="warehouseWhere != null and warehouseWhere != ''">
  196. and c.tld_id = #{warehouseWhere}
  197. </if>
  198. order by a.produc_batch
  199. </select>
  200. <!-- 查询是否存在虚拟库存 -->
  201. <select id="getInventoryVitrual" resultType="com.tld.model.Inventory">
  202. select
  203. id,
  204. storage_location_code,
  205. wllb_class,
  206. library_type,
  207. material_id,
  208. amount,
  209. total,
  210. totime,
  211. hold,
  212. amount_lock,
  213. account_sleeve,
  214. wbs,
  215. supplier_id,
  216. serial,
  217. wllb_code,
  218. produc_date,
  219. scrq
  220. from tld_inventory where storage_location_code = #{storageLocationCodeRk} and material_id = #{materialId}
  221. <if test="accountSleeve != null and accountSleeve != ''">
  222. and account_sleeve = #{accountSleeve}
  223. </if>
  224. <if test="wbs != null and wbs != ''">
  225. and wbs = #{wbs}
  226. </if>
  227. </select>
  228. <!-- 查询是否是借件库 -->
  229. <select id="getWarehouseTransferCodeType" resultType="String">
  230. SELECT
  231. ifnull(warehouse_type, "10") as warehouseType
  232. FROM
  233. tld_warehouse
  234. WHERE
  235. tld_id = #{askGoodsWarehouseId}
  236. </select>
  237. </mapper>