fix
This commit is contained in:
parent
d9a39775f8
commit
a41c881d33
5 changed files with 25 additions and 25 deletions
|
|
@ -130,7 +130,7 @@ ids AS (
|
|||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_PR_1}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
r_ids AS (SELECT id as recruit_id, gender, birth_date,target_recruitment_id from public.recruits
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id = (SELECT recruitment_id FROM ids))
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id IN (SELECT recruitment_id FROM ids))
|
||||
AND current_recruitment_id is null
|
||||
),
|
||||
last_status as (select recruit_id,
|
||||
|
|
@ -162,7 +162,7 @@ vse AS (
|
|||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedFL'->'svedPND'->'svedUchetDisp'->'svedUchet') AS uchet_pnd
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
)
|
||||
ELSE
|
||||
false
|
||||
|
|
@ -177,7 +177,7 @@ vse AS (
|
|||
ON ri.recruit_id = r.recruit_id
|
||||
JOIN public.recruits_history rh on rh.recruit_id=r.recruit_id
|
||||
LEFT JOIN public.decision_deferment_dto ddd ON ddd.recruit_id = r.recruit_id
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid = (SELECT recruitment_id FROM ids)
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid IN (SELECT recruitment_id FROM ids)
|
||||
),
|
||||
extracted_children AS (
|
||||
SELECT
|
||||
|
|
@ -199,7 +199,7 @@ children_count AS (
|
|||
recruit_id,
|
||||
COUNT(*) AS children_under_16
|
||||
FROM children_birth_dates
|
||||
WHERE AGE(make_date(year, month, day)) &lt; interval '16 years'
|
||||
WHERE AGE(make_date(year, month, day)) < interval '16 years'
|
||||
GROUP BY recruit_id
|
||||
),
|
||||
recruit_data AS (
|
||||
|
|
@ -211,7 +211,7 @@ recruit_data AS (
|
|||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 50 AND gender = 'MALE') -- мужчины от 30 до 50 лет
|
||||
OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 45 AND gender = 'FEMALE') -- женщины от 30 до 45 лет
|
||||
AND COALESCE(cc.children_under_16, 0) &lt; 5
|
||||
AND COALESCE(cc.children_under_16, 0) < 5
|
||||
) AS mobilization_criterion, -- критерии от 03.06.2025
|
||||
|
||||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ ids AS (
|
|||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_PR_2}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
r_ids AS (SELECT id as recruit_id, gender, birth_date,target_recruitment_id from public.recruits
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id = (SELECT recruitment_id FROM ids))
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id IN (SELECT recruitment_id FROM ids))
|
||||
AND current_recruitment_id is null
|
||||
),
|
||||
last_status as (select recruit_id,
|
||||
|
|
@ -162,7 +162,7 @@ vse AS (
|
|||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedFL'->'svedPND'->'svedUchetDisp'->'svedUchet') AS uchet_pnd
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' &lt;= current_date::text
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
)
|
||||
ELSE
|
||||
false
|
||||
|
|
@ -177,7 +177,7 @@ vse AS (
|
|||
ON ri.recruit_id = r.recruit_id
|
||||
JOIN public.recruits_history rh on rh.recruit_id=r.recruit_id
|
||||
LEFT JOIN public.decision_deferment_dto ddd ON ddd.recruit_id = r.recruit_id
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid = (SELECT recruitment_id FROM ids)
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid IN (SELECT recruitment_id FROM ids)
|
||||
),
|
||||
extracted_children AS (
|
||||
SELECT
|
||||
|
|
@ -199,7 +199,7 @@ children_count AS (
|
|||
recruit_id,
|
||||
COUNT(*) AS children_under_16
|
||||
FROM children_birth_dates
|
||||
WHERE AGE(make_date(year, month, day)) &lt; interval '16 years'
|
||||
WHERE AGE(make_date(year, month, day)) < interval '16 years'
|
||||
GROUP BY recruit_id
|
||||
),
|
||||
recruit_data AS (
|
||||
|
|
@ -211,7 +211,7 @@ recruit_data AS (
|
|||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 50 AND gender = 'MALE') -- мужчины от 30 до 50 лет
|
||||
OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 45 AND gender = 'FEMALE') -- женщины от 30 до 45 лет
|
||||
AND COALESCE(cc.children_under_16, 0) &lt; 5
|
||||
AND COALESCE(cc.children_under_16, 0) < 5
|
||||
) AS mobilization_criterion, -- критерии от 03.06.2025
|
||||
|
||||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ ids AS (
|
|||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_PR_3}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
r_ids AS (SELECT id as recruit_id, gender, birth_date,target_recruitment_id from public.recruits
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id = (SELECT recruitment_id FROM ids))
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id IN (SELECT recruitment_id FROM ids))
|
||||
AND current_recruitment_id is null
|
||||
),
|
||||
last_status as (select recruit_id,
|
||||
|
|
@ -162,7 +162,7 @@ vse AS (
|
|||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedFL'->'svedPND'->'svedUchetDisp'->'svedUchet') AS uchet_pnd
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' &lt;= current_date::text
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
)
|
||||
ELSE
|
||||
false
|
||||
|
|
@ -177,7 +177,7 @@ vse AS (
|
|||
ON ri.recruit_id = r.recruit_id
|
||||
JOIN public.recruits_history rh on rh.recruit_id=r.recruit_id
|
||||
LEFT JOIN public.decision_deferment_dto ddd ON ddd.recruit_id = r.recruit_id
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid = (SELECT recruitment_id FROM ids)
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid IN (SELECT recruitment_id FROM ids)
|
||||
),
|
||||
extracted_children AS (
|
||||
SELECT
|
||||
|
|
@ -199,7 +199,7 @@ children_count AS (
|
|||
recruit_id,
|
||||
COUNT(*) AS children_under_16
|
||||
FROM children_birth_dates
|
||||
WHERE AGE(make_date(year, month, day)) &lt; interval '16 years'
|
||||
WHERE AGE(make_date(year, month, day)) < interval '16 years'
|
||||
GROUP BY recruit_id
|
||||
),
|
||||
recruit_data AS (
|
||||
|
|
@ -211,7 +211,7 @@ recruit_data AS (
|
|||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 50 AND gender = 'MALE') -- мужчины от 30 до 50 лет
|
||||
OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 45 AND gender = 'FEMALE') -- женщины от 30 до 45 лет
|
||||
AND COALESCE(cc.children_under_16, 0) &lt; 5
|
||||
AND COALESCE(cc.children_under_16, 0) < 5
|
||||
) AS mobilization_criterion, -- критерии от 03.06.2025
|
||||
|
||||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ ids AS (
|
|||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_PR_4}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
r_ids AS (SELECT id as recruit_id, gender, birth_date,target_recruitment_id from public.recruits
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id = (SELECT recruitment_id FROM ids))
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id IN (SELECT recruitment_id FROM ids))
|
||||
AND current_recruitment_id is null
|
||||
),
|
||||
last_status as (select recruit_id,
|
||||
|
|
@ -162,7 +162,7 @@ vse AS (
|
|||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedFL'->'svedPND'->'svedUchetDisp'->'svedUchet') AS uchet_pnd
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' &lt;= current_date::text
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
)
|
||||
ELSE
|
||||
false
|
||||
|
|
@ -177,7 +177,7 @@ vse AS (
|
|||
ON ri.recruit_id = r.recruit_id
|
||||
JOIN public.recruits_history rh on rh.recruit_id=r.recruit_id
|
||||
LEFT JOIN public.decision_deferment_dto ddd ON ddd.recruit_id = r.recruit_id
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid = (SELECT recruitment_id FROM ids)
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid IN (SELECT recruitment_id FROM ids)
|
||||
),
|
||||
extracted_children AS (
|
||||
SELECT
|
||||
|
|
@ -199,7 +199,7 @@ children_count AS (
|
|||
recruit_id,
|
||||
COUNT(*) AS children_under_16
|
||||
FROM children_birth_dates
|
||||
WHERE AGE(make_date(year, month, day)) &lt; interval '16 years'
|
||||
WHERE AGE(make_date(year, month, day)) < interval '16 years'
|
||||
GROUP BY recruit_id
|
||||
),
|
||||
recruit_data AS (
|
||||
|
|
@ -211,7 +211,7 @@ recruit_data AS (
|
|||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 50 AND gender = 'MALE') -- мужчины от 30 до 50 лет
|
||||
OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 45 AND gender = 'FEMALE') -- женщины от 30 до 45 лет
|
||||
AND COALESCE(cc.children_under_16, 0) &lt; 5
|
||||
AND COALESCE(cc.children_under_16, 0) < 5
|
||||
) AS mobilization_criterion, -- критерии от 03.06.2025
|
||||
|
||||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ ids AS (
|
|||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_PR_5}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
r_ids AS (SELECT id as recruit_id, gender, birth_date,target_recruitment_id from public.recruits
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id = (SELECT recruitment_id FROM ids))
|
||||
where (target_recruitment_id IS NULL OR target_recruitment_id IN (SELECT recruitment_id FROM ids))
|
||||
AND current_recruitment_id is null
|
||||
),
|
||||
last_status as (select recruit_id,
|
||||
|
|
@ -162,7 +162,7 @@ vse AS (
|
|||
EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(ri.info->'svedFL'->'svedPND'->'svedUchetDisp'->'svedUchet') AS uchet_pnd
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' &lt;= current_date::text
|
||||
WHERE uchet_pnd->>'dataSnyatUchet' <= current_date::text
|
||||
)
|
||||
ELSE
|
||||
false
|
||||
|
|
@ -177,7 +177,7 @@ vse AS (
|
|||
ON ri.recruit_id = r.recruit_id
|
||||
JOIN public.recruits_history rh on rh.recruit_id=r.recruit_id
|
||||
LEFT JOIN public.decision_deferment_dto ddd ON ddd.recruit_id = r.recruit_id
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid = (SELECT recruitment_id FROM ids)
|
||||
WHERE coalesce(r.target_recruitment_id,rh.target_recruitment_id) ::uuid IN (SELECT recruitment_id FROM ids)
|
||||
),
|
||||
extracted_children AS (
|
||||
SELECT
|
||||
|
|
@ -199,7 +199,7 @@ children_count AS (
|
|||
recruit_id,
|
||||
COUNT(*) AS children_under_16
|
||||
FROM children_birth_dates
|
||||
WHERE AGE(make_date(year, month, day)) &lt; interval '16 years'
|
||||
WHERE AGE(make_date(year, month, day)) < interval '16 years'
|
||||
GROUP BY recruit_id
|
||||
),
|
||||
recruit_data AS (
|
||||
|
|
@ -211,7 +211,7 @@ recruit_data AS (
|
|||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
WHERE (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 50 AND gender = 'MALE') -- мужчины от 30 до 50 лет
|
||||
OR (EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 30 AND 45 AND gender = 'FEMALE') -- женщины от 30 до 45 лет
|
||||
AND COALESCE(cc.children_under_16, 0) &lt; 5
|
||||
AND COALESCE(cc.children_under_16, 0) < 5
|
||||
) AS mobilization_criterion, -- критерии от 03.06.2025
|
||||
|
||||
COUNT(distinct ri.recruit_id) FILTER (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue