rez_core 5.0.62 → 5.0.65
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/repository/action.repository.js +24 -21
- package/dist/module/workflow/repository/action.repository.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js +2 -1
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/repository/action.repository.ts +29 -29
- package/src/module/workflow/service/populate-workflow.service.ts +3 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
NotFoundException,
|
|
6
6
|
} from '@nestjs/common';
|
|
7
7
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
8
|
-
import { DataSource, Repository } from 'typeorm';
|
|
8
|
+
import { DataSource, In, Repository } from 'typeorm';
|
|
9
9
|
import { ActionEntity } from '../entity/action.entity';
|
|
10
10
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
11
11
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
@@ -62,44 +62,42 @@ export class ActionRepository {
|
|
|
62
62
|
async getActions(loggedInUser: UserData, stage_id: number) {
|
|
63
63
|
const { organization_id } = loggedInUser;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
const stageActions = await this.dataSource.query(
|
|
67
|
-
`
|
|
68
|
-
SELECT id, action_id
|
|
69
|
-
FROM frm_wf_stage_action_mapping
|
|
70
|
-
WHERE stage_id = $1
|
|
71
|
-
`,
|
|
72
|
-
[stage_id],
|
|
73
|
-
);
|
|
65
|
+
const workflowStageActionRepo = this.reflectionHelper.getRepoService('StageActionMapping');
|
|
74
66
|
|
|
67
|
+
// Step 1: Get all action_ids for the provided stage_id
|
|
68
|
+
const stageActions = await workflowStageActionRepo.find({
|
|
69
|
+
where: {
|
|
70
|
+
stage_id: stage_id
|
|
71
|
+
}
|
|
72
|
+
})
|
|
75
73
|
if (!stageActions?.length) return [];
|
|
76
74
|
|
|
77
75
|
const actionIds = stageActions.map((sa) => sa.action_id);
|
|
78
76
|
const mappingIds = stageActions.map((sa) => sa.id);
|
|
79
77
|
|
|
80
78
|
// Step 2: Get template codes with mapping IDs
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
79
|
+
const workflowActionTemplateMappingRepo = this.reflectionHelper.getRepoService('ActionTemplateMapping');
|
|
80
|
+
|
|
81
|
+
const templateMappings = await workflowActionTemplateMappingRepo.find({
|
|
82
|
+
where: {
|
|
83
|
+
stg_act_mapping_id: In(mappingIds)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
89
86
|
|
|
90
87
|
const templateCodes = templateMappings.map((tm) => tm.template_code);
|
|
91
88
|
|
|
92
89
|
// Step 3: Fetch template names from frm_wf_comm_template
|
|
93
90
|
const templateCodeToName: Record<string, string> = {};
|
|
94
91
|
|
|
92
|
+
const workflowCommTemplateRepo = this.reflectionHelper.getRepoService('CommTemplate');
|
|
93
|
+
|
|
95
94
|
if (templateCodes.length > 0) {
|
|
96
|
-
const templates = await
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.getRawMany();
|
|
95
|
+
const templates = await workflowCommTemplateRepo.find({
|
|
96
|
+
where: {
|
|
97
|
+
code: In(templateCodes),
|
|
98
|
+
organization_id: organization_id
|
|
99
|
+
}
|
|
100
|
+
});
|
|
103
101
|
|
|
104
102
|
templates.forEach((tpl) => {
|
|
105
103
|
templateCodeToName[tpl.code] = tpl.name;
|
|
@@ -135,7 +133,9 @@ export class ActionRepository {
|
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// Step 6: Fetch action details
|
|
138
|
-
const
|
|
136
|
+
const workflowActionRepo = this.reflectionHelper.getRepoService('ActionEntity');
|
|
137
|
+
|
|
138
|
+
const actionResults = await workflowActionRepo
|
|
139
139
|
.createQueryBuilder()
|
|
140
140
|
.select([
|
|
141
141
|
'a.*',
|
|
@@ -144,15 +144,15 @@ export class ActionRepository {
|
|
|
144
144
|
'ar.name AS action_requirement',
|
|
145
145
|
])
|
|
146
146
|
.from('frm_wf_action', 'a')
|
|
147
|
-
.leftJoin('frm_wf_action_category', 'ac', 'ac.id = a.action_category')
|
|
147
|
+
.leftJoin('frm_wf_action_category', 'ac', 'ac.id::text = a.action_category')
|
|
148
148
|
.leftJoin(
|
|
149
149
|
'frm_list_master_items',
|
|
150
150
|
'ar',
|
|
151
|
-
`ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
|
|
151
|
+
`ar.id::text = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
|
|
152
152
|
{ orgId: organization_id },
|
|
153
153
|
)
|
|
154
154
|
.where('a.organization_id = :orgId', { orgId: organization_id })
|
|
155
|
-
.andWhere('a.id IN (:...actionIds)', { actionIds })
|
|
155
|
+
.andWhere('a.id::text IN (:...actionIds)', { actionIds })
|
|
156
156
|
.getRawMany();
|
|
157
157
|
|
|
158
158
|
// Step 7: Enrich result with template field
|
|
@@ -157,12 +157,14 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
157
157
|
|
|
158
158
|
if (!workflowLevelMappingRepo) continue;
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
const newMapping = workflowLevelMappingRepo.create({
|
|
161
161
|
workflow_id: Number(newWf.id),
|
|
162
162
|
mapped_level_id: organization_id.toString(),
|
|
163
163
|
mapped_level_type: 'ORG',
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
+
await workflowLevelMappingRepo.save(newMapping);
|
|
167
|
+
|
|
166
168
|
workflowIdMap[id] = newWf.id;
|
|
167
169
|
}
|
|
168
170
|
|