InviteMapper.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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,request_type_number,request_type_name,if_commodity)
  24. values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
  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,request_type_number,request_type_name,if_commodity)
  29. values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{num},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
  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. e.part_type as partType,
  69. b.ask_goods_code,
  70. b.company_number,
  71. b.sqrq,
  72. c.name ,
  73. c.code,
  74. c.id AS departmentId,
  75. a.wbs,
  76. a.entry_number,
  77. a.wbs,
  78. f.code as wbsCode
  79. FROM
  80. tld_invite a
  81. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  82. LEFT JOIN tld_department c ON b.department = c.code
  83. JOIN tld_material e ON a.material_id = e.tld_id
  84. LEFT JOIN tld_wbs f ON a.wbs = f.tld_id
  85. WHERE
  86. ( a.num + 0 ) <![CDATA[>]]> (IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
  87. and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
  88. </select>
  89. <!-- 查询指定pda 指定物料扫描总数 -->
  90. <select id="getScanNum" resultType="String">
  91. select if(sum(num) is null, 0, sum(num))
  92. from tld_ask_goods_vitrual
  93. where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
  94. </select>
  95. <!-- 物料库位选择 -->
  96. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  97. select
  98. a.storage_location_code,
  99. a.wllb_class,
  100. a.library_type,
  101. a.material_id,
  102. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  103. a.total,
  104. a.totime,
  105. a.hold,
  106. a.amount_lock,
  107. a.account_sleeve,
  108. a.wbs,
  109. a.supplier_id,
  110. a.serial,
  111. a.wllb_code,
  112. a.produc_date,
  113. a.scrq,
  114. b.storage_location_name as storageLocationName
  115. from tld_inventory a
  116. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  117. join tld_warehouse c on b.warehouse_where = c.tld_id
  118. where a.material_id = #{materialId}
  119. and a.account_sleeve = #{companyNumber}
  120. and a.hold = '0'
  121. and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
  122. and a.wbs = #{wbs}
  123. order by a.produc_batch
  124. </select>
  125. <!-- 新增出库虚拟表 -->
  126. <insert id="addAskGoodsVitrual">
  127. insert into tld_ask_goods_vitrual(unique_code, supplier_id, serial, wllb_code, produc_date, ask_goods_id, type,
  128. storage_location_code, num, user_id, department, attribute, account_sleeve,
  129. storage_location_code_rk, wbs, entry_number)
  130. values (#{uniqueCode}, #{supplierId}, #{serial}, #{wllbCode}, #{producDate}, #{askGoodsId}, #{type},
  131. #{storageLocationCode}, #{num}, #{userId}, #{department}, #{attribute}, #{companyNumber},
  132. #{storageLocationCodeRk}, #{wbs}, #{entryNumber})
  133. </insert>
  134. <!-- 查询指定库存内容 -->
  135. <select id="getInventory" resultType="com.tld.model.Inventory">
  136. select
  137. id,
  138. storage_location_code,
  139. wllb_class,
  140. library_type,
  141. material_id,
  142. amount,
  143. total,
  144. totime,
  145. hold,
  146. amount_lock,
  147. account_sleeve,
  148. wbs,
  149. supplier_id,
  150. serial,
  151. wllb_code,
  152. produc_date,
  153. scrq
  154. from tld_inventory
  155. where supplier_id = #{supplierId}
  156. and serial = #{serial}
  157. and wllb_code = #{wllbCode}
  158. and produc_date = #{producDate}
  159. and account_sleeve = #{companyNumber}
  160. <if test="wbs != null">
  161. and wbs = #{wbs}
  162. </if> limit 1
  163. </select>
  164. <!-- 查询库存是否充足 -->
  165. <select id="getAsk" resultType="com.tld.model.AskGoods">
  166. SELECT ifnull(sum(a.num), 0) as num
  167. FROM tld_ask_goods_vitrual a
  168. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  169. where a.storage_location_code = #{storageLocationCode}
  170. and a.serial = #{serial} and wbs = #{wbs} and account_sleeve = #{accountSleeve}
  171. </select>
  172. <!-- 查询是否扫描 -->
  173. <select id="getScanIsNot" resultType="java.util.Map">
  174. select (select ifnull(max(amount), 0)
  175. from tld_inventory
  176. where supplier_id = #{supplierId}
  177. and serial = #{serial}
  178. and wllb_code = #{wllbCode}
  179. and produc_date = #{producDate}) as inventoryNum,
  180. (select ifnull(sum(num), 0)
  181. from tld_ask_goods_vitrual
  182. where supplier_id = #{supplierId}
  183. and serial = #{serial}
  184. and wllb_code = #{wllbCode}
  185. and produc_date = #{producDate}
  186. and type = #{type}) as virtualNum
  187. from dual
  188. </select>
  189. <!-- 查询指定送货单信息 -->
  190. <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
  191. SELECT
  192. a.id,
  193. a.ask_goods_id,
  194. a.entry_number,
  195. a.production_code,
  196. a.material_id,
  197. a.wbs,
  198. a.measurement_id,
  199. a.num,
  200. a.out_num
  201. FROM
  202. tld_invite a
  203. join tld_material b on a.material_id = b.tld_id
  204. where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode} and a.entry_number = #{entryNumber}
  205. </select>
  206. <!-- 查询已扫描总数 -->
  207. <select id="getAskInfoNumVitrual" resultType="int">
  208. select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
  209. </select>
  210. <!-- 查询此库存在虚拟表里占用的数量 -->
  211. <select id="getInventoryAlready" resultType="int">
  212. 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}
  213. </select>
  214. <!-- 查询虚拟表指定pda跟状态的的数据 -->
  215. <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
  216. select id,
  217. unique_code,
  218. supplier_id,
  219. serial,
  220. wllb_code,
  221. produc_date,
  222. ask_goods_id,
  223. type,
  224. storage_location_code,
  225. num,
  226. user_id,
  227. department,
  228. account_sleeve,
  229. wbs,
  230. storage_location_code_rk,
  231. entry_number
  232. from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
  233. </select>
  234. <!-- 删除库存 -->
  235. <delete id="deleteInventory">
  236. delete from tld_inventory where id = #{id}
  237. </delete>
  238. <!-- 修改库存数量 -->
  239. <update id="updateInventory">
  240. UPDATE tld_inventory
  241. SET amount = amount - ${amount}
  242. WHERE
  243. id = #{id}
  244. </update>
  245. <!-- 删除虚拟表出库记录 -->
  246. <delete id="deleteVirtual">
  247. delete from tld_ask_goods_vitrual where id = #{id}
  248. </delete>
  249. <!-- 删除交货单接口/销售交货出库记录 -->
  250. <delete id="updDelivery">
  251. delete from tld_delivery_f where delivery_id = #{deliveryOrderId};
  252. delete from tld_delivery where delivery_id = #{deliveryOrderId};
  253. </delete>
  254. <!-- 插入出库流水 -->
  255. <insert id="addRemoval">
  256. 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)
  257. values(#{wllbCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department},#{storageCode},#{wbs})
  258. </insert>
  259. <!-- 查询指定物料类型的id -->
  260. <select id="getMaterialId" resultType="String">
  261. select tld_id from tld_material where code = #{wllbCode}
  262. </select>
  263. <!-- 查询要料申请单内容 -->
  264. <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
  265. select
  266. id,
  267. ask_goods_id,
  268. entry_number,
  269. production_code,
  270. material_id,
  271. wbs,
  272. measurement_id,
  273. num,
  274. out_num
  275. from tld_invite
  276. where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
  277. <if test="entryNumber != null and entryNumber != ''">
  278. and entry_number = #{entryNumber}
  279. </if>
  280. </select>
  281. <!-- 新增返回gs数据字表信息 -->
  282. <insert id="addReturnGsRemoval">
  283. insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,document_points_id,storage_location_code)
  284. values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
  285. </insert>
  286. <!-- 查询要货单父级信息 -->
  287. <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
  288. select
  289. id,
  290. ask_goods_id,
  291. ask_goods_code,
  292. company_number,
  293. sqrq,
  294. department,
  295. source_type,
  296. move_type
  297. from tld_invite_f where ask_goods_id = #{askGoodsId}
  298. </select>
  299. <!-- 新增返回gs数据父表信息 -->
  300. <insert id="addReturnGsRemovalF">
  301. insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type)
  302. values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
  303. </insert>
  304. <!-- 半成品/产成品入库通知 -->
  305. <insert id="addNotice">
  306. insert into tld_notice_f (notice_id, notice_code, company_number, notice_time, source_type, move_type,notification_type_number,notification_type_name)
  307. values
  308. <foreach collection="list" index="index" item="item" separator=",">
  309. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType},#{item.notificationTypeNumber},#{item.notificationTypeName})
  310. </foreach>
  311. ;
  312. insert into tld_notice ( notice_id, entry_number, production_code, material_id, wbs, measurement_id, num, type, warehousing_num )
  313. values
  314. <foreach collection="list" index="index" item="item" separator=",">
  315. <foreach collection="item.datalist" index="index" item="items" separator=",">
  316. (#{item.stockInNoticeId},#{items.entryNumber},#{items.prodOrderNo},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  317. </foreach>
  318. </foreach>
  319. ;
  320. insert into tld_notice_log (notice_id, notice_code, company_number, notice_time, source_type, move_type,notification_type_number,notification_type_name,entry_number, production_code, material_id, wbs, measurement_id, num, type, warehousing_num)
  321. values
  322. <foreach collection="list" index="index" item="item" separator=",">
  323. <foreach collection="item.datalist" index="index" item="items" separator=",">
  324. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType} ,#{item.notificationTypeNumber},#{item.notificationTypeName} ,#{items.entryNumber},#{items.prodOrderNo},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  325. </foreach>
  326. </foreach>
  327. ;
  328. </insert>
  329. <!-- 交货单接口 -->
  330. <insert id="addDelivery">
  331. insert into tld_delivery_f (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type)
  332. values
  333. <foreach collection="list" index="index" item="item" separator=",">
  334. (#{item.deliveryOrderId},#{item.deliveryOrderNo},#{item.companyNumber},#{item.customerNo},#{item.docDate},#{item.deloveryGoodsType},#{item.sourceType},#{item.moveType})
  335. </foreach>
  336. ;
  337. insert into tld_delivery ( delivery_id, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num )
  338. values
  339. <foreach collection="list" index="index" item="item" separator=",">
  340. <foreach collection="item.datalist" index="index" item="items" separator=",">
  341. (#{item.deliveryOrderId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0)
  342. </foreach>
  343. </foreach>
  344. ;
  345. 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 )
  346. values
  347. <foreach collection="list" index="index" item="item" separator=",">
  348. <foreach collection="item.datalist" index="index" item="items" separator=",">
  349. (#{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)
  350. </foreach>
  351. </foreach>
  352. ;
  353. </insert>
  354. <!-- 移库通知单 -->
  355. <insert id="addWarehouseTransfer">
  356. insert into tld_warehouse_transfer_f (warehouse_transfer_id, warehouse_transfer_code, ask_goods_warehouse_id, document_time, warehouse_transfer_type)
  357. values
  358. <foreach collection="list" index="index" item="item" separator=",">
  359. (#{item.transferNoticeOrderId},#{item.transferNoticeOrderNo},#{item.requestWarehouseId},#{item.docDate},#{item.moveType})
  360. </foreach>
  361. ;
  362. insert into tld_warehouse_transfer ( warehouse_transfer_id, entry_number, supply_warehouse_id, material_id, wbs, measurement_id, num, out_num, type,account_sleeve)
  363. values
  364. <foreach collection="list" index="index" item="item" separator=",">
  365. <foreach collection="item.datalist" index="index" item="items" separator=",">
  366. (#{item.transferNoticeOrderId},#{items.entryNo},#{items.supplyWarehouseId},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0,#{items.accountSleeve})
  367. </foreach>
  368. </foreach>
  369. ;
  370. 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,account_sleeve)
  371. values
  372. <foreach collection="list" index="index" item="item" separator=",">
  373. <foreach collection="item.datalist" index="index" item="items" separator=",">
  374. (#{item.transferNoticeOrderId},#{item.transferNoticeOrderNo},#{item.requestWarehouseId},#{item.docDate},#{item.moveType},#{items.entryNo},#{items.supplyWarehouseId},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0,#{items.accountSleeve})
  375. </foreach>
  376. </foreach>
  377. ;
  378. </insert>
  379. <!-- 交货单接口 -->
  380. <insert id="addDeliverys">
  381. insert into tld_delivery_f (delivery_id, delivery_code, company_number, customer_code, bills_time, delivery_type,source_type,move_type,project_name,project_code)
  382. values
  383. (#{deliveryOrderId},#{deliveryOrderNo},#{companyNumber},#{customerNo},#{docDate},#{deloveryGoodsType},#{sourceType},#{moveType},#{projectName},#{projectCode})
  384. ;
  385. insert into tld_delivery ( delivery_id, entry_number, material_id, wbs, measurement_id, gs_delivery_num, gs_cancel_num, out_num,status )
  386. values
  387. <foreach collection="datalist" index="index" item="items" separator=",">
  388. (#{items.deliveryOrderId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0,0)
  389. </foreach>
  390. ;
  391. 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 ,status)
  392. values
  393. <foreach collection="datalist" index="index" item="items" separator=",">
  394. (#{deliveryOrderId},#{deliveryOrderNo},#{companyNumber},#{customerNo},#{docDate},#{deloveryGoodsType},#{sourceType},#{moveType},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.gsDeliveryCount},#{items.gsCancelDeliveryCount},0,0)
  395. </foreach>
  396. ;
  397. </insert>
  398. <!--其它入库-->
  399. <insert id="otherReceivingGoods">
  400. insert into tld_notices_f (notice_id, notice_code, company_number, notice_time, source_type, move_type,notification_type_number,notification_type_name)
  401. values
  402. <foreach collection="list" index="index" item="item" separator=",">
  403. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType},#{item.notificationTypeNumber},#{item.notificationTypeName})
  404. </foreach>
  405. ;
  406. insert into tld_notices ( notice_id, entry_number, material_id, wbs, measurement_id, num, type, warehousing_num )
  407. values
  408. <foreach collection="list" index="index" item="item" separator=",">
  409. <foreach collection="item.datalist" index="index" item="items" separator=",">
  410. (#{item.stockInNoticeId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  411. </foreach>
  412. </foreach>
  413. ;
  414. insert into tld_notices_log (notice_id, notice_code, company_number, notice_time, source_type, move_type,notification_type_number,notification_type_name,entry_number, material_id, wbs, measurement_id, num, type, warehousing_num)
  415. values
  416. <foreach collection="list" index="index" item="item" separator=",">
  417. <foreach collection="item.datalist" index="index" item="items" separator=",">
  418. (#{item.stockInNoticeId},#{item.stockInNoticeNo},#{item.companyNo},#{item.noticeDate},#{item.sourceType},#{item.moveType} ,#{item.notificationTypeNumber},#{item.notificationTypeName} ,#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  419. </foreach>
  420. </foreach>
  421. ;
  422. </insert>
  423. <!--其他出库-->
  424. <insert id="otherShipments">
  425. insert into tld_enquiry_f (ask_goods_id, ask_goods_code, company_number, sqrq, department, request_type_number,request_type_name,source_type,move_type,if_commodity)
  426. values
  427. <foreach collection="list" index="index" item="item" separator=",">
  428. (#{item.requestOrderId},#{item.requestOrderNo},#{item.companyNo},#{item.applicationDate},#{item.useDepartment},#{item.requestTypeNumber},#{item.requestTypeName},#{item.sourceType},#{item.moveType},#{item.ifCommodity})
  429. </foreach>
  430. ;
  431. insert into tld_enquiry ( ask_goods_id, entry_number, material_id, wbs, measurement_id, num, out_num, ask_goods_type )
  432. values
  433. <foreach collection="list" index="index" item="item" separator=",">
  434. <foreach collection="item.datalist" index="index" item="items" separator=",">
  435. (#{item.requestOrderId},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  436. </foreach>
  437. </foreach>
  438. ;
  439. insert into tld_enquiry_log (ask_goods_id, ask_goods_code, company_number, sqrq, department, request_type_number,request_type_name,source_type,move_type,if_commodity, entry_number, material_id, wbs, measurement_id, num, out_num, ask_goods_type)
  440. values
  441. <foreach collection="list" index="index" item="item" separator=",">
  442. <foreach collection="item.datalist" index="index" item="items" separator=",">
  443. (#{item.requestOrderId},#{item.requestOrderNo},#{item.companyNo},#{item.applicationDate},#{item.useDepartment},#{item.requestTypeNumber},#{item.requestTypeName},#{item.sourceType},#{item.moveType},#{item.ifCommodity},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  444. </foreach>
  445. </foreach>
  446. ;
  447. </insert>
  448. <!--补领料申请-->
  449. <insert id="sStoresRequisition">
  450. insert into tld_enquiry_f (ask_goods_id, ask_goods_code, company_number, sqrq, department, request_type_number,request_type_name,source_type,move_type,if_commodity,product_code)
  451. values
  452. <foreach collection="list" index="index" item="item" separator=",">
  453. (#{item.requestOrderId},#{item.requestOrderNo},#{item.companyNo},#{item.applicationDate},#{item.useDepartment},#{item.requestTypeNumber},#{item.requestTypeName},#{item.sourceType},#{item.moveType},#{item.ifCommodity},#{item.productCode})
  454. </foreach>
  455. ;
  456. insert into tld_enquiry ( ask_goods_id, entry_number,production_code, material_id, wbs, measurement_id, num, out_num, type )
  457. values
  458. <foreach collection="list" index="index" item="item" separator=",">
  459. <foreach collection="item.datalist" index="index" item="items" separator=",">
  460. (#{item.requestOrderId},#{items.entryNumber},#{items.prodOrderNo},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0)
  461. </foreach>
  462. </foreach>
  463. ;
  464. insert into tld_enquiry_log (ask_goods_id, ask_goods_code, company_number, sqrq, department, request_type_number,request_type_name,source_type,move_type,if_commodity, entry_number, material_id, wbs, measurement_id, num, out_num, type,product_code,production_code)
  465. values
  466. <foreach collection="list" index="index" item="item" separator=",">
  467. <foreach collection="item.datalist" index="index" item="items" separator=",">
  468. (#{item.requestOrderId},#{item.requestOrderNo},#{item.companyNo},#{item.applicationDate},#{item.useDepartment},#{item.requestTypeNumber},#{item.requestTypeName},#{item.sourceType},#{item.moveType},#{item.ifCommodity},#{items.entryNumber},#{items.materialId},#{items.WBS},#{items.measUnitId},#{items.orderCount},0,0,#{item.productCode},#{items.prodOrderNo})
  469. </foreach>
  470. </foreach>
  471. ;
  472. </insert>
  473. <!-- 查询当天出库数量 -->
  474. <select id="getReturnRemovalCount" resultType="int">
  475. select count(*) from tld_return_gs_removal where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
  476. </select>
  477. <!-- 查询回传数据 -->
  478. <select id="plugOutRemoval" resultType="java.util.Map">
  479. select
  480. id,
  481. document_id as askGoodsId,
  482. removal_code as removalCode,
  483. source_type as sourceType,
  484. move_type as moveType
  485. from tld_return_gs_removal where removal_code = #{removalCode}
  486. </select>
  487. <!-- 查询字表回传数据 -->
  488. <select id="getRemovalz" resultType="java.util.Map">
  489. select
  490. material_id as materialId,
  491. wbs,
  492. num,
  493. entry_number as entryNumber,
  494. document_id as askGoodsId,
  495. document_points_id as askId
  496. from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
  497. </select>
  498. <!-- 查询出库流水 -->
  499. <select id="getRemoval" resultType="com.tld.model.AskGoods">
  500. select
  501. a.id,
  502. b.name as materialName,
  503. a.wllb_code,
  504. h.name as supplierName,
  505. a.serial,
  506. a.type,
  507. c.user_name as userName,
  508. e.name as departmentName,
  509. g.storage_location_name as storageLocationName,
  510. a.scrq,
  511. a.num
  512. from tld_removal a
  513. left join tld_material b on a.wllb_code = b.code
  514. left join tld_user c on a.user_id = c.id
  515. left join tld_department e on a.department = e.code
  516. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  517. left join tld_customer h on a.supplier_id = h.code
  518. <trim prefix="WHERE" prefixOverrides="and |or">
  519. <if test="wllbCode != null and wllbCode != ''">
  520. and a.wllb_code = #{wllbCode}
  521. </if>
  522. <if test="startTime != null and startTime != ''">
  523. and a.scrq <![CDATA[>=]]> #{startTime}
  524. </if>
  525. <if test="endTime != null and endTime != ''">
  526. and a.scrq <![CDATA[<=]]> #{endTime}
  527. </if>
  528. <if test="type != null and type != ''">
  529. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  530. </if>
  531. </trim>
  532. </select>
  533. <!-- 导出 -->
  534. <select id="export" resultType="java.util.LinkedHashMap">
  535. select
  536. b.name as materialName,
  537. h.name as supplierName,
  538. a.serial,
  539. a.type,
  540. c.user_name as userName,
  541. e.name as departmentName,
  542. g.storage_location_name as storageLocationName,
  543. a.scrq,
  544. a.num
  545. from tld_removal a
  546. left join tld_material b on a.wllb_code = b.code
  547. left join tld_user c on a.user_id = c.id
  548. left join tld_department e on a.department = e.code
  549. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  550. left join tld_customer h on a.supplier_id = h.code
  551. <trim prefix="WHERE" prefixOverrides="and |or">
  552. <if test="wllbCode != null and wllbCode != ''">
  553. and a.wllb_code = #{wllbCode}
  554. </if>
  555. <if test="startTime != null and startTime != ''">
  556. and a.scrq <![CDATA[>=]]> #{startTime}
  557. </if>
  558. <if test="endTime != null and endTime != ''">
  559. and a.scrq <![CDATA[<=]]> #{endTime}
  560. </if>
  561. <if test="type != null and type != ''">
  562. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  563. </if>
  564. </trim>
  565. </select>
  566. <select id="getCountDelivery" resultType="java.lang.Integer">
  567. select COUNT(*) from tld_delivery where delivery_id = #{deliveryOrderId} and (out_num+0) <![CDATA[>]]> 0
  568. </select>
  569. <!-- 修改出库数量 -->
  570. <update id="updateOutNum">
  571. update tld_invite
  572. set out_num = ifnull(out_num,0) + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
  573. <if test="entryNumber != null and entryNumber != ''">
  574. and entry_number = #{entryNumber}
  575. </if>
  576. </update>
  577. <!--修改交货单状态-->
  578. <update id="updStatus">
  579. update tld_delivery
  580. set status = #{status} where delivery_id = #{deliveryOrderId} and entry_number = #{entryNumber} and material_id = #{materialId}
  581. </update>
  582. <!-- 查询要料申请单 -->
  583. <select id="getDelAskGoods" resultType="java.util.Map">
  584. select * from tld_invite where id = #{id}
  585. </select>
  586. <!-- 删除生产领料 -->
  587. <delete id="delAskGoods">
  588. delete from tld_invite where id = #{id}
  589. </delete>
  590. </mapper>