sozsoft-platform/configs/seeds/postgres/object/Hr_S_PerformanceFeedbackOpen.sql
2026-10-19 17:35:08 +03:00

31 lines
1.3 KiB
PL/PgSQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE OR REPLACE PROCEDURE public."Hr_S_PerformanceFeedbackOpen"(
p_FeedbackId uuid,
p_ActorId uuid DEFAULT NULL
)
LANGUAGE plpgsql
AS $$
DECLARE
v_ReviewId uuid;
v_ReviewerId uuid;
BEGIN
SELECT "ReviewId", "ReviewerId" INTO v_ReviewId, v_ReviewerId
FROM "Hr_T_PerformanceFeedback"
WHERE "Id" = p_FeedbackId AND "IsDeleted" = FALSE;
IF v_ReviewId IS NULL THEN
RETURN;
END IF;
-- Değerlendirici, değerlendirmenin yetkinlikleri üzerinden puan verir; satırlar burada açılır.
INSERT INTO "Hr_T_PerformanceFeedbackScore" ("Id", "TenantId", "FeedbackId", "SkillId", "IsActive", "CreationTime", "CreatorId", "IsDeleted")
SELECT gen_random_uuid(), c."TenantId", p_FeedbackId, c."SkillId", TRUE, NOW() AT TIME ZONE 'UTC', p_ActorId, FALSE
FROM "Hr_T_PerformanceCompetency" c
WHERE c."ReviewId" = v_ReviewId AND c."IsDeleted" = FALSE
AND NOT EXISTS (
SELECT 1 FROM "Hr_T_PerformanceFeedbackScore" s
WHERE s."FeedbackId" = p_FeedbackId AND s."SkillId" = c."SkillId" AND s."IsDeleted" = FALSE);
CALL public."Hr_S_PerformanceNotify"(v_ReviewId, v_ReviewerId, 'Performans360Talebi',
'Hr.Performance.Notification.Feedback.Subject', 'Hr.Performance.Notification.Feedback.Message', p_ActorId);
END
$$;