diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/index.md b/docs/Admin manuals/Настройка правил поиска для ЖСД/index.md
index 864723b..2cb8e9f 100644
--- a/docs/Admin manuals/Настройка правил поиска для ЖСД/index.md
+++ b/docs/Admin manuals/Настройка правил поиска для ЖСД/index.md
@@ -175,7 +175,7 @@
limit 1
)
```
-
\ No newline at end of file
+ ```
+
+#### Аналитическая форма по расписанию задач
+
+??? note "Запрос"
+
+ ![alt text](media/image-28.png)
+
+ Основной запрос:
+
+ ```sql
+ INSERT INTO "tmp_calcWithBaseParams_for_documentStatusJournalProc"( "DocCode" )
+ select null;
+ ```
+
+ Итоговая выборка:
+
+ ```sql
+ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName", "DocName", "DocumentDate",
+ "AnyColumnA" , "AnyColumnB" , "AnyColumnC" , "AnyColumnD" , "AnyColumnE",
+ "AnyColumnF", "AnyColumnG", "AnyColumnH", "AnyColumnI", "AnyColumnJ")
+
+ select dd."Id", 'task'::text, 'taskForm'::text, ('Шедулер' || dd."Name")::text, 'Планировщик задач ' ||dd."Name" , dd."CDate"::date,
+ dd."Name" as "AnyColumnA" , dd."Description" as "AnyColumnB" ,
+ dd."Minutes" as "AnyColumnC" , dd."Hours" as "AnyColumnD" , dd."Days" as "AnyColumnE" , dd."Months" as "AnyColumnF" , dd."DaysOfTheWeek" as "AnyColumnG" ,dd. "Note" as "AnyColumnH" ,dd. "TypeTask" as "AnyColumnI"
+ , sum(comdoc."datediff"('minute',j."TimeStart" , j."TimeEnd"))/ count(j."Id") as "AnyColumnJ"
+ from (
+ select t."Id", t."Name", t."Description",
+ sh."Crontab",
+ max(case when s."VCode" = 1 then s."PartString" else '' end) as "Minutes",
+ max(case when s."VCode" = 2 then s."PartString" else '' end) as "Hours",
+ max(case when s."VCode" = 3 then s."PartString" else '' end) as "Days",
+ max(case when s."VCode" = 4 then s."PartString" else '' end) as "Months",
+ max(case when s."VCode" = 5 then s."PartString" else '' end) as "DaysOfTheWeek",
+ 'по гринвичу' as "Note", 'Шедулер' as "TypeTask", t."CDate"
+ from lex."Task" t
+ join lex."Schedule" sh on t."Id" = sh."Parent"
+ LEFT JOIN LATERAL comdoc."LexStringToListNew"(replace(sh."Crontab",' ','Ё'),'Ё',0) s on true
+ join (select 1 as "VCode", 'мин.' as "Name"
+ union all
+ select 2 as "VCode", 'часы' as "Name"
+ union all
+ select 3 as "VCode", 'день' as "Name"
+ union all
+ select 4 as "VCode", 'месяц' as "Name"
+ union all
+ select 5 as "VCode", 'дни недели' as "Name"
+ ) d on s."VCode" = d."VCode"
+
+ -- inner join lex."StepJournalEntryDetail" s on j."Id" = s."PCode"
+ where coalesce(t."Toggle",false) = true
+ group by t."Id", t."Name", t."Description", sh."Crontab", t."CDate"
+ )dd
+ left join lex."TaskJournalEntry" j on dd."Id" = j."TaskId" and j."TimeStart">= now()::date - '1 month'::interval and j."TimeEnd" is not null
+ --where j."TimeStart">= now()::date - '1 month'::interval and j."TimeEnd" is not null
+ group by dd."Id", dd."Name", dd."Description", dd."Crontab", "Minutes", "Hours", "Days", "Months", "DaysOfTheWeek", "Note", "TypeTask", dd."CDate"
+
+ union all
+ select t."VCode", 'NotificationLexemaDirectory'::text, 'NotificationLexemaDirectoryForm'::text , '', ( 'Задачи планировщика ' ||t."TaskName") ::text, t."CDate"::date,
+ t."TaskName" as "AnyColumnA" , null::text as "AnyColumnB" ,
+ t."Minutes" as "AnyColumnC" , t."Hours" as "AnyColumnD" , t."Days" as "AnyColumnE" , t."Months" as "AnyColumnF" , t."DaysOfTheWeek" as "AnyColumnG" ,'серверное время' as "AnyColumnH" ,'Задачи планировщика' as "AnyColumnI",
+ null::int as "AnyColumnJ"
+ from dfd."NotificationLexemaDirectory" t
+ where coalesce(t."Included",false) = true;
+ ```
+
+#### Логи отправки почты и СМС
+
+Необходимо дополнительно настроить [задачу планировщика](../Функции%20планировщика%20задач/#перенос_логов_отправки_почты_и_смс_в_таблицу_sendlog)
+
+??? note "Запрос"
+
+ ![alt text](media/image-30.png)
+
+ Основной запрос:
+
+ ```sql
+ INSERT INTO "tmp_calcWithBaseParams_for_documentStatusJournalProc"( "DocCode")
+ select 1 from dfd."OutgoingEmailLog" where 1 = 1
+ limit 1;
+ ```
+
+ Итоговая выборка:
+
+ ```sql
+ do $myQ$
+ declare _str text;
+ begin
+ _str := '
+ insert into "tmp_finresult"("AnyColumnA", "AnyColumnB", "AnyColumnC", "AnyColumnD", "AnyColumnE", "AnyColumnF", "AnyColumnG", "AnyColumnH", "AnyColumnI", "AnyColumnJ", "AnyColumnK", "AnyColumnL", "AnyColumnM")
+ select p."Level", p."type", p."To", p."Subject", p."Body", p."Cc", p."Bcc", p."phones", p."text", p."errorText",
+ to_char(p."CDateLog",''DD.MM.YYYY hh:mi'') as "CDateLog", p."CUserLog", p."CHostLog"
+ from comdoc."SendLog" p
+ where coalesce( p."CDateLog"::date,'_bdate'::date) between '_bdate'::date and '_edate'::date
+ order by p."CDateLog" desc'
+ _topcount ;
+ execute _str;
+ end;
+ $myQ$;
+ ```
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-24.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-24.png
new file mode 100644
index 0000000..87074b2
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-24.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-25.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-25.png
new file mode 100644
index 0000000..bba8647
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-25.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-26.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-26.png
new file mode 100644
index 0000000..37a09d2
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-26.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-27.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-27.png
new file mode 100644
index 0000000..fc9aa90
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-27.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-28.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-28.png
new file mode 100644
index 0000000..674839a
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-28.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-29.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-29.png
new file mode 100644
index 0000000..2ea2aae
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-29.png differ
diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-30.png b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-30.png
new file mode 100644
index 0000000..4a279c7
Binary files /dev/null and b/docs/Admin manuals/Настройка правил поиска для ЖСД/media/image-30.png differ
diff --git a/docs/Admin manuals/Функции планировщика задач/index.md b/docs/Admin manuals/Функции планировщика задач/index.md
index c300571..3ff1b4e 100644
--- a/docs/Admin manuals/Функции планировщика задач/index.md
+++ b/docs/Admin manuals/Функции планировщика задач/index.md
@@ -255,244 +255,256 @@ search:
### Документы, не пришедшие из 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 ''|| coalesce(p2."COrgName",'')||' |
- '||coalesce(p2."Workers",'')||' |
- '||coalesce(p2."PostWorkers",'')||' |
-
- ' ||
- '' ||coalesce(p2."name1c",'')|| ''::text || ' |
-
-
' as "Body" from "no1c" p2
- order by p2."COrgName", p2."Workers" ) x)||'
'
-,'<','<'),'>','>'),
-'&','&') 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
+ 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 ''|| coalesce(p2."COrgName",'')||' |
+ '||coalesce(p2."Workers",'')||' |
+ '||coalesce(p2."PostWorkers",'')||' |
+
+ ' ||
+ '' ||coalesce(p2."name1c",'')|| ''::text || ' |
+
+
' as "Body" from "no1c" p2
+ order by p2."COrgName", p2."Workers" ) x)||'
'
+ ,'<','<'),'>','>'),
+ '&','&') 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";
+ ```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;
-$$;
-```
+ 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
+ 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 '' || coalesce(l."COrgName",'') || ' | ' || coalesce(r."NameFull",'') || ' | ' ||
- '' || coalesce(l."Vacation", '') || ' ' || l."DateBeg" || ' | '
- ||'
' as "link"
- FROM list l
- join rp."RP_Worker" r on l."IdWorker" = r."VCode") AS x) || '
'
- ) ::text as "data") d
-```
+ ```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 )
-таблица.столбец | описание | # для шаблона
-----------------|----------|--------------
-d."data" | Список | #query_list#
+ 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 '' || coalesce(l."COrgName",'') || ' | ' || coalesce(r."NameFull",'') || ' | ' ||
+ '' || coalesce(l."Vacation", '') || ' ' || l."DateBeg" || ' | '
+ ||'
' as "link"
+ FROM list l
+ join rp."RP_Worker" r on l."IdWorker" = r."VCode") AS x) || '
'
+ ) ::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 ''||fil||' |
- '||dep||' |
- '||fio||' |
- '||post||' |
-
' 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)||'
'
-,'<','<'),'>','>'),
-'&','&') 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
+ 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 ''||fil||' |
+ '||dep||' |
+ '||fio||' |
+ '||post||' |
+
' 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)||'
'
+ ,'<','<'),'>','>'),
+ '&','&') 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"
- )
+??? Задача
+ ```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
-```
+ 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
+ таблица.столбец | описание | # для шаблона
+ ----------------|----------|--------------
+ d.list | Список документов | #query_list#
+
+### Перенос логов отправки почты и СМС в таблицу SendLog
+
+??? Задача
+
+ ```sql
+ call comdoc."PostToSendLog"();
+ ```
\ No newline at end of file