|
|
|
@@ -256,31 +256,34 @@ fun findAllReleasedJoWorkbenchPickOrders( |
|
|
|
fun incrementSubmittedLines(@Param("pickOrderId") pickOrderId: Long): Int |
|
|
|
|
|
|
|
/** |
|
|
|
* FP-MTMS Version Checklist | Functions Ref. No. 41 | v1.0.0 | 2026-08-03 |
|
|
|
* JO ids that have at least one stock_out_line counted as picked |
|
|
|
* (checked / partially_completed / completed / picking, or rejected with qty > 0). |
|
|
|
* FP-MTMS Version Checklist | Functions Ref. No. 41 | v1.0.1 | 2026-08-06 |
|
|
|
* JO ids whose pick order lines are all completed (one JO ↔ one pick order in practice). |
|
|
|
* Used for production-process 「已提料」 bucket. |
|
|
|
*/ |
|
|
|
@Query( |
|
|
|
value = """ |
|
|
|
SELECT DISTINCT po.joId |
|
|
|
SELECT po.joId |
|
|
|
FROM pick_order po |
|
|
|
INNER JOIN pick_order_line pol ON pol.poId = po.id AND pol.deleted = 0 |
|
|
|
INNER JOIN stock_out_line sol ON sol.pickOrderLineId = pol.id AND sol.deleted = 0 |
|
|
|
WHERE po.deleted = 0 |
|
|
|
AND po.joId IN (:joIds) |
|
|
|
AND ( |
|
|
|
LOWER(COALESCE(sol.status, '')) IN ('checked', 'partially_completed', 'completed', 'picking') |
|
|
|
OR (LOWER(COALESCE(sol.status, '')) = 'rejected' AND COALESCE(sol.qty, 0) > 0) |
|
|
|
) |
|
|
|
GROUP BY po.joId, po.id |
|
|
|
HAVING COUNT(*) > 0 |
|
|
|
AND COUNT(*) = SUM( |
|
|
|
CASE WHEN LOWER(COALESCE(pol.status, '')) = 'completed' THEN 1 ELSE 0 END |
|
|
|
) |
|
|
|
""", |
|
|
|
nativeQuery = true, |
|
|
|
) |
|
|
|
fun findPickedJobOrderIds(@Param("joIds") joIds: Collection<Long>): List<Long> |
|
|
|
|
|
|
|
/** Unlimited: picked + product process still pending / not started. */ |
|
|
|
/** |
|
|
|
* FP-MTMS Version Checklist | Functions Ref. No. 41 | v1.0.1 | 2026-08-06 |
|
|
|
* Unlimited: all POL completed + product process still pending / not started. |
|
|
|
*/ |
|
|
|
@Query( |
|
|
|
value = """ |
|
|
|
SELECT DISTINCT po.joId |
|
|
|
SELECT po.joId |
|
|
|
FROM pick_order po |
|
|
|
INNER JOIN job_order jo |
|
|
|
ON jo.id = po.joId |
|
|
|
@@ -293,13 +296,13 @@ fun incrementSubmittedLines(@Param("pickOrderId") pickOrderId: Long): Int |
|
|
|
AND LOWER(pp.status) = 'pending' |
|
|
|
AND pp.startTime IS NULL |
|
|
|
INNER JOIN pick_order_line pol ON pol.poId = po.id AND pol.deleted = 0 |
|
|
|
INNER JOIN stock_out_line sol ON sol.pickOrderLineId = pol.id AND sol.deleted = 0 |
|
|
|
WHERE po.deleted = 0 |
|
|
|
AND po.joId IS NOT NULL |
|
|
|
AND ( |
|
|
|
LOWER(COALESCE(sol.status, '')) IN ('checked', 'partially_completed', 'completed', 'picking') |
|
|
|
OR (LOWER(COALESCE(sol.status, '')) = 'rejected' AND COALESCE(sol.qty, 0) > 0) |
|
|
|
) |
|
|
|
GROUP BY po.joId, po.id |
|
|
|
HAVING COUNT(*) > 0 |
|
|
|
AND COUNT(*) = SUM( |
|
|
|
CASE WHEN LOWER(COALESCE(pol.status, '')) = 'completed' THEN 1 ELSE 0 END |
|
|
|
) |
|
|
|
""", |
|
|
|
nativeQuery = true, |
|
|
|
) |
|
|
|
|