|
@@ -1112,7 +1112,7 @@ class utils {
|
|
|
and a.serial_no = oo.serial_no
|
|
and a.serial_no = oo.serial_no
|
|
|
and a.act_date is not null
|
|
and a.act_date is not null
|
|
|
order by s.sno desc limit 1) m on true
|
|
order by s.sno desc limit 1) m on true
|
|
|
- WHERE <{ExtendHand_KLN}> and oo.transport_mode = 'sea' and order_from = 'public' and m.code <> '' limit 20
|
|
|
|
|
|
|
+ WHERE <{ExtendHand_KLN}> and oo.transport_mode = 'sea' and order_from = 'public' and m.code <> '' limit 10
|
|
|
) t;select serial_no,h_bol,place_of_receipt_exp,place_of_delivery_exp,description,eta,order_from,cargo_type
|
|
) t;select serial_no,h_bol,place_of_receipt_exp,place_of_delivery_exp,description,eta,order_from,cargo_type
|
|
|
from (
|
|
from (
|
|
|
SELECT oo.serial_no,h_bol, place_of_receipt_exp, place_of_delivery_exp,m.description,eta,order_from, o.cargo_type
|
|
SELECT oo.serial_no,h_bol, place_of_receipt_exp, place_of_delivery_exp,m.description,eta,order_from, o.cargo_type
|
|
@@ -1131,47 +1131,88 @@ class utils {
|
|
|
) t order by eta";
|
|
) t order by eta";
|
|
|
|
|
|
|
|
$data["List shipments with milestone updates in the last 7 days."] = "select count(*)
|
|
$data["List shipments with milestone updates in the last 7 days."] = "select count(*)
|
|
|
- from (
|
|
|
|
|
- select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD') as update_date_format,update_date,
|
|
|
|
|
- COALESCE(jsonb_data->>'milestone','')::jsonb->>'timezone' as timezone,
|
|
|
|
|
- COALESCE(jsonb_data->>'milestone','')::jsonb->>'locations' as locations
|
|
|
|
|
- from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,a.update_date,public.getTimeAndLocationForKln(oo.serial_no,a.code,''::text)::jsonb as jsonb_data
|
|
|
|
|
- from public.ocean_milestone a
|
|
|
|
|
- inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
- inner join public.kln_ocean oo on oo.serial_no = a.serial_no
|
|
|
|
|
- where s.type = 'sea'
|
|
|
|
|
- and a.act_date is not null
|
|
|
|
|
- and a.update_date is not null
|
|
|
|
|
- and a.update_date > '2025-04-06') po
|
|
|
|
|
- )t;select serial_no,order_from,h_bol, description,update_date_format,update_date,timezone,locations
|
|
|
|
|
- from (
|
|
|
|
|
- select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD') as update_date_format,update_date,
|
|
|
|
|
- COALESCE(jsonb_data->>'milestone','')::jsonb->>'timezone' as timezone,
|
|
|
|
|
- COALESCE(jsonb_data->>'milestone','')::jsonb->>'locations' as locations
|
|
|
|
|
- from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,a.update_date,public.getTimeAndLocationForKln(oo.serial_no,a.code,''::text)::jsonb as jsonb_data
|
|
|
|
|
- from public.ocean_milestone a
|
|
|
|
|
- inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
- inner join public.kln_ocean oo on oo.serial_no = a.serial_no
|
|
|
|
|
- where s.type = 'sea'
|
|
|
|
|
- and a.act_date is not null
|
|
|
|
|
- and a.update_date is not null
|
|
|
|
|
- and a.update_date > '2025-04-06') po
|
|
|
|
|
- )t;select aa.update_date_format, COUNT(*) AS total_count
|
|
|
|
|
|
|
+ from (
|
|
|
|
|
+ select serial_no
|
|
|
|
|
+ from (SELECT oo.serial_no from public.ocean_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'sea'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') po
|
|
|
|
|
+ union all
|
|
|
|
|
+ select serial_no
|
|
|
|
|
+ from (SELECT oo.serial_no from public.air_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'air'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') pa
|
|
|
|
|
+ union all
|
|
|
|
|
+ select serial_no
|
|
|
|
|
+ from (SELECT oo.serial_no from sfs.air_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'air'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') sa
|
|
|
|
|
+ )t;select serial_no,order_from,h_bol, description,update_date_format,update_date,
|
|
|
|
|
+ COALESCE(m.jsonb_data->>'milestone','')::jsonb->>'timezone' as timezone,
|
|
|
|
|
+ COALESCE(m.jsonb_data->>'milestone','')::jsonb->>'locations' as locations
|
|
|
|
|
+ from (
|
|
|
|
|
+ select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD') as update_date_format,update_date,code
|
|
|
|
|
+ from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,COALESCE(a.update_date, a.create_date) as update_date,a.code
|
|
|
|
|
+ from public.ocean_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'sea'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') po
|
|
|
|
|
+ union all
|
|
|
|
|
+ select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD')as update_date_format,update_date,code
|
|
|
|
|
+ from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,COALESCE(a.update_date, a.create_date) as update_date,a.code
|
|
|
|
|
+ from public.air_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'air'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') pa
|
|
|
|
|
+ union all
|
|
|
|
|
+ select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD')as update_date_format,update_date,code
|
|
|
|
|
+ from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,COALESCE(a.update_date, a.create_date) as update_date,a.code
|
|
|
|
|
+ from sfs.air_milestone a
|
|
|
|
|
+ inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where s.type = 'air'
|
|
|
|
|
+ and a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') sa
|
|
|
|
|
+ )t left join LATERAL (select public.getTimeAndLocationForKln(serial_no,code,''::text)::jsonb as jsonb_data) m on true
|
|
|
|
|
+ order by update_date limit 10;select aa.update_date_format, COUNT(*) AS total_count
|
|
|
|
|
+ from (
|
|
|
|
|
+ select DISTINCT ON (h_bol) h_bol, update_date_format
|
|
|
from (
|
|
from (
|
|
|
- select DISTINCT ON (h_bol) h_bol, update_date_format
|
|
|
|
|
- from (
|
|
|
|
|
- select serial_no,order_from,h_bol,description,to_char(update_date,'Mon DD') as update_date_format,update_date
|
|
|
|
|
- from (SELECT oo.serial_no,oo.order_from,oo.h_bol,s.description,a.update_date
|
|
|
|
|
- from public.ocean_milestone a
|
|
|
|
|
- inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
- inner join public.kln_ocean oo on oo.serial_no = a.serial_no
|
|
|
|
|
- where s.type = 'sea'
|
|
|
|
|
- and a.act_date is not null
|
|
|
|
|
- and a.update_date > '2025-04-06') po
|
|
|
|
|
-
|
|
|
|
|
- )t order by h_bol
|
|
|
|
|
- ) aa
|
|
|
|
|
- group by aa.update_date_format order by aa.update_date_format ";
|
|
|
|
|
|
|
+ select h_bol,to_char(update_date,'Mon DD') as update_date_format
|
|
|
|
|
+ from (SELECT oo.h_bol,COALESCE(a.update_date, a.create_date) as update_date
|
|
|
|
|
+ from public.ocean_milestone a
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') po
|
|
|
|
|
+ union all
|
|
|
|
|
+ select h_bol,to_char(update_date,'Mon DD') as update_date_format
|
|
|
|
|
+ from (SELECT oo.h_bol,COALESCE(a.update_date, a.create_date) as update_date
|
|
|
|
|
+ from public.air_milestone a
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') pa
|
|
|
|
|
+ union all
|
|
|
|
|
+ select h_bol,to_char(update_date,'Mon DD') as update_date_format
|
|
|
|
|
+ from (SELECT oo.h_bol,COALESCE(a.update_date, a.create_date) as update_date
|
|
|
|
|
+ from sfs.air_milestone a
|
|
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
+ where a.act_date is not null
|
|
|
|
|
+ and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') sa
|
|
|
|
|
+ )t order by h_bol
|
|
|
|
|
+ ) aa
|
|
|
|
|
+ group by aa.update_date_format order by aa.update_date_format ";
|
|
|
$data["What is the current status of my active shipments?"] ="SELECT count(*)
|
|
$data["What is the current status of my active shipments?"] ="SELECT count(*)
|
|
|
FROM public.kln_ocean oo
|
|
FROM public.kln_ocean oo
|
|
|
WHERE <{ExtendHand_KLN}> and ((oo.ata is not null and oo.ata >= CURRENT_DATE - INTERVAL '3 months' AND oo.ata < CURRENT_DATE)
|
|
WHERE <{ExtendHand_KLN}> and ((oo.ata is not null and oo.ata >= CURRENT_DATE - INTERVAL '3 months' AND oo.ata < CURRENT_DATE)
|