temp_fix_punishment_info_
This commit is contained in:
parent
3b752d68c1
commit
fab2e60481
1 changed files with 47 additions and 42 deletions
|
|
@ -21,52 +21,11 @@
|
|||
</notepads>
|
||||
<order>
|
||||
<hop>
|
||||
<from>Table input</from>
|
||||
<from>Table input 2</from>
|
||||
<to>Table output</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
</order>
|
||||
<transform>
|
||||
<name>Table input</name>
|
||||
<type>TableInput</type>
|
||||
<description/>
|
||||
<distribute>Y</distribute>
|
||||
<custom_distribution/>
|
||||
<copies>1</copies>
|
||||
<partitioning>
|
||||
<method>none</method>
|
||||
<schema_name/>
|
||||
</partitioning>
|
||||
<connection>ervu_person_registry</connection>
|
||||
<execute_each_row>N</execute_each_row>
|
||||
<limit>0</limit>
|
||||
<sql>with ugol as
|
||||
(select jsonb_array_elements(ri.info->'svedFL'->'svedSudim'->'sudim'->'osuzhdenie') u,
|
||||
ri.recruit_id
|
||||
from public.recruits_info ri
|
||||
where jsonb_typeof(ri.info->'svedFL'->'svedSudim'->'sudim'->'osuzhdenie') = 'array')
|
||||
select
|
||||
r.id recruit_id,
|
||||
u->>'naimSuda' authority_name,
|
||||
u->>'srokNakaz' sentence,
|
||||
u->>'adresNakaz' sentence_place,
|
||||
u->>'kodVidNakaz' punishment_code,
|
||||
u->>'izmSrokNakaz' sentence_changed,
|
||||
u->>'naimVidNakaz' punishment_type,
|
||||
to_date(u->>'dataNachSrok', 'YYYY-MM-DD') start_date,
|
||||
to_date(u->>'dataOsvobozhd', 'YYYY-MM-DD') release_date,
|
||||
to_date(u->>'dataOsuzhd', 'YYYY-MM-DD') sentense_date,
|
||||
u->>'ugolovZakon' law_point,
|
||||
u->>'osnovOsvobozhd' release_reason
|
||||
from public.recruits r
|
||||
join ugol on r.id = ugol.recruit_id;</sql>
|
||||
<variables_active>N</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>528</xloc>
|
||||
<yloc>304</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Table output</name>
|
||||
<type>TableOutput</type>
|
||||
|
|
@ -101,6 +60,52 @@ join ugol on r.id = ugol.recruit_id;</sql>
|
|||
<yloc>304</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Table input 2</name>
|
||||
<type>TableInput</type>
|
||||
<description/>
|
||||
<distribute>Y</distribute>
|
||||
<custom_distribution/>
|
||||
<copies>1</copies>
|
||||
<partitioning>
|
||||
<method>none</method>
|
||||
<schema_name/>
|
||||
</partitioning>
|
||||
<connection>ervu_person_registry</connection>
|
||||
<execute_each_row>N</execute_each_row>
|
||||
<limit>0</limit>
|
||||
<sql>WITH ugol AS (SELECT ri.recruit_id,
|
||||
jsonb_array_elements(ri.info -> 'svedFL' -> 'svedNakaz' -> 'nakaz') AS nakaz
|
||||
FROM public.recruits_info ri
|
||||
WHERE ri.info -> 'svedFL' -> 'svedNakaz' ->> 'nakaz' != 'null')
|
||||
SELECT recruit_id,
|
||||
nakaz ->> 'naimSud' AS authority_name,
|
||||
nakaz ->> 'srokNakaz' AS sentence,
|
||||
nakaz ->> 'adresOrg' AS sentence_place,
|
||||
-- nakaz->>'vidNakaz' AS punishment_code,
|
||||
nakaz ->> 'naimIzmSrokNakaz' AS sentence_changed,
|
||||
nakaz ->> 'vidNakaz' AS punishment_type,
|
||||
TO_DATE(nakaz ->> 'dataNachSrok', 'YYYY-MM-DD') AS start_date,
|
||||
TO_DATE(nakaz ->> 'dataOsvob', 'YYYY-MM-DD') AS release_date,
|
||||
TO_DATE(nakaz ->> 'dataOsuzhd', 'YYYY-MM-DD') AS sentense_date,
|
||||
nakaz ->> 'ugolovZakon' AS law_point,
|
||||
nakaz ->> 'osnovOsvobozhd' AS release_reason,
|
||||
string_agg(statiuk_elem::text, ', ') AS law_point,
|
||||
nakaz ->> 'osnOsvob' release_reason
|
||||
FROM ugol
|
||||
LEFT JOIN LATERAL jsonb_path_query(nakaz, '$.statiUK[*]') AS statiuk_elem ON true
|
||||
join public.recruits r ON r.id = ugol.recruit_id AND
|
||||
(r.target_recruitment_id = '${RCRT_C}' or
|
||||
r.current_recruitment_id = '${RCRT_C}')
|
||||
GROUP BY recruit_id, nakaz;
|
||||
</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>464</xloc>
|
||||
<yloc>304</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform_error_handling>
|
||||
</transform_error_handling>
|
||||
<attributes/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue