AskGoodsMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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.AskGoodsMapper">
  5. <!-- 查询要货单id+物料id是否存在 -->
  6. <select id="getAskGoods" resultType="int">
  7. select count(*) from tld_ask_goods where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  8. </select>
  9. <!-- 修改要料申请单数量 -->
  10. <update id="updateAskGoodsNum">
  11. update tld_ask_goods
  12. set
  13. num =#{num}
  14. where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  15. </update>
  16. <!-- 新增要料申请单 -->
  17. <insert id="addAskGoods">
  18. insert into tld_ask_goods(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,type,out_num)
  19. values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{num},#{type},'0')
  20. </insert>
  21. <!-- 新增要料日志 -->
  22. <insert id="addAskGoodsLog">
  23. insert into tld_ask_goods_log(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_code,company_number,sqrq,department_id,source_type,move_type,ask_goods_type)
  24. values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{num},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType})
  25. </insert>
  26. <!-- 查询次要货单是否存在 -->
  27. <select id="getAskGoodsf" resultType="int">
  28. select count(*) from tld_ask_goods_f where ask_goods_id = #{askGoodsId} and ask_goods_code = #{askGoodsCode}
  29. </select>
  30. <!-- 新增要料申请单父级 -->
  31. <insert id="addAskGoodsf">
  32. insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type)
  33. values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType})
  34. </insert>
  35. <!-- 查询生产领料单 -->
  36. <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
  37. SELECT
  38. a.ask_goods_id,
  39. a.material_id,
  40. IFNULL( a.out_num, 0 ) AS num,
  41. e.NAME AS materialName,
  42. e.CODE AS materialCode,
  43. b.ask_goods_code,
  44. b.company_number
  45. FROM
  46. tld_ask_goods a
  47. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  48. LEFT JOIN tld_department c ON b.department = c.code
  49. JOIN tld_material e ON a.material_id = e.tld_id
  50. WHERE
  51. ( a.num + 0 ) <![CDATA[>]]> (
  52. IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
  53. </select>
  54. <!-- 查询指定生产单的物料 -->
  55. <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
  56. SELECT
  57. a.ask_goods_id,
  58. a.material_id,
  59. a.num,
  60. IFNULL( a.out_num, 0 ) AS out_num,
  61. e.NAME AS materialName,
  62. e.CODE AS materialCode,
  63. b.ask_goods_code,
  64. b.company_number,
  65. c.name ,
  66. c.code,
  67. c.id AS departmentId
  68. FROM
  69. tld_ask_goods a
  70. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  71. LEFT JOIN tld_department c ON b.department = c.code
  72. JOIN tld_material e ON a.material_id = e.tld_id
  73. WHERE
  74. ( a.num + 0 ) <![CDATA[>]]> (
  75. IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
  76. </select>
  77. <!-- 物料库位选择 -->
  78. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  79. select
  80. a.storage_location_code,
  81. a.wllb_class,
  82. a.library_type,
  83. a.material_id,
  84. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  85. a.total,
  86. a.totime,
  87. a.hold,
  88. a.amount_lock,
  89. a.account_sleeve,
  90. a.wbs,
  91. a.supplier_id,
  92. a.serial,
  93. a.wllb_code,
  94. a.produc_date,
  95. a.scrq,
  96. b.storage_location_name as storageLocationName
  97. from tld_inventory a
  98. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  99. join tld_warehouse c on b.warehouse_where = c.tld_id
  100. 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')
  101. order by a.produc_date
  102. </select>
  103. <!-- 新增出库虚拟表 -->
  104. <insert id="addAskGoodsVitrual">
  105. insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department,attribute,account_sleeve,storage_location_code_rk,wbs)
  106. values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department},#{attribute},#{companyNumber},#{storageLocationCodeRk},#{wbs})
  107. </insert>
  108. <!-- 查询指定库存内容 -->
  109. <select id="getInventory" resultType="com.tld.model.Inventory">
  110. select
  111. id,
  112. storage_location_code,
  113. wllb_class,
  114. library_type,
  115. material_id,
  116. amount,
  117. total,
  118. totime,
  119. hold,
  120. amount_lock,
  121. account_sleeve,
  122. wbs,
  123. supplier_id,
  124. serial,
  125. wllb_code,
  126. produc_date,
  127. scrq
  128. from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber} and wbs = #{wbs}
  129. </select>
  130. <!-- 查询指定库存内容 -->
  131. <select id="getInventoryWarehousing" resultType="com.tld.model.Inventory">
  132. select
  133. id,
  134. storage_location_code,
  135. wllb_class,
  136. library_type,
  137. material_id,
  138. amount,
  139. total,
  140. totime,
  141. hold,
  142. amount_lock,
  143. account_sleeve,
  144. wbs,
  145. supplier_id,
  146. serial,
  147. wllb_code,
  148. produc_date,
  149. scrq
  150. from tld_inventory where storage_location_code = #{storageLocationCode} and wllb_code = #{wllbCode} and account_sleeve = #{companyNumber} and wbs = #{wbs}
  151. </select>
  152. <!-- 查询库存是否充足 -->
  153. <select id="getAsk" resultType="com.tld.model.AskGoods">
  154. SELECT
  155. ifnull(sum(a.num),0) as num
  156. FROM
  157. tld_ask_goods_vitrual a
  158. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  159. where a.storage_location_code = #{storageLocationCode} and a.serial = #{serial}
  160. </select>
  161. <!-- 查询是否扫描 -->
  162. <select id="getScanIsNot" resultType="java.util.Map">
  163. select
  164. (select ifnull(amount,0) from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
  165. (select ifnull(sum(num),0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
  166. from dual
  167. </select>
  168. <!-- 查询指定送货单信息 -->
  169. <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
  170. SELECT
  171. a.id,
  172. a.ask_goods_id,
  173. a.entry_number,
  174. a.production_code,
  175. a.material_id,
  176. a.wbs,
  177. a.measurement_id,
  178. a.num,
  179. ifnull(a.out_num, 0) as out_num
  180. FROM
  181. tld_ask_goods a
  182. join tld_material b on a.material_id = b.tld_id
  183. where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode}
  184. </select>
  185. <!-- 查询指定移庫單 -->
  186. <select id="getWareInfo" resultType="com.tld.model.AskGoods">
  187. SELECT
  188. a.id,
  189. a.warehouse_transfer_id as askGoodsId,
  190. a.entry_number,
  191. a.material_id,
  192. a.wbs,
  193. a.measurement_id,
  194. a.num,
  195. ifnull(a.out_num, 0) as out_num
  196. FROM
  197. tld_warehouse_transfer a
  198. join tld_material b on a.material_id = b.tld_id
  199. where a.warehouse_transfer_id = #{askGoodsId} and b.code = #{wllbCode}
  200. </select>
  201. <!-- 查询已扫描总数 -->
  202. <select id="getAskInfoNumVitrual" resultType="int">
  203. select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{wllbCode} and ask_goods_id = #{askGoodsId} and type = #{type}
  204. </select>
  205. <!-- 查询此库存在虚拟表里占用的数量 -->
  206. <select id="getInventoryAlready" resultType="int">
  207. select ifnull(sum(num), 0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
  208. </select>
  209. <!-- 查询虚拟表指定pda跟状态的的数据 -->
  210. <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
  211. select
  212. id,
  213. unique_code,
  214. supplier_id,
  215. serial,
  216. wllb_code,
  217. produc_date,
  218. ask_goods_id,
  219. type,
  220. storage_location_code,
  221. num,
  222. user_id,
  223. department,
  224. account_sleeve,
  225. wbs,
  226. storage_location_code_rk
  227. from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
  228. </select>
  229. <!-- 删除库存 -->
  230. <delete id="deleteInventory">
  231. delete from tld_inventory where id = #{id}
  232. </delete>
  233. <!-- 修改库存数量 -->
  234. <update id="updateInventory">
  235. UPDATE tld_inventory
  236. SET amount = amount - #{amount}
  237. WHERE
  238. id = #{id}
  239. </update>
  240. <!-- 删除虚拟表出库记录 -->
  241. <delete id="deleteVirtual">
  242. delete from tld_ask_goods_vitrual where id = #{id}
  243. </delete>
  244. <!-- 插入出库流水 -->
  245. <insert id="addRemoval">
  246. insert into tld_removal(wllb_code,supplier_id,serial,num,type,user_id,storage_location_code,scrq,process,ask_goods_id,produc_date,department,storage_code,wbs)
  247. values(#{wllbCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department},#{storageCode},#{wbs})
  248. </insert>
  249. <!-- 查询指定物料类型的id -->
  250. <select id="getMaterialId" resultType="String">
  251. select tld_id from tld_material where code = #{wllbCode}
  252. </select>
  253. <!-- 查询要料申请单内容 -->
  254. <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
  255. select
  256. id,
  257. ask_goods_id,
  258. entry_number,
  259. production_code,
  260. material_id,
  261. wbs,
  262. measurement_id,
  263. num,
  264. out_num
  265. from tld_ask_goods
  266. where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  267. </select>
  268. <!-- 新增返回gs数据字表信息 -->
  269. <insert id="addReturnGsRemoval">
  270. insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,document_points_id,storage_location_code)
  271. values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
  272. </insert>
  273. <!-- 查询要货单父级信息 -->
  274. <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
  275. select
  276. id,
  277. ask_goods_id,
  278. ask_goods_code,
  279. company_number,
  280. sqrq,
  281. department,
  282. source_type,
  283. move_type
  284. from tld_ask_goods_f where ask_goods_id = #{askGoodsId}
  285. </select>
  286. <!-- 新增返回gs数据父表信息 -->
  287. <insert id="addReturnGsRemovalF">
  288. insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type)
  289. values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
  290. </insert>
  291. <!-- 添加 tld_access 记录-->
  292. <insert id="addAccess">
  293. insert into tld_access (type,data,scrq,access_type)
  294. values(#{names},#{returnGsRemoval},now(),#{accessType})
  295. </insert>
  296. <!-- 查询当天出库数量 -->
  297. <select id="getReturnRemovalCount" resultType="int">
  298. select count(*) from tld_return_gs_removal where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  299. </select>
  300. <!-- 查询回传数据 -->
  301. <select id="plugOutRemoval" resultType="java.util.Map">
  302. select
  303. id,
  304. document_id as askGoodsId,
  305. removal_code as removalCode,
  306. source_type as sourceType,
  307. move_type as moveType,
  308. scrq
  309. from tld_return_gs_removal where document_id = #{removalCode}
  310. </select>
  311. <!-- 查询字表回传数据 -->
  312. <select id="getRemovalz" resultType="java.util.Map">
  313. SELECT
  314. a.material_id AS materialId,
  315. a.wbs,
  316. a.num,
  317. a.entry_number AS entryNumber,
  318. a.document_id AS askGoodsId,
  319. a.document_points_id AS askId
  320. FROM
  321. tld_return_gs_removal_z a
  322. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  323. WHERE
  324. a.document_id = #{askGoodsId} and b.warehouse_where = #{warehouseWhere}
  325. </select>
  326. <!-- 查询出库流水 -->
  327. <select id="getRemoval" resultType="com.tld.model.AskGoods">
  328. select
  329. a.id,
  330. b.name as materialName,
  331. a.wllb_code,
  332. h.name as supplierName,
  333. a.serial,
  334. a.type,
  335. c.user_name as userName,
  336. e.name as department,
  337. g.storage_location_name as storageLocationName,
  338. a.scrq,
  339. a.num,
  340. a.storage_code,
  341. a.wbs
  342. from tld_removal a
  343. left join tld_material b on a.wllb_code = b.code
  344. left join tld_user c on a.user_id = c.id
  345. left join tld_department e on a.department = e.code
  346. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  347. left join tld_customer h on a.supplier_id = h.code
  348. <trim prefix="WHERE" prefixOverrides="and |or">
  349. <if test="wllbCode != null and wllbCode != ''">
  350. and a.wllb_code = #{wllbCode}
  351. </if>
  352. <if test="startTime != null and startTime != ''">
  353. and a.scrq <![CDATA[>=]]> #{startTime}
  354. </if>
  355. <if test="endTime != null and endTime != ''">
  356. and a.scrq <![CDATA[<=]]> #{endTime}
  357. </if>
  358. <if test="type != null and type != ''">
  359. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  360. </if>
  361. </trim>
  362. order by a.id desc
  363. </select>
  364. <!-- 导出 -->
  365. <select id="export" resultType="java.util.LinkedHashMap">
  366. select
  367. b.name as materialName,
  368. h.name as supplierName,
  369. a.serial,
  370. a.type,
  371. c.user_name as userName,
  372. e.name as department,
  373. g.storage_location_name as storageLocationName,
  374. a.scrq,
  375. a.num
  376. from tld_removal a
  377. left join tld_material b on a.wllb_code = b.code
  378. left join tld_user c on a.user_id = c.id
  379. left join tld_department e on a.department = e.code
  380. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  381. left join tld_customer h on a.supplier_id = h.code
  382. <trim prefix="WHERE" prefixOverrides="and |or">
  383. <if test="wllbCode != null and wllbCode != ''">
  384. and a.wllb_code = #{wllbCode}
  385. </if>
  386. <if test="startTime != null and startTime != ''">
  387. and a.scrq <![CDATA[>=]]> #{startTime}
  388. </if>
  389. <if test="endTime != null and endTime != ''">
  390. and a.scrq <![CDATA[<=]]> #{endTime}
  391. </if>
  392. <if test="type != null and type != ''">
  393. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  394. </if>
  395. </trim>
  396. order by a.id desc
  397. </select>
  398. <!-- 查询指定pda出库虚拟表 -->
  399. <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
  400. select
  401. id,
  402. unique_code,
  403. supplier_id,
  404. serial,
  405. wllb_code,
  406. produc_date,
  407. ask_goods_id,
  408. type,
  409. storage_location_code,
  410. num,
  411. user_id,
  412. department
  413. from tld_ask_goods_vitrual
  414. where unique_code = #{uniqueCode} and type = #{type}
  415. </select>
  416. <!-- 删除指定虚拟表数据 -->
  417. <delete id="delAskGoodsVitrual">
  418. delete from tld_ask_goods_vitrual where id = #{id} and type = #{type}
  419. </delete>
  420. <!-- 删除出库回传主表信息 -->
  421. <delete id="delPlugOutRemoval">
  422. delete from tld_return_gs_removal where document_id = #{removalCode}
  423. </delete>
  424. <!-- 删除出库回传子表信息 -->
  425. <delete id="delRemovalz">
  426. delete from tld_return_gs_removal_z where document_id = #{removalCode}
  427. </delete>
  428. <!-- 删除入库回传信息 -->
  429. <delete id="delPlugOutWarehousing">
  430. delete from tld_return_gs_warehousing where order_number = #{orderNumber}
  431. </delete>
  432. <!-- 修改出库数量 -->
  433. <update id="updateOutNum">
  434. update tld_ask_goods
  435. set out_num = ifnull(out_num, 0) + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
  436. </update>
  437. <!-- 查询指定pda 指定物料扫描总数 -->
  438. <select id="getScanNum" resultType="String">
  439. select if(sum(num) is null, 0, num)
  440. from tld_ask_goods_vitrual
  441. where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId} and wllb_code = #{wllbCode}
  442. </select>
  443. <!-- 查询半成品出库数据 -->
  444. <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
  445. SELECT
  446. a.id,
  447. a.material_id,
  448. a.num,
  449. a.production_code,
  450. b.name as materialName,
  451. b.code as materialCode,
  452. a.out_num,
  453. a.ask_goods_id,
  454. c.company_number,
  455. e.name as department,
  456. a.type,
  457. a.wbs
  458. FROM
  459. tld_ask_goods a
  460. join tld_material b on a.material_id = b.tld_id
  461. join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
  462. left join tld_department e on c.department = e.code
  463. WHERE
  464. (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type = #{partType}
  465. <if test="productionCode != null and productionCode != ''">
  466. and a.production_code = #{productionCode}
  467. </if>
  468. <if test="askGoodsId != null and askGoodsId != ''">
  469. and a.ask_goods_id = #{askGoodsId}
  470. </if>
  471. <if test="id != null and id != ''">
  472. and a.id = #{id}
  473. </if>
  474. <if test="type != null and type != ''">
  475. and a.type = #{type}
  476. </if>
  477. </select>
  478. <!-- 查询半成品出库流水 -->
  479. <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
  480. select
  481. a.id,
  482. a.wllb_code,
  483. a.num,
  484. a.user_id,
  485. a.scrq,
  486. a.ask_goods_id,
  487. c.name as department,
  488. b.name as materialName,
  489. e.user_name as userName,
  490. b.code as materialCode,
  491. a.storage_code,
  492. a.wbs
  493. from tld_removal_half_product a
  494. left join tld_material b on a.wllb_code = b.code
  495. left join tld_department c on a.department = c.code
  496. left join tld_user e on a.user_id = e.id
  497. <if test="wllbCode != null and wllbCode != ''">
  498. and a.wllb_code = #{wllbCode}
  499. </if>
  500. <if test="startTime != null and startTime != ''">
  501. and a.scrq <![CDATA[>=]]> #{startTime}
  502. </if>
  503. <if test="endTime != null and endTime != ''">
  504. and a.scrq <![CDATA[<=]]> #{endTime}
  505. </if>
  506. order by a.scrq desc
  507. </select>
  508. <!-- 查询半成品出库流水导出 -->
  509. <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
  510. select
  511. b.name as materialName,
  512. a.num,
  513. e.user_name as userName,
  514. a.scrq,
  515. a.ask_goods_id,
  516. c.name as department,
  517. a.storage_code,
  518. a.wbs
  519. from tld_removal_half_product a
  520. left join tld_material b on a.wllb_code = b.code
  521. left join tld_department c on a.department = c.code
  522. left join tld_user e on a.user_id = e.id
  523. <if test="wllbCode != null and wllbCode != ''">
  524. and a.wllb_code = #{wllbCode}
  525. </if>
  526. <if test="startTime != null and startTime != ''">
  527. and a.scrq <![CDATA[>=]]> #{startTime}
  528. </if>
  529. <if test="endTime != null and endTime != ''">
  530. and a.scrq <![CDATA[<=]]> #{endTime}
  531. </if>
  532. order by a.scrq desc
  533. </select>
  534. <!-- 产成品出库流水 -->
  535. <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
  536. select
  537. a.id,
  538. a.wllb_code,
  539. a.num,
  540. a.user_id,
  541. a.scrq,
  542. a.delivery_id,
  543. a.company_number,
  544. a.customer_code,
  545. b.name as materialName,
  546. c.user_name as userName,
  547. e.name as customerName,
  548. f.name as companyName,
  549. b.code as materialCode,
  550. a.storage_code,
  551. a.wbs
  552. from tld_removal_half a
  553. left join tld_material b on a.wllb_code = b.code
  554. left join tld_user c on a.user_id = c.id
  555. left join tld_customer e on a.customer_code = e.code
  556. left join tld_company f on a.company_number = f.tld_id
  557. <if test="wllbCode != null and wllbCode != ''">
  558. and a.wllb_code = #{wllbCode}
  559. </if>
  560. <if test="startTime != null and startTime != ''">
  561. and a.scrq <![CDATA[>=]]> #{startTime}
  562. </if>
  563. <if test="endTime != null and endTime != ''">
  564. and a.scrq <![CDATA[<=]]> #{endTime}
  565. </if>
  566. order by a.scrq desc
  567. </select>
  568. <!-- 产成品导出出库流水 -->
  569. <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
  570. select
  571. b.name as materialName,
  572. a.num,
  573. c.user_name as userName,
  574. a.scrq,
  575. f.name as companyName,
  576. e.name,
  577. a.storage_code,
  578. a.wbs
  579. from tld_removal_half a
  580. left join tld_material b on a.wllb_code = b.code
  581. left join tld_user c on a.user_id = c.id
  582. left join tld_customer e on a.customer_code = e.code
  583. left join tld_company f on a.company_number = f.tld_id
  584. <if test="wllbCode != null and wllbCode != ''">
  585. and a.wllb_code = #{wllbCode}
  586. </if>
  587. <if test="startTime != null and startTime != ''">
  588. and a.scrq <![CDATA[>=]]> #{startTime}
  589. </if>
  590. <if test="endTime != null and endTime != ''">
  591. and a.scrq <![CDATA[<=]]> #{endTime}
  592. </if>
  593. order by a.scrq desc
  594. </select>
  595. <!-- 查询指定物料的库存 -->
  596. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  597. select
  598. id,
  599. storage_location_code,
  600. wllb_class,
  601. library_type,
  602. material_id,
  603. amount,
  604. total,
  605. totime,
  606. hold,
  607. amount_lock,
  608. account_sleeve,
  609. wbs,
  610. supplier_id,
  611. serial,
  612. wllb_code,
  613. produc_date,
  614. scrq,
  615. produc_batch,
  616. attribute
  617. from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and account_sleeve = #{accountSleeve} and amount <![CDATA[>=]]> #{num}
  618. <if test="wbs != '' and wbs != null">
  619. and wbs = #{wbs}
  620. </if>
  621. <if test="wbs == ''.toString() or wbs == null ">
  622. and wbs is null
  623. </if>
  624. <if test="serial != '' and serial != null">
  625. and serial = #{serial}
  626. </if>
  627. <if test="attribute != '' and attribute != null">
  628. and attribute = #{attribute}
  629. </if>
  630. <if test="producDate != '' and producDate != null">
  631. and produc_batch = #{producDate}
  632. </if>
  633. <if test="supplierId != '' and supplierId != null">
  634. and supplier_id = #{supplierId}
  635. </if>
  636. </select>
  637. <!-- 其他入库查询库存是否存在 -->
  638. <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
  639. select
  640. id,
  641. storage_location_code,
  642. wllb_class,
  643. library_type,
  644. material_id,
  645. amount,
  646. total,
  647. totime,
  648. hold,
  649. amount_lock,
  650. account_sleeve,
  651. wbs,
  652. supplier_id,
  653. serial,
  654. wllb_code,
  655. produc_date,
  656. scrq,
  657. produc_batch,
  658. attribute
  659. from tld_inventory where material_id = #{materialId}
  660. <if test="wbs != '' and wbs != null">
  661. and wbs = #{wbs}
  662. </if>
  663. <if test="wbs == ''.toString() or wbs == null ">
  664. and wbs is null
  665. </if>
  666. <if test="serial != '' and serial != null">
  667. and serial = #{serial}
  668. </if>
  669. <if test="attribute != '' and attribute != null">
  670. and attribute = #{attribute}
  671. </if>
  672. <if test="producDate != '' and producDate != null">
  673. and produc_batch = #{producDate}
  674. </if>
  675. <if test="supplierId != '' and supplierId != null">
  676. and supplier_id = #{supplierId}
  677. </if>
  678. <if test="storageLocationCode != '' and storageLocationCode != null">
  679. and storage_location_code = #{storageLocationCode}
  680. </if>
  681. <if test="accountSleeve != '' and accountSleeve != null">
  682. and account_sleeve = #{accountSleeve}
  683. </if>
  684. </select>
  685. <!-- 查询仓库 -->
  686. <select id="getWarehouseWhere" resultType="String">
  687. SELECT
  688. DISTINCT b.warehouse_where
  689. FROM
  690. tld_return_gs_removal_z a
  691. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  692. WHERE
  693. a.document_id = #{removalCode}
  694. </select>
  695. <!-- 查询半成品原始数据 -->
  696. <select id="getInventoryNotice" resultType="java.util.Map">
  697. select * from tld_notice where id = #{id}
  698. </select>
  699. <!-- 删除半成品/产成品入库通知原始信息 -->
  700. <delete id="delInventoryNotice">
  701. delete from tld_notice where id = #{id}
  702. </delete>
  703. <!-- 查询要料申请单 -->
  704. <select id="getDelAskGoods" resultType="java.util.Map">
  705. select * from tld_ask_goods where id = #{id}
  706. </select>
  707. <!-- 销售发货单接口文档 父表信息 -->
  708. <select id="getGsRemoval" resultType="java.util.Map">
  709. select
  710. id,
  711. document_id as askGoodsId,
  712. removal_code as removalCode,
  713. source_type as sourceType,
  714. move_type as moveType,
  715. scrq
  716. from tld_return_gs_removal where document_id = #{removalCode}
  717. </select>
  718. <!-- 删除生产领料 -->
  719. <delete id="delAskGoods">
  720. delete from tld_ask_goods where id = #{id}
  721. </delete>
  722. </mapper>