WarehousingMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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
  11. a.id,
  12. a.storage_location_code,
  13. a.wllb_code
  14. from tld_material_class a
  15. join tld_material b on a.wllb_code = b.tld_id
  16. where b.code = #{wllbCode}
  17. </select>
  18. <!-- 根据物料分类查询库位 -->
  19. <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
  20. select
  21. a.id,
  22. a.storage_location_code
  23. from tld_material_class a
  24. join tld_material b on a.wllb_code = b.code
  25. join tld_inventory c on b.wllb_class = c.wllb_class
  26. where a.wllb_code = #{wllbCode}
  27. </select>
  28. <!-- 新增库位信息虚拟表 -->
  29. <insert id="addWarehousingVirtual">
  30. 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,attribute,notice_id,warehouse_transfer_id)
  31. values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId},#{warehouseTransferId})
  32. </insert>
  33. <!-- 查询总数量 -->
  34. <select id="getScanNum" resultType="java.util.Map">
  35. SELECT
  36. (ifnull(sum(a.num), 0) + ${num} + ifnull(sum(c.amount), 0)) as scanNum,
  37. ifnull(b.storage_location_capacity, 0) as storageLocationCapacity
  38. FROM
  39. tld_warehousing_virtual a
  40. right join tld_storage_location b on a.storage_location_code = b.storage_location_code
  41. left join tld_inventory c on b.storage_location_code = c.storage_location_code
  42. where b.storage_location_code = #{storageLocationCode}
  43. </select>
  44. <!-- 查询 -->
  45. <select id="recommend" resultType="com.tld.model.StorageLocation">
  46. SELECT
  47. id,
  48. storage_location_code,
  49. storage_location_name,
  50. warehouse_where,
  51. storage_location_type,
  52. storage_location_capacity,
  53. is_not_disable,
  54. create_time
  55. FROM
  56. tld_storage_location
  57. WHERE
  58. #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%') and warehouse_where != '5000'
  59. </select>
  60. <!-- 查询是否是混合物料 -->
  61. <select id="getIsNotSisable" resultType="String">
  62. select is_not_disable from tld_material where code = #{wllbCode}
  63. </select>
  64. <!-- 查询混合库位 -->
  65. <select id="getIsNotSisableLocation" resultType="com.tld.model.StorageLocation">
  66. select
  67. id,
  68. storage_location_code,
  69. storage_location_name,
  70. warehouse_where,
  71. storage_location_type,
  72. storage_location_capacity,
  73. is_not_disable,
  74. create_time
  75. from tld_storage_location where is_not_disable = #{isNotDisable}
  76. </select>
  77. <!-- 删除虚拟表 -->
  78. <delete id="delWarehousingVirtual">
  79. delete from tld_warehousing_virtual where serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and supp_id = #{suppId}
  80. </delete>
  81. <!-- 查询虚拟表数据进行入库 -->
  82. <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
  83. select
  84. a.id,
  85. a.unique_code,
  86. a.num,
  87. a.storage_location_code,
  88. a.wllb_code,
  89. a.supp_id,
  90. a.serial,
  91. a.type,
  92. a.produc_date,
  93. a.capacity,
  94. a.seq,
  95. a.user_id,
  96. a.attribute,
  97. a.storage_location_name,
  98. b.user_name
  99. from tld_warehousing_virtual a
  100. left join tld_user b on a.user_id = b.id
  101. where a.unique_code = #{uniqueCode} and a.type = #{type}
  102. </select>
  103. <!-- 查询采购单信息 -->
  104. <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  105. SELECT
  106. a.id,
  107. a.order_code,
  108. a.material_id,
  109. a.purchase_num,
  110. a.arrival_num,
  111. a.type,
  112. a.qualified_num,
  113. a.disqualification_num,
  114. a.wbs,
  115. a.arrival_time,
  116. a.measurement_id,
  117. a.supplier_id,
  118. a.entry_number,
  119. a.warehousing_num,
  120. b.company_number,
  121. b.order_number,
  122. b.source_type,
  123. b.move_type,
  124. f.name as supplierName
  125. FROM
  126. tld_receive_goods a
  127. LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
  128. JOIN tld_material c on a.material_id = c.tld_id
  129. LEFT JOIN tld_customer f on a.supplier_id = f.tld_id
  130. WHERE
  131. a.supplier_id = #{suppId} and IFNULL(a.warehousing_num, 0 ) <![CDATA[<]]> a.qualified_num and c.code = #{wllbCode}
  132. ORDER BY
  133. a.arrival_time DESC
  134. </select>
  135. <!-- 修改采购单入库数量 -->
  136. <update id="updateReceiveGood">
  137. update tld_receive_goods
  138. set
  139. warehousing_num = warehousing_num + #{warehousingNum}
  140. where id = #{id}
  141. </update>
  142. <!-- 查询物料类型 -->
  143. <select id="getWlClass" resultType="com.tld.model.WarehousingVirtual">
  144. select wllb_class,tld_id as materialId from tld_material where code = #{wllbCode}
  145. </select>
  146. <!-- 插入入库流水 -->
  147. <insert id="addStorage">
  148. insert into tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq)
  149. values
  150. <foreach collection="list" index="index" item="item" separator=",">
  151. (#{item.wllbCode},#{item.suppId},#{item.serial},#{item.producDate},#{item.producDate},#{item.num},#{item.seq},#{item.type},#{item.userId},#{item.departmentId},#{item.storageLocationCode},now())
  152. </foreach>
  153. </insert>
  154. <!-- 插入库存 -->
  155. <insert id="addInventory">
  156. 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,produc_batch)
  157. values
  158. <foreach collection="list" index="index" item="item" separator=",">
  159. (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate}, now(),#{item.producDate})
  160. </foreach>
  161. </insert>
  162. <!-- 删除临时表数据 -->
  163. <delete id="delVirtual">
  164. delete from tld_warehousing_virtual where unique_code = #{uniqueCode}
  165. </delete>
  166. <!-- 查询当天质检数量 -->
  167. <select id="getWarehousingCount" resultType="int">
  168. select count(*) from tld_return_gs_warehousing where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  169. </select>
  170. <!-- 存入为gs穿的信息 -->
  171. <insert id="addReturnWarehousing">
  172. 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,user_name,storage_location_code)
  173. values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{id},now(),#{orderNumber},#{userName},#{storageLocationCode});
  174. </insert>
  175. <!-- 入库回传 -->
  176. <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
  177. select * from tld_return_gs_warehousing where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
  178. </select>
  179. <!-- 查询入库流水 -->
  180. <select id="warehousingFlowing" resultType="com.tld.model.Storage">
  181. select
  182. a.id,
  183. b.name as materialName,
  184. a.wllb_code,
  185. h.name as supplierName,
  186. a.serial,
  187. a.produc_date,
  188. a.produc_batch,
  189. a.capacity,
  190. a.seq,
  191. a.type,
  192. c.user_name as userName,
  193. e.name as departmentName,
  194. g.storage_location_name as storageLocationName,
  195. a.scrq
  196. from tld_storage a
  197. left join tld_material b on a.wllb_code = b.code
  198. left join tld_user c on a.user_id = c.id
  199. left join tld_department e on a.department_id = e.tld_id
  200. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  201. left join tld_customer h on a.supplier_id = h.code
  202. <trim prefix="WHERE" prefixOverrides="and |or">
  203. <if test="wllbCode != null and wllbCode != ''">
  204. and a.wllb_code = #{wllbCode}
  205. </if>
  206. <if test="startTime != null and startTime != ''">
  207. and a.scrq <![CDATA[>=]]> #{startTime}
  208. </if>
  209. <if test="endTime != null and endTime != ''">
  210. and a.scrq <![CDATA[<=]]> #{endTime}
  211. </if>
  212. </trim>
  213. order by scrq desc
  214. </select>
  215. <!-- 查询虚拟入库 -->
  216. <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
  217. select
  218. id,
  219. unique_code,
  220. num,
  221. storage_location_code,
  222. wllb_code,
  223. supp_id,
  224. serial,
  225. type,
  226. produc_date,
  227. capacity,
  228. seq,
  229. user_id,
  230. storage_location_name
  231. from tld_warehousing_virtual where unique_code = #{uniqueCode}
  232. </select>
  233. <!-- 查询导出内容 -->
  234. <select id="export" resultType="java.util.LinkedHashMap">
  235. select
  236. b.name as materialName,
  237. h.name as supplierName,
  238. a.serial,
  239. a.produc_date,
  240. a.produc_batch,
  241. a.capacity,
  242. a.seq,
  243. a.type,
  244. c.user_name as userName,
  245. e.name as departmentName,
  246. g.storage_location_name as storageLocationName,
  247. a.scrq
  248. from tld_storage a
  249. left join tld_material b on a.wllb_code = b.code
  250. left join tld_user c on a.user_id = c.id
  251. left join tld_department e on a.department_id = e.tld_id
  252. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  253. left join tld_customer h on a.supplier_id = h.code
  254. <trim prefix="WHERE" prefixOverrides="and |or">
  255. <if test="wllbCode != null and wllbCode != ''">
  256. and a.wllb_code = #{wllbCode}
  257. </if>
  258. <if test="startTime != null and startTime != ''">
  259. and a.scrq <![CDATA[>=]]> #{startTime}
  260. </if>
  261. <if test="endTime != null and endTime != ''">
  262. and a.scrq <![CDATA[<=]]> #{endTime}
  263. </if>
  264. </trim>
  265. order by a.scrq desc
  266. </select>
  267. <!-- 查询是否扫描 -->
  268. <select id="getScanIsNot" resultType="java.util.Map">
  269. select
  270. (select count(*) from tld_inventory where supplier_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryCount,
  271. (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualCount
  272. from dual
  273. </select>
  274. <!-- 查询物料是否存在 -->
  275. <select id="getMateriaIsExist" resultType="com.tld.model.MaterialClass">
  276. select
  277. id,
  278. code,
  279. name,
  280. tld_id,
  281. specification_and_model,
  282. unit_of_measurement,
  283. size,
  284. wllb_class,
  285. is_not_disable,
  286. is_recommend,
  287. part_type
  288. from tld_material where code = #{wllbCode}
  289. </select>
  290. <!-- 查询库存是否同物料同批次存在 -->
  291. <select id="getInventoryProduc" resultType="int">
  292. SELECT
  293. produc_date as producDate
  294. FROM
  295. tld_inventory a
  296. JOIN tld_material b ON a.material_id = b.tld_id
  297. WHERE a.produc_date = #{producDate} AND b.code = #{wllbCode} and a.storage_location_code = #{storageLocationCode} and hold = '0'
  298. </select>
  299. <!-- 查询报工单 -->
  300. <select id="getNotice" resultType="com.tld.model.Notice">
  301. select
  302. a.id,
  303. a.notice_id,
  304. a.entry_number,
  305. a.production_code,
  306. a.material_id,
  307. a.wbs,
  308. a.measurement_id,
  309. a.num,
  310. a.type,
  311. a.warehousing_num,
  312. b.company_number,
  313. c.name as materialName,
  314. c.wllb_class as wllbClass,
  315. c.code as wllbCode
  316. from tld_notice a
  317. join tld_notice_f b on a.notice_id = b.notice_id
  318. join tld_material c on a.material_id = c.tld_id
  319. <trim prefix="WHERE" prefixOverrides="and |or">
  320. <if test="type != null and type != ''">
  321. and a.type = #{type}
  322. </if>
  323. <if test="materialCode != null and materialCode != ''">
  324. and c.code = #{materialCode}
  325. </if>
  326. <if test="startTime != null and startTime != ''">
  327. and b.notice_time <![CDATA[>=]]> #{startTime}
  328. </if>
  329. <if test="endTime != null and endTime != ''">
  330. and b.notice_time <![CDATA[<=]]> #{endTime}
  331. </if>
  332. <if test="partType != null and partType != ''">
  333. and c.part_type = #{partType}
  334. </if>
  335. </trim>
  336. </select>
  337. <!-- 查询通知单是否入库 -->
  338. <select id="getNoticeId" resultType="com.tld.model.Notice">
  339. select
  340. a.id,
  341. a.notice_id,
  342. a.entry_number,
  343. a.production_code,
  344. a.material_id,
  345. a.wbs,
  346. a.measurement_id,
  347. a.num,
  348. a.type,
  349. a.warehousing_num,
  350. b.wllb_class,
  351. c.source_type,
  352. c.move_type,
  353. b.code as materialCode,
  354. c.notice_time as noticeTime
  355. from tld_notice a
  356. join tld_notice_f c on a.notice_id = c.notice_id
  357. left join tld_material b on a.material_id = b.tld_id
  358. where a.notice_id = #{noticeId} and a.material_id = #{materialId}
  359. </select>
  360. <!-- 半成品跟部分产成品入库存 -->
  361. <insert id="addInventoryNotice">
  362. insert into
  363. tld_inventory(storage_location_code,material_id,amount,hold,amount_lock,account_sleeve,wbs,produc_date,scrq,wllb_class,produc_batch,attribute)
  364. value(#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},now(),now(),#{wllbClass},#{producBatch},#{attribute});
  365. update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
  366. </insert>
  367. <!-- 查询库存里是否存在半成品虚拟库位 -->
  368. <select id="getInventoryNotice" resultType="int">
  369. select count(0) from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
  370. </select>
  371. <!-- 增加半成品/产成品虚拟库位数量 -->
  372. <update id="updateInventoryNotice">
  373. update tld_inventory set amount = amount + #{warehousingNum} where storage_location_code = #{storageLocationCode};
  374. update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
  375. </update>
  376. <!-- 半成品出库库存查询 -->
  377. <select id="getHalfInventory" resultType="com.tld.model.Inventory">
  378. select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
  379. </select>
  380. <!-- 删除库存信息 -->
  381. <delete id="delInventoryNotice">
  382. delete from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
  383. </delete>
  384. <!-- 删减库存 -->
  385. <update id="updateInventoryNoticeNum">
  386. update tld_inventory set amount = amount - #{warehousingNum} where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
  387. </update>
  388. <!-- 新增半成品入库流水 -->
  389. <insert id="addProduct">
  390. insert into tld_half_product(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq)
  391. value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now())
  392. </insert>
  393. <!-- 查询半成品入库流水-->
  394. <select id="getProduct" resultType="com.tld.model.Notice">
  395. select
  396. a.id,
  397. a.wllb_code,
  398. a.produc_date,
  399. a.produc_batch,
  400. a.capacity as warehousingNum,
  401. a.user_id,
  402. c.user_name,
  403. a.storage_location_code,
  404. a.scrq,
  405. b.name as materialName
  406. from tld_half_product a
  407. left join tld_material b on a.wllb_code = b.code
  408. left join tld_user c on a.user_id = c.id
  409. <trim prefix="WHERE" prefixOverrides="and |or">
  410. <if test="wllbCode != null and wllbCode != ''">
  411. and a.wllb_code = #{wllbCode}
  412. </if>
  413. <if test="startTime != null and startTime != ''">
  414. and a.scrq <![CDATA[>=]]> #{startTime}
  415. </if>
  416. <if test="endTime != null and endTime != ''">
  417. and a.scrq <![CDATA[<=]]> #{endTime}
  418. </if>
  419. </trim>
  420. order by a.scrq desc
  421. </select>
  422. <!-- 查询半成品入库流水-->
  423. <select id="productExcel" resultType="java.util.LinkedHashMap">
  424. select
  425. b.name,
  426. a.produc_date,
  427. a.capacity,
  428. c.user_name,
  429. a.scrq
  430. from tld_half_product a
  431. left join tld_material b on a.wllb_code = b.code
  432. left join tld_user c on a.user_id = c.id
  433. <trim prefix="WHERE" prefixOverrides="and |or">
  434. <if test="wllbCode != null and wllbCode != ''">
  435. and a.wllb_code = #{wllbCode}
  436. </if>
  437. <if test="startTime != null and startTime != ''">
  438. and a.scrq <![CDATA[>=]]> #{startTime}
  439. </if>
  440. <if test="endTime != null and endTime != ''">
  441. and a.scrq <![CDATA[<=]]> #{endTime}
  442. </if>
  443. </trim>
  444. order by a.scrq desc
  445. </select>
  446. <!-- 查询要料单信息 -->
  447. <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
  448. select
  449. a.id,
  450. a.ask_goods_id,
  451. a.material_id,
  452. a.wbs,
  453. a.measurement_id,
  454. a.num,
  455. a.out_num,
  456. a.entry_number,
  457. b.source_type,
  458. b.move_type,
  459. c.code as wllbCode,
  460. a.type,
  461. b.department
  462. from tld_ask_goods a
  463. join tld_ask_goods_f b on a.ask_goods_id = b. ask_goods_id
  464. left join tld_material c on a.material_id = c.tld_id
  465. where a.ask_goods_id = #{askGoodsId} and a.material_id = #{materialId}
  466. </select>
  467. <!-- 修改要货单出库数量 -->
  468. <update id="updateAskGoodsHalf">
  469. update tld_ask_goods set out_num = out_num + #{warehousingNum},type = '1' where id = #{id}
  470. </update>
  471. <!-- 新增半成品流水 -->
  472. <insert id="addRemovalHalfProduct">
  473. insert into tld_removal_half_product(wllb_code,num,user_id,scrq,ask_goods_id,department)
  474. value(#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department})
  475. </insert>
  476. <!-- 查询指定物料内容 -->
  477. <select id="getMaterial" resultType="com.tld.model.MaterialClass">
  478. select
  479. code as wllbCode,
  480. name as wllbName,
  481. tld_id,
  482. specification_and_model,
  483. unit_of_measurement,
  484. size,
  485. wllb_class,
  486. is_not_disable,
  487. is_recommend,
  488. part_type
  489. from tld_material
  490. <trim prefix="WHERE" prefixOverrides="and |or">
  491. <if test="materialId != null and materialId != ''">
  492. and tld_id = #{materialId}
  493. </if>
  494. <if test="materialCode != null and materialCode != ''">
  495. and code = #{materialCode}
  496. </if>
  497. </trim>
  498. </select>
  499. <!-- 查询库存信息 -->
  500. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  501. select
  502. storage_location_code,
  503. wllb_class,
  504. library_type,
  505. material_id,
  506. amount,
  507. total,
  508. totime,
  509. hold,
  510. amount_lock,
  511. account_sleeve,
  512. wbs,
  513. supplier_id,
  514. serial,
  515. wllb_code,
  516. produc_date,
  517. scrq,
  518. produc_batch,
  519. attribute
  520. from tld_inventory where storage_location_code = #{storageLocationCode}
  521. </select>
  522. <!-- 产成品入库 -->
  523. <insert id="addHalf">
  524. insert into tld_half(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq,serial,seq,attribute)
  525. value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute})
  526. </insert>
  527. <!-- 查询虚拟表数据进行入库 -->
  528. <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
  529. select
  530. a.id,
  531. a.unique_code,
  532. a.num,
  533. a.storage_location_code,
  534. a.wllb_code,
  535. a.supp_id,
  536. a.serial,
  537. a.type,
  538. a.produc_date,
  539. a.capacity,
  540. a.seq,
  541. a.user_id,
  542. a.attribute,
  543. a.storage_location_name,
  544. b.user_name
  545. from tld_warehousing_virtual a
  546. left join tld_user b on a.user_id = b.id
  547. where a.unique_code = #{uniqueCode} and a.type = #{type} and a.notice_id = #{noticeId}
  548. </select>
  549. <!-- 产成品入库流水 -->
  550. <select id="getHalf" resultType="com.tld.model.Notice">
  551. select
  552. a.id,
  553. a.wllb_code,
  554. a.produc_date,
  555. a.produc_batch,
  556. a.capacity,
  557. a.user_id,
  558. a.storage_location_code,
  559. a.scrq,
  560. a.serial,
  561. a.seq,
  562. a.attribute,
  563. b.name as materialName,
  564. c.user_name as userName
  565. from tld_half a
  566. left join tld_material b on a.wllb_code = b.code
  567. left join tld_user c on a.user_id = c.id
  568. <trim prefix="WHERE" prefixOverrides="and |or">
  569. <if test="wllbCode != null and wllbCode != ''">
  570. and a.wllb_code = #{wllbCode}
  571. </if>
  572. <if test="startTime != null and startTime != ''">
  573. and a.scrq <![CDATA[>=]]> #{startTime}
  574. </if>
  575. <if test="endTime != null and endTime != ''">
  576. and a.scrq <![CDATA[<=]]> #{endTime}
  577. </if>
  578. </trim>
  579. order by a.scrq desc
  580. </select>
  581. <!-- 产成品导出 -->
  582. <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
  583. select
  584. b.name as materialName,
  585. a.produc_batch,
  586. a.capacity,
  587. c.user_name as userName
  588. a.storage_location_code,
  589. a.scrq,
  590. a.serial,
  591. a.seq,
  592. a.attribute
  593. from tld_half a
  594. left join tld_material b on a.wllb_code = b.code
  595. left join tld_user c on a.user_id = c.id
  596. <trim prefix="WHERE" prefixOverrides="and |or">
  597. <if test="wllbCode != null and wllbCode != ''">
  598. and a.wllb_code = #{wllbCode}
  599. </if>
  600. <if test="startTime != null and startTime != ''">
  601. and a.scrq <![CDATA[>=]]> #{startTime}
  602. </if>
  603. <if test="endTime != null and endTime != ''">
  604. and a.scrq <![CDATA[<=]]> #{endTime}
  605. </if>
  606. </trim>
  607. order by a.scrq desc
  608. </select>
  609. </mapper>