You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

622 lines
24 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gaotao.modules.boxManage.dao.BoxForNotificationMapper">
  4. <select id="searchSoReceiveBoxesData" resultType="SoReceiveBoxesData">
  5. SELECT
  6. s.id,
  7. s.site,
  8. s.WareHouseID as wareHouseID,
  9. s.box_no as boxNo,
  10. s.order_no as orderNo,
  11. s.status,
  12. s.rolls_qty as rollsQty,
  13. s.box_type as boxType,
  14. s.c_in_stock_flag as cInStockFlag,
  15. s.created_date as createdDate,
  16. s.created_by as createdBy,
  17. s.update_date as updateDate,
  18. s.update_by as updateBy,
  19. s.version,
  20. w.WareHouseName as wareHouseName,
  21. s.bu_no,
  22. T.box_count as boxCount,
  23. T.roll_count as rollCount,
  24. T.rollsCount as rollsCount
  25. from so_receive_boxes s with(nolock)
  26. left join warehouse w with(nolock) on s.WareHouseID = w.WareHouseID and s.site = w.site and s.bu_no = w.bu_no
  27. left JOIN (
  28. select
  29. a.site,
  30. a.bu_no,
  31. a.order_no,
  32. COUNT(DISTINCT a.box_no) AS box_count, --箱标签张数
  33. COUNT(DISTINCT b.final_roll_no) AS roll_count, --卷标签张数
  34. ISNULL(SUM(roll_qty),0) AS rollsCount --物料总数
  35. from so_receive_boxes a with(nolock)
  36. LEFT join so_receive_box_rolls b with(nolock) on a.site = b.site and a.bu_no = b.bu_no and a.box_no = b.box_no
  37. WHERE a.SITE = #{site} AND a.bu_no = #{buNo} and a.order_no = #{orderNo} group by a.site, a.bu_no, a.order_no) T ON S.site = T.site AND S.bu_no = T.bu_no AND S.order_no = T.order_no
  38. <where>
  39. s.site = #{site} and s.bu_no = #{buNo}
  40. <if test="orderNo != null and orderNo != ''">
  41. and s.order_no = #{orderNo}
  42. </if>
  43. <if test="boxType != null and boxType != ''">
  44. and s.box_type = #{boxType}
  45. </if>
  46. </where>
  47. </select>
  48. <insert id="newSoReceiveBoxesData" >
  49. insert into so_receive_boxes
  50. (site,box_no,order_no,[status],rolls_qty,box_type,c_in_stock_flag,created_date,created_by,
  51. version,WareHouseID,bu_no) values
  52. (#{site},#{boxNo},#{orderNo},#{status},#{rollsQty},#{boxType},'Y',GetDate(),#{createdBy},
  53. 0,#{wareHouseID},#{buNo})
  54. </insert>
  55. <select id="searchBoxRollDetail" resultType="SoReceiveBoxRollsData">
  56. select ROW_NUMBER() OVER (ORDER BY a.received_date) orderId, a.id,a.site,a.bu_no,a.box_no,a.final_roll_no,a.roll_qty,a.received_by,a.received_date,a.WareHouseID,a.part_no
  57. from so_receive_box_rolls a
  58. where a.site=#{site} and a.box_no=#{boxNo} and a.bu_no= #{buNo}
  59. order by a.received_date desc
  60. </select>
  61. <select id="searchBoxData" resultType="SoReceiveBoxesData">
  62. select
  63. a.id,
  64. a.site,
  65. a.bu_no,
  66. a.box_no,
  67. a.order_no,
  68. a.status,
  69. a.rolls_qty,
  70. a.box_type,
  71. a.c_in_stock_flag,
  72. a.created_date,
  73. a.created_by,
  74. a.version,
  75. a.WareHouseID,
  76. b.std_packing_qty as stdPackingQty
  77. from so_receive_boxes a
  78. left join outbound_notification_detail b on a.site = b.site and a.bu_no = b.bu_no and a.order_no = b.order_no
  79. where a.site= #{site} and a.box_no= #{boxNo} and a.bu_no= #{buNo}
  80. </select>
  81. <delete id="deleteSoReceiveBoxesData">
  82. delete from so_receive_boxes
  83. where id=#{id}
  84. </delete>
  85. <update id="updateBoxStatus">
  86. update so_receive_boxes
  87. set [status]=#{status}
  88. where id=#{id}
  89. </update>
  90. <select id="selectByRollNo" resultType="com.gaotao.modules.inventoryStock.entity.InventoryStock">
  91. SELECT
  92. site,
  93. bu_no,
  94. roll_no,
  95. parent_roll_no,
  96. parent_roll_type,
  97. part_no,
  98. warehouse_id,
  99. location_id,
  100. batch_no,
  101. status,
  102. qty_on_hand
  103. FROM inventory_stock
  104. WHERE roll_no = #{rollNo}
  105. AND site = #{site}
  106. AND bu_no = #{buNo}
  107. </select>
  108. <select id="selectByRollNo2" resultType="com.gaotao.modules.inventoryStock.entity.InventoryStock">
  109. SELECT
  110. site,
  111. bu_no,
  112. roll_no,
  113. parent_roll_no,
  114. parent_roll_type,
  115. part_no,
  116. warehouse_id,
  117. location_id,
  118. batch_no,
  119. status,
  120. qty_on_hand
  121. FROM inventory_stock
  122. WHERE parent_roll_no = #{rollNo}
  123. AND site = #{site}
  124. AND bu_no = #{buNo}
  125. and status='在库' AND COALESCE(parent_roll_type, '*') NOT IN ('箱标签')
  126. </select>
  127. <update id="updateStockParentRollNo">
  128. UPDATE inventory_stock
  129. SET ori_parent_roll_no = parent_roll_no,
  130. ori_parent_roll_type = parent_roll_type,
  131. parent_roll_no = #{parentRollNo},
  132. parent_roll_type = '箱标签'
  133. WHERE roll_no = #{rollNo}
  134. AND site = #{site}
  135. AND bu_no = #{buNo}
  136. </update>
  137. <insert id="addBoxRoll">
  138. insert into so_receive_box_rolls
  139. (site,box_no,final_roll_no,roll_qty,received_by,received_date,WareHouseID,part_no,bu_no)
  140. values
  141. (#{site},#{boxNo},#{finalRollNo},#{rollQty},#{receivedBy},GetDate(),#{wareHouseID},#{partNo},#{buNo})
  142. </insert>
  143. <update id="updateBoxRollQty">
  144. update so_receive_boxes
  145. set rolls_qty =isnull((select count(1) from so_receive_box_rolls where box_no = #{boxNo} and site=#{site} and bu_no= #{buNo}),0)
  146. where site = #{site}
  147. and box_no = #{boxNo}
  148. and bu_no = #{buNo}
  149. </update>
  150. <select id="searchOutboundNotificationDetail" resultType="com.gaotao.modules.outboundNotification.entity.OutboundNotificationDetailEntity">
  151. select site,bu_no,order_no,part_no,part_desc,unit,required_qty,out_warehouse,out_batch_no,created_by,created_date,updated_by,
  152. updated_date,order_qty,related_order_no,related_order_line_no,inspection_flag
  153. from outbound_notification_detail
  154. where site = #{site} and bu_no = #{buNo} and order_no = #{orderNo}
  155. </select>
  156. <select id="getOutboundNotificationDetailByKey" resultType="com.gaotao.modules.outboundNotification.entity.OutboundNotificationDetailEntity">
  157. select site,bu_no,order_no,part_no,part_desc,unit,required_qty,out_warehouse,out_batch_no,created_by,created_date,updated_by,
  158. updated_date,order_qty,related_order_no,related_order_line_no,inspection_flag
  159. from outbound_notification_detail
  160. where site = #{site} and bu_no = #{buNo} and order_no = #{orderNo} and part_no = #{partNo}
  161. </select>
  162. <update id="updateBoxWareHouse">
  163. update so_receive_boxes
  164. set WareHouseID = #{warehouseId}
  165. where site = #{site}
  166. and box_no = #{boxNo}
  167. and bu_no = #{buNo}
  168. </update>
  169. <delete id="deleteBoxRoll">
  170. delete from so_receive_box_rolls
  171. where site = #{site}
  172. and box_no = #{boxNo}
  173. and bu_no = #{buNo}
  174. and final_roll_no = #{finalRollNo}
  175. </delete>
  176. <select id="searchRollForOrderNo" resultType="SoReceiveBoxRollsData">
  177. select
  178. ROW_NUMBER() OVER (ORDER BY b.received_date) orderId,
  179. b.id,
  180. b.site,
  181. b.bu_no,
  182. b.box_no,
  183. b.final_roll_no,
  184. b.roll_qty,
  185. b.received_by,
  186. b.received_date,
  187. b.WareHouseID,
  188. b.part_no,
  189. c.warehouse_id,
  190. c.batch_no,
  191. c.location_id
  192. from so_receive_boxes a
  193. INNER join so_receive_box_rolls b on a.site = b.site and a.box_no = b.box_no and a.bu_no = b.bu_no
  194. left join inventory_stock c on b.site = c.site and b.final_roll_no = c.roll_no and b.bu_no = c.bu_no
  195. where a.site = #{site} and a.order_no = #{orderNo} and a.bu_no = #{buNo}
  196. </select>
  197. <!-- 盒清单相关SQL -->
  198. <select id="searchSoReceiveCasesData" resultType="SoReceiveCasesData">
  199. SELECT
  200. s.Id as id,
  201. s.NotifyNo as notifyNo,
  202. s.cases_no as casesNo,
  203. s.roll_no as rollNo,
  204. s.roll_qty as rollQty,
  205. s.part_no as partNo,
  206. s.part_desc as partDesc,
  207. s.create_date as createDate,
  208. s.create_by as createBy,
  209. s.Remark as remark,
  210. s.site,
  211. s.bu_no as buNo,
  212. agg.box_count_cases as boxCountCases,
  213. agg.box_count_rolls as boxCountRolls,
  214. agg.total_qty as totalQty
  215. FROM so_receive_cases s WITH(NOLOCK)
  216. LEFT JOIN (
  217. SELECT
  218. site,
  219. NotifyNo,
  220. COUNT(DISTINCT cases_no) AS box_count_cases, --盒标签张数
  221. COUNT(DISTINCT roll_no) AS box_count_rolls, --卷标签张数
  222. SUM(roll_qty) AS total_qty --物料总数
  223. FROM so_receive_cases WITH(NOLOCK)
  224. WHERE site = #{site} and NotifyNo = #{notifyNo}
  225. GROUP BY site, NotifyNo
  226. ) as agg ON s.site = agg.site AND s.NotifyNo = agg.NotifyNo
  227. <where>
  228. s.site = #{site} AND s.bu_no = #{buNo}
  229. <if test="notifyNo != null and notifyNo != ''">
  230. AND s.NotifyNo = #{notifyNo}
  231. </if>
  232. <if test="casesNo != null and casesNo != ''">
  233. AND s.cases_no = #{casesNo}
  234. </if>
  235. </where>
  236. ORDER BY s.create_date DESC
  237. </select>
  238. <delete id="deleteSoReceiveCasesData">
  239. DELETE FROM so_receive_cases
  240. WHERE Id = #{id}
  241. AND site = #{site}
  242. AND bu_no = #{buNo}
  243. </delete>
  244. <select id="validateCaseRoll" resultType="SoReceiveCasesData">
  245. SELECT
  246. #{casesNo} as casesNo,
  247. a.roll_no as rollNo,
  248. a.qty_on_hand as rollQty,
  249. a.part_no as partNo,
  250. b.PartDescription as partDesc,
  251. a.batch_no as batchNo,
  252. a.status,
  253. a.parent_roll_type as parentRollType
  254. FROM
  255. inventory_stock a
  256. INNER JOIN part b ON a.site = b.site
  257. AND a.part_no = b.PartNo
  258. WHERE
  259. a.site = #{site}
  260. AND a.parent_roll_no = #{rollNo}
  261. AND a.part_no = #{partNo}
  262. </select>
  263. <insert id="saveSoReceiveCases">
  264. INSERT INTO so_receive_cases (
  265. NotifyNo,
  266. cases_no,
  267. roll_no,
  268. roll_qty,
  269. part_no,
  270. part_desc,
  271. create_date,
  272. create_by,
  273. Remark,
  274. site,
  275. bu_no
  276. ) VALUES (
  277. #{notifyNo},
  278. #{casesNo},
  279. #{rollNo},
  280. #{rollQty},
  281. #{partNo},
  282. #{partDesc},
  283. GETDATE(),
  284. #{createBy},
  285. #{remark},
  286. #{site},
  287. #{buNo}
  288. )
  289. </insert>
  290. <update id="updateStockParentRollType">
  291. UPDATE inventory_stock
  292. SET ori_parent_roll_no = parent_roll_no,
  293. ori_parent_roll_type = parent_roll_type,
  294. parent_roll_no = #{parentRollNo},
  295. parent_roll_type = #{parentRollType}
  296. WHERE roll_no = #{rollNo}
  297. AND site = #{site}
  298. AND bu_no = #{buNo}
  299. </update>
  300. <!-- 恢复库存的原始上级标签 -->
  301. <update id="restoreStockParentRollType">
  302. UPDATE inventory_stock
  303. SET parent_roll_no = ori_parent_roll_no,
  304. parent_roll_type = ori_parent_roll_type
  305. WHERE roll_no = #{rollNo}
  306. AND site = #{site}
  307. AND bu_no = #{buNo}
  308. </update>
  309. <!-- 查询出库通知单主记录(关联明细) -->
  310. <select id="searchOutboundNotificationWithDetail" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationHeadVo">
  311. SELECT
  312. a.site,
  313. a.bu_no as buNo,
  314. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  315. a.order_no as orderNo,
  316. a.order_type as orderType,
  317. a.order_status as orderStatus,
  318. a.customer_id as customerId,
  319. c.customerName,
  320. c.CustomerAbb as customerAbb,
  321. <!-- a.related_order_no as relatedOrderNo,-->
  322. <!-- a.related_order_line_no as relatedOrderLineNo,-->
  323. a.required_outbound_date as requiredOutboundDate,
  324. a.remarks,
  325. a.erp_order_no as erpOrderNo,
  326. a.erp_order_line_no as erpOrderLineNo,
  327. a.erp_order_date as erpOrderDate,
  328. a.created_by as createdBy,
  329. a.created_date as createdDate,
  330. a.updated_by as updatedBy,
  331. a.updated_date as updatedDate,
  332. a.assigned_by as assignedBy,
  333. a.assigned_date as assignedDate,
  334. a.closed_by as closedBy,
  335. a.closed_date as closedDate,
  336. a.archived_by as archivedBy,
  337. a.archived_date as archivedDate,
  338. a.orderref1,
  339. a.orderref2,
  340. a.orderref3,
  341. a.orderref4,
  342. a.orderref5,
  343. a.order_date as orderDate,
  344. a.close_flag as closeFlag,
  345. a.out_warehouse as outWarehouse,
  346. a.customer_order_no as customerOrderNo,
  347. a.show_in_query_flag as showInQueryFlag,
  348. <!-- 关联明细信息 -->
  349. b.part_no as partNo,
  350. b.part_desc as partDesc,
  351. b.unit,
  352. b.required_qty as requiredQty,
  353. b.out_warehouse as detailOutWarehouse,
  354. b.out_batch_no as outBatchNo,
  355. b.order_qty as orderQty,
  356. b.related_order_no as relatedOrderNo,
  357. b.related_order_line_no as relatedOrderLineNo,
  358. <!-- 已扫描数量和未扫描数量 -->
  359. ISNULL(SUM(e.roll_qty), 0) as rollQty,
  360. CASE WHEN b.required_qty - ISNULL(SUM(e.roll_qty), 0) > 0
  361. THEN ROUND(b.required_qty - ISNULL(SUM(e.roll_qty), 0), 3)
  362. ELSE 0
  363. END as unScanQty ,
  364. ISNULL(SUM(i.qty_on_hand), 0) as availableStock,
  365. b.std_packing_qty,
  366. ISNULL(b.inspection_flag,'N') as inspectionFlag
  367. FROM outbound_notification_head a
  368. LEFT JOIN Customer c ON a.site = c.site AND a.customer_id = c.CustomerID
  369. LEFT JOIN outbound_notification_detail b ON a.site = b.site AND a.bu_no = b.bu_no AND a.order_no = b.order_no
  370. LEFT JOIN inventory_stock I ON B.site = I.site AND B.part_no = I.part_no AND I.status = '在库' and i.batch_no = b.out_batch_no
  371. LEFT JOIN so_receive_boxes d ON b.site = d.site AND b.bu_no = d.bu_no AND b.order_no = d.order_no
  372. LEFT JOIN so_receive_box_rolls e ON b.site = e.site AND b.bu_no = e.bu_no AND d.box_no = e.box_no AND b.part_no = e.part_no
  373. <where>
  374. <if test="site != null and site != ''">
  375. AND a.site = #{site}
  376. </if>
  377. <if test="buNo != null and buNo != ''">
  378. AND a.bu_no = #{buNo}
  379. </if>
  380. <if test="orderNo != null and orderNo != ''">
  381. AND a.order_no LIKE '%' + #{orderNo} + '%'
  382. </if>
  383. <if test="orderType != null and orderType != ''">
  384. AND a.order_type = #{orderType}
  385. </if>
  386. <if test="orderStatus != null and orderStatus != ''">
  387. AND a.order_status in
  388. <foreach collection="statusArr" close=")" open="(" item="item" separator=",">
  389. #{item}
  390. </foreach>
  391. </if>
  392. <if test="orderStatus == null or orderStatus == ''">
  393. AND a.order_status not in ('待出库', '草稿')
  394. </if>
  395. <if test="customerId != null and customerId != ''">
  396. AND a.customer_id LIKE '%' + #{customerId} + '%'
  397. </if>
  398. <if test="customerName != null and customerName != ''">
  399. AND c.customerName LIKE '%' + #{customerName} + '%'
  400. </if>
  401. <if test="inspectionFlag != null and inspectionFlag != ''">
  402. AND ISNULL(b.inspection_flag,'N') = #{inspectionFlag}
  403. </if>
  404. <if test="startDate != null">
  405. AND a.required_outbound_date >= #{startDate}
  406. </if>
  407. <if test="endDate != null">
  408. AND #{endDate} >= a.required_outbound_date
  409. </if>
  410. </where>
  411. GROUP BY
  412. a.site, a.bu_no, a.order_no, a.order_type, a.order_status, a.customer_id, c.customerName,
  413. a.related_order_no, a.related_order_line_no, a.required_outbound_date, a.remarks,
  414. a.erp_order_no, a.erp_order_line_no, a.erp_order_date, a.created_by, a.created_date,
  415. a.updated_by, a.updated_date, a.assigned_by, a.assigned_date, a.closed_by, a.closed_date,
  416. a.archived_by, a.archived_date, a.orderref1, a.orderref2, a.orderref3, a.orderref4, a.orderref5,
  417. a.order_date, a.close_flag, a.out_warehouse, a.customer_order_no, a.show_in_query_flag,
  418. b.part_no, b.part_desc, b.unit, b.required_qty, b.out_warehouse, b.out_batch_no, b.order_qty,
  419. b.related_order_no, b.related_order_line_no, b.std_packing_qty, b.inspection_flag, c.CustomerAbb
  420. ORDER BY a.created_date DESC, b.part_no
  421. </select>
  422. <!-- 更新出库通知单状态 -->
  423. <update id="updateOrderStatus">
  424. UPDATE outbound_notification_head
  425. SET order_status = #{orderStatus}
  426. WHERE site = #{site}
  427. AND bu_no = #{buNo}
  428. AND order_no = #{orderNo}
  429. </update>
  430. <!-- ==================== 托清单相关SQL ==================== -->
  431. <!-- 查询托清单列表 -->
  432. <select id="searchSoReceivePalletsData" resultType="SoReceivePalletsData">
  433. SELECT
  434. s.id,
  435. s.site,
  436. s.bu_no as buNo,
  437. s.pallet_no as palletNo,
  438. s.order_no as orderNo,
  439. s.status,
  440. s.boxes_qty as boxesQty,
  441. s.pallet_type as palletType,
  442. s.c_in_stock_flag as cInStockFlag,
  443. s.created_date as createdDate,
  444. s.created_by as createdBy,
  445. s.update_date as updateDate,
  446. s.update_by as updateBy,
  447. s.version,
  448. ISNULL(pallet_count, 0) as palletCount,
  449. ISNULL(boxesCount, 0) as boxesCount,
  450. ISNULL(rollCount, 0) as rollCount,
  451. ISNULL(rollsQty, 0) as rollsQty
  452. FROM so_receive_pallets s with(nolock)
  453. LEFT JOIN (
  454. select
  455. a.site,
  456. a.bu_no,
  457. a.order_no,
  458. COUNT(DISTINCT a.pallet_no) AS pallet_count, -- 托数量
  459. COUNT(DISTINCT B.box_no) AS boxesCount, -- 箱标签张数
  460. COUNT(DISTINCT c.final_roll_no) AS rollCount, -- 卷标签张数
  461. ISNULL(SUM(c.roll_qty), 0) AS rollsQty -- 物料总数
  462. from so_receive_pallets A with(nolock)
  463. INNER JOIN so_receive_pallet_boxes B with(nolock) ON A.site = B.site AND A.pallet_no = B.pallet_no
  464. INNER JOIN so_receive_box_rolls C with(nolock) ON C.site = B.site AND B.box_no = C.box_no
  465. WHERE a.SITE = #{site} AND a.bu_no = #{buNo} and a.order_no = #{orderNo} group by a.site, a.bu_no, a.order_no
  466. ) T ON S.site = T.site AND S.bu_no = T.bu_no AND S.order_no = T.order_no
  467. WHERE s.site = #{site}
  468. AND s.bu_no = #{buNo}
  469. AND s.order_no = #{orderNo}
  470. ORDER BY s.created_date DESC
  471. </select>
  472. <!-- 新增托 -->
  473. <insert id="newSoReceivePalletsData">
  474. INSERT INTO so_receive_pallets
  475. (site, pallet_no, order_no, [status], boxes_qty, pallet_type, c_in_stock_flag, created_date, created_by,
  476. version, bu_no)
  477. VALUES
  478. (#{site}, #{palletNo}, #{orderNo}, #{status}, #{boxesQty}, #{palletType}, 'Y', GETDATE(), #{createdBy},
  479. 0, #{buNo})
  480. </insert>
  481. <!-- 查询托明细列表 -->
  482. <select id="searchPalletBoxDetail" resultType="SoReceivePalletBoxesData">
  483. SELECT ROW_NUMBER() OVER (ORDER BY a.received_date) orderId,
  484. a.id, a.site, a.bu_no, a.pallet_no, a.box_no, a.boxes_qty, a.received_by, a.received_date
  485. FROM so_receive_pallet_boxes a
  486. WHERE a.site = #{site}
  487. AND a.pallet_no = #{palletNo}
  488. AND a.bu_no = #{buNo}
  489. ORDER BY a.received_date DESC
  490. </select>
  491. <!-- 查询托数据 -->
  492. <select id="searchPalletData" resultType="SoReceivePalletsData">
  493. SELECT a.id, a.site, a.bu_no, a.pallet_no, a.order_no, [status], boxes_qty, pallet_type, c_in_stock_flag,
  494. created_date, created_by, version
  495. FROM so_receive_pallets a
  496. WHERE a.site = #{site}
  497. AND a.pallet_no = #{palletNo}
  498. AND a.bu_no = #{buNo}
  499. </select>
  500. <!-- 删除托 -->
  501. <delete id="deleteSoReceivePalletsData">
  502. DELETE FROM so_receive_pallets
  503. WHERE id = #{id}
  504. </delete>
  505. <!-- 更新托状态 -->
  506. <update id="updatePalletStatus">
  507. UPDATE so_receive_pallets
  508. SET [status] = #{status}
  509. WHERE id = #{id}
  510. </update>
  511. <!-- 根据箱号查询箱信息(用于装托扫描) -->
  512. <select id="selectBoxByBoxNo" resultType="SoReceiveBoxesData">
  513. SELECT a.id, a.site, a.bu_no, a.box_no as boxNo, a.order_no as orderNo, a.[status], a.rolls_qty as rollsQty,
  514. a.box_type as boxType, a.WareHouseID as wareHouseID
  515. FROM so_receive_boxes a
  516. WHERE a.site = #{site}
  517. AND a.box_no = #{boxNo}
  518. AND a.bu_no = #{buNo}
  519. </select>
  520. <!-- 装托:添加箱到托 -->
  521. <insert id="addBoxToPallet">
  522. INSERT INTO so_receive_pallet_boxes
  523. (site, bu_no, pallet_no, box_no, boxes_qty, received_by, received_date)
  524. VALUES
  525. (#{site}, #{buNo}, #{palletNo}, #{boxNo}, #{boxesQty}, #{receivedBy}, GETDATE())
  526. </insert>
  527. <!-- 拆托:从托中删除箱 -->
  528. <delete id="deleteBoxFromPallet">
  529. DELETE FROM so_receive_pallet_boxes
  530. WHERE site = #{site}
  531. AND bu_no = #{buNo}
  532. AND pallet_no = #{palletNo}
  533. <if test="boxNo != null and boxNo != ''">
  534. AND box_no = #{boxNo}
  535. </if>
  536. </delete>
  537. <!-- 更新托的箱数量 -->
  538. <update id="updatePalletBoxesQty">
  539. UPDATE so_receive_pallets
  540. SET boxes_qty = (
  541. SELECT COUNT(*)
  542. FROM so_receive_pallet_boxes
  543. WHERE site = #{site}
  544. AND bu_no = #{buNo}
  545. AND pallet_no = #{palletNo}
  546. )
  547. WHERE site = #{site}
  548. AND bu_no = #{buNo}
  549. AND pallet_no = #{palletNo}
  550. </update>
  551. <!-- 检查箱是否在托中 -->
  552. <select id="checkBoxInPallet" resultType="SoReceivePalletBoxesData">
  553. SELECT id, site, bu_no, pallet_no, box_no, boxes_qty, received_by, received_date
  554. FROM so_receive_pallet_boxes
  555. WHERE site = #{site}
  556. AND bu_no = #{buNo}
  557. AND box_no = #{boxNo}
  558. </select>
  559. <!-- 检查卷是否已装箱 -->
  560. <select id="checkRollInBox" resultType="SoReceiveBoxRollsData">
  561. SELECT id, site, bu_no, box_no, final_roll_no, roll_qty, received_by, received_date, WareHouseID, part_no
  562. FROM so_receive_box_rolls
  563. WHERE site = #{site}
  564. AND bu_no = #{buNo}
  565. AND final_roll_no = #{rollNo}
  566. </select>
  567. <!-- 查询装箱明细列表(关联仓库和物料信息) -->
  568. <select id="searchBoxRollDetailList" resultType="map">
  569. SELECT
  570. br.box_no AS boxNo,
  571. br.final_roll_no AS finalRollNo,
  572. br.roll_qty AS rollQty,
  573. br.received_by AS receivedBy,
  574. br.received_date AS receivedDate,
  575. br.WareHouseID AS wareHouseId,
  576. wh.WareHouseName AS wareHouseName,
  577. br.part_no AS partNo,
  578. p.PartDescription AS partDesc
  579. FROM so_receive_box_rolls br
  580. LEFT JOIN WareHouse wh ON br.site = wh.site and br.WareHouseID = wh.WareHouseID
  581. LEFT JOIN Part p ON br.site = p.site and br.part_no = p.partNo
  582. WHERE br.site = #{site}
  583. AND br.bu_no = #{buNo}
  584. AND br.box_no = #{boxNo}
  585. ORDER BY br.received_date DESC
  586. </select>
  587. </mapper>