18643 настройки ЖСД
This commit is contained in:
parent
97b9328bee
commit
cc02f2d144
|
@ -7,7 +7,7 @@
|
|||
|
||||
Откроется новая форма.
|
||||
|
||||
![alt text](media/image-4.png)
|
||||
![alt text](media/image-6.png)
|
||||
|
||||
При нажатии на кнопку **"Показать подсказки"** в верхней части раскрываются рекомендации по работе с данной формой:
|
||||
|
||||
|
@ -19,19 +19,19 @@
|
|||
|
||||
* **Не используется** - при включенной функции данная настройка не будет отображаться в журнале состояния документов.
|
||||
|
||||
![Не используется](media/neIspol.png)
|
||||
![alt text](media/image-7.png)
|
||||
|
||||
![Фильтр](media/filtr.png)
|
||||
|
||||
* **№ / Пользовательское наименование** - указывается порядковый номер и наименование настройки для отображения в журнале состояния документов.
|
||||
|
||||
![alt text](media/image-1.png)
|
||||
![alt text](media/image-9.png)
|
||||
|
||||
![Наименование](media/polNam2.png)
|
||||
|
||||
* **Служебное наименование** - указывается служебное наименование по которому фильтруется реестр документов. Служебное наименование должно быть **уникальным** в системе.
|
||||
|
||||
![alt text](media/image-2.png)
|
||||
![alt text](media/image-10.png)
|
||||
|
||||
* **Показывать в форме** - указывается служебное наименование формы, в которой необходимо отображать данную настройку, например, в личном кабинете HR. Если поле незаполнено то данная настройка отображается во всех формах.
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
|||
|
||||
* **рассчитывать просрочку в документах** - рассчитывает количество дней по нарушением сроков обработки в столбце "Просрочено (дней)"
|
||||
|
||||
* **Работа России** - отображает кнопку ["Отправить в РР"](https://ecm-user-manuals.readthedocs.io/ru/latest/User%20manuals/%D0%A0%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%20%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D0%B8/) в журнале.
|
||||
|
||||
### Скрыть столбцы
|
||||
|
||||
* **Подразделение инициатора** - скрывает колонку "Подразделение инициатора";
|
||||
|
@ -65,7 +67,9 @@
|
|||
|
||||
* **Решение** - скрывает колонку "Решение";
|
||||
|
||||
* **Вложения** - скрывает колонку "Вложения".
|
||||
* **Вложения** - скрывает колонку "Вложения";
|
||||
|
||||
* **Документ** - скрывает колонку "Документ".
|
||||
|
||||
### Добавить группировку
|
||||
|
||||
|
@ -109,20 +113,40 @@
|
|||
|
||||
В данном блоке указывается часть с динамическим запросом, содержащим непосредственно запроса для отображения документов.
|
||||
|
||||
!!! 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 цвет
|
||||
В запросе возможно настроить цветовое отображение полей документов в зависимости от условий. Для этого в запросе необходимо указать поле "Colors" и заполнить его одним из следующих значений: `1 - colors.gray 2 - colors.orange 3 - colors.yellow 4 - colors.green 5 - colors.blue 6 - colors.indigo 7 -colors.violet`.
|
||||
|
||||
!!! note
|
||||
Для того чтобы запрос фильтровался по заданному количеству документов, которое указывается в поле **Кол-во строк/Период (с/по):** необзодимо в конце запроса добавить строку `_topcount` , например: ```left join "tmp_workers_for_documentStatusJournalProc" w2 on w2."VCode" = t."IdWorker" _topcount;```
|
||||
!!! example "Пример:"
|
||||
|
||||
В запросе: **Все документы** данное значение указано в конце запроса:
|
||||
|
||||
```sql
|
||||
(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 цвет
|
||||
|
||||
|
||||
Для того чтобы запрос фильтровался по заданному количеству документов, которое указывается в поле **Кол-во строк/Период (с/по):** необходимо в конце запроса добавить строку `_topcount`
|
||||
|
||||
!!! example "Пример:"
|
||||
```sql
|
||||
left join "tmp_workers_for_documentStatusJournalProc" w2 on w2."VCode" = t."IdWorker" _topcount;
|
||||
```
|
||||
|
||||
### Примеры запросов
|
||||
|
||||
**Просроченные документы** - в реестре отображаются документы, по которым были нарушены сроки обработки:
|
||||
#### Просроченные документы
|
||||
|
||||
В реестре отображаются документы, по которым были нарушены сроки обработки
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -156,11 +180,16 @@ where
|
|||
coalesce(dd."expired", 0) <> 0 ;
|
||||
```
|
||||
|
||||
**Зависшие документы у инициатора** - в реестре отображаются документы, которые были инициированы сотрудником, но не запущены далее по маршруту согласования.
|
||||
#### Зависшие документы у инициатора
|
||||
|
||||
В реестре отображаются документы, которые были инициированы сотрудником, но не запущены далее по маршруту согласования.
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -183,11 +212,16 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa
|
|||
) ;
|
||||
```
|
||||
|
||||
**Поступят к hr в ближайшее время** - в реестре отображаются документы, которые в данный момент находятся на стадии согласования у руководителя сотрудника, и после этого поступят в HR службу.
|
||||
#### Поступят к hr в ближайшее время
|
||||
|
||||
В реестре отображаются документы, которые в данный момент находятся на стадии согласования у руководителя сотрудника, и после этого поступят в HR службу.
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -219,11 +253,16 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa
|
|||
) ;
|
||||
```
|
||||
|
||||
**Сейчас в работе у hr** - в реестре отображаются документы, которые в данный момент находятся в HR службе в работе
|
||||
#### Сейчас в работе у hr
|
||||
|
||||
В реестре отображаются документы, которые в данный момент находятся в HR службе в работе
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -248,11 +287,16 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa
|
|||
) ;
|
||||
```
|
||||
|
||||
**Обработано службой HR сегодня** - в реестре отображаются документы, которые были обработаны сегодня службой HR сегодня.
|
||||
#### Обработано службой HR сегодня
|
||||
|
||||
В реестре отображаются документы, которые были обработаны сегодня службой HR сегодня.
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -278,9 +322,12 @@ insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeNa
|
|||
) ;
|
||||
```
|
||||
|
||||
**Все документы**
|
||||
#### Все документы
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
```sql
|
||||
do $myQ$
|
||||
declare _str text;
|
||||
|
@ -314,7 +361,9 @@ end;
|
|||
$myQ$;
|
||||
```
|
||||
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
IF NOT comdoc."isTableExists"('tmp_addAtribute_for_documentStatusJournalProc', 'temp') THEN
|
||||
CREATE TEMP TABLE "tmp_addAtribute_for_documentStatusJournalProc"(
|
||||
|
@ -471,11 +520,14 @@ drop table "tmp_addAtribute_for_documentStatusJournalProc";
|
|||
drop table "tmp_workers_for_documentStatusJournalProc";
|
||||
```
|
||||
|
||||
**Документы на подписание, просроченные работниками**
|
||||
#### Документы на подписание, просроченные работниками
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```sql
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
|
@ -507,9 +559,12 @@ where coalesce(t."RouteStatusId",0) in (2) and t."StageItemStatus"= 2 and t."IsM
|
|||
;
|
||||
```
|
||||
|
||||
**Договоры и доп. соглашения**
|
||||
#### Договоры и доп. соглашения
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
```sql
|
||||
do $newQ$
|
||||
declare _str text;
|
||||
|
@ -550,12 +605,11 @@ $newQ$;
|
|||
```
|
||||
|
||||
Итоговая выборка:
|
||||
```sql
|
||||
|
||||
```sql
|
||||
do
|
||||
$$
|
||||
begin
|
||||
|
||||
--CREATE INDEX IF NOT EXISTS "idx_tr1_tmp_CategoryAttributeType" ON "tmp_CategoryAttributeType"("PCode" );
|
||||
|
||||
if not comdoc."isTableExists"('tmp_UserRole','temp') then
|
||||
|
@ -612,12 +666,9 @@ round(comdoc."dfwcGetDuration"(t."eDate", COALESCE(t."ActionDate", _now::date),
|
|||
) a
|
||||
where coalesce(a."expired", 0) > 0
|
||||
group by a."DocCode", a."Role";
|
||||
|
||||
|
||||
end;
|
||||
$$;
|
||||
|
||||
|
||||
insert into "tmp_finresult"( "DocCode" , "DocType" , "DocForm" , "DocTypeName" , "SettingsId"
|
||||
, "orgId" , "DocumentDate" , "DocumentNumber" , "VirtualCUser" , "DateOfExecution"
|
||||
, "DateControl" , "RouteVCode" , "RouteStatusId" , "RouteStatusName" , "DocName"
|
||||
|
@ -754,7 +805,9 @@ inner join contract."VContractRegistry" c on t."DocCode" = c."VCode"
|
|||
FETCH FIRST 1 ROWS WITH TIES ) --as "workers"
|
||||
AS wi ON wi."lexLogin" = t."VirtualCUser"
|
||||
LEFT JOIN LATERAL comdoc."getDocRouteCurrentStatus"(t."DocCode", t."DocType") AS rst ON true
|
||||
|
||||
--where c."DateContract" BETWEEN _bdate AND _edate
|
||||
|
||||
/*union all
|
||||
select distinct t."DocCode" , t."DocType" , t."DocForm" , t."DocTypeName" , t."SettingsId"
|
||||
, t."orgId" , t."DocumentDate" , t."DocumentNumber" , t."VirtualCUser" , t."DateOfExecution"
|
||||
|
@ -858,6 +911,259 @@ from "tmp_preresult" t
|
|||
AS wi ON wi."lexLogin" = t."VirtualCUser"
|
||||
LEFT JOIN LATERAL comdoc."getDocRouteCurrentStatus"(t."DocCode", t."DocType") AS rst ON true
|
||||
-- where c."DateContract" BETWEEN _bdate AND _edate
|
||||
|
||||
*/
|
||||
```
|
||||
|
||||
#### Документы в работе у подчиненных
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```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" , "DocumentSubtype" ,
|
||||
"AnyColumnA" ,"AnyColumnB" , "AnyColumnC","AnyColumnD" ,
|
||||
"AnyColumnE" ,
|
||||
"AnyColumnF", "AnyColumnG" , "AnyColumnH" , "AnyColumnI", "AnyColumnJ","AnyColumnK")
|
||||
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 pc."Code" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
join rp."RP_PersonContact" AS pc ON pc."Pcode" = w."IdPerson" AND pc."IdTypeContact" = 6
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else t."VirtualCUser" end,
|
||||
|
||||
t."DateOfExecution"
|
||||
, t."DateControl" , t."RouteVCode" , t."RouteStatusId" , t."RouteStatusName" , t."DocName"
|
||||
, t."DocSubject" ,
|
||||
comdoc."dfwcGetDuration"(t."eDate", COALESCE(t."ActionDate", _now), false, t."orgId", 1, _dayoff1, _dayoff2, null) ,
|
||||
t."StageNumber" , t."BeginDate" , t."ActionDate"
|
||||
, t."DocumentAction" , t."DocumentStatus" , t."FromMessage" , t."eDate"
|
||||
, t."StageUser" , t."StageItemStatus" , t."StageStatus" , t."StageItemAction", t."DocumentSubtype", t."AnyColumnA" ,
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."ID_RP",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select coalesce(m."ID_RP",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnB" ,
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."RP_Txt",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1) else (select coalesce(m."RP_Txt",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnC",
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."ID_ER",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1) else (select coalesce(m."ID_ER",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnD" ,
|
||||
t."AnyColumnE",
|
||||
(select to_char(daa1."DateValue", 'DD.MM.YYYY') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#bdate#' where t."DocumentCategory" = bd."PCode" limit 1) as "AnyColumnF" ,
|
||||
(select to_char(daa1."DateValue", 'DD.MM.YYYY') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#edate#' where t."DocumentCategory" = bd."PCode" limit 1) as "AnyColumnG" ,
|
||||
(select daa1."BigIntValue"::text from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" ='#kolvo#' where t."DocumentCategory" = bd."PCode" limit 1) 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 dfd."DocumentAdditionalAttribute" atr
|
||||
join dfd."DocumentCategoryAttributeType" dca on atr."CategoryAttributeType" = dca."VCode"
|
||||
where t."DocCode" = atr."PCode" and dca."ColumnName" not in ('#bdate#', '#edate#', '#kolvo#')) as "AnyColumnI",
|
||||
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select w."NumTab" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select r."NumTab" from rp."RP_Worker" as r where r."VCode" = t."IdWorker") end ,
|
||||
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select w."NameFull" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select r."NameFull" from rp."RP_Worker" as r where r."VCode" = t."IdWorker") end
|
||||
from "tmp_preresult" t
|
||||
where coalesce(t."RouteStatusId",0) = 2 and t."IsMarked" is not true
|
||||
and t."StageItemStatus"= 2 and
|
||||
exists (select 1
|
||||
from comdoc."getWorkerChiefStructure"(null::bigint,lex."getVirtualLogin"(),1) s
|
||||
join rp."RP_Worker" r on s."VCode" = r."VCode"
|
||||
join rp."RP_PersonContact" c on r."IdPerson" = c."Pcode" and c."IdTypeContact" = 6
|
||||
where c."Code" = coalesce(t."StageUser",'') )
|
||||
AND (
|
||||
t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate
|
||||
) and t."DocType" not in ('ServiceDesk', 'CancellationAct') ;
|
||||
|
||||
```
|
||||
|
||||
#### Универсальные документы подчиненных
|
||||
|
||||
??? note "Запрос"
|
||||
|
||||
Основной запрос:
|
||||
|
||||
Итоговая выборка:
|
||||
|
||||
```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" , "DocumentSubtype" ,
|
||||
"AnyColumnA" ,"AnyColumnB" , "AnyColumnC","AnyColumnD" ,
|
||||
"AnyColumnE" ,
|
||||
"AnyColumnF", "AnyColumnG" , "AnyColumnH" , "AnyColumnI", "AnyColumnJ","AnyColumnK")
|
||||
select distinct 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 pc."Code" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
join rp."RP_PersonContact" AS pc ON pc."Pcode" = w."IdPerson" AND pc."IdTypeContact" = 6
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else t."VirtualCUser" end,
|
||||
|
||||
t."DateOfExecution"
|
||||
, t."DateControl" , t."RouteVCode" , t."RouteStatusId" , t."RouteStatusName" , t."DocName"
|
||||
, t."DocSubject" ,
|
||||
comdoc."dfwcGetDuration"(t."eDate", COALESCE(t."ActionDate", _now), false, t."orgId", 1, _dayoff1, _dayoff2, null) ,
|
||||
t."StageNumber" , t."BeginDate" , t."ActionDate"
|
||||
, t."DocumentAction" , t."DocumentStatus" , t."FromMessage" , t."eDate"
|
||||
, t."StageUser" , t."StageItemStatus" , t."StageStatus" , t."StageItemAction", t."DocumentSubtype", t."AnyColumnA" ,
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."ID_RP",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select coalesce(m."ID_RP",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnB" ,
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."RP_Txt",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1) else (select coalesce(m."RP_Txt",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnC",
|
||||
case when t."DocType" in ('DocumentForSigining','UniversalDocument') then (select coalesce(w."ID_ER",'') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_WorkerMove" w on w."IdWorker" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1) else (select coalesce(m."ID_ER",'') from rp."RP_WorkerMove" AS m where m."IdWorker" = t."IdWorker" limit 1) end as "AnyColumnD" ,
|
||||
t."AnyColumnE",
|
||||
(select to_char(daa1."DateValue", 'DD.MM.YYYY') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#bdate#' where t."DocumentCategory" = bd."PCode" limit 1) as "AnyColumnF" ,
|
||||
(select to_char(daa1."DateValue", 'DD.MM.YYYY') from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#edate#' where t."DocumentCategory" = bd."PCode" limit 1) as "AnyColumnG" ,
|
||||
(select daa1."BigIntValue"::text from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" ='#kolvo#' where t."DocumentCategory" = bd."PCode" limit 1) 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 dfd."DocumentAdditionalAttribute" atr
|
||||
join dfd."DocumentCategoryAttributeType" dca on atr."CategoryAttributeType" = dca."VCode"
|
||||
where t."DocCode" = atr."PCode" and dca."ColumnName" not in ('#bdate#', '#edate#', '#kolvo#')) as "AnyColumnI",
|
||||
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select w."NumTab" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select r."NumTab" from rp."RP_Worker" as r where r."VCode" = t."IdWorker") end ,
|
||||
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select w."NameFull" from dfd."DocumentCategoryAttributeType" bd
|
||||
join dfd."DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
|
||||
join rp."RP_Worker" w on w."VCode" = daa1."BigIntValue"
|
||||
where t."DocumentCategory" = bd."PCode" limit 1)
|
||||
else (select r."NameFull" from rp."RP_Worker" as r where r."VCode" = t."IdWorker") end
|
||||
from "tmp_preresult" t
|
||||
where t."IsMarked" is not true and
|
||||
exists (select 1
|
||||
from comdoc."getWorkerChiefStructure"(null::bigint,lex."getVirtualLogin"(),1) s
|
||||
join rp."RP_Worker" r on s."VCode" = r."VCode"
|
||||
join rp."RP_PersonContact" c on r."IdPerson" = c."Pcode" and c."IdTypeContact" = 6
|
||||
where c."Code" = coalesce(t."StageUser",'') )
|
||||
AND (
|
||||
t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate
|
||||
) and t."DocType" in ('UniversalDocument') ;
|
||||
```
|
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue