Notes
Notes - notes.io |
UTM as (
select
"@УТМ"
from "УТМ"
--where "Организация" = 1
),
InDocs as (
select
"@Документ",
"Содержимое",
"Документ"."ДатаВремя",
"УведомлениеЭДО",
"Тип",
'Входящий'::TEXT as "ТипДокумент",
"ВхДокумент"."Статус" AS "Статус",
"ВхДокумент"."ДатаВремя" AS "ПоследняяОбработка"
from "ВхДокумент"
inner join UTM on "УТМ" = "@УТМ"
left join "Документ" on "Документ" = "@Документ"
where "Документ"."Тип" = ANY(ARRAY[10,30,50])
order by "@ВхДокумент" DESC
limit 10
),
OutDocs as (
select
"@Документ",
"Содержимое",
"Документ"."ДатаВремя",
"УведомлениеЭДО",
"Тип",
'Исходящий'::TEXT as "ТипДокумент",
"ИсхДокумент"."Статус" AS "Статус",
"ИсхДокумент"."ДатаВремя" AS "ПоследняяОбработка"
from "ИсхДокумент"
inner join UTM on "УТМ" = "@УТМ"
left join "Документ" on "Документ" = "@Документ"
where "Документ"."Тип" = ANY(ARRAY[10,30,50])
order by "@ИсхДокумент" DESC
limit 10
),
AggResult as (
select * from InDocs
union
select * from OutDocs
order by "ДатаВремя" DESC
limit 10
)
select
"@Документ",
"Содержимое",
"ДатаВремя",
"УведомлениеЭДО",
"Статус",
"ПоследняяОбработка",
"Тип",
"ТипДокумент",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Shipper.*>.*<(?:w+:)?s*FullName.*>(d+)</(?:w+:)?s*FullNames*>.*</w+:s*Shippers*>'), '.'))
ELSE NULL
END AS "ОтправительНазвание",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Shipper.*>.*<(?:w+:)?s*INN.*>(d+)</(?:w+:)?s*INNs*>.*</w+:s*Shippers*>'), '.'))
ELSE NULL
END AS "ОтправительИНН",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Shipper.*>.*<(?:w+:)?s*KPP.*>(d+)</(?:w+:)?s*KPPs*>.*</w+:s*Shippers*>'), '.'))
ELSE NULL
END AS "ОтправительКПП",
CASE
WHEN "ТипДокумент" = 'Исходящий'
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Owner.*>.*<(?:w+:)?s*FSRAR_ID.*>(d+)</(?:w+:)?s*FSRAR_IDs*>.*</w+:s*Owners*>'), '.'))
ELSE (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Shipper.*>.*<(?:w+:)?s*ClientRegId.*>(d+)</(?:w+:)?s*ClientRegIds*>.*</w+:s*Shippers*>'), '.'))
END AS "ОтправительФСРАР",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Consignee.*>.*<(?:w+:)?s*FullName.*>(d+)</(?:w+:)?s*FullNames*>.*</w+:s*Consignees*>'), '.'))
ELSE NULL
END AS "ПолучательНазвание",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Consignee.*>.*<(?:w+:)?s*INN.*>(d+)</(?:w+:)?s*INNs*>.*</w+:s*Consignees*>'), '.'))
ELSE NULL
END AS "ПолучательИНН",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Consignee.*>.*<(?:w+:)?s*KPP.*>(d+)</(?:w+:)?s*KPPs*>.*</w+:s*Consignees*>'), '.'))
ELSE NULL
END AS "ПолучательКПП",
CASE
WHEN "Тип" = 10
THEN (SELECT ARRAY_TO_STRING(REGEXP_MATCHES("Содержимое", '<w+:s*Consignee.*>.*<(?:w+:)?s*ClientRegId.*>(d+)</(?:w+:)?s*ClientRegIds*>.*</w+:s*Consignees*>'), '.'))
ELSE NULL
END AS "ПолучательФСРАР"
from AggResult
left join "ЭДОДокумент" on "@Документ" = "Документ"
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team