From 00bcb411a298848f2f66d6429f52dd49d5a5aa6e Mon Sep 17 00:00:00 2001 From: mirzakaev_tf Date: Mon, 4 Sep 2023 15:57:56 +0500 Subject: [PATCH] =?UTF-8?q?14494=20=D1=86=D0=B2=D0=B5=D1=82=20=D0=B2=20?= =?UTF-8?q?=D0=96=D0=A1=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Настройка правил поиска для ЖСД.md | 155 +++++++++++++++++- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/docs/Admin manuals/Настройка правил поиска для ЖСД/Настройка правил поиска для ЖСД.md b/docs/Admin manuals/Настройка правил поиска для ЖСД/Настройка правил поиска для ЖСД.md index 0abb587..7bf1951 100644 --- a/docs/Admin manuals/Настройка правил поиска для ЖСД/Настройка правил поиска для ЖСД.md +++ b/docs/Admin manuals/Настройка правил поиска для ЖСД/Настройка правил поиска для ЖСД.md @@ -71,11 +71,16 @@ В данном блоке указывается часть с динамическим запросом, содержащим непосредственно запроса для отображения документов. +!!! note + В запросе возможно настроить цветовое отображение полей документов в зависимости от условий. Для этого в запросе необходимо указать поле "Colors" и заполнить его одним из следующих значений: `1 - colors.gray 2 - colors.orange 3 - colors.yellow 4 - colors.green 5 - colors.blue 6 - colors.indigo 7 -colors.violet`. Например в запросе: **Все документы** данное значение указано в конце запроса: `(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "AnyColumnO" + , 2`, где цифра 2 цвет + + Примеры запросов: **Просроченные документы** - в реестре отображаются документы, по которым были нарушены сроки обработки: -``` +```sql insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" @@ -106,12 +111,11 @@ from ( ) ) dd where coalesce(dd."expired", 0) <> 0 ; - ``` **Зависшие документы у инициатора** - в реестре отображаются документы, которые были инициированы сотрудником, но не запущены далее по маршруту согласования. -``` +```sql insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" @@ -135,7 +139,7 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa **Поступят к hr в ближайшее время** - в реестре отображаются документы, которые в данный момент находятся на стадии согласования у руководителя сотрудника, и после этого поступят в HR службу. -``` +```sql insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" @@ -164,12 +168,11 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa AND ( t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate ) ; - ``` **Сейчас в работе у hr** - в реестре отображаются документы, которые в данный момент находятся в HR службе в работе -``` +```sql insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" @@ -195,7 +198,7 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa **Обработано службой HR сегодня** - в реестре отображаются документы, которые были обработаны сегодня службой HR сегодня. -``` +```sql insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" @@ -218,4 +221,142 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa AND ( t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate ) ; +``` + +**Все документы** + +```sql +insert into #tmp_finresult( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId" + , "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution" + , "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName" + , "DocSubject" , "expired" , "StageNumber" , "BeginDate" , "ActionDate" + , "DocumentAction" , "DocumentStatus" , "FromMessage" , "eDate" + , "StageUser" , "StageItemStatus" , "StageStatus" , "StageItemAction" , "IsMarked", "DocumentSubtype" , "AnyColumnA" , "AnyColumnB" , "AnyColumnC" , "AnyColumnD" , "AnyColumnE", + "AnyColumnF", "AnyColumnG" , "AnyColumnH" , "AnyColumnI", "AnyColumnJ", "AnyColumnK","AnyColumnL", "AnyColumnM","AnyColumnN", "EmailRecipient","AnyColumnO", "Colors") + +select t."DocCode" , t."DocType" , t."DocForm" , t."DocTypeName" , t."SettingsId" + , t."orgId" , t."DocumentDate" , t."DocumentNumber" , +(case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select top 1 pc."Code" from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#' + join "RP_Worker" w on w."VCode" = daa1."BigIntValue" + join "RP_PersonContact" AS pc ON pc."Pcode" = w."IdPerson" AND pc."IdTypeContact" = 6 + where t."DocumentCategory" = bd."PCode") + else t."VirtualCUser" end) , + null/*t."DateOfExecution"*/ , t."DateControl" , t."RouteVCode" , t."RouteStatusId" , t."RouteStatusName" , t."DocName" + , t."DocSubject" , +null/* comdoc."dfwcGetDuration"( + t."eDate", COALESCE(t."ActionDate", _now), false, t."orgId", 1, _dayoff1, _dayoff2, null + ) */ + , null/* t."StageNumber" */ , null/*t."BeginDate" */ , null/*t."ActionDate" */ + ,null/* t."DocumentAction"*/ , null/*t."DocumentStatus" */ , null /*t."FromMessage" */ , null /*t."eDate"*/ + , null /*t."StageUser" */ , null /*t."StageItemStatus"*/ , null/*t."StageStatus" */ , null/*t."StageItemAction"*/, t."IsMarked", t."DocumentSubtype" , t."AnyColumnA" , +null as "AnyColumnB" , +null as "AnyColumnC", +null as "AnyColumnD" , t."AnyColumnE" , +(select top 1 convert(varchar,daa1."DateValue",104) from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#bdate#' where t."DocumentCategory" = bd."PCode" ) as "AnyColumnF" , +(select top 1 convert(varchar,daa1."DateValue",104) from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#edate#' where t."DocumentCategory" = bd."PCode") as "AnyColumnG" , +(select top 1 daa1."BigIntValue" from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" ='#kolvo#' where t."DocumentCategory" = bd."PCode") as "AnyColumnH", +/* (select string_agg(dca."Name" || ':' || (case + when coalesce(dca."AttributeType",'') = 'string' and coalesce(atr."Value",'') <> '' then atr."Value" + when coalesce(dca."AttributeType",'') = 'string' and coalesce(atr."Value",'') = '' then ' ' + + when coalesce(dca."AttributeType",'') = 'bigint' and atr."BigIntValue" is not null then cast(atr."BigIntValue" as varchar(255)) + when coalesce(dca."AttributeType",'') = 'bigint' and atr."BigIntValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'string' and atr."BigIntValue" is not null then cast(atr."BigIntValue" as varchar(255)) + when coalesce(dca."AttributeType",'') = 'string' and atr."BigIntValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'Base.Unispr' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.Unispr' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'Base.Post' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.Post' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'Base.RP_Worker' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.RP_Worker' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'Base.Contract' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.Contract' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'Base.Contractor' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.Contractor' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'Base.Department' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' ' + when coalesce(dca."AttributeType",'') = 'Base.Department' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + + when coalesce(dca."AttributeType",'') = 'money' and atr."MoneyValue" is not null then cast(atr."MoneyValue" as varchar(255)) + when coalesce(dca."AttributeType",'') = 'money' and atr."MoneyValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'Date' and atr."DateValue" is not null then to_char(atr."DateValue", 'DD.MM.YYYY') + when coalesce(dca."AttributeType",'') = 'Date' and atr."DateValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'DateTime' and atr."DateTimeValue" is not null then to_char(atr."DateValue", 'DD.MM.YYYY') + when coalesce(dca."AttributeType",'') = 'DateTime' and atr."DateTimeValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'double' and atr."DoubleValue" is not null then cast(atr."DoubleValue" as varchar(255)) + when coalesce(dca."AttributeType",'') = 'double' and atr."DoubleValue" is null then ' ' + + when coalesce(dca."AttributeType",'') = 'ServiceWord' and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ') + when coalesce(dca."AttributeType",'') = 'ServiceWord' and coalesce(atr."Value",'') = '' then ' ' + + when coalesce(dca."AttributeType",'') = 'bool' and coalesce("BigIntValue"::integer,0) = 0 then substring(coalesce("Value",'|'), position('|' in coalesce("Value",'|'))+1,char_length(coalesce("Value",'|'))) + when coalesce(dca."AttributeType",'') = 'bool' and coalesce("BigIntValue"::integer,0) = 1 then substring(coalesce("Value",'|'),0, position('|' in coalesce("Value",'|'))) + + end), '; ') AS "x" + from "DocumentAdditionalAttribute" atr + join "DocumentCategoryAttributeType" dca on atr."CategoryAttributeType" = dca."VCode" + where t."DocCode" = atr."PCode" and dca."ColumnName" not in ('#bdate#', '#edate#', '#kolvo#')) +*/ null as "AnyColumnI", +null/*sii."Name"*/, +case when coalesce(t."RouteStatusId",0) = 2 and exists (select 1 from "RouteStage" rs + where rs."PCode" = t."RouteVCode" and rs."StageNumber" = 1 and rs."Status" = 2 ) then 'Не запущен' + when coalesce(t."RouteStatusId",0) = 2 and t."StageItemStatus"= 2 and t."StageNumber" > 1 + and exists (select 1 from "RouteStage" rs + where rs."PCode" = t."RouteVCode" + and isnull(rs."IsMarked",0) = 1 + and rs."StageName" in ( 'Исполнить') + and rs."Status"=1) then 'На согласовании / на согл у рук-ля' + when coalesce(t."RouteStatusId",0) = 3 + and not exists (select 1 from "RouteStage" rs + join "StageItem" si on rs."VCode" = si."PCode" + where rs."PCode" = t."RouteVCode" + and si."DocumentStatus" in (19,23)) then 'Завершен' + when coalesce(t."RouteStatusId",0) = 3 and exists (select 1 from "RouteStage" rs + join "StageItem" si on rs."VCode" = si."PCode" + where rs."PCode" = t."RouteVCode" + and si."DocumentStatus" in (19,23)) then 'Отклонен' +end as "AnyColumnK", +/*( SELECT DISTINCT string_agg(u."Initials"|| '(' || ds."Name"|| ')' , '; ') AS "x" + FROM "RouteStage" as rs + join "StageItem" AS i on i."PCode" = rs."VCode" + join "VUserMeta" AS u ON u."VCode" = i."StageUser" + join "DocumentStatus" AS ds ON ds."VCode" = i."DocumentStatus" + WHERE rs."PCode" = t."RouteVCode" + AND i."StageItemStatus" = 3 + and coalesce(i."DocumentStatus",0) <> 0 + ) */ '' as "AnyColumnL", + +case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select top 1 w."NumTab" from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#' + join "RP_Worker" w on w."VCode" = daa1."BigIntValue" + where t."DocumentCategory" = bd."PCode") + else (select r."NumTab" from "RP_Worker" as r where r."VCode" = t."IdWorker") end as "AnyColumnM", + +case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select top 1 w."NameFull" from "DocumentCategoryAttributeType" bd + join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#' + join "RP_Worker" w on w."VCode" = daa1."BigIntValue" + where t."DocumentCategory" = bd."PCode" ) + else (select r."NameFull" from "RP_Worker" as r where r."VCode" = t."IdWorker") end as "AnyColumnN", +(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "EmailRecipient", +(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "AnyColumnO" +, 2 +from #tmp_preresult t + where t."DocType" not in ('ServiceDesk') and + ( + t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN @_bdate AND @_edate +) + and t."DocType" not in ('ServiceDesk') ; ``` \ No newline at end of file