|
|
@@ -1148,27 +1148,16 @@ class utils {
|
|
|
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}>)
|
|
|
+ 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 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,
|
|
|
+ ) po
|
|
|
+
|
|
|
+
|
|
|
+ )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 (
|
|
|
@@ -1176,53 +1165,24 @@ class utils {
|
|
|
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}>)
|
|
|
+ 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 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
|
|
|
+ ) po
|
|
|
)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
|
|
|
+ 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 (
|
|
|
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}>)
|
|
|
+ inner join public.kln_ocean oo on oo.serial_no = a.serial_no
|
|
|
where a.act_date is not null
|
|
|
- and COALESCE(a.update_date, a.create_date) >= CURRENT_DATE - INTERVAL '7 days') sa
|
|
|
+ ) po
|
|
|
+
|
|
|
)t order by h_bol
|
|
|
) aa
|
|
|
group by aa.update_date_format order by aa.update_date_format ";
|