Поменял логику, при необходимости откатить

This commit is contained in:
adel.ka 2025-10-21 12:53:28 +03:00
parent 360e9f3e77
commit 44c15abe85
24 changed files with 1179 additions and 1656 deletions

View file

@ -40,21 +40,11 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update 2</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success </to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update 2</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success </to>
@ -65,26 +55,31 @@
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Group by 2</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>User defined Java expression 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Change job status on error </to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<from>Table input </from>
<to>Group by 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Group by 2</from>
<to>User defined Java expression 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input </from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -171,8 +166,8 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>1744</xloc>
<yloc>608</yloc>
<xloc>576</xloc>
<yloc>1040</yloc>
</GUI>
</transform>
<transform>
@ -217,8 +212,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1568</xloc>
<yloc>480</yloc>
<xloc>304</xloc>
<yloc>1040</yloc>
</GUI>
</transform>
<transform>
@ -253,8 +248,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<send_true_to>Change job status on success </send_true_to>
<attributes/>
<GUI>
<xloc>1392</xloc>
<yloc>608</yloc>
<xloc>896</xloc>
<yloc>1040</yloc>
</GUI>
</transform>
<transform>
@ -298,25 +293,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<prefix>grp</prefix>
<attributes/>
<GUI>
<xloc>560</xloc>
<yloc>480</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>784</xloc>
<xloc>304</xloc>
<yloc>480</yloc>
</GUI>
</transform>
@ -324,7 +301,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<name>Table input </name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -334,53 +311,60 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0 -- умершие не могут быть несовершеннолетними
WHEN dates.birth_date IS NULL THEN 0 -- если дата рождения неизвестна, считаем взрослым
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
<sql>WITH children_data AS (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0
WHEN dates.birth_date IS NULL THEN 0
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array';</sql>
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM children_data) as last_row
FROM children_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -466,7 +450,7 @@ WHERE
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>560</xloc>
<xloc>896</xloc>
<yloc>800</yloc>
</GUI>
</transform>
@ -550,7 +534,7 @@ WHERE
</formula>
<attributes/>
<GUI>
<xloc>1024</xloc>
<xloc>688</xloc>
<yloc>480</yloc>
</GUI>
</transform>

View file

@ -18,26 +18,6 @@
<modified_date>2025/08/11 13:22:56.048</modified_date>
</info>
<notepads>
<notepad>
<backgroundcolorblue>251</backgroundcolorblue>
<backgroundcolorgreen>232</backgroundcolorgreen>
<backgroundcolorred>201</backgroundcolorred>
<bordercolorblue>90</bordercolorblue>
<bordercolorgreen>58</bordercolorgreen>
<bordercolorred>14</bordercolorred>
<fontbold>N</fontbold>
<fontcolorblue>90</fontcolorblue>
<fontcolorgreen>58</fontcolorgreen>
<fontcolorred>14</fontcolorred>
<fontitalic>N</fontitalic>
<fontname>Segoe UI</fontname>
<fontsize>9</fontsize>
<height>26</height>
<xloc>574</xloc>
<yloc>358</yloc>
<note>1. insert/update, update указан лишний error_code для error handling</note>
<width>384</width>
</notepad>
</notepads>
<order>
<hop>
@ -45,11 +25,6 @@
<to>Change job status on error </to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Group by</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update </from>
<to>Change job status on error </to>
@ -65,21 +40,11 @@
<to>Table input 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update </from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success </to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update </from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success </to>
@ -91,18 +56,28 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Group by</from>
<to>Identify last row in a stream</to>
<from>Table input 2</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Group by</from>
<to>User defined Java expression</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input 2</from>
<to>Insert / update</to>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input 2</from>
<to>Group by</to>
<enabled>Y</enabled>
</hop>
</order>
@ -191,8 +166,8 @@ and status = 'DELTA_PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1872</xloc>
<yloc>0</yloc>
<xloc>784</xloc>
<yloc>496</yloc>
</GUI>
</transform>
<transform>
@ -239,8 +214,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1616</xloc>
<yloc>144</yloc>
<xloc>496</xloc>
<yloc>496</yloc>
</GUI>
</transform>
<transform>
@ -275,8 +250,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success </send_true_to>
<attributes/>
<GUI>
<xloc>1616</xloc>
<yloc>0</yloc>
<xloc>1072</xloc>
<yloc>496</yloc>
</GUI>
</transform>
<transform>
@ -320,25 +295,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<prefix>grp</prefix>
<attributes/>
<GUI>
<xloc>784</xloc>
<yloc>0</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>1024</xloc>
<xloc>496</xloc>
<yloc>0</yloc>
</GUI>
</transform>
@ -432,7 +389,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>784</xloc>
<xloc>1072</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -440,7 +397,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<name>Table input 2</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -450,54 +407,61 @@ and recruitment_id = '${IDM_ID}';</sql>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0 -- умершие не могут быть несовершеннолетними
WHEN dates.birth_date IS NULL THEN 0 -- если дата рождения неизвестна, считаем взрослым
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
<sql>WITH children_data AS (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0
WHEN dates.birth_date IS NULL THEN 0
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp,
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array';</sql>
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM children_data) as last_row
FROM children_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -585,7 +549,7 @@ WHERE
</formula>
<attributes/>
<GUI>
<xloc>1232</xloc>
<xloc>784</xloc>
<yloc>0</yloc>
</GUI>
</transform>

View file

@ -18,26 +18,6 @@
<modified_date>2025/08/08 13:25:52.319</modified_date>
</info>
<notepads>
<notepad>
<backgroundcolorblue>251</backgroundcolorblue>
<backgroundcolorgreen>232</backgroundcolorgreen>
<backgroundcolorred>201</backgroundcolorred>
<bordercolorblue>90</bordercolorblue>
<bordercolorgreen>58</bordercolorgreen>
<bordercolorred>14</bordercolorred>
<fontbold>N</fontbold>
<fontcolorblue>90</fontcolorblue>
<fontcolorgreen>58</fontcolorgreen>
<fontcolorred>14</fontcolorred>
<fontitalic>N</fontitalic>
<fontname>Segoe UI</fontname>
<fontsize>9</fontsize>
<height>26</height>
<xloc>368</xloc>
<yloc>592</yloc>
<note>1.Insert/update не указан error_description для error handling</note>
<width>338</width>
</notepad>
</notepads>
<order>
<hop>
@ -60,26 +40,11 @@
<to>Change job status on error 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Group by</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success</to>
@ -91,18 +56,28 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Group by</from>
<to>Identify last row in a stream</to>
<from>Table input 2</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Group by</from>
<to>User defined Java expression</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input 2</from>
<to>Insert / update</to>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input 2</from>
<to>Group by</to>
<enabled>Y</enabled>
</hop>
</order>
@ -192,8 +167,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1440</xloc>
<yloc>0</yloc>
<xloc>416</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
@ -255,8 +230,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1216</xloc>
<yloc>0</yloc>
<xloc>224</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
@ -291,8 +266,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1216</xloc>
<yloc>128</yloc>
<xloc>608</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
@ -336,26 +311,8 @@ DO UPDATE SET
<prefix>grp</prefix>
<attributes/>
<GUI>
<xloc>608</xloc>
<yloc>192</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>608</xloc>
<yloc>0</yloc>
<xloc>224</xloc>
<yloc>176</yloc>
</GUI>
</transform>
<transform>
@ -456,7 +413,7 @@ DO UPDATE SET
<name>Table input 2</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -465,58 +422,64 @@ DO UPDATE SET
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0 -- умершие не могут быть несовершеннолетними
WHEN dates.birth_date IS NULL THEN 0 -- если дата рождения неизвестна, считаем взрослым
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
<sql>WITH children_data AS (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS child_external_id,
NULLIF(ch->>'idERN', '') AS child_id_ern,
CASE NULLIF(ch->>'rodstvSvyazReb', '')::int
WHEN 1 THEN 3
WHEN 2 THEN 4
END AS kinship_type,
ch->'svedFLBS'->'fio'->>'familiya' AS last_name,
ch->'svedFLBS'->'fio'->>'imya' AS first_name,
ch->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'svedFLBS'->'fio'->>'familiya',
ch->'svedFLBS'->'fio'->>'imya',
ch->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
dates.birth_date,
dates.death_date,
ch->'svedSmert'->>'nomerZapis' AS death_az_number,
ch->'svedAZRozhd'->>'nomerZapis' AS birth_az_number,
CASE WHEN dates.death_date IS NOT NULL THEN 1 ELSE 0 END AS is_dead,
CASE
WHEN dates.death_date IS NOT NULL THEN 0
WHEN dates.birth_date IS NULL THEN 0
WHEN dates.birth_date > CURRENT_DATE - INTERVAL '18 years' THEN 1
ELSE 0
END AS is_minor,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedDeti'->'rebenok') AS ch
CROSS JOIN LATERAL (
SELECT
MAKE_DATE(
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
MAKE_DATE(
NULLIF(ch->'svedSmert'->'dataSmert'->>'god', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'mesyacz', '')::int,
NULLIF(ch->'svedSmert'->'dataSmert'->>'den', '')::int
) AS death_date
) AS dates
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array';</sql>
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedDeti'->'rebenok') = 'array'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM children_data) as last_row
FROM children_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
<xloc>272</xloc>
<xloc>224</xloc>
<yloc>432</yloc>
</GUI>
</transform>
@ -560,7 +523,7 @@ WHERE
<attributes/>
<GUI>
<xloc>976</xloc>
<yloc>0</yloc>
<yloc>176</yloc>
</GUI>
</transform>
<transform>
@ -600,8 +563,8 @@ WHERE
</formula>
<attributes/>
<GUI>
<xloc>800</xloc>
<yloc>0</yloc>
<xloc>608</xloc>
<yloc>176</yloc>
</GUI>
</transform>
<transform_error_handling>

View file

@ -35,11 +35,6 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -51,18 +46,18 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Identify last row in a stream</to>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Table input</from>
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
@ -118,7 +113,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>832</xloc>
<xloc>928</xloc>
<yloc>704</yloc>
</GUI>
</transform>
@ -197,7 +192,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>832</xloc>
<xloc>576</xloc>
<yloc>96</yloc>
</GUI>
</transform>
@ -237,29 +232,11 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<yloc>320</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>640</xloc>
<yloc>320</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -268,35 +245,40 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id::uuid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
<sql>WITH address_data AS (
SELECT
ri.recruit_id::uuid,
ri.ctid as source_ctid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
ELSE NULL
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
GROUP BY ri.recruit_id;</sql>
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
GROUP BY ri.recruit_id, ri.ctid
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM address_data) as last_row
FROM address_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
<xloc>464</xloc>
<xloc>576</xloc>
<yloc>320</yloc>
</GUI>
</transform>
@ -374,7 +356,7 @@ GROUP BY ri.recruit_id;</sql>
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>832</xloc>
<xloc>928</xloc>
<yloc>320</yloc>
</GUI>
</transform>

View file

@ -51,20 +51,15 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -200,7 +195,7 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>752</xloc>
<xloc>400</xloc>
<yloc>16</yloc>
</GUI>
</transform>
@ -240,24 +235,6 @@ and recruitment_id = '${IDM_ID}';</sql>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>944</xloc>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
<name>Insert / update</name>
<type>InsertUpdate</type>
@ -346,7 +323,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -356,31 +333,37 @@ and recruitment_id = '${IDM_ID}';</sql>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id::uuid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
<sql>WITH address_data AS (
SELECT
ri.recruit_id::uuid,
ri.ctid as source_ctid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
ELSE NULL
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
GROUP BY ri.recruit_id;</sql>
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
GROUP BY ri.recruit_id, ri.ctid
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM address_data) as last_row
FROM address_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -30,11 +30,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -51,18 +46,18 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Filter rows</to>
<from>Table input</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Insert / update</to>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -214,7 +209,7 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>768</xloc>
<xloc>480</xloc>
<yloc>16</yloc>
</GUI>
</transform>
@ -254,24 +249,6 @@ DO UPDATE SET
<yloc>272</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>960</xloc>
<yloc>272</yloc>
</GUI>
</transform>
<transform>
<name>Insert / update</name>
<type>InsertUpdate</type>
@ -360,7 +337,7 @@ DO UPDATE SET
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -369,31 +346,36 @@ DO UPDATE SET
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id::uuid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
<sql>WITH address_data AS (
SELECT
ri.recruit_id::uuid,
ri.ctid as source_ctid,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN addr->>'reg' END) AS residence_address,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateStart')::date END) AS residence_registration_date,
MAX(CASE WHEN addr->>'type' = 'actualAddress' THEN (addr->>'regDateEnd')::date END) AS residence_deregistration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
ELSE NULL
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
GROUP BY ri.recruit_id;</sql>
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'reg' END) AS place_stay_address,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateStart')::date END) AS place_stay_registration_date,
MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN (addr->>'regDateEnd')::date END) AS place_stay_deregistration_date,
CASE
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '1' THEN 'В жилом помещении, не являющимся местом жительства физического лица'
WHEN MAX(CASE WHEN addr->>'type' = 'residenceAddress' THEN addr->>'kodTipReg' END) = '2' THEN 'В учреждении уголовно-исполнительной системы'
END AS place_stay_registration_type,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN addr->>'reg' END) AS factual_address,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateStart')::date END) AS factual_info_received_date,
MAX(CASE WHEN addr->>'type' = 'residentialAddress' THEN (addr->>'regDateEnd')::date END) AS factual_info_expiry_date
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.addresses) AS addr
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
GROUP BY ri.recruit_id, ri.ctid
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM address_data) as last_row
FROM address_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -45,11 +45,6 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success 2</to>
@ -61,22 +56,22 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1840</xloc>
<yloc>0</yloc>
<xloc>816</xloc>
<yloc>720</yloc>
</GUI>
</transform>
<transform>
@ -212,8 +207,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1280</xloc>
<yloc>688</yloc>
<xloc>496</xloc>
<yloc>560</yloc>
</GUI>
</transform>
<transform>
@ -248,26 +243,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<send_true_to>Change job status on success 2</send_true_to>
<attributes/>
<GUI>
<xloc>1520</xloc>
<yloc>0</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>1008</xloc>
<yloc>0</yloc>
<xloc>816</xloc>
<yloc>464</yloc>
</GUI>
</transform>
<transform>
@ -300,7 +277,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</fields>
<attributes/>
<GUI>
<xloc>720</xloc>
<xloc>496</xloc>
<yloc>0</yloc>
</GUI>
</transform>
@ -308,7 +285,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -317,33 +294,39 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array';</sql>
<sql>WITH guardianship_data AS (
SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM guardianship_data) as last_row
FROM guardianship_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -417,7 +400,7 @@ WHERE
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>720</xloc>
<xloc>816</xloc>
<yloc>320</yloc>
</GUI>
</transform>

View file

@ -50,34 +50,29 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -169,8 +164,8 @@ WHERE job_name = '${JOB_NAME}'
</sql>
<attributes/>
<GUI>
<xloc>1712</xloc>
<yloc>0</yloc>
<xloc>880</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -217,8 +212,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1216</xloc>
<yloc>608</yloc>
<xloc>544</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -253,26 +248,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1456</xloc>
<yloc>0</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>944</xloc>
<yloc>0</yloc>
<xloc>880</xloc>
<yloc>384</yloc>
</GUI>
</transform>
<transform>
@ -350,7 +327,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>704</xloc>
<xloc>880</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -384,7 +361,7 @@ and recruitment_id = '${IDM_ID}';</sql>
</fields>
<attributes/>
<GUI>
<xloc>704</xloc>
<xloc>544</xloc>
<yloc>0</yloc>
</GUI>
</transform>
@ -392,7 +369,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -401,34 +378,40 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp;</sql>
<sql>WITH guardianship_data AS (
SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM guardianship_data) as last_row
FROM guardianship_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -45,11 +45,6 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Filter rows</from>
<to>Change job status on success</to>
@ -61,23 +56,23 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Sort rows</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -170,8 +165,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1808</xloc>
<yloc>48</yloc>
<xloc>704</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -233,8 +228,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1232</xloc>
<yloc>576</yloc>
<xloc>416</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -269,26 +264,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1504</xloc>
<yloc>48</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>992</xloc>
<yloc>48</yloc>
<xloc>704</xloc>
<yloc>384</yloc>
</GUI>
</transform>
<transform>
@ -400,7 +377,7 @@ DO UPDATE SET
</fields>
<attributes/>
<GUI>
<xloc>704</xloc>
<xloc>416</xloc>
<yloc>48</yloc>
</GUI>
</transform>
@ -408,7 +385,7 @@ DO UPDATE SET
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -418,32 +395,39 @@ DO UPDATE SET
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array';</sql>
<sql>WITH guardianship_data AS (
SELECT
ri.recruit_id AS recruit_id,
(ch->>'id')::uuid AS guardianship_external_id,
NULLIF(ch->>'idERN', '') AS guardian_id_ern,
ch->'fioOpek'->>'familiya' AS last_name,
ch->'fioOpek'->>'imya' AS first_name,
ch->'fioOpek'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
ch->'fioOpek'->>'familiya',
ch->'fioOpek'->>'imya',
ch->'fioOpek'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(ch->'dataRozhdDok'->>'god', '')::int,
NULLIF(ch->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(ch->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
REGEXP_REPLACE(ch->>'snils', '[-\s]', '', 'g') AS snils,
true AS is_guardian,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen c ON c.recruit_id = ri.recruit_id
CROSS JOIN LATERAL jsonb_array_elements(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') AS ch
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'svedOpekun'->'svedSoczPod') = 'array'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM guardianship_data) as last_row
FROM guardianship_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -40,11 +40,6 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -55,24 +50,24 @@
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -92,8 +87,8 @@
<row_threshold>0</row_threshold>
<attributes/>
<GUI>
<xloc>1168</xloc>
<yloc>448</yloc>
<xloc>880</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -128,8 +123,8 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>1008</xloc>
<yloc>448</yloc>
<xloc>720</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
@ -161,8 +156,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1488</xloc>
<yloc>624</yloc>
<xloc>1104</xloc>
<yloc>160</yloc>
</GUI>
</transform>
<transform>
@ -207,8 +202,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1488</xloc>
<yloc>320</yloc>
<xloc>336</xloc>
<yloc>160</yloc>
</GUI>
</transform>
<transform>
@ -243,33 +238,15 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1200</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>720</xloc>
<yloc>624</yloc>
<xloc>1104</xloc>
<yloc>320</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -278,23 +255,27 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>
<sql>WITH wanted_data AS (
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
)
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
</sql>
*,
source_ctid = (SELECT MAX(source_ctid) FROM wanted_data) as last_row
FROM wanted_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -400,7 +381,7 @@ WHERE'${IDM_ID}' != ''
<use_batch>N</use_batch>
<attributes/>
<GUI>
<xloc>1008</xloc>
<xloc>336</xloc>
<yloc>624</yloc>
</GUI>
</transform>

View file

@ -30,11 +30,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -55,23 +50,23 @@
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
@ -92,8 +87,8 @@
<row_threshold>0</row_threshold>
<attributes/>
<GUI>
<xloc>1120</xloc>
<yloc>384</yloc>
<xloc>1008</xloc>
<yloc>480</yloc>
</GUI>
</transform>
<transform>
@ -128,8 +123,8 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>960</xloc>
<yloc>384</yloc>
<xloc>752</xloc>
<yloc>480</yloc>
</GUI>
</transform>
<transform>
@ -161,8 +156,8 @@ and status = 'DELTA_PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1280</xloc>
<yloc>608</yloc>
<xloc>1008</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
@ -210,8 +205,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1280</xloc>
<yloc>224</yloc>
<xloc>400</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
@ -246,26 +241,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1072</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>752</xloc>
<yloc>608</yloc>
<xloc>1008</xloc>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
@ -336,7 +313,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -345,24 +322,28 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>
<sql>WITH wanted_data AS (
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
)
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
</sql>
*,
source_ctid = (SELECT MAX(source_ctid) FROM wanted_data) as last_row
FROM wanted_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -406,8 +387,8 @@ WHERE'${IDM_ID}' != ''
<use_batch>N</use_batch>
<attributes/>
<GUI>
<xloc>960</xloc>
<yloc>608</yloc>
<xloc>400</xloc>
<yloc>480</yloc>
</GUI>
</transform>
<transform_error_handling>

View file

@ -45,16 +45,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Change job status on error</to>
@ -67,14 +57,19 @@
</hop>
<hop>
<from>Insert / update</from>
<to>Identify last row in a stream 2</to>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream 2</from>
<from>Table input</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -92,8 +87,8 @@
<row_threshold>0</row_threshold>
<attributes/>
<GUI>
<xloc>1152</xloc>
<yloc>432</yloc>
<xloc>1008</xloc>
<yloc>416</yloc>
</GUI>
</transform>
<transform>
@ -128,8 +123,8 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>992</xloc>
<yloc>432</yloc>
<xloc>688</xloc>
<yloc>416</yloc>
</GUI>
</transform>
<transform>
@ -161,8 +156,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1312</xloc>
<yloc>640</yloc>
<xloc>1024</xloc>
<yloc>80</yloc>
</GUI>
</transform>
<transform>
@ -224,8 +219,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1312</xloc>
<yloc>272</yloc>
<xloc>416</xloc>
<yloc>80</yloc>
</GUI>
</transform>
<transform>
@ -260,26 +255,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1136</xloc>
<yloc>640</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream 2</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>688</xloc>
<yloc>640</yloc>
<xloc>1024</xloc>
<yloc>272</yloc>
</GUI>
</transform>
<transform>
@ -350,7 +327,7 @@ DO UPDATE SET
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -360,22 +337,27 @@ DO UPDATE SET
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>
<sql>WITH wanted_data AS (
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
)
SELECT
ri.recruit_id,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrg' AS name_organ_start_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'ugolovZakon' AS article_criminal_code,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataNachRozisk', 'YYYY-MM-DD') AS wanted_start_date,
TO_DATE(ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'dataPrekrRozysk', 'YYYY-MM-DD') AS wanted_end_date,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'osnovPrekrRozysk' AS grounds_stopping_search,
ri.info -> 'svedFL' -> 'extend' -> 'rozysk' ->> 'naimOrgPrekrRozysk' AS name_organ_end_search,
true AS is_wanted // Наличие информации о розыске
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
WHERE'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND jsonb_typeof(ri.info->'svedFL'->'extend'->'rozysk') = 'object'
</sql>
*,
source_ctid = (SELECT MAX(source_ctid) FROM wanted_data) as last_row
FROM wanted_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -419,8 +401,8 @@ WHERE'${IDM_ID}' != ''
<use_batch>N</use_batch>
<attributes/>
<GUI>
<xloc>992</xloc>
<yloc>640</yloc>
<xloc>416</xloc>
<yloc>416</yloc>
</GUI>
</transform>
<transform_error_handling>

View file

@ -35,11 +35,6 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -50,34 +45,34 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output 2</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output 2</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Table output 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Table output 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -133,7 +128,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>912</xloc>
<xloc>736</xloc>
<yloc>192</yloc>
</GUI>
</transform>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1120</xloc>
<yloc>64</yloc>
<xloc>576</xloc>
<yloc>912</yloc>
</GUI>
</transform>
<transform>
@ -212,8 +207,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1120</xloc>
<yloc>576</yloc>
<xloc>352</xloc>
<yloc>912</yloc>
</GUI>
</transform>
<transform>
@ -249,25 +244,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<attributes/>
<GUI>
<xloc>736</xloc>
<yloc>64</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>736</xloc>
<yloc>288</yloc>
<yloc>912</yloc>
</GUI>
</transform>
<transform>
@ -300,15 +277,15 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</fields>
<attributes/>
<GUI>
<xloc>736</xloc>
<yloc>416</yloc>
<xloc>352</xloc>
<yloc>192</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -317,45 +294,52 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}';</sql>
<sql>WITH spouse_data AS (
SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM spouse_data) as last_row
FROM spouse_data;
</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -495,7 +479,7 @@ WHERE
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>736</xloc>
<xloc>544</xloc>
<yloc>192</yloc>
</GUI>
</transform>

View file

@ -40,44 +40,39 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update 2</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update 2</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Insert / update 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Insert / update 2</to>
<enabled>Y</enabled>
</hop>
</order>
@ -136,7 +131,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>960</xloc>
<xloc>768</xloc>
<yloc>176</yloc>
</GUI>
</transform>
@ -169,8 +164,8 @@ WHERE job_name = '${JOB_NAME}'
</sql>
<attributes/>
<GUI>
<xloc>1200</xloc>
<yloc>80</yloc>
<xloc>1072</xloc>
<yloc>688</yloc>
</GUI>
</transform>
<transform>
@ -217,8 +212,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1200</xloc>
<yloc>496</yloc>
<xloc>496</xloc>
<yloc>688</yloc>
</GUI>
</transform>
<transform>
@ -253,26 +248,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>80</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>272</yloc>
<xloc>1072</xloc>
<yloc>496</yloc>
</GUI>
</transform>
<transform>
@ -419,7 +396,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>768</xloc>
<xloc>496</xloc>
<yloc>176</yloc>
</GUI>
</transform>
@ -453,8 +430,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</fields>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>384</yloc>
<xloc>496</xloc>
<yloc>320</yloc>
</GUI>
</transform>
<transform>
@ -471,45 +448,52 @@ and recruitment_id = '${IDM_ID}';</sql>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.update_date >= '${M_R_UP_DATE}'::timestamp;
<sql>WITH spouse_data AS (
SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.update_date >= '${M_R_UP_DATE}'::timestamp
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM spouse_data) as last_row
FROM spouse_data;
</sql>
<variables_active>Y</variables_active>
<attributes/>

View file

