diff --git a/docs/Admin manuals/Функции планировщика задач/index.md b/docs/Admin manuals/Функции планировщика задач/index.md index 3ff1b4e..da4c692 100644 --- a/docs/Admin manuals/Функции планировщика задач/index.md +++ b/docs/Admin manuals/Функции планировщика задач/index.md @@ -507,4 +507,57 @@ search: ```sql call comdoc."PostToSendLog"(); + ``` + +### Уведомление о просрочке предоставления ответа на входящие документы + +??? Задача + + ```sql + with param as (select COALESCE(comdoc."getFilial"(), 2) as "getFilial", + comdoc."fnDefineRegion"(null::bigint, comdoc."getFilial"()::bigint, now()::date) as "Region") + + insert into "#forInsNotification" ("DocflowUser", "txt", "Link", "DocType", "DocName", "DocSubject", "IdWorker") + select (SELECT DISTINCT string_agg(x."EMail", ',') + from (select distinct du."EMail"--,da."Name", da."InternalName" AS "DocumentAction" ,da.* + FROM comdoc."Route" AS a + JOIN comdoc."RouteStage" AS s ON s."PCode" = a."VCode" + join comdoc."StageItem" as i on i."PCode" = s."VCode" + LEFT JOIN comdoc."DocumentAction" AS da ON da."VCode" = i."DocumentAction" + LEFT JOIN comdoc."DocflowUser" AS du ON du."VCode" = i."StageUser" + WHERE s."IsMarked" IS NOT true + and a."DocCode" = Incoming."VCode" + and a."DocType" = 'IncomingDocument' + and (da."InternalName" like 'Execute%' or da."InternalName" = 'Run') + )x + )as "DocflowUser", + 'По документу ' || + '' || + ''||'Входящий документ №'||coalesce(Incoming."DocumentNumber",'')||'' || '' + ||'' ||''||' не предоставлен ответ. Срок: '|| to_char("ResponseDatePlan"::date, 'DD.MM.YYYY')|| '' as "txt", + null::bigint as "Link", + null as "DocType", + '' as "DocName", --это для физ уведомления + 'Входящие документы с истекающей датой предоставления ответа'::text as "DocSubject", + null::bigint as "IdWorker" --это для физ уведомления; + + from dfd."DocflowDocument" Incoming + cross join (select "LocationProtocol" || '//' || "LocationHostName" as "link_txt" from comdoc."DocflowSettings") ss + left join comdoc."DocflowDocumentSettings" AS dds ON dds."DocType" = Incoming."TypeName" + where Incoming."TypeName" = 'IncomingDocument' + and "ResponseDatePlan" is not null + --and comdoc."datediff"('day',"ResponseDatePlan",CURRENT_DATE)>3 + and "NeedResponse" =true + and coalesce((select count(*) + from comdoc."VDocflowCalendar" d + cross join param p + where ((d."RDate" between CURRENT_DATE and "ResponseDatePlan" and "ResponseDatePlan">CURRENT_DATE) ) + and d."isDayOff" = false + and ((d."orgId" = p."getFilial" and coalesce(p."Region",0) =0 ) or d."Region" = p."Region")),0)<4 + and not exists(select "DocCode1" + from comdoc."DocflowLink" l + where l."DocCode2" = Incoming."VCode" + and "DocType2" = 'IncomingDocument' + and "DocType1" = 'OutgoingDocument' + ) ``` \ No newline at end of file