932 lines
26 KiB
XML
932 lines
26 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
||
<pipeline>
|
||
<info>
|
||
<name>main_dashboard.recruitment_campaign</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>
|
||
<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>
|
||
</info>
|
||
<notepads>
|
||
</notepads>
|
||
<order>
|
||
<hop>
|
||
<from>Sort rows 2 2</from>
|
||
<to>Merge join 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Sort rows 3</from>
|
||
<to>Merge join 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (person_registry) РФ/осень</from>
|
||
<to>Sort rows 3</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (subpoena) РФ/осень</from>
|
||
<to>Sort rows 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Merge join 2</from>
|
||
<to>Insert / update (main_dashboard.recruitment_campaign)</to>
|
||
<enabled>N</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Sort rows 2 2 2</from>
|
||
<to>Merge join 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Sort rows 3 2</from>
|
||
<to>Merge join 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (subpoena) РФ/весна</from>
|
||
<to>Sort rows 2 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Merge join 2 2</from>
|
||
<to>Insert / update (main_dashboard.recruitment_campaign) 2</to>
|
||
<enabled>N</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Table input (person_registry) РФ/весна</from>
|
||
<to>Sort rows 3 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Get variables 2 2</from>
|
||
<to>Select values 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Get variables 2 2 2</from>
|
||
<to>Select values 2 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Merge join 2</from>
|
||
<to>Get variables 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Select values 2 2</from>
|
||
<to>Insert / update (main_dashboard.recruitment_campaign)</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Merge join 2 2</from>
|
||
<to>Get variables 2 2 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
<hop>
|
||
<from>Select values 2 2 2</from>
|
||
<to>Insert / update (main_dashboard.recruitment_campaign) 2</to>
|
||
<enabled>Y</enabled>
|
||
</hop>
|
||
</order>
|
||
<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>
|
||
<commit>100</commit>
|
||
<connection>ervu-dashboard</connection>
|
||
<lookup>
|
||
<key>
|
||
<condition>=</condition>
|
||
<field>spring_autumn</field>
|
||
<name>spring_autumn</name>
|
||
<name2/>
|
||
</key>
|
||
<key>
|
||
<condition>=</condition>
|
||
<field>recruitment_id</field>
|
||
<name>REG_ID</name>
|
||
<name2/>
|
||
</key>
|
||
<schema>main_dashboard</schema>
|
||
<table>recruitment_campaign</table>
|
||
<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>
|
||
<update_bypassed>N</update_bypassed>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>1360</xloc>
|
||
<yloc>128</yloc>
|
||
</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>
|
||
<commit>100</commit>
|
||
<connection>ervu-dashboard</connection>
|
||
<lookup>
|
||
<key>
|
||
<condition>=</condition>
|
||
<field>spring_autumn</field>
|
||
<name>spring_autumn</name>
|
||
<name2/>
|
||
</key>
|
||
<key>
|
||
<condition>=</condition>
|
||
<field>recruitment_id</field>
|
||
<name>REG_ID</name>
|
||
<name2/>
|
||
</key>
|
||
<schema>main_dashboard</schema>
|
||
<table>recruitment_campaign</table>
|
||
<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>
|
||
<update_bypassed>N</update_bypassed>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>1360</xloc>
|
||
<yloc>400</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Merge join 2</name>
|
||
<type>MergeJoin</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<join_type>FULL OUTER</join_type>
|
||
<keys_1>
|
||
<key>org</key>
|
||
</keys_1>
|
||
<keys_2>
|
||
<key>org</key>
|
||
</keys_2>
|
||
<transform1>Sort rows 2 2</transform1>
|
||
<transform2>Sort rows 3</transform2>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>864</xloc>
|
||
<yloc>128</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Merge join 2 2</name>
|
||
<type>MergeJoin</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<join_type>FULL OUTER</join_type>
|
||
<keys_1>
|
||
<key>org</key>
|
||
</keys_1>
|
||
<keys_2>
|
||
<key>org</key>
|
||
</keys_2>
|
||
<transform1>Sort rows 2 2 2</transform1>
|
||
<transform2>Sort rows 3 2</transform2>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>864</xloc>
|
||
<yloc>400</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Sort rows 2 2</name>
|
||
<type>SortRows</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<compress>N</compress>
|
||
<directory>%%java.io.tmpdir%%</directory>
|
||
<fields>
|
||
<field>
|
||
<ascending>Y</ascending>
|
||
<case_sensitive>N</case_sensitive>
|
||
<collator_enabled>N</collator_enabled>
|
||
<collator_strength>0</collator_strength>
|
||
<name>org</name>
|
||
<presorted>N</presorted>
|
||
</field>
|
||
</fields>
|
||
<sort_size>1000000</sort_size>
|
||
<unique_rows>N</unique_rows>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>768</xloc>
|
||
<yloc>128</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Sort rows 2 2 2</name>
|
||
<type>SortRows</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<compress>N</compress>
|
||
<directory>%%java.io.tmpdir%%</directory>
|
||
<fields>
|
||
<field>
|
||
<ascending>Y</ascending>
|
||
<case_sensitive>N</case_sensitive>
|
||
<collator_enabled>N</collator_enabled>
|
||
<collator_strength>0</collator_strength>
|
||
<name>org</name>
|
||
<presorted>N</presorted>
|
||
</field>
|
||
</fields>
|
||
<sort_size>1000000</sort_size>
|
||
<unique_rows>N</unique_rows>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>768</xloc>
|
||
<yloc>400</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Sort rows 3</name>
|
||
<type>SortRows</type>
|
||
<description/>
|
||
<distribute>N</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<compress>N</compress>
|
||
<directory>%%java.io.tmpdir%%</directory>
|
||
<fields>
|
||
<field>
|
||
<ascending>Y</ascending>
|
||
<case_sensitive>N</case_sensitive>
|
||
<collator_enabled>N</collator_enabled>
|
||
<collator_strength>0</collator_strength>
|
||
<name>org</name>
|
||
<presorted>N</presorted>
|
||
</field>
|
||
</fields>
|
||
<sort_size>1000000</sort_size>
|
||
<unique_rows>N</unique_rows>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>752</xloc>
|
||
<yloc>240</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Sort rows 3 2</name>
|
||
<type>SortRows</type>
|
||
<description/>
|
||
<distribute>N</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<compress>N</compress>
|
||
<directory>%%java.io.tmpdir%%</directory>
|
||
<fields>
|
||
<field>
|
||
<ascending>Y</ascending>
|
||
<case_sensitive>N</case_sensitive>
|
||
<collator_enabled>N</collator_enabled>
|
||
<collator_strength>0</collator_strength>
|
||
<name>org</name>
|
||
<presorted>N</presorted>
|
||
</field>
|
||
</fields>
|
||
<sort_size>1000000</sort_size>
|
||
<unique_rows>N</unique_rows>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>752</xloc>
|
||
<yloc>512</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Table input (person_registry) РФ/весна</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>SELECT
|
||
1 AS org,
|
||
COUNT(*) FILTER (
|
||
WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30
|
||
AND gender = 'MALE' -- мужчины от 18 до 30 лет
|
||
AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки
|
||
) AS new_recruits,
|
||
COUNT(*) FILTER (
|
||
WHERE conscription = true
|
||
) AS postponement_granted,
|
||
ROUND(COUNT(*) FILTER (WHERE conscription = true) * 100.0 / NULLIF(COUNT(*) FILTER (
|
||
WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30
|
||
AND gender = 'MALE' -- мужчины от 18 до 30 лет
|
||
AND (conscription IS NULL OR conscription = false)), 0), 2) AS postponement_granted_percent
|
||
FROM public.recruits AS r
|
||
JOIN public.recruits_info AS ri
|
||
ON ri.recruit_id = r.id
|
||
WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true'
|
||
AND r.current_recruitment_id IS NOT NULL
|
||
AND r.target_recruitment_id IS NOT NULL</sql>
|
||
<variables_active>N</variables_active>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>496</xloc>
|
||
<yloc>512</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Table input (person_registry) РФ/осень</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>SELECT
|
||
1 AS org,
|
||
COUNT(*) FILTER (
|
||
WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30
|
||
AND gender = 'MALE' -- мужчины от 18 до 30 лет
|
||
AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки
|
||
) AS new_recruits,
|
||
COUNT(*) FILTER (
|
||
WHERE conscription = true
|
||
) AS postponement_granted,
|
||
ROUND(COUNT(*) FILTER (WHERE conscription = true) * 100.0 / NULLIF(COUNT(*) FILTER (
|
||
WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30
|
||
AND gender = 'MALE' -- мужчины от 18 до 30 лет
|
||
AND (conscription IS NULL OR conscription = false)), 0), 2) AS postponement_granted_percent
|
||
FROM public.recruits AS r
|
||
JOIN public.recruits_info AS ri
|
||
ON ri.recruit_id = r.id
|
||
WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true'
|
||
AND r.current_recruitment_id IS NOT NULL
|
||
AND r.target_recruitment_id IS NOT NULL</sql>
|
||
<variables_active>N</variables_active>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>496</xloc>
|
||
<yloc>240</yloc>
|
||
</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>
|
||
<execute_each_row>N</execute_each_row>
|
||
<limit>0</limit>
|
||
<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,
|
||
s.recruit_id, -- recruit_id добавляем, если есть
|
||
sh.date_time
|
||
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 = '3'
|
||
AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30
|
||
),
|
||
last_status_data AS (
|
||
-- Выбираем последнюю дату истории для каждой subpoena
|
||
SELECT
|
||
s.subpoena_id,
|
||
MAX(s.history_date) AS last_history_date
|
||
FROM subpoena_data s
|
||
GROUP BY s.subpoena_id
|
||
),
|
||
last_status AS (
|
||
-- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи
|
||
SELECT
|
||
sd.*
|
||
FROM subpoena_data sd
|
||
JOIN last_status_data lsd
|
||
ON sd.subpoena_id = lsd.subpoena_id
|
||
AND sd.history_date = lsd.last_history_date
|
||
),
|
||
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 in ('5', '5.1')
|
||
),
|
||
t4 AS (
|
||
SELECT COUNT(DISTINCT recruit_id) AS new_recruits
|
||
FROM subpoena_data
|
||
)
|
||
SELECT
|
||
t1.count_subpoena,
|
||
t2.count_appeared,
|
||
t3.count_not_appeared,
|
||
ROUND(count_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS appeared_on_subpoenas_percent,
|
||
ROUND(count_not_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS not_appeared_on_subpoenas_percent,
|
||
-- t4.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
|
||
JOIN t2 ON true
|
||
JOIN t3 ON true
|
||
JOIN t4 ON true;</sql>
|
||
<variables_active>Y</variables_active>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>496</xloc>
|
||
<yloc>400</yloc>
|
||
</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>
|
||
<execute_each_row>N</execute_each_row>
|
||
<limit>0</limit>
|
||
<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,
|
||
s.recruit_id, -- recruit_id добавляем, если есть
|
||
sh.date_time
|
||
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 = '3' -- статус изменен на 3
|
||
AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30
|
||
),
|
||
last_status_data AS (
|
||
-- Выбираем последнюю дату истории для каждой subpoena
|
||
SELECT
|
||
s.subpoena_id,
|
||
MAX(s.history_date) AS last_history_date
|
||
FROM subpoena_data s
|
||
GROUP BY s.subpoena_id
|
||
),
|
||
last_status AS (
|
||
-- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи
|
||
SELECT
|
||
sd.*
|
||
FROM subpoena_data sd
|
||
JOIN last_status_data lsd
|
||
ON sd.subpoena_id = lsd.subpoena_id
|
||
AND sd.history_date = lsd.last_history_date
|
||
),
|
||
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 in ('5', '5.1') -- добавлен статус 5.1
|
||
),
|
||
t4 AS (
|
||
SELECT COUNT(DISTINCT recruit_id) AS new_recruits
|
||
FROM subpoena_data
|
||
)
|
||
SELECT
|
||
t1.count_subpoena,
|
||
t2.count_appeared,
|
||
t3.count_not_appeared,
|
||
ROUND(count_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS appeared_on_subpoenas_percent,
|
||
ROUND(count_not_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS not_appeared_on_subpoenas_percent,
|
||
-- t4.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
|
||
JOIN t2 ON true
|
||
JOIN t3 ON true
|
||
JOIN t4 ON true;</sql>
|
||
<variables_active>Y</variables_active>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>496</xloc>
|
||
<yloc>128</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Get variables 2 2</name>
|
||
<type>GetVariable</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<field>
|
||
<length>-1</length>
|
||
<name>REG_ID</name>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
<type>String</type>
|
||
</field>
|
||
<field>
|
||
<length>-1</length>
|
||
<name>VK_ARRAY</name>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
<type>String</type>
|
||
</field>
|
||
</fields>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>1008</xloc>
|
||
<yloc>208</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Select values 2 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/>
|
||
<GUI>
|
||
<xloc>1216</xloc>
|
||
<yloc>208</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Get variables 2 2 2</name>
|
||
<type>GetVariable</type>
|
||
<description/>
|
||
<distribute>Y</distribute>
|
||
<custom_distribution/>
|
||
<copies>1</copies>
|
||
<partitioning>
|
||
<method>none</method>
|
||
<schema_name/>
|
||
</partitioning>
|
||
<fields>
|
||
<field>
|
||
<length>-1</length>
|
||
<name>REG_ID</name>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
<type>String</type>
|
||
</field>
|
||
<field>
|
||
<length>-1</length>
|
||
<name>VK_ARRAY</name>
|
||
<precision>-1</precision>
|
||
<trim_type>none</trim_type>
|
||
<type>String</type>
|
||
</field>
|
||
</fields>
|
||
<attributes/>
|
||
<GUI>
|
||
<xloc>1008</xloc>
|
||
<yloc>496</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform>
|
||
<name>Select values 2 2 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/>
|
||
<GUI>
|
||
<xloc>1216</xloc>
|
||
<yloc>496</yloc>
|
||
</GUI>
|
||
</transform>
|
||
<transform_error_handling>
|
||
</transform_error_handling>
|
||
<attributes/>
|
||
</pipeline>
|