@ -32,8 +32,8 @@
<fontitalic>N</fontitalic>
<fontsize>-1</fontsize>
<height>149</height>
<xloc>528</xloc>
<yloc>608</yloc>
<xloc>0</xloc>
<yloc>64</yloc>
<note>
M_R_UP_DATE
@ -67,44 +67,39 @@ M_R_CR_DATE
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update 2</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update 2</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Insert / update 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Insert / update 2</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
@ -163,7 +158,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>912</xloc>
<xloc>704</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -198,8 +193,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1152</xloc>
<yloc>64</yloc>
<xloc>944</xloc>
<yloc>752</yloc>
</GUI>
</transform>
<transform>
@ -261,8 +256,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1152</xloc>
<yloc>528</yloc>
<xloc>352</xloc>
<yloc>752</yloc>
</GUI>
</transform>
<transform>
@ -297,26 +292,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>704</xloc>
<yloc>64</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>704</xloc>
<yloc>320</yloc>
<xloc>944</xloc>
<yloc>528</yloc>
</GUI>
</transform>
<transform>
@ -463,7 +440,7 @@ DO UPDATE SET
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>704</xloc>
<xloc>352</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -497,8 +474,8 @@ DO UPDATE SET
</fields>
<attributes/>
<GUI>
<xloc>704</xloc>
<yloc>416</yloc>
<xloc>352</xloc>
<yloc>368</yloc>
</GUI>
</transform>
<transform>
@ -515,44 +492,52 @@ DO UPDATE SET
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}';</sql>
<sql>WITH spouse_data AS (
SELECT
ri.recruit_id AS recruit_id,
(supr->>'id')::uuid AS spouse_external_id,
NULLIF(supr->>'idERN', '') AS spouse_id_ern,
NULLIF(supr->>'rodstvSvyazSuprug', '')::int AS kinship_type,
supr->'svedFLBS'->'fio'->>'familiya' AS last_name,
supr->'svedFLBS'->'fio'->>'imya' AS first_name,
supr->'svedFLBS'->'fio'->>'otchestvo' AS middle_name,
CONCAT_WS(' ',
supr->'svedFLBS'->'fio'->>'familiya',
supr->'svedFLBS'->'fio'->>'imya',
supr->'svedFLBS'->'fio'->>'otchestvo'
) AS full_name,
MAKE_DATE(
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'god', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'mesyacz', '')::int,
NULLIF(supr->'svedFLBS'->'dataRozhdDok'->>'den', '')::int
) AS birth_date,
(supr->'svedSmert'->'extend'->>'dataSmert')::date AS death_date,
supr->'svedSmert'->>'nomerZapis' AS death_az_number,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'nomerZapis' AS marriage_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZBrak'->>'dataBrakKalend')::date AS marriage_date,
ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'nomerZapis' AS divorce_az_number,
(ri.info->'svedFL'->'svedSemPolozh'->'svedAZRazvod'->>'dataRastBrakKalend')::date AS divorce_date,
CASE
WHEN ri.info->'svedFL'->'svedSemPolozh'->>'svedSuprIskl' = '1' THEN true
ELSE false
END AS information_excluded,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
CROSS JOIN LATERAL (
SELECT supri
FROM jsonb_array_elements(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') AS supri
WHERE jsonb_typeof(ri.info->'svedFL'->'svedSemPolozh'->'suprugi') = 'array'
) AS supr(supr)
WHERE
'${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM spouse_data) as last_row
FROM spouse_data;
</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -30,26 +30,11 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
@ -65,6 +50,16 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -197,7 +192,7 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>896</xloc>
<xloc>496</xloc>
<yloc>176</yloc>
</GUI>
</transform>
@ -237,29 +232,11 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<yloc>320</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>640</xloc>
<yloc>320</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -269,33 +246,39 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4 and
LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6</sql>
<sql>WITH passport_data AS (
SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4
AND LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM passport_data) as last_row
FROM passport_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -30,26 +30,11 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
@ -65,6 +50,16 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -200,7 +195,7 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>752</xloc>
<xloc>400</xloc>
<yloc>80</yloc>
</GUI>
</transform>
@ -240,24 +235,6 @@ and recruitment_id = '${IDM_ID}';</sql>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>560</xloc>
<yloc>224</yloc>
</GUI>
</transform>
<transform>
<name>Insert / update</name>
<type>InsertUpdate</type>
@ -331,7 +308,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -341,36 +318,40 @@ and recruitment_id = '${IDM_ID}';</sql>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND '${M_R_CR_DATE}'::timestamp >= r.recruit_create_date
AND r.update_date >= '${M_R_UP_DATE}'::timestamp
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4 and
LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6
</sql>
<sql>WITH passport_data AS (
SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND r.update_date >= '${M_R_UP_DATE}'::timestamp
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4
AND LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM passport_data) as last_row
FROM passport_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -30,11 +30,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -50,21 +45,21 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Identify last row in a stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Change job status on error</from>
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -214,7 +209,7 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>768</xloc>
<xloc>416</xloc>
<yloc>16</yloc>
</GUI>
</transform>
@ -254,24 +249,6 @@ DO UPDATE SET
<yloc>272</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>608</xloc>
<yloc>272</yloc>
</GUI>
</transform>
<transform>
<name>Insert / update</name>
<type>InsertUpdate</type>
@ -345,7 +322,7 @@ DO UPDATE SET
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -355,34 +332,39 @@ DO UPDATE SET
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4 and
LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6
</sql>
<sql>WITH passport_data AS (
SELECT
ri.recruit_id,
NULLIF(p.passport_data->>'nomDok', '') AS passport_number,
NULLIF(p.passport_data->>'serDok', '') AS passport_series,
NULLIF(p.passport_data->>'vydDok', '') AS organization_name,
NULLIF(p.passport_data->>'kodVydDok', '') AS unit_code,
TO_DATE(NULLIF(p.passport_data->>'dataDok', ''), 'YYYY-MM-DD') AS issue_date,
CASE
WHEN NULLIF(p.passport_data->>'kodStatus', '') = '1' THEN TRUE
ELSE FALSE
END AS actual,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r
ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
JOIN LATERAL (
SELECT passport_data
FROM UNNEST(ARRAY[
ri.info->'svedFL'->'svedBS'->'pasportRF'->'aktPasportRF',
ri.info->'svedFL'->'svedBS'->'pasportRF'->'predPasportRF'
]) AS passport_data
WHERE passport_data IS NOT NULL AND passport_data::text &lt;&gt; 'null'
) AS p ON TRUE
WHERE LENGTH(REGEXP_REPLACE(p.passport_data->>'serDok', '[^0-9]', '', 'g')) = 4
AND LENGTH(REGEXP_REPLACE(p.passport_data->>'nomDok', '[^0-9]', '', 'g')) = 6
)
SELECT
*,
source_ctid = (SELECT MAX(source_ctid) FROM passport_data) as last_row
FROM passport_data;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -40,11 +40,6 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -55,29 +50,29 @@
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -133,7 +128,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>1056</xloc>
<xloc>848</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1456</xloc>
<yloc>32</yloc>
<xloc>1072</xloc>
<yloc>640</yloc>
</GUI>
</transform>
<transform>
@ -212,8 +207,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1456</xloc>
<yloc>464</yloc>
<xloc>480</xloc>
<yloc>640</yloc>
</GUI>
</transform>
<transform>
@ -248,26 +243,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1200</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>832</xloc>
<yloc>32</yloc>
<xloc>1072</xloc>
<yloc>464</yloc>
</GUI>
</transform>
<transform>
@ -300,15 +277,15 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</fields>
<attributes/>
<GUI>
<xloc>832</xloc>
<yloc>224</yloc>
<xloc>480</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -318,14 +295,14 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH
ugolov_presl AS (
<sql>WITH ugolov_presl AS (
SELECT
jsonb_array_elements(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') AS up,
ri.recruit_id
ri.recruit_id,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != '' -- Проверка на пустую строку
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE jsonb_typeof(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') = 'array'
)
@ -358,11 +335,12 @@ SELECT
WHEN (up->>'sledSudTekst') IS NOT NULL AND up->>'sledSudTekst' != 'null' THEN 'Сведения о фактах уголовного преследования или судимости в текстовом виде'
ELSE 'Есть сведения о фактах уголовного преследования или судимости без указания подробностей'
END AS type_info,
true AS has_criminal_prosecution
true AS has_criminal_prosecution,
up.source_ctid = (SELECT MAX(source_ctid) FROM ugolov_presl) as last_row
FROM ervu_dashboard.citizen r
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up;</sql>
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up.up, up.source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -484,7 +462,7 @@ GROUP BY r.recruit_id, up;</sql>
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>832</xloc>
<xloc>848</xloc>
<yloc>464</yloc>
</GUI>
</transform>
@ -524,7 +502,7 @@ GROUP BY r.recruit_id, up;</sql>
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>1056</xloc>
<xloc>848</xloc>
<yloc>32</yloc>
</GUI>
</transform>

View file

@ -30,11 +30,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -50,11 +45,6 @@
<to>Abort</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
@ -66,18 +56,23 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Sort rows</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream 2</to>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream 2</from>
<to>Update</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
</order>
@ -133,7 +128,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>880</xloc>
<xloc>736</xloc>
<yloc>592</yloc>
</GUI>
</transform>
@ -166,8 +161,8 @@ and status = 'DELTA_PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1152</xloc>
<yloc>416</yloc>
<xloc>896</xloc>
<yloc>944</yloc>
</GUI>
</transform>
<transform>
@ -215,8 +210,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1152</xloc>
<yloc>768</yloc>
<xloc>384</xloc>
<yloc>944</yloc>
</GUI>
</transform>
<transform>
@ -251,26 +246,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1024</xloc>
<yloc>416</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream 2</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>736</xloc>
<yloc>416</yloc>
<xloc>896</xloc>
<yloc>768</yloc>
</GUI>
</transform>
<transform>
@ -442,15 +419,15 @@ and recruitment_id = '${IDM_ID}';</sql>
</fields>
<attributes/>
<GUI>
<xloc>736</xloc>
<yloc>560</yloc>
<xloc>384</xloc>
<yloc>416</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -460,53 +437,53 @@ and recruitment_id = '${IDM_ID}';</sql>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH
ugolov_presl AS (
SELECT
jsonb_array_elements(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') AS up,
ri.recruit_id
--'prOtsSvedUgolovPresl'
FROM ervu_dashboard.recruits_info ri
join ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != '' -- Проверка на пустую строку
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
WHERE jsonb_typeof(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') = 'array'
<sql>WITH ugolov_presl AS (
SELECT
jsonb_array_elements(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') AS up,
ri.recruit_id,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
WHERE jsonb_typeof(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') = 'array'
)
SELECT
r.recruit_id AS recruit_id,
(up->>'id')::uuid AS prosecution_external_id,
NULLIF(up->'sledSud'->>'uk', '') AS uk_name, -- УК осуждения
NULLIF(up->'sledSud'->'extend'->>'nomerUDPredv', '') AS case_number, -- номер уголовного дела (предварительный)
NULLIF(up->'sledSud'->'extend'->>'svedPerekvalif', '') AS reclassification, -- сведения о переквалификации деяния
NULLIF(up->'sledSud'->'extend'->>'naimVidUgolovPresl', '') AS kind, -- наименование вида уголовного преследования
NULLIF(up->'sledSud'->>'uk', '') AS uk_name,
NULLIF(up->'sledSud'->'extend'->>'nomerUDPredv', '') AS case_number,
NULLIF(up->'sledSud'->'extend'->>'svedPerekvalif', '') AS reclassification,
NULLIF(up->'sledSud'->'extend'->>'naimVidUgolovPresl', '') AS kind,
CASE
WHEN up->'sledSud'->'extend'->>'priznakPeredachSud' = '1' THEN true -- передано в суд
WHEN up->'sledSud'->'extend'->>'priznakPeredachSud' = '1' THEN true
ELSE false -- нет или нет инфы
END AS transfer_to_court, -- признак передачи в суд уголовного дела в отношении гражданина
NULLIF(up->'sledSud'->>'naimSud','') AS court_name, -- Наименование суда, вынесшего приговор
NULLIF(up->'sledSud'->>'nomerUD','') AS case_number_court, -- номер уголовного дела (судебный)
STRING_AGG(TRIM(BOTH ' "' FROM law.f), ', ') AS law_point, -- статьи уголовного кодекса
NULLIF(up->'sledSud'->>'naimOrgan', '') AS authority_name, -- наименование органа, принявшего решение о возбуждении уголовного дела
NULLIF(up->'sledSud'->'svedSnyat'->>'osnSnyatSud', '') AS conviction_removal_basis, -- основание снятия судимости
TO_DATE(up->'sledSud'->'svedSnyat'->>'dataSnyatSud', 'YYYY-MM-DD') AS conviction_removal_date, -- дата снятия судимости
TO_DATE(up->'sledSud'->>'dataOsuzhd', 'YYYY-MM-DD') AS conviction_date, -- дата осуждения
TO_DATE(up->'sledSud'->>'dataVozbUD', 'YYYY-MM-DD') AS create_date, -- дата возбуждения уголовного дела
NULLIF(up->'sledSud'->>'osnPrekrUD', '') AS termination_basis, -- основания прекращения уголовного дела
NULLIF(up->'sledSud'->>'statusNaim', '') AS conviction_status, -- статус судимости
TO_DATE(up->'sledSud'->>'dataPrekrUD', 'YYYY-MM-DD') AS close_date, -- дата прекращения уголовного дела
NULLIF(up->'sledSudTekst'->>'svedTekst' , '') AS sled_sud_tekst_sved_tekst, -- текст судимости в текстовом формате
NULLIF(up->'sledSudTekst'->>'statusNaim', '') AS sled_sud_tekst_status_naim, -- статус судимости в текстовом формате
END AS transfer_to_court,
NULLIF(up->'sledSud'->>'naimSud','') AS court_name,
NULLIF(up->'sledSud'->>'nomerUD','') AS case_number_court,
STRING_AGG(TRIM(BOTH ' "' FROM law.f), ', ') AS law_point,
NULLIF(up->'sledSud'->>'naimOrgan', '') AS authority_name,
NULLIF(up->'sledSud'->'svedSnyat'->>'osnSnyatSud', '') AS conviction_removal_basis,
TO_DATE(up->'sledSud'->'svedSnyat'->>'dataSnyatSud', 'YYYY-MM-DD') AS conviction_removal_date,
TO_DATE(up->'sledSud'->>'dataOsuzhd', 'YYYY-MM-DD') AS conviction_date,
TO_DATE(up->'sledSud'->>'dataVozbUD', 'YYYY-MM-DD') AS create_date,
NULLIF(up->'sledSud'->>'osnPrekrUD', '') AS termination_basis,
NULLIF(up->'sledSud'->>'statusNaim', '') AS conviction_status,
TO_DATE(up->'sledSud'->>'dataPrekrUD', 'YYYY-MM-DD') AS close_date,
NULLIF(up->'sledSudTekst'->>'svedTekst' , '') AS sled_sud_tekst_sved_tekst,
NULLIF(up->'sledSudTekst'->>'statusNaim', '') AS sled_sud_tekst_status_naim,
CASE
WHEN (up->>'sledSud') IS NOT NULL AND up->>'sledSud' != 'null' THEN 'Сведения о фактах уголовного преследования или судимости в структурированном формате'
WHEN (up->>'sledSudTekst') IS NOT NULL AND up->>'sledSudTekst' != 'null' THEN 'Сведения о фактах уголовного преследования или судимости в текстовом виде'
ELSE 'Есть сведения о фактах уголовного преследования или судимости без указания подробностей'
END AS type_info,
true AS has_criminal_prosecution
true AS has_criminal_prosecution,
up.source_ctid = (SELECT MAX(source_ctid) FROM ugolov_presl) as last_row
FROM ervu_dashboard.citizen r
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up;</sql>
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up.up, up.source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
@ -550,7 +527,7 @@ GROUP BY r.recruit_id, up;</sql>
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>880</xloc>
<xloc>736</xloc>
<yloc>416</yloc>
</GUI>
</transform>

View file

@ -30,11 +30,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -55,29 +50,29 @@
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Sort rows</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -133,7 +128,7 @@ and recruitment_id = '${IDM_ID}';
</sql>
<attributes/>
<GUI>
<xloc>944</xloc>
<xloc>768</xloc>
<yloc>736</yloc>
</GUI>
</transform>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1296</xloc>
<yloc>576</yloc>
<xloc>928</xloc>
<yloc>1088</yloc>
</GUI>
</transform>
<transform>
@ -229,8 +224,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1296</xloc>
<yloc>944</yloc>
<xloc>432</xloc>
<yloc>1088</yloc>
</GUI>
</transform>
<transform>
@ -265,26 +260,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1088</xloc>
<yloc>576</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>576</yloc>
<xloc>928</xloc>
<yloc>944</yloc>
</GUI>
</transform>
<transform>
@ -456,15 +433,15 @@ DO UPDATE SET
</fields>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>768</yloc>
<xloc>432</xloc>
<yloc>576</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -474,20 +451,20 @@ DO UPDATE SET
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH
ugolov_presl AS (
<sql>WITH ugolov_presl AS (
SELECT
jsonb_array_elements(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') AS up,
ri.recruit_id
ri.recruit_id,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != '' -- Проверка на пустую строку
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE jsonb_typeof(ri.info->'svedFL'->'svedUgolovPresl'->'faktyUgolovPresl') = 'array'
)
SELECT
r.recruit_id AS recruit_id,
(up->>'id')::uuid AS prosecution_external_id,
(up->>'id')::uuid AS prosecution_external_id,
NULLIF(up->'sledSud'->>'uk', '') AS uk_name,
NULLIF(up->'sledSud'->'extend'->>'nomerUDPredv', '') AS case_number,
NULLIF(up->'sledSud'->'extend'->>'svedPerekvalif', '') AS reclassification,
@ -514,15 +491,16 @@ SELECT
WHEN (up->>'sledSudTekst') IS NOT NULL AND up->>'sledSudTekst' != 'null' THEN 'Сведения о фактах уголовного преследования или судимости в текстовом виде'
ELSE 'Есть сведения о фактах уголовного преследования или судимости без указания подробностей'
END AS type_info,
true AS has_criminal_prosecution
true AS has_criminal_prosecution,
up.source_ctid = (SELECT MAX(source_ctid) FROM ugolov_presl) as last_row
FROM ervu_dashboard.citizen r
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up;</sql>
JOIN ugolov_presl up ON r.recruit_id = up.recruit_id
LEFT JOIN LATERAL jsonb_array_elements_text(up->'sledSud'->'statiUK') AS law(f) ON true
GROUP BY r.recruit_id, up.up, up.source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
<xloc>416</xloc>
<xloc>432</xloc>
<yloc>944</yloc>
</GUI>
</transform>
@ -562,7 +540,7 @@ GROUP BY r.recruit_id, up;</sql>
<use_batch>Y</use_batch>
<attributes/>
<GUI>
<xloc>976</xloc>
<xloc>768</xloc>
<yloc>576</yloc>
</GUI>
</transform>

View file

@ -40,11 +40,6 @@
<to>Change job status on success</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -55,29 +50,29 @@
<to>Table output</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table output</from>
<from>Sort rows</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<to>Update</to>
<from>Table output</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1488</xloc>
<yloc>624</yloc>
<xloc>544</xloc>
<yloc>144</yloc>
</GUI>
</transform>
<transform>
@ -212,8 +207,8 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</partitioning>
<attributes/>
<GUI>
<xloc>1488</xloc>
<yloc>320</yloc>
<xloc>336</xloc>
<yloc>144</yloc>
</GUI>
</transform>
<transform>
@ -247,27 +242,9 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</compare>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1200</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>720</xloc>
<yloc>624</yloc>
<yloc>144</yloc>
</GUI>
</transform>
<transform>
@ -300,15 +277,15 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
</fields>
<attributes/>
<GUI>
<xloc>720</xloc>
<yloc>464</yloc>
<xloc>336</xloc>
<yloc>624</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -319,16 +296,18 @@ VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH punishment_data AS (
SELECT ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
SELECT
ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
)
SELECT recruit_id,
(punishment_info ->&gt; 'id')::uuid AS punishment_external_id,
(punishment_info ->> 'id')::uuid AS punishment_external_id,
-- Блок "Сведения о вынесенном приговоре"
punishment_info ->> 'vidNakaz' AS punishment_type, -- Вид наказания
punishment_info ->> 'kodVidNakaz' AS punishment_code, -- Код вида наказания
@ -347,7 +326,7 @@ SELECT recruit_id,
punishment_info ->> 'naimOrg' AS facility_name, -- Название учреждения
punishment_info ->> 'adresOrg' AS facility_address, -- Адрес учреждения
punishment_info ->> 'nomerUD' AS criminal_case_number, -- Номер уголовного дела
TO_DATE(punishment_info ->&gt; 'dataNachSrok', 'YYYY-MM-DD') AS start_date, -- Дата начала срока
TO_DATE(punishment_info ->> 'dataNachSrok', 'YYYY-MM-DD') AS start_date, -- Дата начала срока
TO_DATE(punishment_info ->> 'dataOkonchSrok', 'YYYY-MM-DD') AS planned_date, -- Планируемая дата освобождения
CASE
WHEN punishment_info ->> 'kodPerekvalif' = '1' THEN 'Изменений статьи не было'
@ -357,10 +336,11 @@ SELECT recruit_id,
punishment_info ->> 'osnOsvob' AS release_reason, -- Основание освобождения
TO_DATE(punishment_info ->> 'dataOsvob', 'YYYY-MM-DD') AS release_date, -- Фактическая дата освобождения
true AS has_punishment_execution_info,
true AS has_sentence_info
true AS has_sentence_info,
source_ctid = (SELECT MAX(source_ctid) FROM punishment_data) as last_row
FROM punishment_data
LEFT JOIN LATERAL jsonb_array_elements_text(punishment_info -> 'statiUK') AS law_articles ON true
GROUP BY recruit_id, punishment_info;</sql>
GROUP BY recruit_id, punishment_info,source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -49,11 +49,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Detect empty stream</from>
<to>Change job status on success</to>
@ -74,31 +69,31 @@
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream</from>
<from>Sort rows</from>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Abort</name>
@ -185,8 +180,8 @@ and status = 'DELTA_PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1280</xloc>
<yloc>608</yloc>
<xloc>608</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
@ -234,8 +229,8 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<attributes/>
<GUI>
<xloc>1280</xloc>
<yloc>224</yloc>
<xloc>400</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
@ -270,26 +265,8 @@ and recruitment_id = '${IDM_ID}';</sql>
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1072</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>752</xloc>
<yloc>608</yloc>
<xloc>784</xloc>
<yloc>32</yloc>
</GUI>
</transform>
<transform>
@ -417,7 +394,7 @@ and recruitment_id = '${IDM_ID}';</sql>
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>752</xloc>
<xloc>784</xloc>
<yloc>224</yloc>
</GUI>
</transform>
@ -451,15 +428,15 @@ and recruitment_id = '${IDM_ID}';</sql>
</fields>
<attributes/>
<GUI>
<xloc>752</xloc>
<yloc>384</yloc>
<xloc>400</xloc>
<yloc>608</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -468,19 +445,20 @@ and recruitment_id = '${IDM_ID}';</sql>
</partitioning>
<connection>ervu-dashboard</connection>
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH punishment_data AS (
SELECT ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
SELECT
ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
AND ri.updated_at >= '${M_R_UP_DATE}'::timestamp
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
)
SELECT recruit_id,
(punishment_info ->> 'id')::uuid AS punishment_external_id,
(punishment_info ->> 'id')::uuid AS punishment_external_id,
-- Блок "Сведения о вынесенном приговоре"
punishment_info ->> 'vidNakaz' AS punishment_type, -- Вид наказания
punishment_info ->> 'kodVidNakaz' AS punishment_code, -- Код вида наказания
@ -492,7 +470,7 @@ SELECT recruit_id,
WHEN punishment_info ->> 'kodIzmSrokNakaz' = '2' THEN 'Были изменения срока наказания'
ELSE punishment_info ->> 'kodIzmSrokNakaz'
END AS sentence_changed, -- Признак изменения срока
STRING_AGG(TRIM(BOTH ' "' FROM law_articles), ', ') AS law_point, -- Статьи УК
STRING_AGG(TRIM(BOTH ' "' FROM law_articles), ', ') AS law_point, -- Статьи УК
-- Блок "Сведения об отбывании наказания"
punishment_info ->> 'katUcheta' AS registration_category, -- Категория учета
punishment_info ->> 'naimSubekt' AS region_name, -- Наименование субъекта
@ -509,10 +487,11 @@ SELECT recruit_id,
punishment_info ->> 'osnOsvob' AS release_reason, -- Основание освобождения
TO_DATE(punishment_info ->> 'dataOsvob', 'YYYY-MM-DD') AS release_date, -- Фактическая дата освобождения
true AS has_punishment_execution_info,
true AS has_sentence_info
true AS has_sentence_info,
source_ctid = (SELECT MAX(source_ctid) FROM punishment_data) as last_row
FROM punishment_data
LEFT JOIN LATERAL jsonb_array_elements_text(punishment_info -> 'statiUK') AS law_articles ON true
GROUP BY recruit_id, punishment_info;</sql>
GROUP BY recruit_id, punishment_info,source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>

View file

@ -45,16 +45,6 @@
<to>Change job status on error</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Change job status on error</to>
@ -66,18 +56,23 @@
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<from>Table input</from>
<to>Sort rows</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Sort rows</from>
<to>Identify last row in a stream 2</to>
<to>Update</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Identify last row in a stream 2</from>
<to>Update</to>
<from>Table input</from>
<to>Detect empty stream</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Insert / update</from>
<to>Filter rows</to>
<enabled>Y</enabled>
</hop>
</order>
@ -166,8 +161,8 @@ and status = 'PROCESSING';
</sql>
<attributes/>
<GUI>
<xloc>1312</xloc>
<yloc>640</yloc>
<xloc>640</xloc>
<yloc>112</yloc>
</GUI>
</transform>
<transform>
@ -229,8 +224,8 @@ DO UPDATE SET
</partitioning>
<attributes/>
<GUI>
<xloc>1312</xloc>
<yloc>272</yloc>
<xloc>416</xloc>
<yloc>112</yloc>
</GUI>
</transform>
<transform>
@ -265,26 +260,8 @@ DO UPDATE SET
<send_true_to>Change job status on success</send_true_to>
<attributes/>
<GUI>
<xloc>1136</xloc>
<yloc>640</yloc>
</GUI>
</transform>
<transform>
<name>Identify last row in a stream 2</name>
<type>DetectLastRow</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<resultfieldname>last_row</resultfieldname>
<attributes/>
<GUI>
<xloc>688</xloc>
<yloc>640</yloc>
<xloc>816</xloc>
<yloc>112</yloc>
</GUI>
</transform>
<transform>
@ -412,7 +389,7 @@ DO UPDATE SET
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>688</xloc>
<xloc>816</xloc>
<yloc>272</yloc>
</GUI>
</transform>
@ -446,15 +423,15 @@ DO UPDATE SET
</fields>
<attributes/>
<GUI>
<xloc>688</xloc>
<yloc>448</yloc>
<xloc>416</xloc>
<yloc>640</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<distribute>N</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
@ -465,16 +442,18 @@ DO UPDATE SET
<execute_each_row>N</execute_each_row>
<limit/>
<sql>WITH punishment_data AS (
SELECT ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
SELECT
ri.recruit_id,
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS punishment_info,
ri.ctid as source_ctid
FROM ervu_dashboard.recruits_info ri
JOIN ervu_dashboard.citizen r ON r.recruit_id = ri.recruit_id
AND '${IDM_ID}' != ''
AND COALESCE(ri.current_recruitment_id, ri.target_recruitment_id) = '${IDM_ID}'
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null'
)
SELECT recruit_id,
(punishment_info ->> 'id')::uuid AS punishment_external_id,
(punishment_info ->> 'id')::uuid AS punishment_external_id,
-- Блок "Сведения о вынесенном приговоре"
punishment_info ->> 'vidNakaz' AS punishment_type, -- Вид наказания
punishment_info ->> 'kodVidNakaz' AS punishment_code, -- Код вида наказания
@ -486,7 +465,7 @@ SELECT recruit_id,
WHEN punishment_info ->> 'kodIzmSrokNakaz' = '2' THEN 'Были изменения срока наказания'
ELSE punishment_info ->> 'kodIzmSrokNakaz'
END AS sentence_changed, -- Признак изменения срока
STRING_AGG(TRIM(BOTH ' "' FROM law_articles), ', ') AS law_point, -- Статьи УК
STRING_AGG(TRIM(BOTH ' "' FROM law_articles), ', ') AS law_point, -- Статьи УК
-- Блок "Сведения об отбывании наказания"
punishment_info ->> 'katUcheta' AS registration_category, -- Категория учета
punishment_info ->> 'naimSubekt' AS region_name, -- Наименование субъекта
@ -503,10 +482,11 @@ SELECT recruit_id,
punishment_info ->> 'osnOsvob' AS release_reason, -- Основание освобождения
TO_DATE(punishment_info ->> 'dataOsvob', 'YYYY-MM-DD') AS release_date, -- Фактическая дата освобождения
true AS has_punishment_execution_info,
true AS has_sentence_info
true AS has_sentence_info,
source_ctid = (SELECT MAX(source_ctid) FROM punishment_data) as last_row
FROM punishment_data
LEFT JOIN LATERAL jsonb_array_elements_text(punishment_info -> 'statiUK') AS law_articles ON true
GROUP BY recruit_id, punishment_info;</sql>
GROUP BY recruit_id, punishment_info,source_ctid;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>