635 lines
19 KiB
Text
635 lines
19 KiB
Text
|
|
<pipeline>
|
||
|
|
<info>
|
||
|
|
<name>main_dashboard.recruitment_campaign(reg)</name>
|
||
|
|
<name_sync_with_filename>Y</name_sync_with_filename>
|
||
|
|
<description/>
|
||
|
|
<extended_description/>
|
||
|
|
<pipeline_version/>
|
||
|
|
<pipeline_type>Normal</pipeline_type>
|
||
|
|
<pipeline_status>0</pipeline_status>
|
||
|
|
<directory>/</directory>
|
||
|
|
<parameters>
|
||
|
|
</parameters>
|
||
|
|
<capture_transform_performance>N</capture_transform_performance>
|
||
|
|
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
|
||
|
|
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
|
||
|
|
<created_user>-</created_user>
|
||
|
|
<created_date>2024/08/02 11:56:22.507</created_date>
|
||
|
|
<modified_user>-</modified_user>
|
||
|
|
<modified_date>2024/08/02 11:56:22.507</modified_date>
|
||
|
|
<key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
|
||
|
|
<is_key_private>N</is_key_private>
|
||
|
|
</info>
|
||
|
|
<notepads>
|
||
|
|
</notepads>
|
||
|
|
<order>
|
||
|
|
<hop>
|
||
|
|
<from>Get variables 4 3</from>
|
||
|
|
<to>Select values 4 3</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
<hop>
|
||
|
|
<from>Table input (subpoena) регион/осень</from>
|
||
|
|
<to>Get variables 4 3</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
<hop>
|
||
|
|
<from>Get variables 4 3 2</from>
|
||
|
|
<to>Select values 4 3 2</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
<hop>
|
||
|
|
<from>Table input (subpoena) регион/весна</from>
|
||
|
|
<to>Get variables 4 3 2</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
<hop>
|
||
|
|
<from>Select values 4 3</from>
|
||
|
|
<to>Insert / update (main_dashboard.recruitment_campaign)</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
<hop>
|
||
|
|
<from>Select values 4 3 2</from>
|
||
|
|
<to>Insert / update (main_dashboard.recruitment_campaign) 2</to>
|
||
|
|
<enabled>Y</enabled>
|
||
|
|
</hop>
|
||
|
|
</order>
|
||
|
|
<transform>
|
||
|
|
<name>Get variables 4 3</name>
|
||
|
|
<type>GetVariable</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<fields>
|
||
|
|
<field>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<variable/>
|
||
|
|
<type>String</type>
|
||
|
|
<format/>
|
||
|
|
<currency/>
|
||
|
|
<decimal/>
|
||
|
|
<group/>
|
||
|
|
<length>-1</length>
|
||
|
|
<precision>-1</precision>
|
||
|
|
<trim_type>none</trim_type>
|
||
|
|
</field>
|
||
|
|
<field>
|
||
|
|
<name>VK_ARRAY</name>
|
||
|
|
<variable/>
|
||
|
|
<type>String</type>
|
||
|
|
<format/>
|
||
|
|
<currency/>
|
||
|
|
<decimal/>
|
||
|
|
<group/>
|
||
|
|
<length>-1</length>
|
||
|
|
<precision>-1</precision>
|
||
|
|
<trim_type>none</trim_type>
|
||
|
|
</field>
|
||
|
|
</fields>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>464</xloc>
|
||
|
|
<yloc>432</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Get variables 4 3 2</name>
|
||
|
|
<type>GetVariable</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<fields>
|
||
|
|
<field>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<variable/>
|
||
|
|
<type>String</type>
|
||
|
|
<format/>
|
||
|
|
<currency/>
|
||
|
|
<decimal/>
|
||
|
|
<group/>
|
||
|
|
<length>-1</length>
|
||
|
|
<precision>-1</precision>
|
||
|
|
<trim_type>none</trim_type>
|
||
|
|
</field>
|
||
|
|
<field>
|
||
|
|
<name>VK_ARRAY</name>
|
||
|
|
<variable/>
|
||
|
|
<type>String</type>
|
||
|
|
<format/>
|
||
|
|
<currency/>
|
||
|
|
<decimal/>
|
||
|
|
<group/>
|
||
|
|
<length>-1</length>
|
||
|
|
<precision>-1</precision>
|
||
|
|
<trim_type>none</trim_type>
|
||
|
|
</field>
|
||
|
|
</fields>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>448</xloc>
|
||
|
|
<yloc>496</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Insert / update (main_dashboard.recruitment_campaign)</name>
|
||
|
|
<type>InsertUpdate</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<connection>ervu-dashboard</connection>
|
||
|
|
<commit>100</commit>
|
||
|
|
<update_bypassed>N</update_bypassed>
|
||
|
|
<lookup>
|
||
|
|
<schema>main_dashboard</schema>
|
||
|
|
<table>recruitment_campaign</table>
|
||
|
|
<key>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<field>recruitment_id</field>
|
||
|
|
<condition>=</condition>
|
||
|
|
<name2/>
|
||
|
|
</key>
|
||
|
|
<value>
|
||
|
|
<name>subpoenas_sent</name>
|
||
|
|
<rename>count_subpoena</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>appeared_on_subpoenas</name>
|
||
|
|
<rename>count_appeared</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>not_appeared_on_subpoenas</name>
|
||
|
|
<rename>count_not_appeared</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>new_recruits</name>
|
||
|
|
<rename>new_recruits</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_have_right</name>
|
||
|
|
<rename>postponement_have_right</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_granted</name>
|
||
|
|
<rename>postponement_granted</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>appeared_on_subpoenas_percent</name>
|
||
|
|
<rename>appeared_on_subpoenas_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>not_appeared_on_subpoenas_percent</name>
|
||
|
|
<rename>not_appeared_on_subpoenas_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_have_right_percent</name>
|
||
|
|
<rename>postponement_have_right_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_granted_percent</name>
|
||
|
|
<rename>postponement_granted_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>recruitment_id</name>
|
||
|
|
<rename>recruitment_id</rename>
|
||
|
|
<update>N</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>spring_autumn</name>
|
||
|
|
<rename>spring_autumn</rename>
|
||
|
|
<update>N</update>
|
||
|
|
</value>
|
||
|
|
</lookup>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>960</xloc>
|
||
|
|
<yloc>432</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Insert / update (main_dashboard.recruitment_campaign) 2</name>
|
||
|
|
<type>InsertUpdate</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<connection>ervu-dashboard</connection>
|
||
|
|
<commit>100</commit>
|
||
|
|
<update_bypassed>N</update_bypassed>
|
||
|
|
<lookup>
|
||
|
|
<schema>main_dashboard</schema>
|
||
|
|
<table>recruitment_campaign</table>
|
||
|
|
<key>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<field>recruitment_id</field>
|
||
|
|
<condition>=</condition>
|
||
|
|
<name2/>
|
||
|
|
</key>
|
||
|
|
<value>
|
||
|
|
<name>subpoenas_sent</name>
|
||
|
|
<rename>count_subpoena</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>appeared_on_subpoenas</name>
|
||
|
|
<rename>count_appeared</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>not_appeared_on_subpoenas</name>
|
||
|
|
<rename>count_not_appeared</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>new_recruits</name>
|
||
|
|
<rename>new_recruits</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_have_right</name>
|
||
|
|
<rename>postponement_have_right</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_granted</name>
|
||
|
|
<rename>postponement_granted</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>appeared_on_subpoenas_percent</name>
|
||
|
|
<rename>appeared_on_subpoenas_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>not_appeared_on_subpoenas_percent</name>
|
||
|
|
<rename>not_appeared_on_subpoenas_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_have_right_percent</name>
|
||
|
|
<rename>postponement_have_right_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>postponement_granted_percent</name>
|
||
|
|
<rename>postponement_granted_percent</rename>
|
||
|
|
<update>Y</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>recruitment_id</name>
|
||
|
|
<rename>recruitment_id</rename>
|
||
|
|
<update>N</update>
|
||
|
|
</value>
|
||
|
|
<value>
|
||
|
|
<name>spring_autumn</name>
|
||
|
|
<rename>spring_autumn</rename>
|
||
|
|
<update>N</update>
|
||
|
|
</value>
|
||
|
|
</lookup>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>960</xloc>
|
||
|
|
<yloc>496</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Select values 4 3</name>
|
||
|
|
<type>SelectValues</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<fields>
|
||
|
|
<select_unspecified>N</select_unspecified>
|
||
|
|
<meta>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<rename>REG_ID</rename>
|
||
|
|
<type>String</type>
|
||
|
|
<length>-2</length>
|
||
|
|
<precision>-2</precision>
|
||
|
|
<conversion_mask/>
|
||
|
|
<date_format_lenient>false</date_format_lenient>
|
||
|
|
<date_format_locale/>
|
||
|
|
<date_format_timezone/>
|
||
|
|
<lenient_string_to_number>false</lenient_string_to_number>
|
||
|
|
<encoding/>
|
||
|
|
<decimal_symbol/>
|
||
|
|
<grouping_symbol/>
|
||
|
|
<currency_symbol/>
|
||
|
|
<storage_type/>
|
||
|
|
</meta>
|
||
|
|
<meta>
|
||
|
|
<name>VK_ARRAY</name>
|
||
|
|
<rename>VK_ARRAY</rename>
|
||
|
|
<type>String</type>
|
||
|
|
<length>-2</length>
|
||
|
|
<precision>-2</precision>
|
||
|
|
<conversion_mask/>
|
||
|
|
<date_format_lenient>false</date_format_lenient>
|
||
|
|
<date_format_locale/>
|
||
|
|
<date_format_timezone/>
|
||
|
|
<lenient_string_to_number>false</lenient_string_to_number>
|
||
|
|
<encoding/>
|
||
|
|
<decimal_symbol/>
|
||
|
|
<grouping_symbol/>
|
||
|
|
<currency_symbol/>
|
||
|
|
<storage_type/>
|
||
|
|
</meta>
|
||
|
|
</fields>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>640</xloc>
|
||
|
|
<yloc>432</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Select values 4 3 2</name>
|
||
|
|
<type>SelectValues</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<fields>
|
||
|
|
<select_unspecified>N</select_unspecified>
|
||
|
|
<meta>
|
||
|
|
<name>REG_ID</name>
|
||
|
|
<rename>REG_ID</rename>
|
||
|
|
<type>String</type>
|
||
|
|
<length>-2</length>
|
||
|
|
<precision>-2</precision>
|
||
|
|
<conversion_mask/>
|
||
|
|
<date_format_lenient>false</date_format_lenient>
|
||
|
|
<date_format_locale/>
|
||
|
|
<date_format_timezone/>
|
||
|
|
<lenient_string_to_number>false</lenient_string_to_number>
|
||
|
|
<encoding/>
|
||
|
|
<decimal_symbol/>
|
||
|
|
<grouping_symbol/>
|
||
|
|
<currency_symbol/>
|
||
|
|
<storage_type/>
|
||
|
|
</meta>
|
||
|
|
<meta>
|
||
|
|
<name>VK_ARRAY</name>
|
||
|
|
<rename>VK_ARRAY</rename>
|
||
|
|
<type>String</type>
|
||
|
|
<length>-2</length>
|
||
|
|
<precision>-2</precision>
|
||
|
|
<conversion_mask/>
|
||
|
|
<date_format_lenient>false</date_format_lenient>
|
||
|
|
<date_format_locale/>
|
||
|
|
<date_format_timezone/>
|
||
|
|
<lenient_string_to_number>false</lenient_string_to_number>
|
||
|
|
<encoding/>
|
||
|
|
<decimal_symbol/>
|
||
|
|
<grouping_symbol/>
|
||
|
|
<currency_symbol/>
|
||
|
|
<storage_type/>
|
||
|
|
</meta>
|
||
|
|
</fields>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>640</xloc>
|
||
|
|
<yloc>496</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Table input (subpoena) регион/весна</name>
|
||
|
|
<type>TableInput</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<connection>postgres.subpoena</connection>
|
||
|
|
<sql>WITH subpoena_data AS (
|
||
|
|
SELECT
|
||
|
|
s.id AS subpoena_id,
|
||
|
|
s.status_id,
|
||
|
|
sr.type,
|
||
|
|
ssh.code AS sub_stat_hist,
|
||
|
|
s.send_date,
|
||
|
|
sh.date_time::timestamp AS history_date,
|
||
|
|
rdi.restriction_document_cancel_id AS restr_dc,
|
||
|
|
rdi.applied_date AS ap_date,
|
||
|
|
rdi.id AS rdi_id,
|
||
|
|
ssi.delivery_code AS d_code,
|
||
|
|
ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn -- добавляем строку для получения последнего статуса
|
||
|
|
FROM public.subpoena s
|
||
|
|
JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id
|
||
|
|
JOIN public.subpoena_status AS ss ON ss.id = s.status_id
|
||
|
|
JOIN public.subpoena_status AS ssh ON ssh.id = sh.status_id
|
||
|
|
JOIN public.subpoena_reason AS sr ON sr.id = s.reason_id
|
||
|
|
LEFT JOIN public.restriction_document AS rd ON rd.subpoena_id = s.id
|
||
|
|
LEFT JOIN public.restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id
|
||
|
|
LEFT JOIN public.subpoena_send_info AS ssi ON ssi.subpoena_id = s.id
|
||
|
|
WHERE sr.type = '1' -- от 18 до 30 лет и нет отсрочки (нужны эти условия), разделение весна/осень
|
||
|
|
AND (
|
||
|
|
'${VK_ARRAY}' IS NULL
|
||
|
|
OR '${VK_ARRAY}' = ''
|
||
|
|
OR s.department_id = ANY (
|
||
|
|
string_to_array(
|
||
|
|
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
|
||
|
|
)::uuid[]
|
||
|
|
)
|
||
|
|
)
|
||
|
|
),
|
||
|
|
last_status AS (
|
||
|
|
SELECT *
|
||
|
|
FROM subpoena_data
|
||
|
|
WHERE rn = 1 -- выбираем только последнюю запись для каждой повестки
|
||
|
|
),
|
||
|
|
t1 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist IS NOT NULL
|
||
|
|
),
|
||
|
|
t2 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_appeared
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist IN ('4.1', '4.2')
|
||
|
|
),
|
||
|
|
t3 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist = '5'
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t1.count_subpoena END AS count_subpoena,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t2.count_appeared END AS count_appeared,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t3.count_not_appeared END AS count_not_appeared,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE ROUND(t2.count_appeared * 100.0 / NULLIF(t1.count_subpoena, 0), 2) END AS appeared_on_subpoenas_percent,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE ROUND(t3.count_not_appeared * 100.0 / NULLIF(t1.count_subpoena, 0), 2) END AS not_appeared_on_subpoenas_percent,
|
||
|
|
0 AS new_recruits,
|
||
|
|
0 AS postponement_have_right,
|
||
|
|
0 AS postponement_granted,
|
||
|
|
0 AS postponement_have_right_percent,
|
||
|
|
0 AS postponement_granted_percent,
|
||
|
|
'Весна' AS spring_autumn,
|
||
|
|
'${REG_ID}' AS recruitment_id,
|
||
|
|
1 AS org
|
||
|
|
FROM t1
|
||
|
|
FULL OUTER JOIN t2 ON 1 = 1
|
||
|
|
FULL OUTER JOIN t3 ON 1 = 1;</sql>
|
||
|
|
<limit>0</limit>
|
||
|
|
<lookup/>
|
||
|
|
<execute_each_row>N</execute_each_row>
|
||
|
|
<variables_active>Y</variables_active>
|
||
|
|
<lazy_conversion_active>N</lazy_conversion_active>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>208</xloc>
|
||
|
|
<yloc>496</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform>
|
||
|
|
<name>Table input (subpoena) регион/осень</name>
|
||
|
|
<type>TableInput</type>
|
||
|
|
<description/>
|
||
|
|
<distribute>Y</distribute>
|
||
|
|
<custom_distribution/>
|
||
|
|
<copies>1</copies>
|
||
|
|
<partitioning>
|
||
|
|
<method>none</method>
|
||
|
|
<schema_name/>
|
||
|
|
</partitioning>
|
||
|
|
<connection>postgres.subpoena</connection>
|
||
|
|
<sql>WITH subpoena_data AS (
|
||
|
|
SELECT
|
||
|
|
s.id AS subpoena_id,
|
||
|
|
s.status_id,
|
||
|
|
sr.type,
|
||
|
|
ssh.code AS sub_stat_hist,
|
||
|
|
s.send_date,
|
||
|
|
sh.date_time::timestamp AS history_date,
|
||
|
|
rdi.restriction_document_cancel_id AS restr_dc,
|
||
|
|
rdi.applied_date AS ap_date,
|
||
|
|
rdi.id AS rdi_id,
|
||
|
|
ssi.delivery_code AS d_code,
|
||
|
|
ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY sh.date_time DESC) AS rn -- добавляем строку для получения последнего статуса
|
||
|
|
FROM public.subpoena s
|
||
|
|
JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id
|
||
|
|
JOIN public.subpoena_status AS ss ON ss.id = s.status_id
|
||
|
|
JOIN public.subpoena_status AS ssh ON ssh.id = sh.status_id
|
||
|
|
JOIN public.subpoena_reason AS sr ON sr.id = s.reason_id
|
||
|
|
LEFT JOIN public.restriction_document AS rd ON rd.subpoena_id = s.id
|
||
|
|
LEFT JOIN public.restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id
|
||
|
|
LEFT JOIN public.subpoena_send_info AS ssi ON ssi.subpoena_id = s.id
|
||
|
|
WHERE sr.type = '1' -- от 18 до 30 лет и нет отсрочки (нужны эти условия), разделение весна/осень
|
||
|
|
AND (
|
||
|
|
'${VK_ARRAY}' IS NULL
|
||
|
|
OR '${VK_ARRAY}' = ''
|
||
|
|
OR s.department_id = ANY (
|
||
|
|
string_to_array(
|
||
|
|
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
|
||
|
|
)::uuid[]
|
||
|
|
)
|
||
|
|
)
|
||
|
|
),
|
||
|
|
last_status AS (
|
||
|
|
SELECT *
|
||
|
|
FROM subpoena_data
|
||
|
|
WHERE rn = 1 -- выбираем только последнюю запись для каждой повестки
|
||
|
|
),
|
||
|
|
t1 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist IS NOT NULL
|
||
|
|
),
|
||
|
|
t2 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_appeared
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist IN ('4.1', '4.2')
|
||
|
|
),
|
||
|
|
t3 AS (
|
||
|
|
SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared
|
||
|
|
FROM last_status
|
||
|
|
WHERE sub_stat_hist = '5'
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t1.count_subpoena END AS count_subpoena,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t2.count_appeared END AS count_appeared,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE t3.count_not_appeared END AS count_not_appeared,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE ROUND(t2.count_appeared * 100.0 / NULLIF(t1.count_subpoena, 0), 2) END AS appeared_on_subpoenas_percent,
|
||
|
|
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE ROUND(t3.count_not_appeared * 100.0 / NULLIF(t1.count_subpoena, 0), 2) END AS not_appeared_on_subpoenas_percent,
|
||
|
|
0 AS new_recruits,
|
||
|
|
0 AS postponement_have_right,
|
||
|
|
0 AS postponement_granted,
|
||
|
|
0 AS postponement_have_right_percent,
|
||
|
|
0 AS postponement_granted_percent,
|
||
|
|
'Осень' AS spring_autumn,
|
||
|
|
'${REG_ID}' AS recruitment_id,
|
||
|
|
1 AS org
|
||
|
|
FROM t1
|
||
|
|
FULL OUTER JOIN t2 ON 1 = 1
|
||
|
|
FULL OUTER JOIN t3 ON 1 = 1;</sql>
|
||
|
|
<limit>0</limit>
|
||
|
|
<lookup/>
|
||
|
|
<execute_each_row>N</execute_each_row>
|
||
|
|
<variables_active>Y</variables_active>
|
||
|
|
<lazy_conversion_active>N</lazy_conversion_active>
|
||
|
|
<attributes/>
|
||
|
|
<cluster_schema/>
|
||
|
|
<GUI>
|
||
|
|
<xloc>208</xloc>
|
||
|
|
<yloc>432</yloc>
|
||
|
|
<draw>Y</draw>
|
||
|
|
</GUI>
|
||
|
|
</transform>
|
||
|
|
<transform_error_handling>
|
||
|
|
</transform_error_handling>
|
||
|
|
<attributes/>
|
||
|
|
</pipeline>
|