задачи шедулера по справочнику
This commit is contained in:
parent
864949663f
commit
d8cf27eef3
|
@ -4,8 +4,6 @@ search:
|
||||||
---
|
---
|
||||||
# Функции планировщика задач
|
# Функции планировщика задач
|
||||||
|
|
||||||
В системе список задач, выполняемых по расписанию постоянно обновляется. На текущий момент доступны следующие задачи:
|
|
||||||
|
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="200px">Название действия (задача)</th>
|
<th width="200px">Название действия (задача)</th>
|
||||||
|
@ -254,7 +252,253 @@ search:
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Способы и примеры настройки расписания задаются в формате crontab**
|
**Способы и примеры настройки расписания задаются в формате crontab**
|
||||||
Ознакомиться подробнее можно в разделе [Создание расписания в формате Crontab](../FAQ/#использование_crontab_для_сервиса_sheduler)
|
Ознакомиться подробнее можно в разделе [Создание расписания в формате Crontab](../FAQ/#использование_crontab_для_сервиса_sheduler)
|
||||||
|
|
||||||
|
## Настройка заданий для планировщика
|
||||||
|
|
||||||
|
Также для планировщика возможно настроить иные задания с помощью справочника ["настройки заданий"](../Настройка%20внутрисистемных%20уведомлений/#настройка_заданий_для_планировщика), где во вкладке "Задача" указывается часть содержащая динамический запрос для выполнения задачи. Текст для таких задач возможно назначить с помощью ["Конструктора уведомлений"](../Конструктор%20уведомлений/#вид_уведомления_настройка_заданий_для_планировщика) Данные задачи отрабатывают при запуске задачи **"Уведомления Lexema"**. Далее представлены примеры запросов.
|
||||||
|
|
||||||
|
### Документы, не пришедшие из 1с
|
||||||
|
|
||||||
|
```sql
|
||||||
|
with "no1c"
|
||||||
|
as
|
||||||
|
(select r."COrgName" , 'таб.№ ' || r."NumTab"|| ' ' || r."Workers" as "Workers" ,r."PostWorkers" ,
|
||||||
|
r."name1c" || ' По заявлению № ' || r."DocumentNumber" || ' от ' || to_char( "DocumentDate"::date, 'DD.MM.YYYY') as "name1c"
|
||||||
|
, l."link_txt" || '#/view/'|| r."TypeName" ||'Form' ||'/' || r."VCode" as "link"
|
||||||
|
from odata."getExchange1CGuidsRegistry"(null, null, (now()::date+ '-45 day'::interval)::date , (now()::date+ '-3 day'::interval)::Date , null) r
|
||||||
|
cross join (select "LocationProtocol" || '//' || "LocationHostName" as "link_txt" from comdoc."DocflowSettings") l
|
||||||
|
where
|
||||||
|
coalesce( "DeletionMark",'false') = 'false ' and
|
||||||
|
r."VCode" is not null and
|
||||||
|
r."DFS_VCode" is null and
|
||||||
|
r."guid" is not null and
|
||||||
|
r.name1c not ilike '%больнич%'
|
||||||
|
and
|
||||||
|
r.name1c not ilike '%НДФЛ%'
|
||||||
|
and
|
||||||
|
r.name1c not ilike '%вычет%'
|
||||||
|
and
|
||||||
|
r.name1c not ilike '%мат%пом%'
|
||||||
|
and
|
||||||
|
r. "DocumentDate" >= now()::date+ '-45 day'::interval
|
||||||
|
and
|
||||||
|
r. "DocumentDate" <= now()::date+ '-3 day'::interval
|
||||||
|
)
|
||||||
|
|
||||||
|
insert into "#forInsNotification" ("DocflowUser", "txt", "Link", "DocType", "DocName", "DocSubject", "IdWorker")
|
||||||
|
select distinct 'Personnel' as "DocflowUser" ,
|
||||||
|
--rlU."DocflowUser" ,
|
||||||
|
'Следующие документы не пришли на подписание из 1С : <br/>' ||
|
||||||
|
replace(
|
||||||
|
replace(replace(
|
||||||
|
'<table style = "border-collapse:collapse">
|
||||||
|
<tr>
|
||||||
|
<th style="text-align:center; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Организация</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Работник</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Должность</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Документ</th>
|
||||||
|
</tr>'||
|
||||||
|
(SELECT DISTINCT string_agg(x."Body", '')
|
||||||
|
FROM(select '<tr><td style="text-align:center; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black">'|| coalesce(p2."COrgName",'')||'</td>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black;">'||coalesce(p2."Workers",'')||'</td>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black;">'||coalesce(p2."PostWorkers",'')||'</td>
|
||||||
|
|
||||||
|
<td style="text-align:center; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black">' ||
|
||||||
|
'<a href="' || coalesce(p2."link",'') || '">' ||coalesce(p2."name1c",'')|| '</a>'::text || '</td>
|
||||||
|
|
||||||
|
</tr>' as "Body" from "no1c" p2
|
||||||
|
order by p2."COrgName", p2."Workers" ) x)||'</table>'
|
||||||
|
,'<','<'),'>','>'),
|
||||||
|
'&','&') as txt,
|
||||||
|
null::bigint as "link", 'Первичный документ', 'Первичный документ',
|
||||||
|
'Информационное сообщение о документах, не пришедших из 1С',
|
||||||
|
null::bigint as "IdWorker"
|
||||||
|
from "no1c" dd
|
||||||
|
/*join comdoc."ReadListGroup" rl on rl."Name" = 'Кадровики для рассылки документов, не пришедших из 1С'
|
||||||
|
and rl."DocTypes" ilike '%NotificationLexema%'
|
||||||
|
join comdoc."ReadListGroupUsers" rlU on rl."VCode" = rlU."PCode"*/
|
||||||
|
--group by rlU."DocflowUser"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Задача по изменению фамилии в карточке пользователя + склонение в карточке физического лица
|
||||||
|
|
||||||
|
```sql
|
||||||
|
do $$
|
||||||
|
begin
|
||||||
|
IF NOT comdoc."isTableExists"('#fio', 'temp') THEN
|
||||||
|
CREATE TEMP TABLE "#fio"("Id" bigint, "OldFam" text, "OldName" text, "OldOtch" text,
|
||||||
|
"IdPerson" bigint, "NewFam" varchar(255), "NewName" varchar(255), "NewOtch" varchar(255), "UserName" varchar(255), "Code" varchar(2550)
|
||||||
|
) ON COMMIT DROP;
|
||||||
|
END IF;
|
||||||
|
insert into "#fio"
|
||||||
|
select m."Id",m."LastName", m."FirstName", m."MiddleName", per."VCode", per."Family", per."Name", per."Father", m."UserName" , c."Code"
|
||||||
|
from lex."UserMeta" m
|
||||||
|
join rp."RP_PersonContact" c on c."IdTypeContact" = 6 and m."UserName" = c."Code"
|
||||||
|
join rp."RP_Person" per on per."VCode" = c."Pcode"
|
||||||
|
where (lower(coalesce(m."LastName",''))<> lower(coalesce(per."Family",'')) or lower(coalesce(m."FirstName",''))<> lower(coalesce(per."Name",''))
|
||||||
|
or lower(coalesce(m."MiddleName",''))<>lower(coalesce(per."Father",'')))
|
||||||
|
and (select count(a."Pc") from (select distinct c."Pcode" as "Pc" from rp."RP_PersonContact" c
|
||||||
|
join rp."RP_Person" per on per."VCode" = c."Pcode"
|
||||||
|
where c."Code" =m."UserName")a) =1;
|
||||||
|
|
||||||
|
update lex."UserMeta" m set "LastName" = q."NewFam", "FirstName" = q."NewName", "MiddleName" = q."NewOtch"
|
||||||
|
from "#fio" q
|
||||||
|
where q."Id" = m."Id";
|
||||||
|
|
||||||
|
update rp."RP_Person" per set "Note" = case when per."Note" is not null then per."Note" ||'
|
||||||
|
' else '' end ||to_char(now(),'DD.MM.YYYY')
|
||||||
|
|| (select ' изменено ФИО с '||coalesce(f."OldFam",'')||' '||coalesce(f."OldName",'')||' '||coalesce(f."OldOtch",'')||' на '
|
||||||
|
||coalesce(f."NewFam",'')||' '||coalesce(f."NewName",'')||' '||coalesce(f."NewOtch",'')from "#fio" f where f."IdPerson" = per."VCode" limit 1),
|
||||||
|
"FNFAccusative" = comdoc."Lexsklon"(per."Family", per."Name", per."Father", case when per."Sex" = 1 then 'Ж' else 'M' end, 1),
|
||||||
|
"FNFDative" = comdoc."Lexsklon"(per."Family", per."Name", per."Father", case when per."Sex" = 1 then 'Ж' else 'M' end, 0),
|
||||||
|
"FNFGenitive" = comdoc."Lexsklon"(per."Family", per."Name", per."Father", case when per."Sex" = 1 then 'Ж' else 'M' end, 2)
|
||||||
|
from "#fio" q
|
||||||
|
where per."VCode" = q."IdPerson";
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
$$;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Оповещение о необходимости замены паспорта
|
||||||
|
|
||||||
|
```sql
|
||||||
|
insert into "#forInsNotification" ("DocflowUser", "txt", "Link", "DocType", "DocName", "DocSubject", "IdWorker")
|
||||||
|
select distinct pc."Code" , '<font size="3"> <b>Настоящим сообщаем, что приближается срок замены паспорта </b> <br/>' || '</font>' ,
|
||||||
|
null::bigint as "link", '', '',
|
||||||
|
'Инф. сообщение о замене паспорта',
|
||||||
|
w."VCode" as "IdWorker"
|
||||||
|
from rp."RP_Person" p
|
||||||
|
join rp."RP_Worker" w on p."VCode" = w."IdPerson"
|
||||||
|
left join rp."RP_WorkerMove" wm on w."VCode" = wm."IdWorker" and now() between coalesce(wm."DateBeg", '20010101') and coalesce(wm."DateEnd", '20700101')
|
||||||
|
left join comdoc."Department" dep on wm."IdDepartment" = dep."VCode"
|
||||||
|
left join rp."RP_Post" post on wm."IdPost" = post."VCode"
|
||||||
|
left join rp."RP_PersonContact" pc on p."VCode" = pc."Pcode" and pc."IdTypeContact" = 6
|
||||||
|
LEFT JOIN LATERAL comdoc."getAccountingConstantValues"(w."COrg", 'СЭД_Уведомления_Сообщения_о_замене_паспорта', NULL) cv on true
|
||||||
|
where (
|
||||||
|
now() between p."DateBirth" - (coalesce(cv."valueConst",30) || ' day')::interval + (date_part('year',age(p."DateBirth"))+1 || 'year')::interval and
|
||||||
|
p."DateBirth" + (date_part('year',age(p."DateBirth"))+1 || 'year')::interval and
|
||||||
|
date_part('year',age(p."DateBirth" - (coalesce(cv."valueConst",30) || ' day')::interval ))::int in (20,45)
|
||||||
|
) or w."VCode" = 53
|
||||||
|
```
|
||||||
|
|
||||||
|
### Оповещение о списке работников, которые не создали заявление об отпуске из уведомления
|
||||||
|
|
||||||
|
```sql
|
||||||
|
with list as (
|
||||||
|
select ud."VCode", ud."IdWorker", atr."Value" as "Vacation", to_char(atrD."DateValue",'DD.MM.YYYY') as "DateBeg" , f."Name" as "COrgName"
|
||||||
|
from dfd."UniversalDocument" AS ud
|
||||||
|
join dfd."DocumentConstructor" dc on ud."DocumentCategory" = dc."VCode"
|
||||||
|
join dfd."DocumentSubtype" ds on dc."DocumentSubtype" = ds."VCode"
|
||||||
|
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" = 'string' and atrtype."ColumnName" = '#typeVacation#'
|
||||||
|
join dfd."DocumentAdditionalAttribute" atrD on ud."VCode" = atrD."PCode"
|
||||||
|
join dfd."DocumentCategoryAttributeType" atrtypeD on atrD."CategoryAttributeType" = atrtypeD."VCode" and ud."DocumentCategory" = atrtypeD."PCode" and
|
||||||
|
atrtypeD."AttributeType" = 'Date' and atrtypeD."ColumnName" = '#bdate#'
|
||||||
|
join comdoc."VFilials" f on ud."COrg" = f."VCode"
|
||||||
|
where ud."TypeName" = 'NotificationLexema' and
|
||||||
|
ds."InternalName" = 'NotificationVacation' and
|
||||||
|
not exists (select 1
|
||||||
|
from dfd."UniversalDocument" es
|
||||||
|
join comdoc."DocflowLink" dle on ud."VCode" = dle."DocCode2" and
|
||||||
|
((dle."DocType2" = ud."TypeName" and ud."VCode" = dle."DocCode2") or
|
||||||
|
(dle."DocType1" = ud."TypeName" and ud."VCode" = dle."DocCode1")
|
||||||
|
)
|
||||||
|
where es."TypeName" = 'EmployeeStatement' ) and
|
||||||
|
atrD."DateValue" > now()::date )
|
||||||
|
|
||||||
|
insert into "#forInsNotification" ( "txt", "txtSMS", "txtTelegram")
|
||||||
|
select null as "txt", null as "txtSMS", null as "txtTelegram"
|
||||||
|
from (select ('<table><tr><th align="left">Организация</th><th align="left">Сотрудник</th><th align="left">Отпуск</th></tr>' ||
|
||||||
|
(SELECT DISTINCT string_agg(x."link", '')
|
||||||
|
FROM ( SELECT '<tr><td>' || coalesce(l."COrgName",'') || '</td><td>' || coalesce(r."NameFull",'') || '</td>' ||
|
||||||
|
'<td>' || coalesce(l."Vacation", '') || ' ' || l."DateBeg" || '</td>'
|
||||||
|
||'</tr>' as "link"
|
||||||
|
FROM list l
|
||||||
|
join rp."RP_Worker" r on l."IdWorker" = r."VCode") AS x) || '</table>'
|
||||||
|
) ::text as "data") d
|
||||||
|
```
|
||||||
|
|
||||||
|
таблица.столбец | описание | # для шаблона
|
||||||
|
----------------|----------|--------------
|
||||||
|
d."data" | Список | #query_list#
|
||||||
|
|
||||||
|
### Отсутствие планового графика отпусков по подразделению
|
||||||
|
|
||||||
|
```sql
|
||||||
|
with "chiefStruct" as
|
||||||
|
(select * from vac."SendingLateApplicationNotice"())
|
||||||
|
insert into "#forInsNotification" ("DocflowUser","CopyTo", "txt")
|
||||||
|
select /*main."ChiefLogin"*/ 'Loginovasa@lexema.ru', (select DISTINCT string_agg(coalesce(ch."ChiefLogin",''),', ') from "chiefStruct" ch
|
||||||
|
where ch."IdWorker" = main."Chief" and main."ChiefLogin"<>coalesce(ch."ChiefLogin",'')),
|
||||||
|
'Добрый день, ' || '<b>'||RTRIM(coalesce(du."FirstName",'') || ' ' || coalesce(du."MiddleName",''))||'</b>' ||
|
||||||
|
'. <br><br>' ||
|
||||||
|
'<br> По следующим сотрудникам не сформированы заявки на отпуск на '||main."planYear"::text||' год:'||
|
||||||
|
'<br><br>' ||
|
||||||
|
replace(
|
||||||
|
replace(replace(
|
||||||
|
'<table style = "border-collapse:collapse">
|
||||||
|
<tr>
|
||||||
|
<th style="text-align:center; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Организация</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Подразделение</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Работник</th>
|
||||||
|
<th style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black; border-top: 1px solid black">Должность</th>
|
||||||
|
</tr>'||
|
||||||
|
(SELECT DISTINCT string_agg(x."link", '')
|
||||||
|
FROM(select '<tr><td style="text-align:center; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black">'||fil||'</td>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black">'||dep||'</td>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black;">'||fio||'</td>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black;">'||post||'</td>
|
||||||
|
</tr>' as "link" from (select distinct f."Name" as fil, coalesce(dep."Name",'') as "dep", coalesce(w."NameShort",w."NameFull",'') as fio , coalesce(rp."Name",'') as post
|
||||||
|
from "chiefStruct" p2
|
||||||
|
left join rp."RP_Worker" w on w."VCode" = p2."IdWorker"
|
||||||
|
left join comdoc."Department" dep on dep."VCode" = p2."IdDepartment"
|
||||||
|
left join rp."RP_Post" rp on rp."VCode" = p2."IdPost"
|
||||||
|
left join comdoc."VFilials" f on w."COrg" = f."VCode"
|
||||||
|
where coalesce(p2."ChiefLogin",'') = coalesce(main."ChiefLogin",'')) qw
|
||||||
|
order by fil, "dep", fio ) as x)||'</table>'
|
||||||
|
,'<','<'),'>','>'),
|
||||||
|
'&','&') as "Body"
|
||||||
|
from "chiefStruct" main
|
||||||
|
inner join comdoc."DocflowUser" du on main."ChiefLogin" = du."UserName"
|
||||||
|
group by main."Chief", coalesce(du."FirstName",''), coalesce(du."MiddleName",''), main."ChiefLogin", main."planYear";
|
||||||
|
```
|
||||||
|
### Смена организации по умолчанию при смене основного места работы
|
||||||
|
|
||||||
|
```sql
|
||||||
|
call dfd."updateUsersDefaultOrganization" (null, 'Admin;EVIvaschenko')
|
||||||
|
|
||||||
|
/* 1 - коды исключен физ лиц через ;
|
||||||
|
2 - логины исключения через ; */
|
||||||
|
```
|
||||||
|
|
||||||
|
### Создание отзывов доверенностей МЧД по уволенным
|
||||||
|
|
||||||
|
```sql
|
||||||
|
with res as (select * ,
|
||||||
|
'<tr>
|
||||||
|
<td style="text-align:center; border-right: 1px solid black; border-bottom: 1px solid black;">'||
|
||||||
|
'<a href="' ||
|
||||||
|
(select "LocationProtocol" || '//' || "LocationHostName" || coalesce(':'||"LocationPort",'') from comdoc."DocflowSettings" order by "CDate" desc limit 1)
|
||||||
|
|| '/#/view/' || se."DocForm" || '/' || r."VCode"::text
|
||||||
|
|| '">' || case when r."TypeName" = 'EmpowermentRevocation' then 'Отзыв доверенности' else 'Доверенность' end || ' № ' ||coalesce(r."DocumentNumber",'') || ' от ' || to_char(r."DocumentDate",'DD.MM.YYYY')
|
||||||
|
|| '</a>'::text ||'</td> </tr>' as "ref_link"
|
||||||
|
from dfd."createEmpowermentRevocationUvol" () r
|
||||||
|
join comdoc."DocflowDocumentSettings" se on r."TypeName" = se."DocType"
|
||||||
|
)
|
||||||
|
|
||||||
|
insert into "#forInsNotification" ("DocflowUser", "txt")
|
||||||
|
select d."DocflowUser", null as "txt"
|
||||||
|
from (select distinct r."DocflowUser", (select string_agg(coalesce(r1."ref_link",''),'')
|
||||||
|
from res r1 where r."DocflowUser" = r1."DocflowUser") as list
|
||||||
|
from res r
|
||||||
|
) d
|
||||||
|
```
|
||||||
|
|
||||||
|
таблица.столбец | описание | # для шаблона
|
||||||
|
----------------|----------|--------------
|
||||||
|
d.list | Список документов | #query_list#
|
Loading…
Reference in New Issue