forlogic-core 2.5.2 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,44 +55,81 @@ BEGIN
55
55
  AND o.removed = 0
56
56
  WHERE os.id_batch = @id_batch;
57
57
 
58
- -- INSERÇÃO: Apenas registros válidos
59
58
  INSERT INTO occurrences.occurrences
60
59
  (
61
- code,
62
- name,
63
- id_type,
64
- id_category,
65
- description,
66
- id_creation_user,
67
- id_responsible,
68
- start_date,
69
- end_date,
70
- id_status,
71
- id_company,
72
- root_cause_identification_required,
73
- checker_responsible_equals_in_occurrences,
74
- creation_date,
75
- last_modified,
76
- removed
60
+ id_company,
61
+ id_status,
62
+ id_method,
63
+ code,
64
+ name,
65
+ description,
66
+ description_text,
67
+ id_type,
68
+ id_category,
69
+ id_creation_user,
70
+ id_responsible,
71
+ start_date,
72
+ end_date,
73
+ creation_date,
74
+ last_modified,
75
+ sketch,
76
+ removed,
77
+ is_mobile,
78
+ id_days_work,
79
+ allow_plan_before_analyze,
80
+ complete_actions_before_advance,
81
+ checker_actions_required,
82
+ checker_responsible_equals,
83
+ allow_define_action_plan_out_deadline,
84
+ ishikawa_diagram_required,
85
+ tree_5why_diagram_required,
86
+ allow_tree_diagram,
87
+ canceled_by_audit,
88
+ has_module,
89
+ removed_by_audit,
90
+ mandatory_attachment,
91
+ root_cause_identification_required,
92
+ checker_responsible_equals_in_occurrences,
93
+ allow_attachments_before_approval
77
94
  )
78
95
  SELECT
96
+ os.id_company,
97
+ os.id_status,
98
+ 1 AS id_method,
79
99
  os.code,
80
100
  os.name,
101
+ NULLIF(os.description, ''),
102
+ NULLIF(os.description, ''),
81
103
  os.id_type,
82
104
  os.id_category,
83
- os.description,
84
105
  os.id_creation_user,
85
106
  os.id_responsible,
86
107
  os.start_date,
87
108
  os.end_date,
88
- os.id_status,
89
- os.id_company,
90
- 1,
91
- 0,
92
- SYSDATETIMEOFFSET(),
93
- SYSDATETIMEOFFSET(),
94
- 0
109
+ SYSDATETIMEOFFSET() AS creation_date,
110
+ SYSDATETIMEOFFSET() AS last_modified,
111
+ 0 AS sketch,
112
+ 0 AS removed,
113
+ 0 AS is_mobile,
114
+ ISNULL(c.id_days_work, 1) AS id_days_work,
115
+ 0 AS allow_plan_before_analyze,
116
+ 0 AS complete_actions_before_advance,
117
+ 0 AS checker_actions_required,
118
+ 0 AS checker_responsible_equals,
119
+ 0 AS allow_define_action_plan_out_deadline,
120
+ 0 AS ishikawa_diagram_required,
121
+ 0 AS tree_5why_diagram_required,
122
+ 0 AS allow_tree_diagram,
123
+ 0 AS canceled_by_audit,
124
+ 0 AS has_module,
125
+ 0 AS removed_by_audit,
126
+ 0 AS mandatory_attachment,
127
+ 1 AS root_cause_identification_required,
128
+ 0 AS checker_responsible_equals_in_occurrences,
129
+ 0 AS allow_attachments_before_approval
95
130
  FROM import.occurrences_staging os WITH (NOLOCK)
131
+ LEFT JOIN occurrences.configurations c WITH (NOLOCK)
132
+ ON c.id_company COLLATE Latin1_General_CS_AS = os.id_company
96
133
  WHERE os.id_batch = @id_batch
97
134
  AND NOT EXISTS (
98
135
  SELECT 1
@@ -155,7 +192,6 @@ BEGIN
155
192
  WHERE os.id_batch = @id_batch
156
193
  AND o.id_category IS NOT NULL;
157
194
 
158
- -- create a record table that will hold one row per phase, calculated sequentially
159
195
  CREATE TABLE #phase_records (
160
196
  id_company CHAR(8),
161
197
  id_occurrence CHAR(8),
@@ -167,80 +203,38 @@ BEGIN
167
203
 
168
204
  -- evaluation
169
205
  INSERT INTO #phase_records
170
- SELECT
171
- id_company,
172
- id_occurrence,
173
- id_responsible,
174
- 2,
175
- days_evaluation,
176
- dbo.AddDays(days_evaluation, start_date, id_days_work, 0)
206
+ SELECT id_company, id_occurrence, id_responsible, 2, days_evaluation, dbo.AddDays(days_evaluation, start_date, id_days_work, 0)
177
207
  FROM #occurrence_phases;
178
208
 
179
- -- cause analysis (cumulative)
209
+ -- cause analysis
180
210
  INSERT INTO #phase_records
181
- SELECT
182
- id_company,
183
- id_occurrence,
184
- id_responsible,
185
- 3,
186
- days_causes_analysis,
187
- dbo.AddDays(days_evaluation + days_causes_analysis, start_date, id_days_work, 0)
211
+ SELECT id_company, id_occurrence, id_responsible, 3, days_causes_analysis, dbo.AddDays(days_evaluation + days_causes_analysis, start_date, id_days_work, 0)
188
212
  FROM #occurrence_phases;
189
213
 
190
- -- action plan elaboration (cumulative)
214
+ -- action plan elaboration
191
215
  INSERT INTO #phase_records
192
- SELECT
193
- id_company,
194
- id_occurrence,
195
- id_responsible,
196
- 4,
197
- days_action_plan_elaboration,
198
- dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration, start_date, id_days_work, 0)
216
+ SELECT id_company, id_occurrence, id_responsible, 4, days_action_plan_elaboration, dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration, start_date, id_days_work, 0)
199
217
  FROM #occurrence_phases;
200
218
 
201
- -- action plan execution (cumulative)
219
+ -- action plan execution
202
220
  INSERT INTO #phase_records
203
- SELECT
204
- id_company,
205
- id_occurrence,
206
- id_responsible,
207
- 5,
208
- days_action_plan_execution,
209
- dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution, start_date, id_days_work, 0)
221
+ SELECT id_company, id_occurrence, id_responsible, 5, days_action_plan_execution, dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution, start_date, id_days_work, 0)
210
222
  FROM #occurrence_phases;
211
223
 
212
- -- effectiveness check (cumulative)
224
+ -- effectiveness check
213
225
  INSERT INTO #phase_records
214
- SELECT
215
- id_company,
216
- id_occurrence,
217
- id_responsible,
218
- 6,
219
- days_effectiveness_check,
220
- dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution + days_effectiveness_check, start_date, id_days_work, 0)
226
+ SELECT id_company, id_occurrence, id_responsible, 6, days_effectiveness_check, dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution + days_effectiveness_check, start_date, id_days_work, 0)
221
227
  FROM #occurrence_phases;
222
228
 
223
- -- standardization (cumulative)
229
+ -- standardization
224
230
  INSERT INTO #phase_records
225
- SELECT
226
- id_company,
227
- id_occurrence,
228
- id_responsible,
229
- 7,
230
- days_standardization,
231
- dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution + days_effectiveness_check + days_standardization, start_date, id_days_work, 0)
231
+ SELECT id_company, id_occurrence, id_responsible, 7, days_standardization, dbo.AddDays(days_evaluation + days_causes_analysis + days_action_plan_elaboration + days_action_plan_execution + days_effectiveness_check + days_standardization, start_date, id_days_work, 0)
232
232
  FROM #occurrence_phases;
233
233
 
234
- -- finally insert all records into production at once
235
234
  INSERT INTO occurrences.phase_associations
236
235
  (id_company, id_occurrence, id_responsible, id_status, duration_days, end_date)
237
236
  SELECT
238
- id_company,
239
- id_occurrence,
240
- id_responsible,
241
- phase_status,
242
- phase_duration,
243
- phase_end_date
237
+ id_company, id_occurrence, id_responsible, phase_status, phase_duration, phase_end_date
244
238
  FROM #phase_records;
245
239
 
246
240
  DROP TABLE #occurrence_phases;
@@ -249,8 +243,8 @@ BEGIN
249
243
  END
250
244
  GO
251
245
 
252
- use [qualiex_common]
253
- go
246
+ USE [qualiex_common]
247
+ GO
254
248
 
255
249
  CREATE OR ALTER PROCEDURE import.get_errors_occurrences
256
250
  (
@@ -292,4 +286,4 @@ BEGIN
292
286
  os.id_status
293
287
  ORDER BY e.row_num;
294
288
  END
295
- GO
289
+ GO
@@ -132,20 +132,25 @@ BEGIN
132
132
  AND ocs.active_standardization = 'Sim'
133
133
  AND (ocs.days_standardization IS NULL OR LTRIM(RTRIM(ocs.days_standardization)) = '');
134
134
 
135
- -- Validação 9: Regra de priorização informada deve existir
135
+ -- Validação 9: Regra de priorização informada deve existir e estar ativa
136
136
  INSERT INTO import.errors (id_batch, row_num, error_msg)
137
- SELECT @id_batch, ocs.row_num, 'Regra de priorização não encontrada'
137
+ SELECT @id_batch, ocs.row_num, 'Regra de priorização não encontrada ou inativa'
138
138
  FROM import.occurrences_categories_staging ocs WITH (NOLOCK)
139
139
  WHERE ocs.id_batch = @id_batch
140
140
  AND ocs.id_rule_prioritization IS NOT NULL
141
141
  AND LTRIM(RTRIM(ocs.id_rule_prioritization)) <> ''
142
142
  AND NOT EXISTS (
143
- SELECT 1 FROM occurrences.rules_prioritization rp WITH (NOLOCK)
144
- -- Correção: Collation explícito aqui também!
145
- WHERE rp.id COLLATE Latin1_General_CS_AS = ocs.id_rule_prioritization
146
- AND rp.id_company COLLATE Latin1_General_CS_AS = ocs.id_company
143
+ SELECT 1 FROM dbo.prioritization_rules_template rp WITH (NOLOCK)
144
+ WHERE rp.id COLLATE Latin1_General_CS_AS = LTRIM(RTRIM(ocs.id_rule_prioritization)) COLLATE Latin1_General_CS_AS
145
+ AND rp.removed = 0
146
+ AND rp.is_active = 1
147
+ AND (
148
+ rp.id_company IS NULL
149
+ OR rp.id_company COLLATE Latin1_General_CS_AS = ocs.id_company COLLATE Latin1_General_CS_AS
150
+ )
147
151
  );
148
152
 
153
+
149
154
  -- INSERÇÃO DOS DADOS VÁLIDOS
150
155
  INSERT INTO occurrences.categories
151
156
  (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forlogic-core",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -126,7 +126,6 @@
126
126
  "@tiptap/extension-underline": "^3.14.0",
127
127
  "@tiptap/react": "^3.14.0",
128
128
  "@tiptap/starter-kit": "^3.14.0",
129
- "@types/dompurify": "^3.2.0",
130
129
  "class-variance-authority": "^0.7.1",
131
130
  "clsx": "^2.1.1",
132
131
  "date-fns": "^3.6.0",