ред скрипт для отпуска в справочнике уведомлений

This commit is contained in:
mirzakaev_tf 2023-04-17 11:09:16 +05:00
parent 0a0d074df6
commit 86a3739a45
1 changed files with 47 additions and 58 deletions

View File

@ -50,73 +50,62 @@
Пример: Пример:
``` ```
iinsert into "#forInsNotification" ("DocflowUser", "txt", "Link", "DocType", "DocName", "DocSubject", "IdWorker", "DateBeg", "Days", "TypeVacation", "Vacation", "DateEnd", "CopyTo") insert into "#forInsNotification" ("DocflowUser", "txt", "Link", "DocType", "DocName", "DocSubject", "IdWorker", "DateBeg", "Days", "TypeVacation", "Vacation", "DateEnd", "CopyTo", "txtSMS", "txtTelegram")
select pc_ch."Code" as "User", '<font size="4"> </font><p style="text-align: center;">' || p_ch."Name" || ' ' || coalesce(p_ch."Father", '') || ', добрый день!</p><p style="text-align: center;"><br></p> select pc_ch."Code" as "User", null as "txt",
p."VCode" as "link",p."TypeName", null /*case when "TypeName" = 'Base.RP_DocVacationChanges' then 'Переносы отпусков' else 'График отпусков' end*/,
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;На основании
статьи 123 Трудового кодекса Российской Федерации и согласно утвержденному&nbsp;графику отпусков на ' || p."Year"::text ||' год информируем о дате начала Вашего оплачиваемого отпуска (<b>' || coalesce(tw."Name",ex.name1c,'')||') </b> с <strong>' || to_char(coalesce(m."DateBegPer",m."DateBeg")::date, 'DD.MM.YYYY') || '</strong> сроком на <strong>' || coalesce(m."DaysPer",m."Days")::text
|| '</strong> календарных
дня(ей). Дата выхода на работу <strong>' ||to_char((coalesce(m."DateEndPer",m."DateEnd") + '1 day'::interval)::date, 'DD.MM.YYYY')
|| '</strong>. В случае, если дата выхода на
работу приходится на выходной день, она переносится на ближайший рабочий день.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ВАЖНО! </p>
<p><em>В связи с
вышеизложенным Вам следует подать заявление о предоставлении отпуска для
своевременного проведения расчетов и подготовки соответствующих документов. </em></p>
<p><em>Если Вы не
планируете использовать отпуск в указанные даты, обязательно сформируйте
заявление о переносе отпуска. </em></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Заявление на
отпуск или перенос отпуска необходимо сформировать в системе КЭДО Lexema по
соответствующей операции через кнопку «Операции» на панели инструментов данного
уведомления.</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Уведомление
можно закрыть только после выполнения одного из действий.</strong></p>
<p><br>
Приятного отдыха! </p>
<font size="4"></font>' as txt,
p."VCode" as "link",p."TypeName",
null /*case when "TypeName" = 'Base.RP_DocVacationChanges' then 'Переносы отпусков' else 'График отпусков' end*/,
null, /*'Уведомление работника о времени начала отпуска',*/ null, /*'Уведомление работника о времени начала отпуска',*/
m."IdWorker", m."IdWorker", coalesce(m."DateBegPer",m."DateBeg")::date, coalesce(m."DaysPer",m."Days"), m."HolidayTypeGuid", coalesce(tw."Name",ex.name1c), coalesce(m."DateEndPer",m."DateEnd") , null, null as "txtSMS", null as "txtTelegram"
coalesce(m."DateBegPer",m."DateBeg")::date as "DateBeg", coalesce(m."DaysPer",m."Days") as "Days",
m."HolidayTypeGuid", coalesce(tw."Name",ex.name1c), coalesce(m."DateEndPer",m."DateEnd") as "DateEnd", null as "CopyTo"
from aw."RP_DocVacation" p from aw."RP_DocVacation" p
join aw."RP_WorkerVacation" m on p."VCode" = m."Pcode" join aw."RP_WorkerVacation" m on p."VCode" = m."Pcode"
cross join (select (now() + '1 day'::interval)::date as bd, (now() + '6 day'::interval)::date as ed ) dt cross join (select (now() + '8 day'::interval)::date as bd, (now() + '8 day'::interval)::date as ed ) dt
cross join (select "LocationProtocol" || '//' || "LocationHostName" as "link_txt" from comdoc."DocflowSettings") l cross join (select "LocationProtocol" || '//' || "LocationHostName" as "link_txt" from comdoc."DocflowSettings") l
join rp."RP_Worker" w_ch on w_ch."VCode" = m."IdWorker" join rp."RP_Worker" w_ch on w_ch."VCode" = m."IdWorker"
join rp."RP_Person" p_ch on w_ch."IdPerson" = p_ch."VCode" join rp."RP_Person" p_ch on w_ch."IdPerson" = p_ch."VCode"
join rp."RP_PersonContact" pc_ch on p_ch."VCode" = pc_ch."Pcode" and pc_ch."IdTypeContact" = 6 join rp."RP_PersonContact" pc_ch on p_ch."VCode" = pc_ch."Pcode" and pc_ch."IdTypeContact" = 6
left join odata.exchange1cguids ex on m."HolidayTypeGuid" = ex.guid and ex.atype = 'TypeVacation' and ex.corg= p."COrg" left join odata.exchange1cguids ex on m."HolidayTypeGuid" = ex.guid and ex.atype = 'TypeVacation' and ex.corg= p."COrg"
left join aw."VTypeTimeWork" tw on m."TypeVacation" = tw."VCode" left join aw."VTypeTimeWork" tw on m."TypeVacation" = tw."VCode"
where coalesce(m."DateBegPer",m."DateBeg")>= dt.bd and coalesce(m."DateBegPer",m."DateBeg") <=dt.ed and where p."COrg" <> 4 and
not exists (select 1 coalesce(m."DateBegPer",m."DateBeg")>= dt.bd and coalesce(m."DateBegPer",m."DateBeg") <=dt.ed and
from "dfd"."UniversalDocument" AS "ud" not exists (select 1
join comdoc."ReadListItem" "rl" on "ud"."VCode" = "rl"."DocCode" from "dfd"."UniversalDocument" AS "ud"
join comdoc."DocflowLink" "dl" on "dl"."DocCode2" = p."VCode" and "dl"."DocCode1" = "ud"."VCode" join comdoc."ReadListItem" "rl" on "ud"."VCode" = "rl"."DocCode"
where "rl"."DocflowUser" = pc_ch."Code" and join comdoc."DocflowLink" "dl" on "dl"."DocCode2" = p."VCode" and "dl"."DocCode1" = "ud"."VCode"
"ud"."TypeName" = 'NotificationLexema' and join dfd."DocumentAdditionalAttribute" atr on "ud"."VCode" = atr."PCode"
"ud"."Text" like '%'|| to_char(coalesce(m."DateBegPer",m."DateBeg")::date, 'DD.MM.YYYY') ||'%') join dfd."DocumentCategoryAttributeType" atrtype on "atr"."CategoryAttributeType" = atrtype."VCode" and "ud"."DocumentCategory" = atrtype."PCode" and atrtype."AttributeType" = 'Date' and atrtype."ColumnName" = '#bdate#'
and 1 = coalesce((select "IdTypeBusy" where "rl"."DocflowUser" = pc_ch."Code" and
from rp."RP_WorkerMove" rpwm "ud"."TypeName" = 'NotificationLexema' and
where rpwm."IdWorker" = w_ch."VCode" atr."DateValue" = coalesce(m."DateBegPer",m."DateBeg")
and (rpwm."DateEnd" is null --"ud"."Text" like '%'|| to_char(coalesce(m."DateBegPer",m."DateBeg")::date, 'DD.MM.YYYY') ||'%'
OR (now()::date <= coalesce(rpwm."DateEnd", '2100-01-01'::date))) ) and
limit 1) w_ch."DateEDM" is not null and
, 1) w_ch."DateEnd" is null and
--проверка на созданное заявление с завершенным маршрутом, на отпуск или на перенос
not exists (select 1
from "dfd"."UniversalDocument" AS "ud"
join dfd."DocumentAdditionalAttribute" atr on "ud"."VCode" = atr."PCode"
join dfd."DocumentCategoryAttributeType" atrtype on "atr"."CategoryAttributeType" = atrtype."VCode" and "ud"."DocumentCategory" = atrtype."PCode" and atrtype."AttributeType" = 'Date' and atrtype."ColumnName" = '#bdate#'
join dfd."DocumentConstructor" dc on "ud"."DocumentCategory" = dc."VCode"
join dfd."DocumentSubtype" ds on dc."DocumentSubtype" = ds."VCode"
join comdoc."Route" r on ud."VCode" = r."DocCode" and ud."TypeName" = r."DocType" and r."RouteStatus" = 3
where "ud"."TypeName" = 'EmployeeStatement' and
"ud"."IdWorker" = m."IdWorker" and
atr."DateValue" = coalesce(m."DateBegPer",m."DateBeg") and
ds."InternalName" in ('EmployeeStatementVacation','EmployeeStatementTransperVacation') and
ud."Removed" is not true and
not exists (select 1 from dfd."CancellationAct" a where a."DocCode" = ud."VCode" and a."DocType" = ud."TypeName") and
not exists (select 1
from comdoc."Route" r
join comdoc."RouteStage" rs on r."VCode" = rs."PCode"
join comdoc."StageItem" si on rs."VCode" = si."PCode"
inner join comdoc."DocflowDocumentSettings" as sts on sts."DocType" = r."DocType"
inner join comdoc."DocflowDocumentSettingsDetail" as dfs on dfs."PCode" = sts."VCode" and
dfs."DocumentAction" = si."DocumentAction" and
dfs."DocumentStatus" = si."DocumentStatus"
where r."DocCode" = "ud"."VCode" and
r."DocType" = p."TypeName" and
dfs."NegativeStatus" is true)
)
``` ```
Таблица **"#forInsNotification"** представляет собой список логинов и текстов сообщений: Таблица **"#forInsNotification"** представляет собой список логинов и текстов сообщений: