Merge remote-tracking branch 'origin/apache_hop_mapping_new' into feature/SUPPORT-8925_query_optimization
* origin/apache_hop_mapping_new: fix # Conflicts: # v1_apache-hop dash mapping/country/total_registered.busyness.hpl # v1_apache-hop dash mapping/mil_district/total_registered.busyness(m_d).hpl # v1_apache-hop dash mapping/region/total_registered.busyness(reg).hpl
This commit is contained in:
commit
26622a953f
10 changed files with 1068 additions and 443 deletions
|
|
@ -1000,7 +1000,7 @@
|
|||
<hop>
|
||||
<from>select_recruitments_country</from>
|
||||
<to>appeals.reasons_appeal.hpl</to>
|
||||
<enabled>Y</enabled>
|
||||
<enabled>N</enabled>
|
||||
<evaluation>Y</evaluation>
|
||||
<unconditional>N</unconditional>
|
||||
</hop>
|
||||
|
|
|
|||
|
|
@ -122,21 +122,31 @@ WHERE recording_date = current_date
|
|||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>REG_ID</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>registered</field>
|
||||
<name>registered</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>busyness</table>
|
||||
|
|
@ -177,12 +187,12 @@ WHERE recording_date = current_date
|
|||
</value>
|
||||
<value>
|
||||
<name>not_work</name>
|
||||
<rename>not_work</rename>
|
||||
<rename>no_info</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_work_percent</name>
|
||||
<rename>not_work_percent</rename>
|
||||
<rename>no_info_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
|
|
@ -198,12 +208,7 @@ WHERE recording_date = current_date
|
|||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts_percent</name>
|
||||
<rename>convicts_percent</rename>
|
||||
<update>Y</update>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
|
|
@ -281,135 +286,63 @@ WHERE recording_date = current_date
|
|||
<connection>ervu-dashboard</connection>
|
||||
<execute_each_row>N</execute_each_row>
|
||||
<limit>0</limit>
|
||||
<sql>WITH
|
||||
a AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
<sql>SELECT
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(study) END AS study,
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(work) END AS work,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS study_percent,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS work_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(not_work) END AS no_info,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS no_info_percent,
|
||||
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY ('${VK_ARRAY}')
|
||||
AND schema = 'Region'
|
||||
AND "all_M_W" IN ('M', 'W')
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered
|
||||
),
|
||||
|
||||
a2 AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY ('${VK_ARRAY}')
|
||||
AND schema = 'Region'
|
||||
AND "all_M_W" = 'ALL'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY registered
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(busyness) END AS total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered,
|
||||
convicts,
|
||||
'Ministry' AS schema
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY (
|
||||
string_to_array(
|
||||
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
|
||||
)::uuid[]
|
||||
)
|
||||
|
||||
SELECT
|
||||
a.study,
|
||||
a.work,
|
||||
a.convicts,
|
||||
a.study_percent,
|
||||
a.work_percent,
|
||||
a.not_work,
|
||||
a.not_work_percent,
|
||||
a.total_people,
|
||||
a.recruitment_id,
|
||||
a.gender,
|
||||
a.registered,
|
||||
'Ministry' AS schema,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN a2.convicts > 0
|
||||
THEN ROUND((a.convicts / a2.convicts * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) AS convicts_percent
|
||||
FROM a
|
||||
LEFT JOIN a2 ON a.recruitment_id = a2.recruitment_id AND a.registered = a2.registered
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
a2.study,
|
||||
a2.work,
|
||||
a2.convicts,
|
||||
a2.study_percent,
|
||||
a2.work_percent,
|
||||
a2.not_work,
|
||||
a2.not_work_percent,
|
||||
a2.total_people,
|
||||
a2.recruitment_id,
|
||||
'ALL' AS gender,
|
||||
a2.registered,
|
||||
'Ministry' AS schema,
|
||||
0 AS convicts_percent
|
||||
FROM a2</sql>
|
||||
AND schema = 'Region'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered, convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
|
|
@ -133,6 +133,11 @@ WHERE recording_date = current_date
|
|||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>education_level</table>
|
||||
<value>
|
||||
|
|
@ -195,6 +200,11 @@ WHERE recording_date = current_date
|
|||
<rename>schema</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
|
|
@ -324,12 +334,13 @@ WHERE recording_date = current_date
|
|||
COALESCE(SUM(education_level)) total,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
convicts,
|
||||
'Ministry' AS schema
|
||||
FROM total_registered.education_level
|
||||
WHERE recruitment_id = ANY ('${VK_ARRAY}')
|
||||
AND schema = 'Region'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W";</sql>
|
||||
GROUP BY "all_M_W", convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,26 @@
|
|||
<to>Insert / update (total_registered.busyness) 2</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Get variables 3 2 2 2</from>
|
||||
<to>Select values 3 2 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Select values 3 2 2 2</from>
|
||||
<to>Insert / update (total_registered.busyness) 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Table input (person_registry) РФ/мужчины 2</from>
|
||||
<to>Get variables 3 2 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Table input (person_registry) РФ/мужчины 2</from>
|
||||
<to>Insert / update (total_registered.busyness) 2 2</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
</order>
|
||||
<transform>
|
||||
<name>Get variables 3 2 2</name>
|
||||
|
|
@ -75,6 +95,39 @@
|
|||
<yloc>624</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Get variables 3 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>REC_ID</name>
|
||||
<precision>-1</precision>
|
||||
<trim_type>none</trim_type>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<length>-1</length>
|
||||
<name>SCM</name>
|
||||
<precision>-1</precision>
|
||||
<trim_type>none</trim_type>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1568</xloc>
|
||||
<yloc>800</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Insert / update (total_registered.busyness) 2</name>
|
||||
<type>InsertUpdate</type>
|
||||
|
|
@ -109,6 +162,11 @@
|
|||
<field>recording_date</field>
|
||||
<name>recording_date</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>busyness</table>
|
||||
<value>
|
||||
|
|
@ -164,12 +222,7 @@
|
|||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts_percent</name>
|
||||
<rename>convicts_percent</rename>
|
||||
<update>Y</update>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
|
|
@ -179,6 +232,110 @@
|
|||
<yloc>544</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Insert / update (total_registered.busyness) 2 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>recruitment_id</field>
|
||||
<name>recruitment_id</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>registered</field>
|
||||
<name>registered</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>recording_date</field>
|
||||
<name>recording_date</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>busyness</table>
|
||||
<value>
|
||||
<name>study</name>
|
||||
<rename>study</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>work</name>
|
||||
<rename>work</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>study_percent</name>
|
||||
<rename>study_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>work_percent</name>
|
||||
<rename>work_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>recruitment_id</name>
|
||||
<rename>recruitment_id</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>registered</name>
|
||||
<rename>registered</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>"all_M_W"</name>
|
||||
<rename>gender</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_work</name>
|
||||
<rename>no_info</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_work_percent</name>
|
||||
<rename>no_info_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>busyness</name>
|
||||
<rename>total_people</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1968</xloc>
|
||||
<yloc>720</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Select values 3 2 2</name>
|
||||
<type>SelectValues</type>
|
||||
|
|
@ -233,6 +390,60 @@
|
|||
<yloc>624</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Select values 3 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>REC_ID</name>
|
||||
<rename>REC_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>SCM</name>
|
||||
<rename>SCM</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>1712</xloc>
|
||||
<yloc>800</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Table input (person_registry) РФ/мужчины</name>
|
||||
<type>TableInput</type>
|
||||
|
|
@ -301,14 +512,15 @@ status_info AS (
|
|||
info->'svedTrud'->>'prOtsSvedTrud' = '1' AS no_info_work,
|
||||
r.target_recruitment_id AS recruitment_id,
|
||||
r.gender,
|
||||
r.vu_current_info -> 'isMilitaryRegistered' AS registered,
|
||||
r.vu_current_info->>'recruitmentCommercialInfo' AS sidit
|
||||
r.vu_current_info -> 'isMilitaryRegistered' AS registered--,
|
||||
--r.vu_current_info->>'recruitmentCommercialInfo' AS sidit
|
||||
FROM public.recruits_info ri
|
||||
JOIN public.recruits r ON ri.recruit_id = r.id
|
||||
WHERE r.vu_current_info -> 'isMilitaryRegistered' IN ('true', 'false')
|
||||
AND r.gender IN ('MALE', 'FEMALE')
|
||||
AND r.current_recruitment_id IS NOT NULL
|
||||
AND r.target_recruitment_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
--AND r.vu_current_info->>'recruitmentCommercialInfo' = 'true' -- осужденные
|
||||
),
|
||||
summary AS (
|
||||
SELECT
|
||||
|
|
@ -328,9 +540,9 @@ summary AS (
|
|||
COUNT(CASE WHEN no_info_vuz AND no_info_college AND no_info_work THEN 1 END) AS no_info,
|
||||
|
||||
-- Общее количество людей
|
||||
COUNT(si.recruitment_id) AS total_people,
|
||||
COUNT(si.recruitment_id) AS total_people
|
||||
|
||||
COUNT(CASE WHEN sidit = 'true' THEN 1 END) AS convicts
|
||||
--COUNT(CASE WHEN sidit = 'true' THEN 1 END) AS convicts
|
||||
|
||||
FROM status_info si
|
||||
GROUP BY si.recruitment_id, si.gender, si.registered
|
||||
|
|
@ -343,8 +555,8 @@ summary_all AS (
|
|||
SUM(study) AS study,
|
||||
SUM(work) AS work,
|
||||
SUM(no_info) AS no_info,
|
||||
SUM(total_people) AS total_people,
|
||||
SUM(convicts) AS convicts
|
||||
SUM(total_people) AS total_people--,
|
||||
--SUM(convicts) AS convicts
|
||||
FROM summary
|
||||
GROUP BY recruitment_id, registered
|
||||
)
|
||||
|
|
@ -357,7 +569,7 @@ SELECT
|
|||
s.work,
|
||||
s.no_info,
|
||||
s.total_people,
|
||||
s.convicts,
|
||||
'ALL' AS convicts,
|
||||
|
||||
-- Процент людей, которые учатся
|
||||
COALESCE(ROUND(s.study * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS study_percent,
|
||||
|
|
@ -366,9 +578,9 @@ SELECT
|
|||
COALESCE(ROUND(s.work * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS work_percent,
|
||||
|
||||
-- Процент людей, для которых отсутствуют сведения
|
||||
COALESCE(ROUND(s.no_info * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS no_info_percent,
|
||||
COALESCE(ROUND(s.no_info * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS no_info_percent--,
|
||||
|
||||
COALESCE(ROUND(s.convicts * 100.0 / NULLIF((select sum(convicts) from summary_all), 0), 2), 0.0) AS convicts_percent
|
||||
--COALESCE(ROUND(s.convicts * 100.0 / NULLIF((select sum(convicts) from summary_all), 0), 2), 0.0) AS convicts_percent
|
||||
|
||||
FROM summary s
|
||||
UNION ALL
|
||||
|
|
@ -381,7 +593,7 @@ SELECT
|
|||
sa.work,
|
||||
sa.no_info,
|
||||
sa.total_people,
|
||||
sa.convicts,
|
||||
'ALL' AS convicts,
|
||||
|
||||
-- Процент людей, которые учатся
|
||||
COALESCE(ROUND(sa.study * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS study_percent,
|
||||
|
|
@ -390,8 +602,8 @@ SELECT
|
|||
COALESCE(ROUND(sa.work * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS work_percent,
|
||||
|
||||
-- Процент людей, для которых отсутствуют сведения
|
||||
COALESCE(ROUND(sa.no_info * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS no_info_percent,
|
||||
'0.0' AS convicts_percent
|
||||
COALESCE(ROUND(sa.no_info * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS no_info_percent--,
|
||||
--'0.0' AS convicts_percent
|
||||
FROM summary_all sa</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
|
|
@ -400,6 +612,202 @@ FROM summary_all sa</sql>
|
|||
<yloc>544</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Table input (person_registry) РФ/мужчины 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
|
||||
ids AS (
|
||||
-- Преобразуем строковый массив в таблицу UUID
|
||||
SELECT unnest(string_to_array(trim(both '{}' from
|
||||
'${ARR_MC}'
|
||||
), ','))::uuid AS recruitment_id
|
||||
),
|
||||
gender_separations AS (
|
||||
SELECT 'MALE' AS gender
|
||||
UNION ALL
|
||||
SELECT 'FEMALE' AS gender
|
||||
),
|
||||
registered_separation AS (
|
||||
SELECT 'true' AS registered
|
||||
UNION ALL
|
||||
SELECT 'false' AS registered
|
||||
),
|
||||
data_combinations AS (
|
||||
-- Создаём все комбинации recruitment_id, gender и registered
|
||||
SELECT
|
||||
i.recruitment_id AS recruitment_id,
|
||||
gs.gender,
|
||||
rs.registered
|
||||
FROM ids i
|
||||
CROSS JOIN gender_separations gs
|
||||
CROSS JOIN registered_separation rs
|
||||
),
|
||||
status_info AS (
|
||||
SELECT
|
||||
-- Проверка на обучение в вузе (есть информация и обучается)
|
||||
(
|
||||
CASE
|
||||
WHEN jsonb_typeof(info->'svedVUZ'->'vuz') = 'array' THEN
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(info->'svedVUZ'->'vuz') AS vuz
|
||||
WHERE vuz->>'kodStatus' = '1'
|
||||
)
|
||||
ELSE false
|
||||
END
|
||||
) AS is_studying_in_vuz,
|
||||
|
||||
-- Проверка на обучение в колледже (есть информация и обучается)
|
||||
(
|
||||
CASE
|
||||
WHEN jsonb_typeof(info->'svedKolledzh'->'kolledzh') = 'array' THEN
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(info->'svedKolledzh'->'kolledzh') AS kolledzh
|
||||
WHERE kolledzh->>'kodStatus' = '1'
|
||||
)
|
||||
ELSE false
|
||||
END
|
||||
) AS is_studying_in_college,
|
||||
|
||||
-- Проверка на работу (есть информация и работает)
|
||||
(
|
||||
CASE
|
||||
WHEN jsonb_typeof(info->'svedTrud'->'trudDeyat') = 'array' THEN
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(info->'svedTrud'->'trudDeyat') AS trud
|
||||
WHERE trud->>'prAktMestRab' = '1'
|
||||
)
|
||||
ELSE false
|
||||
END
|
||||
) AS is_working,
|
||||
-- Проверка на отсутствие сведений о вузе
|
||||
info->'svedVUZ'->>'prOtsSvedVUZ' = '1' AS no_info_vuz,
|
||||
|
||||
-- Проверка на отсутствие сведений о колледже
|
||||
info->'svedKolledzh'->>'prOtsSvedKolledzh' = '1' AS no_info_college,
|
||||
|
||||
-- Проверка на отсутствие сведений о работе
|
||||
info->'svedTrud'->>'prOtsSvedTrud' = '1' AS no_info_work,
|
||||
r.target_recruitment_id AS recruitment_id,
|
||||
r.gender,
|
||||
r.vu_current_info -> 'isMilitaryRegistered' AS registered--,
|
||||
--r.vu_current_info->>'recruitmentCommercialInfo' AS sidit
|
||||
FROM public.recruits_info ri
|
||||
JOIN public.recruits r ON ri.recruit_id = r.id
|
||||
WHERE (r.vu_current_info -> 'isMilitaryRegistered' = 'true' OR r.vu_current_info -> 'isMilitaryRegistered' = 'false')
|
||||
AND (r.gender = 'MALE' OR r.gender = 'FEMALE')
|
||||
AND r.current_recruitment_id IS NOT NULL
|
||||
AND r.target_recruitment_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
AND r.vu_current_info->>'recruitmentCommercialInfo' = 'true' -- осужденные
|
||||
),
|
||||
summary AS (
|
||||
SELECT
|
||||
dc.recruitment_id,
|
||||
CASE
|
||||
WHEN dc.gender = 'MALE' THEN 'M'
|
||||
WHEN dc.gender = 'FEMALE' THEN 'W'
|
||||
ELSE NULL
|
||||
END AS gender,
|
||||
dc.registered,
|
||||
-- Количество людей, которые учатся (в вузе или колледже)
|
||||
COUNT(CASE WHEN is_studying_in_vuz OR is_studying_in_college THEN 1 END) AS study,
|
||||
|
||||
-- Количество людей, которые работают
|
||||
COUNT(CASE WHEN is_working THEN 1 END) AS work,
|
||||
|
||||
-- Количество людей, для которых отсутствуют сведения о вузе, колледже и работе
|
||||
COUNT(CASE WHEN no_info_vuz AND no_info_college AND no_info_work THEN 1 END) AS no_info,
|
||||
|
||||
-- Общее количество людей
|
||||
COUNT(si.recruitment_id) AS total_people
|
||||
|
||||
--COUNT(CASE WHEN sidit = 'true' THEN 1 END) AS convicts
|
||||
|
||||
FROM data_combinations dc
|
||||
LEFT JOIN status_info si
|
||||
ON si.recruitment_id = dc.recruitment_id
|
||||
AND si.gender = dc.gender
|
||||
AND si.registered::text = dc.registered
|
||||
GROUP BY dc.recruitment_id, dc.gender, dc.registered
|
||||
),
|
||||
summary_all AS (
|
||||
SELECT
|
||||
recruitment_id,
|
||||
registered,
|
||||
'ALL' AS gender,
|
||||
SUM(study) AS study,
|
||||
SUM(work) AS work,
|
||||
SUM(no_info) AS no_info,
|
||||
SUM(total_people) AS total_people--,
|
||||
--SUM(convicts) AS convicts
|
||||
FROM summary
|
||||
GROUP BY recruitment_id, registered
|
||||
)
|
||||
SELECT
|
||||
current_date AS recording_date,
|
||||
s.gender,
|
||||
s.registered,
|
||||
s.recruitment_id,
|
||||
s.study,
|
||||
s.work,
|
||||
s.no_info,
|
||||
s.total_people,
|
||||
'CONVICT' AS convicts,
|
||||
|
||||
-- Процент людей, которые учатся
|
||||
COALESCE(ROUND(s.study * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS study_percent,
|
||||
|
||||
-- Процент людей, которые работают
|
||||
COALESCE(ROUND(s.work * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS work_percent,
|
||||
|
||||
-- Процент людей, для которых отсутствуют сведения
|
||||
COALESCE(ROUND(s.no_info * 100.0 / NULLIF(s.total_people, 0), 2), 0.0) AS no_info_percent--,
|
||||
|
||||
--COALESCE(ROUND(s.convicts * 100.0 / NULLIF((select sum(convicts) from summary_all), 0), 2), 0.0) AS convicts_percent
|
||||
|
||||
FROM summary s
|
||||
UNION ALL
|
||||
SELECT
|
||||
current_date AS recording_date,
|
||||
sa.gender,
|
||||
sa.registered,
|
||||
sa.recruitment_id,
|
||||
sa.study,
|
||||
sa.work,
|
||||
sa.no_info,
|
||||
sa.total_people,
|
||||
'CONVICT' AS convicts,
|
||||
|
||||
-- Процент людей, которые учатся
|
||||
COALESCE(ROUND(sa.study * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS study_percent,
|
||||
|
||||
-- Процент людей, которые работают
|
||||
COALESCE(ROUND(sa.work * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS work_percent,
|
||||
|
||||
-- Процент людей, для которых отсутствуют сведения
|
||||
COALESCE(ROUND(sa.no_info * 100.0 / NULLIF(sa.total_people, 0), 2), 0.0) AS no_info_percent--,
|
||||
--'0.0' AS convicts_percent
|
||||
FROM summary_all sa</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1328</xloc>
|
||||
<yloc>720</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform_error_handling>
|
||||
</transform_error_handling>
|
||||
<attributes/>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,26 @@
|
|||
<to>Insert / update (total_registered.education_level) 2</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Get variables 3 2 2 2</from>
|
||||
<to>Select values 3 2 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Select values 3 2 2 2</from>
|
||||
<to>Insert / update (total_registered.education_level) 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Table input (person_registry) РФ/мужчины 2</from>
|
||||
<to>Get variables 3 2 2 2</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Table input (person_registry) РФ/мужчины 2</from>
|
||||
<to>Insert / update (total_registered.education_level) 2 2</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
</order>
|
||||
<transform>
|
||||
<name>Get variables 3 2 2</name>
|
||||
|
|
@ -104,6 +124,11 @@
|
|||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>education_level</table>
|
||||
<value>
|
||||
|
|
@ -161,6 +186,11 @@
|
|||
<rename>total</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
|
|
@ -348,6 +378,7 @@ SELECT
|
|||
WHEN fc.gender = 'MALE' THEN 'M'
|
||||
ELSE 'W'
|
||||
END AS gender,
|
||||
'ALL' AS convicts,
|
||||
fc.recruitment_id,
|
||||
fc.higher,
|
||||
fc.average_prof,
|
||||
|
|
@ -363,6 +394,7 @@ UNION ALL
|
|||
SELECT
|
||||
current_date AS recording_date,
|
||||
fca.gender,
|
||||
'ALL' AS convicts,
|
||||
fca.recruitment_id,
|
||||
fca.higher,
|
||||
fca.average_prof,
|
||||
|
|
@ -381,6 +413,374 @@ FROM final_counts_all fca</sql>
|
|||
<yloc>496</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Get variables 3 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>REC_ID</name>
|
||||
<precision>-1</precision>
|
||||
<trim_type>none</trim_type>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<length>-1</length>
|
||||
<name>SCM</name>
|
||||
<precision>-1</precision>
|
||||
<trim_type>none</trim_type>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1328</xloc>
|
||||
<yloc>880</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Insert / update (total_registered.education_level) 2 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>recruitment_id</field>
|
||||
<name>recruitment_id</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>recording_date</field>
|
||||
<name>recording_date</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>education_level</table>
|
||||
<value>
|
||||
<name>higher</name>
|
||||
<rename>higher</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>average</name>
|
||||
<rename>average_prof</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>"all_M_W"</name>
|
||||
<rename>gender</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>only_general</name>
|
||||
<rename>only_general</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>no_data</name>
|
||||
<rename>count_nodata</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>higher_percent</name>
|
||||
<rename>higher_percentage</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>average_percent</name>
|
||||
<rename>average_prof_percentage</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>only_general_percent</name>
|
||||
<rename>only_general_percentage</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>no_data_percent</name>
|
||||
<rename>count_nodata_percentage</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>recruitment_id</name>
|
||||
<rename>recruitment_id</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>education_level</name>
|
||||
<rename>total</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1728</xloc>
|
||||
<yloc>752</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Select values 3 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>REC_ID</name>
|
||||
<rename>REC_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>SCM</name>
|
||||
<rename>SCM</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>1472</xloc>
|
||||
<yloc>880</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Table input (person_registry) РФ/мужчины 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
|
||||
ids AS (
|
||||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_MC}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
gender_separations AS (
|
||||
SELECT 'MALE' AS gender
|
||||
UNION ALL
|
||||
SELECT 'FEMALE' AS gender
|
||||
),
|
||||
data_combinations AS (
|
||||
SELECT
|
||||
i.recruitment_id AS recruitment_id,
|
||||
gs.gender
|
||||
FROM ids i
|
||||
CROSS JOIN gender_separations gs
|
||||
),
|
||||
education_status AS (
|
||||
SELECT
|
||||
ri.id,
|
||||
r.target_recruitment_id AS recruitment_id,
|
||||
r.gender,
|
||||
-- Высшее образование (российское или иностранное)
|
||||
(
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedRObr'->'robr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedRObr'->'robr') = 'array'
|
||||
AND education->>'kodUrObr' IN ('1', '2', '3', '4', '5')
|
||||
) OR EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedInObr'->'inObr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedInObr'->'inObr') = 'array'
|
||||
AND education->>'kodUrObr' IN ('1', '2', '3', '4', '5')
|
||||
)
|
||||
) AS has_higher,
|
||||
|
||||
-- Среднее профессиональное образование (если нет высшего)
|
||||
(
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedRObr'->'robr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedRObr'->'robr') = 'array'
|
||||
AND education->>'kodUrObr' = '10'
|
||||
) OR EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedInObr'->'inObr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedInObr'->'inObr') = 'array'
|
||||
AND education->>'kodUrObr' = '10'
|
||||
)
|
||||
) AS has_average_prof,
|
||||
|
||||
-- Общее образование (если нет высшего и среднего)
|
||||
(
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedRObr'->'robr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedRObr'->'robr') = 'array'
|
||||
AND education->>'kodUrObr' IN ('7', '9')
|
||||
) OR EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedInObr'->'inObr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedInObr'->'inObr') = 'array'
|
||||
AND education->>'kodUrObr' IN ('7', '9')
|
||||
)
|
||||
) AS has_only_general,
|
||||
|
||||
-- Нет данных об образовании (российское или иностранное)
|
||||
(
|
||||
NOT (
|
||||
(
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedRObr'->'robr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedRObr'->'robr') = 'array'
|
||||
) OR EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedInObr'->'inObr') AS education
|
||||
WHERE jsonb_typeof(ri.info->'svedInObr'->'inObr') = 'array'
|
||||
)
|
||||
)
|
||||
) AND (
|
||||
ri.info->'svedRObr'->>'prOtsRObr' = '1'
|
||||
OR ri.info->'svedInObr'->>'prOtsInObr' = '1'
|
||||
)
|
||||
) AS has_no_data
|
||||
|
||||
FROM public.recruits_info ri
|
||||
JOIN public.recruits r ON ri.recruit_id = r.id
|
||||
WHERE r.vu_current_info->>'isMilitaryRegistered' = 'true'
|
||||
AND (r.gender = 'MALE' OR r.gender = 'FEMALE')
|
||||
AND r.current_recruitment_id IS NOT NULL
|
||||
AND r.target_recruitment_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
AND r.vu_current_info->>'recruitmentCommercialInfo' = 'true' -- осужденные
|
||||
),
|
||||
final_counts AS (
|
||||
SELECT
|
||||
dc.gender,
|
||||
dc.recruitment_id,
|
||||
COUNT(DISTINCT es.id) AS total,
|
||||
COUNT(DISTINCT CASE WHEN es.has_higher THEN es.id END) AS higher,
|
||||
COUNT(DISTINCT CASE WHEN NOT es.has_higher AND es.has_average_prof THEN es.id END) AS average_prof,
|
||||
COUNT(DISTINCT CASE WHEN NOT es.has_higher AND NOT es.has_average_prof AND es.has_only_general THEN es.id END) AS only_general,
|
||||
COUNT(DISTINCT CASE WHEN es.has_no_data THEN es.id END) AS count_nodata
|
||||
FROM data_combinations dc
|
||||
LEFT JOIN education_status es
|
||||
ON dc.recruitment_id = es.recruitment_id
|
||||
AND dc.gender = es.gender
|
||||
GROUP BY dc.recruitment_id, dc.gender
|
||||
),
|
||||
final_counts_all AS (
|
||||
SELECT
|
||||
'ALL' AS gender,
|
||||
recruitment_id,
|
||||
SUM(total) AS total,
|
||||
SUM(higher) AS higher,
|
||||
SUM(average_prof) AS average_prof,
|
||||
SUM(only_general) AS only_general,
|
||||
SUM(count_nodata) AS count_nodata
|
||||
FROM final_counts
|
||||
GROUP BY recruitment_id
|
||||
)
|
||||
SELECT
|
||||
current_date AS recording_date,
|
||||
CASE
|
||||
WHEN fc.gender = 'MALE' THEN 'M'
|
||||
WHEN fc.gender = 'FEMALE' THEN 'W'
|
||||
ELSE NULL
|
||||
END AS gender,
|
||||
'CONVICT' AS convicts,
|
||||
fc.recruitment_id,
|
||||
fc.higher,
|
||||
fc.average_prof,
|
||||
fc.only_general,
|
||||
fc.count_nodata,
|
||||
fc.total,
|
||||
COALESCE(ROUND(fc.higher * 100.0 / NULLIF(fc.total, 0), 2), 0) AS higher_percentage,
|
||||
COALESCE(ROUND(fc.average_prof * 100.0 / NULLIF(fc.total, 0), 2), 0) AS average_prof_percentage,
|
||||
COALESCE(ROUND(fc.only_general * 100.0 / NULLIF(fc.total, 0), 2), 0) AS only_general_percentage,
|
||||
COALESCE(ROUND(fc.count_nodata * 100.0 / NULLIF(fc.total, 0), 2), 0) AS count_nodata_percentage
|
||||
FROM final_counts fc
|
||||
UNION ALL
|
||||
SELECT
|
||||
current_date AS recording_date,
|
||||
fca.gender,
|
||||
'CONVICT' AS convicts,
|
||||
fca.recruitment_id,
|
||||
fca.higher,
|
||||
fca.average_prof,
|
||||
fca.only_general,
|
||||
fca.count_nodata,
|
||||
fca.total,
|
||||
COALESCE(ROUND(fca.higher * 100.0 / NULLIF(fca.total, 0), 2), 0) AS higher_percentage,
|
||||
COALESCE(ROUND(fca.average_prof * 100.0 / NULLIF(fca.total, 0), 2), 0) AS average_prof_percentage,
|
||||
COALESCE(ROUND(fca.only_general * 100.0 / NULLIF(fca.total, 0), 2), 0) AS only_general_percentage,
|
||||
COALESCE(ROUND(fca.count_nodata * 100.0 / NULLIF(fca.total, 0), 2), 0) AS count_nodata_percentage
|
||||
FROM final_counts_all fca</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1072</xloc>
|
||||
<yloc>752</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform_error_handling>
|
||||
</transform_error_handling>
|
||||
<attributes/>
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@
|
|||
<hop>
|
||||
<from>job_get_rows_mildis.hwf</from>
|
||||
<to>appeals.reasons_appeal(m_d).hpl</to>
|
||||
<enabled>Y</enabled>
|
||||
<enabled>N</enabled>
|
||||
<evaluation>Y</evaluation>
|
||||
<unconditional>N</unconditional>
|
||||
</hop>
|
||||
|
|
|
|||
|
|
@ -158,21 +158,31 @@ WHERE recording_date = current_date
|
|||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>MD_ID</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>registered</field>
|
||||
<name>registered</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>busyness</table>
|
||||
|
|
@ -213,12 +223,12 @@ WHERE recording_date = current_date
|
|||
</value>
|
||||
<value>
|
||||
<name>not_work</name>
|
||||
<rename>not_work</rename>
|
||||
<rename>no_info</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_work_percent</name>
|
||||
<rename>not_work_percent</rename>
|
||||
<rename>no_info_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
|
|
@ -234,12 +244,7 @@ WHERE recording_date = current_date
|
|||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts_percent</name>
|
||||
<rename>convicts_percent</rename>
|
||||
<update>Y</update>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
|
|
@ -317,153 +322,63 @@ WHERE recording_date = current_date
|
|||
<connection>ervu-dashboard</connection>
|
||||
<execute_each_row>N</execute_each_row>
|
||||
<limit>0</limit>
|
||||
<sql>WITH
|
||||
a AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
<sql>SELECT
|
||||
CASE WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = '' THEN 0 ELSE SUM(study) END AS study,
|
||||
CASE WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = '' THEN 0 ELSE SUM(work) END AS work,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS study_percent,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS work_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
CASE WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = '' THEN 0 ELSE SUM(not_work) END AS no_info,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS no_info_percent,
|
||||
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${MD_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY ('${MD_ARRAY}')
|
||||
AND "all_M_W" IN ('M', 'W')
|
||||
AND schema = 'Organization'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered
|
||||
),
|
||||
|
||||
a2 AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
CASE
|
||||
WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${MD_ID}' AS recruitment_id,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY ('${MD_ARRAY}')
|
||||
AND "all_M_W" = 'ALL'
|
||||
AND schema = 'Organization'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY registered
|
||||
CASE WHEN '${MD_ARRAY}' IS NULL OR '${MD_ARRAY}' = '' THEN 0 ELSE SUM(busyness) END AS total_people,
|
||||
'${MD_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered,
|
||||
convicts,
|
||||
'Region' AS schema
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY (
|
||||
string_to_array(
|
||||
trim(both '{}' FROM replace('${MD_ARRAY}', ' ', '')), ','
|
||||
)::uuid[]
|
||||
)
|
||||
|
||||
SELECT
|
||||
a.study,
|
||||
a.work,
|
||||
a.convicts,
|
||||
a.study_percent,
|
||||
a.work_percent,
|
||||
a.not_work,
|
||||
a.not_work_percent,
|
||||
a.total_people,
|
||||
a.recruitment_id,
|
||||
a.gender,
|
||||
a.registered,
|
||||
'Region' AS schema,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN a2.convicts > 0
|
||||
THEN ROUND((a.convicts / a2.convicts * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) AS convicts_percent
|
||||
FROM a
|
||||
LEFT JOIN a2 ON a.recruitment_id = a2.recruitment_id AND a.registered = a2.registered
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
a2.study,
|
||||
a2.work,
|
||||
a2.convicts,
|
||||
a2.study_percent,
|
||||
a2.work_percent,
|
||||
a2.not_work,
|
||||
a2.not_work_percent,
|
||||
a2.total_people,
|
||||
a2.recruitment_id,
|
||||
'ALL' AS gender,
|
||||
a2.registered,
|
||||
'Region' AS schema,
|
||||
0 AS convicts_percent
|
||||
FROM a2</sql>
|
||||
AND schema = 'Organization'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered, convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
|
|
@ -167,6 +167,12 @@ WHERE recording_date = current_date
|
|||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>education_level</table>
|
||||
<value>
|
||||
|
|
@ -229,6 +235,11 @@ WHERE recording_date = current_date
|
|||
<rename>schema</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
|
|
@ -346,12 +357,13 @@ WHERE recording_date = current_date
|
|||
COALESCE(SUM(education_level), 0) total,
|
||||
'${MD_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
convicts,
|
||||
'Region' AS schema
|
||||
FROM total_registered.education_level
|
||||
WHERE recruitment_id = ANY ('${MD_ARRAY}')
|
||||
AND schema = 'Organization'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W";</sql>
|
||||
GROUP BY "all_M_W", convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
|
|
@ -88,16 +88,25 @@
|
|||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>REG_ID</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>busyness</table>
|
||||
|
|
@ -138,12 +147,12 @@
|
|||
</value>
|
||||
<value>
|
||||
<name>not_work</name>
|
||||
<rename>not_work</rename>
|
||||
<rename>no_info</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_work_percent</name>
|
||||
<rename>not_work_percent</rename>
|
||||
<rename>no_info_percent</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
|
|
@ -159,12 +168,7 @@
|
|||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>Y</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts_percent</name>
|
||||
<rename>convicts_percent</rename>
|
||||
<update>Y</update>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
|
|
@ -242,135 +246,62 @@
|
|||
<connection>ervu-dashboard</connection>
|
||||
<execute_each_row>N</execute_each_row>
|
||||
<limit>0</limit>
|
||||
<sql>WITH a AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
<sql>SELECT
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(study) END AS study,
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(work) END AS work,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS study_percent,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS work_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY (
|
||||
string_to_array(
|
||||
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
|
||||
)::uuid[]
|
||||
)
|
||||
AND schema IN ('Department', 'REG_LVL')
|
||||
AND "all_M_W" IN ('M', 'W')
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered
|
||||
),
|
||||
a2 AS (
|
||||
SELECT
|
||||
COALESCE(SUM(study), 0) study,
|
||||
COALESCE(SUM(work), 0) work,
|
||||
COALESCE(SUM(convicts), 0) convicts,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(study) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) study_percent,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) work_percent,
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(not_work) END AS no_info,
|
||||
CASE
|
||||
WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = ''
|
||||
THEN 0
|
||||
ELSE COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
)
|
||||
END AS no_info_percent,
|
||||
|
||||
COALESCE(SUM(not_work), 0) not_work,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(busyness) > 0
|
||||
THEN ROUND((SUM(not_work) / SUM(busyness) * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) not_work_percent,
|
||||
COALESCE(SUM(busyness), 0) total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
registered
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY ('${VK_ARRAY}')
|
||||
AND schema IN ('Department', 'REG_LVL')
|
||||
AND "all_M_W" = 'ALL'
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY registered, "all_M_W"
|
||||
CASE WHEN '${VK_ARRAY}' IS NULL OR '${VK_ARRAY}' = '' THEN 0 ELSE SUM(busyness) END AS total_people,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
registered,
|
||||
convicts,
|
||||
'Organization' AS schema
|
||||
FROM total_registered.busyness
|
||||
WHERE recruitment_id = ANY (
|
||||
string_to_array(
|
||||
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
|
||||
)::uuid[]
|
||||
)
|
||||
|
||||
SELECT
|
||||
a.study,
|
||||
a.work,
|
||||
a.convicts,
|
||||
a.study_percent,
|
||||
a.work_percent,
|
||||
a.not_work,
|
||||
a.not_work_percent,
|
||||
a.total_people,
|
||||
a.recruitment_id,
|
||||
a.gender,
|
||||
a.registered,
|
||||
'Organization' AS schema,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN a2.convicts > 0
|
||||
THEN ROUND((a.convicts / a2.convicts * 100), 2)
|
||||
ELSE 0
|
||||
END,
|
||||
0
|
||||
) AS convicts_percent
|
||||
FROM a
|
||||
LEFT JOIN a2 ON a.recruitment_id = a2.recruitment_id AND a.registered = a2.registered
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
a2.study,
|
||||
a2.work,
|
||||
a2.convicts,
|
||||
a2.study_percent,
|
||||
a2.work_percent,
|
||||
a2.not_work,
|
||||
a2.not_work_percent,
|
||||
a2.total_people,
|
||||
a2.recruitment_id,
|
||||
'ALL' AS gender,
|
||||
a2.registered,
|
||||
'Organization' AS schema,
|
||||
0 AS convicts_percent
|
||||
FROM a2</sql>
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W", registered, convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
|
|
@ -88,16 +88,25 @@
|
|||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>REG_ID</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>"all_M_W"</field>
|
||||
<name>gender</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>convicts</field>
|
||||
<name>convicts</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>total_registered</schema>
|
||||
<table>education_level</table>
|
||||
|
|
@ -161,6 +170,11 @@
|
|||
<rename>schema</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
<value>
|
||||
<name>convicts</name>
|
||||
<rename>convicts</rename>
|
||||
<update>N</update>
|
||||
</value>
|
||||
</lookup>
|
||||
<update_bypassed>Y</update_bypassed>
|
||||
<attributes/>
|
||||
|
|
@ -290,12 +304,13 @@
|
|||
COALESCE(SUM(education_level) END AS total,
|
||||
'${REG_ID}' AS recruitment_id,
|
||||
"all_M_W" AS gender,
|
||||
convicts,
|
||||
'Organization' AS schema
|
||||
FROM total_registered.education_level
|
||||
WHERE recruitment_id = ANY ('${VK_ARRAY}')
|
||||
AND schema IN ('Department', 'REG_LVL')
|
||||
AND recording_date = CURRENT_DATE
|
||||
GROUP BY "all_M_W";</sql>
|
||||
GROUP BY "all_M_W", convicts;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue