rez_core 2.1.147 → 2.1.148
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.
- package/dist/module/workflow/controller/action.controller.d.ts +1 -1
- package/dist/module/workflow/entity/action.entity.d.ts +1 -1
- package/dist/module/workflow/entity/action.entity.js +2 -2
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/service/action-category.service.js +4 -1
- package/dist/module/workflow/service/action-category.service.js.map +1 -1
- package/dist/module/workflow/service/action.service.d.ts +1 -1
- package/dist/module/workflow/service/action.service.js +57 -53
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/entity/action.entity.ts +2 -2
- package/src/module/workflow/service/action-category.service.ts +4 -1
- package/src/module/workflow/service/action.service.ts +71 -68
package/package.json
CHANGED
|
@@ -24,8 +24,8 @@ export class ActionEntity extends BaseEntity {
|
|
|
24
24
|
@Column({ type: 'varchar', nullable: true })
|
|
25
25
|
reason_code: string;
|
|
26
26
|
|
|
27
|
-
@Column({ type: '
|
|
28
|
-
default_reason_code:
|
|
27
|
+
@Column({ type: 'int', nullable: true })
|
|
28
|
+
default_reason_code: number;
|
|
29
29
|
|
|
30
30
|
@Column({ default: 0, type: 'boolean' })
|
|
31
31
|
default_value: boolean;
|
|
@@ -37,8 +37,6 @@ export class ActionService extends EntityServiceImpl {
|
|
|
37
37
|
manager?: EntityManager | null,
|
|
38
38
|
appcode?: string,
|
|
39
39
|
): Promise<any> {
|
|
40
|
-
console.log('entityData', entityData);
|
|
41
|
-
|
|
42
40
|
let actionData = entityData as any;
|
|
43
41
|
|
|
44
42
|
let action = await super.createEntity(
|
|
@@ -196,7 +194,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
196
194
|
}
|
|
197
195
|
const result = await this.dataSource.query(
|
|
198
196
|
`
|
|
199
|
-
SELECT name,
|
|
197
|
+
SELECT name, id
|
|
200
198
|
FROM cr_list_master_items
|
|
201
199
|
WHERE listtype = ? AND organization_id = ?
|
|
202
200
|
`,
|
|
@@ -205,8 +203,8 @@ export class ActionService extends EntityServiceImpl {
|
|
|
205
203
|
|
|
206
204
|
// Format as array of key-value pairs
|
|
207
205
|
return result.map((row: any) => ({
|
|
208
|
-
label: row.
|
|
209
|
-
value: row.
|
|
206
|
+
label: row.name,
|
|
207
|
+
value: row.id,
|
|
210
208
|
}));
|
|
211
209
|
}
|
|
212
210
|
|
|
@@ -228,88 +226,93 @@ export class ActionService extends EntityServiceImpl {
|
|
|
228
226
|
const actionIds = stageActions.map((sa) => sa.action_id);
|
|
229
227
|
const mappingIds = stageActions.map((sa) => sa.id);
|
|
230
228
|
|
|
229
|
+
// Step 2: Get template codes with mapping IDs
|
|
231
230
|
const templateMappings = await this.dataSource.query(
|
|
232
231
|
`
|
|
233
|
-
SELECT template_code
|
|
232
|
+
SELECT stg_act_mapping_id, template_code
|
|
234
233
|
FROM cr_wf_action_template_mapping
|
|
235
|
-
WHERE stg_act_mapping_id IN (?)
|
|
234
|
+
WHERE stg_act_mapping_id IN (${mappingIds.map(() => '?').join(',')})
|
|
236
235
|
`,
|
|
237
|
-
|
|
236
|
+
mappingIds,
|
|
238
237
|
);
|
|
239
238
|
|
|
240
239
|
const templateCodes = templateMappings.map((tm) => tm.template_code);
|
|
241
240
|
|
|
242
241
|
// Step 3: Fetch template names from cr_wf_comm_template
|
|
243
|
-
|
|
242
|
+
const templateCodeToName: Record<string, string> = {};
|
|
244
243
|
|
|
245
244
|
if (templateCodes.length > 0) {
|
|
246
|
-
const templates = await this.dataSource
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
// Map template_code to name
|
|
257
|
-
const codeToNameMap = templates.reduce((acc, curr) => {
|
|
258
|
-
acc[curr.code] = curr.name;
|
|
259
|
-
return acc;
|
|
260
|
-
}, {});
|
|
261
|
-
|
|
262
|
-
// Group template names by mapping_id
|
|
263
|
-
templateMappings.forEach((tm) => {
|
|
264
|
-
const mappingId = tm.stg_act_mapping_id;
|
|
265
|
-
const name = codeToNameMap[tm.template_code];
|
|
266
|
-
if (name) {
|
|
267
|
-
if (!templateNameMap[mappingId]) {
|
|
268
|
-
templateNameMap[mappingId] = name;
|
|
269
|
-
} else {
|
|
270
|
-
templateNameMap[mappingId] += `, ${name}`;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
245
|
+
const templates = await this.dataSource
|
|
246
|
+
.createQueryBuilder()
|
|
247
|
+
.select(['t.code AS code', 't.name AS name'])
|
|
248
|
+
.from('cr_wf_comm_template', 't')
|
|
249
|
+
.where('t.code IN (:...codes)', { codes: templateCodes })
|
|
250
|
+
.andWhere('t.organization_id = :orgId', { orgId: organization_id })
|
|
251
|
+
.getRawMany();
|
|
252
|
+
|
|
253
|
+
templates.forEach((tpl) => {
|
|
254
|
+
templateCodeToName[tpl.code] = tpl.name;
|
|
273
255
|
});
|
|
274
256
|
}
|
|
275
257
|
|
|
276
|
-
// Step
|
|
277
|
-
|
|
278
|
-
const result = await this.dataSource.query(
|
|
279
|
-
`
|
|
280
|
-
SELECT
|
|
281
|
-
a.id,
|
|
282
|
-
a.name AS action_name,
|
|
283
|
-
ac.name AS action_category,
|
|
284
|
-
ar.name AS action_requirement
|
|
285
|
-
FROM cr_wf_action a
|
|
286
|
-
LEFT JOIN cr_wf_action_category ac
|
|
287
|
-
ON ac.id = a.action_cat_id
|
|
288
|
-
LEFT JOIN cr_list_master_items ar
|
|
289
|
-
ON ar.id = a.action_requirement
|
|
290
|
-
AND ar.listtype = 'ACRQ'
|
|
291
|
-
AND ar.organization_id = ?
|
|
292
|
-
WHERE a.organization_id = ?
|
|
293
|
-
AND a.id IN (?)
|
|
294
|
-
`,
|
|
295
|
-
[organization_id, organization_id, actionIds],
|
|
296
|
-
);
|
|
258
|
+
// Step 4: Build map of mapping_id → template names
|
|
259
|
+
const mappingIdToTemplates: Record<number, string[]> = {};
|
|
297
260
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
261
|
+
for (const tm of templateMappings) {
|
|
262
|
+
const mappingId = tm.stg_act_mapping_id;
|
|
263
|
+
const name = templateCodeToName[tm.template_code];
|
|
264
|
+
if (name) {
|
|
265
|
+
if (!mappingIdToTemplates[mappingId]) {
|
|
266
|
+
mappingIdToTemplates[mappingId] = [];
|
|
267
|
+
}
|
|
268
|
+
mappingIdToTemplates[mappingId].push(name);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Step 5: Build action_id → template names using mappingIdToTemplates + stageActions
|
|
273
|
+
const actionIdToTemplates: Record<number, string[]> = {};
|
|
274
|
+
|
|
275
|
+
for (const sa of stageActions) {
|
|
276
|
+
const mappingId = sa.id;
|
|
277
|
+
const templates = mappingIdToTemplates[mappingId];
|
|
278
|
+
if (templates?.length) {
|
|
279
|
+
if (!actionIdToTemplates[sa.action_id]) {
|
|
280
|
+
actionIdToTemplates[sa.action_id] = [];
|
|
281
|
+
}
|
|
282
|
+
actionIdToTemplates[sa.action_id].push(...templates);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
304
285
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
286
|
+
// Step 6: Fetch action details
|
|
287
|
+
const actionResults = await this.dataSource
|
|
288
|
+
.createQueryBuilder()
|
|
289
|
+
.select([
|
|
290
|
+
'a.id AS id',
|
|
291
|
+
'a.name AS action_name',
|
|
292
|
+
'ac.name AS action_category',
|
|
293
|
+
'ar.name AS action_requirement',
|
|
294
|
+
])
|
|
295
|
+
.from('cr_wf_action', 'a')
|
|
296
|
+
.leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_cat_id')
|
|
297
|
+
.leftJoin(
|
|
298
|
+
'cr_list_master_items',
|
|
299
|
+
'ar',
|
|
300
|
+
`ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
|
|
301
|
+
{ orgId: organization_id },
|
|
302
|
+
)
|
|
303
|
+
.where('a.organization_id = :orgId', { orgId: organization_id })
|
|
304
|
+
.andWhere('a.id IN (:...actionIds)', { actionIds })
|
|
305
|
+
.getRawMany();
|
|
306
|
+
|
|
307
|
+
// Step 7: Enrich result with template field
|
|
308
|
+
const enrichedResult = actionResults.map((row) => {
|
|
309
|
+
const actionId = Number(row.id); // Ensure numeric ID match
|
|
310
|
+
const templates = actionIdToTemplates[actionId] || [];
|
|
311
|
+
const uniqueTemplates = [...new Set(templates)]; // remove duplicates
|
|
309
312
|
|
|
310
313
|
return {
|
|
311
314
|
...row,
|
|
312
|
-
template:
|
|
315
|
+
template: uniqueTemplates.join(', '),
|
|
313
316
|
};
|
|
314
317
|
});
|
|
315
318
|
|