convert_after_postgres.sql
8.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
do $$
begin
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalrule' and column_name = 'rewkperftype')
then
update
Sungero_Docflow_ApprovalRule
set
RewkPerfType = 'Author'
where
RewkPerfType is null;
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalrule' and column_name = 'rewkdeadline')
then
update
Sungero_Docflow_ApprovalRule
set
RewkDeadline = 3
where
RewkDeadline is null;
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalstage' and column_name = 'allowsendrwk')
then
-- Выключить Разрешить отправку на доработку в этапах печати, регистрации, отправке, создании поручений.
update
Sungero_Docflow_ApprovalStage
set
AllowSendRwk = false
where
StageType in ('Print', 'Register', 'Sending', 'Execution')
and AllowSendRwk is null;
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalstage' and column_name = 'rewkperftype')
then
-- Заполнить Отв. за доработку в этапах согласования, согласования с руководителем, подписания, рассмотрения, задание с доработкой.
update
Sungero_Docflow_ApprovalStage
set
RewkPerfType = 'FromRule'
where
RewkPerfType is null
and (StageType in ('Approvers', 'Manager', 'Sign', 'Review')
or StageType = 'SimpleAgr' and AllowSendRwk = true);
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalstage' and column_name = 'allowchangerwk')
then
-- Выключить Разрешить выбор ответственного за доработку в этапах печати, регистрации, отправке, создании поручений,
-- согласования, согласования с руководителем, подписания, рассмотрения, задание с доработкой.
update
Sungero_Docflow_ApprovalStage
set
AllowChangeRwk = false
where
StageType in ('Print', 'Register', 'Sending', 'Execution', 'Approvers', 'Manager', 'Sign', 'Review', 'SimpleAgr')
and AllowChangeRwk is null;
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_docflow_approvalstage' and column_name = 'reworktype')
then
-- Заполнить Доработку в этапах согласование с рук., печати, подписания, регистрации, отправке, создании поручений, рассмотрения.
update
Sungero_Docflow_ApprovalStage
set
ReworkType = null
where
ReworkType = 'AfterAll'
and StageType in ('Manager', 'Print', 'Sign', 'Register', 'Sending', 'Execution', 'Review');
end if;
-- *******************************
-- Заполенение свойств в заданиях.
-- *******************************
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperformer_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании согласования.
update Sungero_WF_Assignment a
set
RewkPerformer_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerformer_Docflow_Sungero is null
and a.Discriminator = 'daf1900f-e66b-4368-b724-a073266145d7';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperfcheck_docflow_sungero')
then
-- Заполнить Отв. за доработку в простом задании с доработкой.
update Sungero_WF_Assignment a
set
RewkPerfCheck_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerfCheck_Docflow_Sungero is null
and a.Discriminator = 'c09f0ae4-c959-4a57-9895-ae9aaf1f1855';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforexe_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании исполнения поручения.
update Sungero_WF_Assignment a
set
RewkPerforExe_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforExe_Docflow_Sungero is null
and a.Discriminator = '495600a5-5f7a-49aa-ac49-9351c9af1109';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforman_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании согласования с руководителем.
update Sungero_WF_Assignment a
set
RewkPerforMan_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforMan_Docflow_Sungero is null
and a.Discriminator = 'bbb08f45-60c1-4496-9ff6-b32caed44215';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforprn_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании на печать.
update Sungero_WF_Assignment a
set
RewkPerforPrn_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforPrn_Docflow_Sungero is null
and a.Discriminator = '8cd7f587-a910-4e2f-ac4f-afcc15fc3e2f';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforreg_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании на регистрацию.
update Sungero_WF_Assignment a
set
RewkPerforReg_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforReg_Docflow_Sungero is null
and a.Discriminator = 'a3b19bde-a0a5-4c7b-9ad4-5a7e800156a9';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforrev_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании на рассмотрение.
update Sungero_WF_Assignment a
set
RewkPerforRev_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforRev_Docflow_Sungero is null
and a.Discriminator = '079b6ce1-8a62-41a6-aa89-0de5e5266253';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforsen_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании на отправку КА.
update Sungero_WF_Assignment a
set
RewkPerforSen_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforSen_Docflow_Sungero is null
and a.Discriminator = '5d86a6e4-ae51-497a-9122-8a812eba0fc7';
end if;
if exists(select *
from information_schema.columns
where table_name = 'sungero_wf_assignment' and column_name = 'rewkperforsig_docflow_sungero')
then
-- Заполнить Отв. за доработку в задании на подпись.
update Sungero_WF_Assignment a
set
RewkPerforSig_Docflow_Sungero = t.Author
from Sungero_WF_Assignment aa
join Sungero_WF_Task t
on aa.Task = t.Id
where a.Id = aa.Id
and a.Status = 'InProcess'
and a.RewkPerforSig_Docflow_Sungero is null
and a.Discriminator = 'db516acc-0f02-4ea7-960a-08f3f734db4f';
end if;
end $$;