feat(ucepsa): add validated canonical context arbitration shadow
This commit is contained in:
parent
f9095e6a7b
commit
2efcb750a3
@ -170,9 +170,10 @@ shopfloor AS (
|
||||
p.productive_context,
|
||||
'mv_loss_intelligence.odoo_shopfloor_sessions'::text
|
||||
AS source_table,
|
||||
s.shopfloor_session_id::text
|
||||
s.context_session_id::text
|
||||
AS source_native_id,
|
||||
s.shopfloor_session_id,
|
||||
s.context_session_id
|
||||
AS shopfloor_session_id,
|
||||
NULL::bigint
|
||||
AS production_context_session_id,
|
||||
s.effective_from
|
||||
@ -600,13 +601,10 @@ segments AS (
|
||||
),
|
||||
candidate_matches AS (
|
||||
SELECT
|
||||
s.tenant,
|
||||
s.site,
|
||||
s.machine_id,
|
||||
c.*,
|
||||
s.activity_island_id,
|
||||
s.segment_from,
|
||||
s.segment_to,
|
||||
c.*
|
||||
s.segment_to
|
||||
FROM segments s
|
||||
JOIN candidates c
|
||||
ON c.tenant = s.tenant
|
||||
@ -1281,13 +1279,20 @@ enriched AS (
|
||||
AS canonical_product_id,
|
||||
p.product_name
|
||||
AS canonical_product_name,
|
||||
p.operator_employee_id,
|
||||
p.operator_name,
|
||||
p.operator_candidate_employee_id,
|
||||
p.operator_candidate_name,
|
||||
p.operator_confirmation_status,
|
||||
p.quantity_confirmation_status,
|
||||
p.operator_employee_id
|
||||
AS canonical_operator_employee_id,
|
||||
p.operator_name
|
||||
AS canonical_operator_name,
|
||||
p.operator_candidate_employee_id
|
||||
AS canonical_operator_candidate_employee_id,
|
||||
p.operator_candidate_name
|
||||
AS canonical_operator_candidate_name,
|
||||
p.operator_confirmation_status
|
||||
AS canonical_operator_confirmation_status,
|
||||
p.quantity_confirmation_status
|
||||
AS canonical_quantity_confirmation_status,
|
||||
p.individual_attribution_eligible
|
||||
AS canonical_individual_attribution_eligible
|
||||
FROM machines m
|
||||
LEFT JOIN active_summary s
|
||||
ON s.tenant = m.tenant
|
||||
@ -1459,38 +1464,38 @@ SELECT
|
||||
END AS canonical_product_name,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.operator_employee_id
|
||||
THEN a.canonical_operator_employee_id
|
||||
ELSE NULL::bigint
|
||||
END AS operator_employee_id,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.operator_name
|
||||
THEN a.canonical_operator_name
|
||||
ELSE NULL::text
|
||||
END AS operator_name,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.operator_candidate_employee_id
|
||||
THEN a.canonical_operator_candidate_employee_id
|
||||
ELSE NULL::bigint
|
||||
END AS operator_candidate_employee_id,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.operator_candidate_name
|
||||
THEN a.canonical_operator_candidate_name
|
||||
ELSE NULL::text
|
||||
END AS operator_candidate_name,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.operator_confirmation_status
|
||||
THEN a.canonical_operator_confirmation_status
|
||||
ELSE NULL::text
|
||||
END AS operator_confirmation_status,
|
||||
CASE
|
||||
WHEN a.authoritative_candidate_count = 1
|
||||
THEN a.quantity_confirmation_status
|
||||
THEN a.canonical_quantity_confirmation_status
|
||||
ELSE NULL::text
|
||||
END AS quantity_confirmation_status,
|
||||
(
|
||||
a.authoritative_candidate_count = 1
|
||||
AND COALESCE(
|
||||
a.individual_attribution_eligible,
|
||||
a.canonical_individual_attribution_eligible,
|
||||
false
|
||||
)
|
||||
) AS individual_attribution_eligible,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user