InviteMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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.InviteMapper">
  5. <!-- 查询要货单id+物料id是否存在 -->
  6. <select id="getAskGoods" resultType="int">
  7. select count(*) from tld_invite 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 = (select num from tld_invite where ask_goods_id = #{askGoodsId} and material_id = #{materialId})
  14. where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  15. </update>
  16. <!-- 新增要料申请单 -->
  17. <insert id="addAskGoods">
  18. insert into tld_invite(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_type)
  19. values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{num},'0',#{askGoodsType})
  20. </insert>
  21. <!-- 新增要料申请单父级 -->
  22. <insert id="addAskGoodsf">
  23. insert into tld_invite_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type,ask_goods_apply_type)
  24. values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType},#{askGoodsApplyType})
  25. </insert>
  26. <!-- 新增要料日志 -->
  27. <insert id="addAskGoodsLog">
  28. 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)
  29. values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{num},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType})
  30. </insert>
  31. <!-- 查询次要货单是否存在 -->
  32. <select id="getAskGoodsf" resultType="int">
  33. select count(*) from tld_invite_f where ask_goods_id = #{askGoodsId} and ask_goods_code = #{askGoodsCode}
  34. </select>
  35. <!-- 新增要料申请单父级 -->
  36. <insert id="addAskGoodsNumf">
  37. insert into tld_invite_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type)
  38. values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType})
  39. </insert>
  40. <!-- 查询生产领料单 -->
  41. <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
  42. SELECT
  43. a.ask_goods_id,
  44. a.material_id,
  45. IFNULL( a.out_num, 0 ) AS num,
  46. e.NAME AS materialName,
  47. e.CODE AS materialCode,
  48. b.ask_goods_code,
  49. b.company_number
  50. FROM
  51. tld_invite a
  52. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  53. LEFT JOIN tld_department c ON b.department = c.code
  54. JOIN tld_material e ON a.material_id = e.tld_id
  55. WHERE
  56. ( a.num + 0 ) <![CDATA[>]]> (
  57. IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
  58. </select>
  59. <!-- 查询指定生产单的物料 -->
  60. <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
  61. SELECT
  62. a.ask_goods_id,
  63. a.material_id,
  64. a.num,
  65. IFNULL( a.out_num, 0 ) AS out_num,
  66. e.NAME AS materialName,
  67. e.CODE AS materialCode,
  68. b.ask_goods_code,
  69. b.company_number,
  70. c.name ,
  71. c.code,
  72. c.id AS departmentId
  73. FROM
  74. tld_invite a
  75. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  76. LEFT JOIN tld_department c ON b.department = c.code
  77. JOIN tld_material e ON a.material_id = e.tld_id
  78. WHERE
  79. ( a.num + 0 ) <![CDATA[>]]> (
  80. IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
  81. </select>
  82. <!-- 查询指定pda 指定物料扫描总数 -->
  83. <select id="getScanNum" resultType="String">
  84. select if(AVG(num) is null, 0, num)
  85. from tld_ask_goods_vitrual
  86. where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
  87. </select>
  88. <!-- 物料库位选择 -->
  89. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  90. select
  91. a.storage_location_code,
  92. a.wllb_class,
  93. a.library_type,
  94. a.material_id,
  95. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  96. a.total,
  97. a.totime,
  98. a.hold,
  99. a.amount_lock,
  100. a.account_sleeve,
  101. a.wbs,
  102. a.supplier_id,
  103. a.serial,
  104. a.wllb_code,
  105. a.produc_date,
  106. a.scrq,
  107. b.storage_location_name as storageLocationName
  108. from tld_inventory a
  109. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  110. where a.material_id = #{materialId} and a.account_sleeve = #{companyNumber} and a.hold = '0' and b.warehouse_where != '5000' order by a.produc_date
  111. </select>
  112. <!-- 新增出库虚拟表 -->
  113. <insert id="addAskGoodsVitrual">
  114. 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)
  115. values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department})
  116. </insert>
  117. <!-- 查询指定库存内容 -->
  118. <select id="getInventory" resultType="com.tld.model.Inventory">
  119. select
  120. id,
  121. storage_location_code,
  122. wllb_class,
  123. library_type,
  124. material_id,
  125. amount,
  126. total,
  127. totime,
  128. hold,
  129. amount_lock,
  130. account_sleeve,
  131. wbs,
  132. supplier_id,
  133. serial,
  134. wllb_code,
  135. produc_date,
  136. scrq
  137. from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}
  138. </select>
  139. <!-- 查询库存是否充足 -->
  140. <select id="getAsk" resultType="com.tld.model.AskGoods">
  141. SELECT
  142. ifnull(sum(a.num),0) as num
  143. FROM
  144. tld_ask_goods_vitrual a
  145. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  146. where a.storage_location_code = #{storageLocationCode}
  147. </select>
  148. <!-- 查询是否扫描 -->
  149. <select id="getScanIsNot" resultType="java.util.Map">
  150. select
  151. (select ifnull(amount,0) from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
  152. (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
  153. from dual
  154. </select>
  155. <!-- 查询指定送货单信息 -->
  156. <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
  157. SELECT
  158. a.id,
  159. a.ask_goods_id,
  160. a.entry_number,
  161. a.production_code,
  162. a.material_id,
  163. a.wbs,
  164. a.measurement_id,
  165. a.num,
  166. a.out_num
  167. FROM
  168. tld_invite a
  169. join tld_material b on a.material_id = b.tld_id
  170. where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode}
  171. </select>
  172. <!-- 查询已扫描总数 -->
  173. <select id="getAskInfoNumVitrual" resultType="int">
  174. select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
  175. </select>
  176. <!-- 查询此库存在虚拟表里占用的数量 -->
  177. <select id="getInventoryAlready" resultType="int">
  178. 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}
  179. </select>
  180. <!-- 查询虚拟表指定pda跟状态的的数据 -->
  181. <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
  182. select
  183. id,
  184. unique_code,
  185. supplier_id,
  186. serial,
  187. wllb_code,
  188. produc_date,
  189. ask_goods_id,
  190. type,
  191. storage_location_code,
  192. num,
  193. user_id,
  194. department,
  195. account_sleeve
  196. from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
  197. </select>
  198. <!-- 删除库存 -->
  199. <delete id="deleteInventory">
  200. delete from tld_inventory where id = #{id}
  201. </delete>
  202. <!-- 修改库存数量 -->
  203. <update id="updateInventory">
  204. UPDATE tld_inventory
  205. SET amount = amount - ${amount}
  206. WHERE
  207. id = #{id}
  208. </update>
  209. <!-- 删除虚拟表出库记录 -->
  210. <delete id="deleteVirtual">
  211. delete from tld_ask_goods_vitrual where id = #{id}
  212. </delete>
  213. <!-- 删除交货单接口/销售交货出库记录 -->
  214. <delete id="updDelivery">
  215. delete from tld_delivery_f where delivery_id = #{deliveryOrderId};
  216. delete from tld_delivery where delivery_id = #{deliveryOrderId};
  217. </delete>
  218. <!-- 插入出库流水 -->
  219. <insert id="addRemoval">
  220. 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)
  221. values(#{wllbCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department},#{storageCode},#{wbs})
  222. </insert>
  223. <!-- 查询指定物料类型的id -->
  224. <select id="getMaterialId" resultType="String">
  225. select tld_id from tld_material where code = #{wllbCode}
  226. </select>
  227. <!-- 查询要料申请单内容 -->
  228. <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
  229. select
  230. id,
  231. ask_goods_id,
  232. entry_number,
  233. production_code,
  234. material_id,
  235. wbs,
  236. measurement_id,
  237. num,
  238. out_num
  239. from tld_invite
  240. where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  241. </select>
  242. <!-- 新增返回gs数据字表信息 -->
  243. <insert id="addReturnGsRemoval">
  244. insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,document_points_id,storage_location_code)
  245. values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
  246. </insert>
  247. <!-- 查询要货单父级信息 -->
  248. <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
  249. select
  250. id,
  251. ask_goods_id,
  252. ask_goods_code,
  253. company_number,
  254. sqrq,
  255. department,
  256. source_type,
  257. move_type
  258. from tld_invite_f where ask_goods_id = #{askGoodsId}
  259. </select>
  260. <!-- 新增返回gs数据父表信息 -->
  261. <insert id="addReturnGsRemovalF">
  262. insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type)
  263. values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
  264. </insert>
  265. <!-- 半成品/产成品入库通知 -->
  266. <insert id="addNotice">
  267. insert into tld_notice_f (notice_id, notice_code, company_number, notice_time, source_type, move_type)
  268. values
  269. <foreach collection="list" index="index" item="item" separator=",">
  270. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType})
  271. </foreach>
  272. ;
  273. insert into tld_notice ( notice_id, entry_number, production_code, material_id, wbs, measurement_id, num, type, warehousing_num )
  274. values
  275. <foreach collection="list" index="index" item="item" separator=",">
  276. <foreach collection="item.datalist" index="index" item="items" separator=",">
  277. (#{item.stockInNoticeId},#{items.entryNumber},#{items.prodOrderNo},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  278. </foreach>
  279. </foreach>
  280. ;
  281. insert into tld_notice_log (notice_id, notice_code, company_number, notice_time, source_type, move_type,entry_number, production_code, material_id, wbs, measurement_id, num, type, warehousing_num)
  282. values
  283. <foreach collection="list" index="index" item="item" separator=",">
  284. <foreach collection="item.datalist" index="index" item="items" separator=",">
  285. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType},#{items.entryNumber},#{items.prodOrderNo},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  286. </foreach>
  287. </foreach>
  288. ;
  289. </insert>
  290. <!-- 交货单接口 -->
  291. <insert id="addDelivery">
  292. insert into tld_delivery_f (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type)
  293. values
  294. <foreach collection="list" index="index" item="item" separator=",">
  295. (#{item.deliveryOrderId},#{item.deliveryOrderNo},#{item.companyNumber},#{item.customerNo},#{item.docDate},#{item.deloveryGoodsType},#{item.sourceType},#{item.moveType})
  296. </foreach>
  297. ;
  298. insert into tld_delivery ( delivery_id, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num )
  299. values
  300. <foreach collection="list" index="index" item="item" separator=",">
  301. <foreach collection="item.datalist" index="index" item="items" separator=",">
  302. (#{item.deliveryOrderId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0)
  303. </foreach>
  304. </foreach>
  305. ;
  306. insert into tld_delivery_log (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num )
  307. values
  308. <foreach collection="list" index="index" item="item" separator=",">
  309. <foreach collection="item.datalist" index="index" item="items" separator=",">
  310. (#{item.deliveryOrderId},#{item.deliveryOrderNo},#{item.companyNumber},#{item.customerNo},#{item.docDate},#{item.deloveryGoodsType},#{item.sourceType},#{item.moveType},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0)
  311. </foreach>
  312. </foreach>
  313. ;
  314. </insert>
  315. <!-- 移库通知单 -->
  316. <insert id="addWarehouseTransfer">
  317. insert into tld_warehouse_transfer_f (warehouse_transfer_id, warehouse_transfer_code, ask_goods_warehouse_id, document_time, warehouse_transfer_type)
  318. values
  319. <foreach collection="list" index="index" item="item" separator=",">
  320. (#{item.transferNoticeOrderId},#{item.transferNoticeOrderNo},#{item.requestWarehouseId},#{item.docDate},#{item.moveType})
  321. </foreach>
  322. ;
  323. insert into tld_warehouse_transfer ( warehouse_transfer_id, entry_number, supply_warehouse_id, material_id, wbs, measurement_id, num, out_num, type)
  324. values
  325. <foreach collection="list" index="index" item="item" separator=",">
  326. <foreach collection="item.datalist" index="index" item="items" separator=",">
  327. (#{item.transferNoticeOrderId},#{items.entryNo},#{items.supplyWarehouseId},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  328. </foreach>
  329. </foreach>
  330. ;
  331. insert into tld_warehouse_transfer_log (warehouse_transfer_id, warehouse_transfer_code, ask_goods_warehouse_id, document_time, warehouse_transfer_type, entry_number, supply_warehouse_id, material_id, wbs, measurement_id, num, out_num, type)
  332. values
  333. <foreach collection="list" index="index" item="item" separator=",">
  334. <foreach collection="item.datalist" index="index" item="items" separator=",">
  335. (#{item.transferNoticeOrderId},#{item.transferNoticeOrderNo},#{item.requestWarehouseId},#{item.docDate},#{item.moveType},#{items.entryNo},#{items.supplyWarehouseId},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  336. </foreach>
  337. </foreach>
  338. ;
  339. </insert>
  340. <!-- 交货单接口 -->
  341. <insert id="addDeliverys">
  342. insert into tld_delivery_f (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type)
  343. values
  344. (#{deliveryOrderId},#{deliveryOrderNo},#{companyNumber},#{customerNo},#{docDate},#{deloveryGoodsType},#{sourceType},#{moveType})
  345. ;
  346. insert into tld_delivery ( delivery_id, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num )
  347. values
  348. <foreach collection="datalist" index="index" item="items" separator=",">
  349. (#{items.deliveryOrderId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0)
  350. </foreach>
  351. ;
  352. insert into tld_delivery_log (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num )
  353. values
  354. <foreach collection="datalist" index="index" item="items" separator=",">
  355. (#{deliveryOrderId},#{deliveryOrderNo},#{companyNumber},#{customerNo},#{docDate},#{deloveryGoodsType},#{sourceType},#{moveType},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0)
  356. </foreach>
  357. ;
  358. </insert>
  359. <!-- 查询当天出库数量 -->
  360. <select id="getReturnRemovalCount" resultType="int">
  361. select count(*) from tld_return_gs_removal where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  362. </select>
  363. <!-- 查询回传数据 -->
  364. <select id="plugOutRemoval" resultType="java.util.Map">
  365. select
  366. id,
  367. document_id as askGoodsId,
  368. removal_code as removalCode,
  369. source_type as sourceType,
  370. move_type as moveType
  371. from tld_return_gs_removal where removal_code = #{removalCode}
  372. </select>
  373. <!-- 查询字表回传数据 -->
  374. <select id="getRemovalz" resultType="java.util.Map">
  375. select
  376. material_id as materialId,
  377. wbs,
  378. num,
  379. entry_number as entryNumber,
  380. document_id as askGoodsId,
  381. document_points_id as askId
  382. from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
  383. </select>
  384. <!-- 查询出库流水 -->
  385. <select id="getRemoval" resultType="com.tld.model.AskGoods">
  386. select
  387. a.id,
  388. b.name as materialName,
  389. a.wllb_code,
  390. h.name as supplierName,
  391. a.serial,
  392. a.type,
  393. c.user_name as userName,
  394. e.name as departmentName,
  395. g.storage_location_name as storageLocationName,
  396. a.scrq,
  397. a.num
  398. from tld_removal a
  399. left join tld_material b on a.wllb_code = b.code
  400. left join tld_user c on a.user_id = c.id
  401. left join tld_department e on a.department = e.code
  402. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  403. left join tld_customer h on a.supplier_id = h.code
  404. <trim prefix="WHERE" prefixOverrides="and |or">
  405. <if test="wllbCode != null and wllbCode != ''">
  406. and a.wllb_code = #{wllbCode}
  407. </if>
  408. <if test="startTime != null and startTime != ''">
  409. and a.scrq <![CDATA[>=]]> #{startTime}
  410. </if>
  411. <if test="endTime != null and endTime != ''">
  412. and a.scrq <![CDATA[<=]]> #{endTime}
  413. </if>
  414. <if test="type != null and type != ''">
  415. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  416. </if>
  417. </trim>
  418. </select>
  419. <!-- 导出 -->
  420. <select id="export" resultType="java.util.LinkedHashMap">
  421. select
  422. b.name as materialName,
  423. h.name as supplierName,
  424. a.serial,
  425. a.type,
  426. c.user_name as userName,
  427. e.name as departmentName,
  428. g.storage_location_name as storageLocationName,
  429. a.scrq,
  430. a.num
  431. from tld_removal a
  432. left join tld_material b on a.wllb_code = b.code
  433. left join tld_user c on a.user_id = c.id
  434. left join tld_department e on a.department = e.code
  435. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  436. left join tld_customer h on a.supplier_id = h.code
  437. <trim prefix="WHERE" prefixOverrides="and |or">
  438. <if test="wllbCode != null and wllbCode != ''">
  439. and a.wllb_code = #{wllbCode}
  440. </if>
  441. <if test="startTime != null and startTime != ''">
  442. and a.scrq <![CDATA[>=]]> #{startTime}
  443. </if>
  444. <if test="endTime != null and endTime != ''">
  445. and a.scrq <![CDATA[<=]]> #{endTime}
  446. </if>
  447. <if test="type != null and type != ''">
  448. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  449. </if>
  450. </trim>
  451. </select>
  452. <select id="getCountDelivery" resultType="java.lang.Integer">
  453. select COUNT(*) from tld_delivery where delivery_id = #{deliveryOrderId} and out_num > 0
  454. </select>
  455. <!-- 修改出库数量 -->
  456. <update id="updateOutNum">
  457. update tld_invite
  458. set out_num = ifnull(out_num,0) + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
  459. </update>
  460. <!-- 查询要料申请单 -->
  461. <select id="getDelAskGoods" resultType="java.util.Map">
  462. select * from tld_invite where id = #{id}
  463. </select>
  464. <!-- 删除生产领料 -->
  465. <delete id="delAskGoods">
  466. delete from tld_invite where id = #{id}
  467. </delete>
  468. </mapper>