From d8cf27eef39b41b42fcfa047fb738365de887beb Mon Sep 17 00:00:00 2001 From: mirzakaev_tf Date: Wed, 24 Jan 2024 17:32:34 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8=20=D1=88?= =?UTF-8?q?=D0=B5=D0=B4=D1=83=D0=BB=D0=B5=D1=80=D0=B0=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Функции планировщика задач/index.md | 254 +++++++++++++++++- 1 file changed, 249 insertions(+), 5 deletions(-) diff --git a/docs/Admin manuals/Функции планировщика задач/index.md b/docs/Admin manuals/Функции планировщика задач/index.md index 9cf0b15..234419a 100644 --- a/docs/Admin manuals/Функции планировщика задач/index.md +++ b/docs/Admin manuals/Функции планировщика задач/index.md @@ -4,8 +4,6 @@ search: --- # Функции планировщика задач -В системе список задач, выполняемых по расписанию постоянно обновляется. На текущий момент доступны следующие задачи: - @@ -254,7 +252,253 @@ search:
Название действия (задача)
- -  **Способы и примеры настройки расписания задаются в формате crontab** -Ознакомиться подробнее можно в разделе [Создание расписания в формате Crontab](../FAQ/#использование_crontab_для_сервиса_sheduler) \ No newline at end of file +Ознакомиться подробнее можно в разделе [Создание расписания в формате 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С :
' || +replace( +replace(replace( +' + + + + + + '|| +(SELECT DISTINCT string_agg(x."Body", '') + FROM(select ' + + + + + + ' as "Body" from "no1c" p2 + order by p2."COrgName", p2."Workers" ) x)||'
ОрганизацияРаботникДолжностьДокумент
'|| coalesce(p2."COrgName",'')||''||coalesce(p2."Workers",'')||''||coalesce(p2."PostWorkers",'')||'' || + '' ||coalesce(p2."name1c",'')|| ''::text || '
' +,'<','<'),'>','>'), +'&','&') 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" , ' Настоящим сообщаем, что приближается срок замены паспорта
' || '
' , + 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 ('' || +(SELECT DISTINCT string_agg(x."link", '') + FROM ( SELECT '' || + '' + ||'' as "link" + FROM list l + join rp."RP_Worker" r on l."IdWorker" = r."VCode") AS x) || '
ОрганизацияСотрудникОтпуск
' || coalesce(l."COrgName",'') || '' || coalesce(r."NameFull",'') || '' || coalesce(l."Vacation", '') || ' ' || l."DateBeg" || '
' + ) ::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",'')), +'Добрый день, ' || ''||RTRIM(coalesce(du."FirstName",'') || ' ' || coalesce(du."MiddleName",''))||'' || + '.

' || + '
По следующим сотрудникам не сформированы заявки на отпуск на '||main."planYear"::text||' год:'|| + '

' || +replace( +replace(replace( +' + + + + + + '|| +(SELECT DISTINCT string_agg(x."link", '') + FROM(select ' + + + + ' 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)||'
ОрганизацияПодразделениеРаботникДолжность
'||fil||''||dep||''||fio||''||post||'
' +,'<','<'),'>','>'), +'&','&') 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 * , + ' + '|| + '' || case when r."TypeName" = 'EmpowermentRevocation' then 'Отзыв доверенности' else 'Доверенность' end || ' № ' ||coalesce(r."DocumentNumber",'') || ' от ' || to_char(r."DocumentDate",'DD.MM.YYYY') + || ''::text ||' ' 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# \ No newline at end of file