fix count subpoena
This commit is contained in:
parent
a10d61856c
commit
69ac3a2072
10 changed files with 295 additions and 121 deletions
|
|
@ -78,15 +78,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -95,7 +100,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -85,15 +85,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -102,7 +107,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids WHERE spring_autumn = 'Весна')
|
||||
|
|
@ -146,15 +151,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -163,7 +173,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND /*rdi.rn_di = 1 AND*/ ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids WHERE spring_autumn = 'Осень')
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@
|
|||
<hop>
|
||||
<from>Table input (subpoena) осень/регионы</from>
|
||||
<to>Insert / update (recruitment_campaign.subpoenas) 3</to>
|
||||
<enabled>N</enabled>
|
||||
</hop>
|
||||
<hop>
|
||||
<from>Table input (subpoena) осень/регионы</from>
|
||||
<to>Update recruitment_campaign.subpoenas</to>
|
||||
<enabled>Y</enabled>
|
||||
</hop>
|
||||
</order>
|
||||
|
|
@ -319,15 +324,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -336,7 +346,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
@ -561,6 +571,115 @@ LEFT JOIN t13 ON ss.recruitment_id = t13.recruitment_id AND ss.spring_autumn = t
|
|||
<yloc>400</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform>
|
||||
<name>Update recruitment_campaign.subpoenas</name>
|
||||
<type>Update</type>
|
||||
<description/>
|
||||
<distribute>Y</distribute>
|
||||
<custom_distribution/>
|
||||
<copies>1</copies>
|
||||
<partitioning>
|
||||
<method>none</method>
|
||||
<schema_name/>
|
||||
</partitioning>
|
||||
<commit>100</commit>
|
||||
<connection>ervu-dashboard</connection>
|
||||
<error_ignored>Y</error_ignored>
|
||||
<lookup>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>recruitment_id</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>spring_autumn</field>
|
||||
<name>spring_autumn</name>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>recording_date</field>
|
||||
<name>recording_date</name>
|
||||
</key>
|
||||
<schema>recruitment_campaign</schema>
|
||||
<table>subpoenas</table>
|
||||
<value>
|
||||
<name>subpoena</name>
|
||||
<rename>count_subpoena</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>appeared</name>
|
||||
<rename>count_appeared</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_appeared</name>
|
||||
<rename>count_not_appeared</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_ap_good_reason</name>
|
||||
<rename>count_not_ap_good_reason</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>ap_not_required</name>
|
||||
<rename>count_ap_not_required</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>restrictions_applied</name>
|
||||
<rename>count_restrictions_applied</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>appeared_percent</name>
|
||||
<rename>appeared_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_appeared_percent</name>
|
||||
<rename>not_appeared_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_ap_good_reason_percent</name>
|
||||
<rename>not_ap_good_reason_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>ap_not_required_percent</name>
|
||||
<rename>ap_not_required_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>restrictions_applied_percent</name>
|
||||
<rename>restrictions_applied_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>introduced_measures</name>
|
||||
<rename>count_introduced_measures</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>introduced_measures_percent</name>
|
||||
<rename>introduced_measures_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>count_not_delivery</name>
|
||||
<rename>count_not_delivery</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>appear_date_is_good</name>
|
||||
<rename>appear_date_is_good</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>not_delivery_percent</name>
|
||||
<rename>not_delivery_percent</rename>
|
||||
</value>
|
||||
<value>
|
||||
<name>appear_date_is_good_percent</name>
|
||||
<rename>appear_date_is_good_percent</rename>
|
||||
</value>
|
||||
</lookup>
|
||||
<skip_lookup>N</skip_lookup>
|
||||
<use_batch>Y</use_batch>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>960</xloc>
|
||||
<yloc>240</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
<transform_error_handling>
|
||||
</transform_error_handling>
|
||||
<attributes/>
|
||||
|
|
|
|||
|
|
@ -331,15 +331,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -348,7 +353,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND /*rdi.rn_di = 1 AND */ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids WHERE spring_autumn = 'Весна')
|
||||
|
|
@ -392,15 +397,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -409,7 +419,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type = '3'
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids WHERE spring_autumn = 'Осень')
|
||||
|
|
@ -749,7 +759,7 @@ LEFT JOIN t13 ON ss.recruitment_id = t13.recruitment_id AND ss.spring_autumn = t
|
|||
<use_batch>Y</use_batch>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
<xloc>1040</xloc>
|
||||
<xloc>1056</xloc>
|
||||
<yloc>400</yloc>
|
||||
</GUI>
|
||||
</transform>
|
||||
|
|
|
|||
|
|
@ -343,15 +343,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -360,7 +365,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -241,15 +241,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -258,7 +263,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -241,15 +241,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -258,7 +263,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -241,15 +241,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -258,7 +263,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -241,15 +241,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -258,7 +263,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
|
|
@ -241,15 +241,20 @@ subpoena_data AS (
|
|||
id
|
||||
FROM restriction_document
|
||||
) AS rd ON rd.subpoena_id = s.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM restriction_document_item
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
restriction_document_create_id,
|
||||
restriction_document_cancel_id,
|
||||
applied_date,
|
||||
id
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY restriction_document_create_id ORDER BY created_at DESC) AS rn_di,
|
||||
*
|
||||
FROM restriction_document_item
|
||||
) sub
|
||||
WHERE rn_di = 1
|
||||
) AS rdi ON rdi.restriction_document_create_id = rd.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY subpoena_id ORDER BY send_date DESC) AS rn_si,
|
||||
|
|
@ -258,7 +263,7 @@ subpoena_data AS (
|
|||
act_number
|
||||
FROM subpoena_send_info
|
||||
) AS ssi ON ssi.subpoena_id = s.id
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 AND rdi.rn_di = 1 AND ssi.rn_si = 1
|
||||
WHERE sh.rn = 1 AND rd.rn_d = 1 /*AND rdi.rn_di = 1*/ AND ssi.rn_si = 1
|
||||
AND sr.type IS NOT NULL
|
||||
AND ssh.code NOT IN ('3.7','3.72', '3.71') -- 3.14 снесено от 14.03.2025
|
||||
AND s.department_id::uuid IN (SELECT recruitment_id FROM ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue