rez_core 2.1.148 → 2.1.150
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/meta/entity/base-entity.entity.js.map +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +1 -1
- package/dist/module/workflow/controller/task.controller.d.ts +12 -0
- package/dist/module/workflow/controller/task.controller.js +45 -0
- package/dist/module/workflow/controller/task.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow-meta.controller.d.ts +9 -3
- package/dist/module/workflow/controller/workflow-meta.controller.js +17 -10
- package/dist/module/workflow/controller/workflow-meta.controller.js.map +1 -1
- package/dist/module/workflow/entity/action-data.entity.d.ts +12 -0
- package/dist/module/workflow/entity/action-data.entity.js +58 -0
- package/dist/module/workflow/entity/action-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/action.entity.d.ts +1 -0
- package/dist/module/workflow/entity/action.entity.js +4 -0
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage-movement-data.entity.d.ts +2 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js +8 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +15 -0
- package/dist/module/workflow/entity/task-data.entity.js +70 -0
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.d.ts +7 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.js +38 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.js.map +1 -0
- package/dist/module/workflow/repository/stage-movement.repository.d.ts +23 -0
- package/dist/module/workflow/repository/stage-movement.repository.js +138 -0
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -0
- package/dist/module/workflow/repository/task.repository.d.ts +7 -0
- package/dist/module/workflow/repository/task.repository.js +42 -0
- package/dist/module/workflow/repository/task.repository.js.map +1 -0
- package/dist/module/workflow/service/action.service.js +1 -1
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +1 -1
- package/dist/module/workflow/service/comm-template.service.js +1 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +8 -0
- package/dist/module/workflow/service/task.service.js +31 -0
- package/dist/module/workflow/service/task.service.js.map +1 -0
- package/dist/module/workflow/service/workflow-meta.service.d.ts +11 -5
- package/dist/module/workflow/service/workflow-meta.service.js +57 -22
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +14 -0
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/entity/base-entity.entity.ts +1 -1
- package/src/module/workflow/controller/task.controller.ts +40 -0
- package/src/module/workflow/controller/workflow-meta.controller.ts +29 -5
- package/src/module/workflow/entity/action-data.entity.ts +34 -0
- package/src/module/workflow/entity/action.entity.ts +3 -0
- package/src/module/workflow/entity/stage-movement-data.entity.ts +6 -0
- package/src/module/workflow/entity/task-data.entity.ts +43 -0
- package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -0
- package/src/module/workflow/repository/stage-movement.repository.ts +215 -0
- package/src/module/workflow/repository/task.repository.ts +30 -0
- package/src/module/workflow/service/action.service.ts +1 -1
- package/src/module/workflow/service/comm-template.service.ts +1 -1
- package/src/module/workflow/service/task.service.ts +25 -0
- package/src/module/workflow/service/workflow-meta.service.ts +128 -23
- package/src/module/workflow/workflow.module.ts +14 -0
|
@@ -1,14 +1,38 @@
|
|
|
1
|
+
import { log } from 'console';
|
|
1
2
|
import { Injectable } from '@nestjs/common';
|
|
2
3
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
4
|
import { Repository } from 'typeorm';
|
|
4
5
|
import { StageMovementData } from '../entity/stage-movement-data.entity';
|
|
6
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
7
|
+
import { StageMovementRepository } from '../repository/stage-movement.repository';
|
|
8
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
5
9
|
|
|
6
10
|
@Injectable()
|
|
7
|
-
export class WorkflowMetaService {
|
|
11
|
+
export class WorkflowMetaService extends EntityServiceImpl {
|
|
8
12
|
constructor(
|
|
9
13
|
@InjectRepository(StageMovementData)
|
|
10
14
|
private readonly stageMovementRepo: Repository<StageMovementData>,
|
|
11
|
-
|
|
15
|
+
private readonly stageMovementRepository: StageMovementRepository,
|
|
16
|
+
) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// get first stage from stage table
|
|
21
|
+
async getFirstStage(
|
|
22
|
+
loggedInUser: UserData,
|
|
23
|
+
mapped_entity_type: string,
|
|
24
|
+
mapped_entity_id: number,
|
|
25
|
+
): Promise<any | null> {
|
|
26
|
+
// step1 find in workflow_level_mapping if not found with current level_id and level_type search in for ORG
|
|
27
|
+
// step2 find in stage_group => workflow_id
|
|
28
|
+
// step3 find in stage => stage_group_id
|
|
29
|
+
// step4 get first stage from stage table
|
|
30
|
+
return this.stageMovementRepository.getFirstStage({
|
|
31
|
+
loggedInUser,
|
|
32
|
+
mapped_entity_type,
|
|
33
|
+
mapped_entity_id,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
12
36
|
|
|
13
37
|
/**
|
|
14
38
|
* Get the current active stage for a given mapped entity
|
|
@@ -16,26 +40,37 @@ export class WorkflowMetaService {
|
|
|
16
40
|
async getCurrentStage(
|
|
17
41
|
mapped_entity_type: string,
|
|
18
42
|
mapped_entity_id: number,
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
loggedInUser: UserData,
|
|
44
|
+
): Promise<any | null> {
|
|
45
|
+
// Try to find the current stage movement entry
|
|
46
|
+
let currentStage = await this.stageMovementRepo.findOne({
|
|
21
47
|
where: {
|
|
22
48
|
mapped_entity_type,
|
|
23
49
|
mapped_entity_id,
|
|
24
50
|
is_current: 'Y',
|
|
25
51
|
},
|
|
26
52
|
});
|
|
53
|
+
|
|
54
|
+
// Return the found or newly created current stage movement
|
|
55
|
+
return currentStage;
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
/**
|
|
30
59
|
* Get next stage ID based on current stage
|
|
31
60
|
* (Stub logic – replace with real stage transition resolution)
|
|
32
61
|
*/
|
|
33
|
-
async getNextStage(currentStage:
|
|
34
|
-
//
|
|
35
|
-
const
|
|
36
|
-
|
|
62
|
+
async getNextStage(currentStage: any): Promise<any | null> {
|
|
63
|
+
// get all stage for that stage group
|
|
64
|
+
const nextStage =
|
|
65
|
+
await this.stageMovementRepository.getNextStageOrFirstOfNextGroup(
|
|
66
|
+
currentStage.stage_group_id,
|
|
67
|
+
currentStage.stage_id,
|
|
68
|
+
);
|
|
37
69
|
|
|
38
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
hasNextStage: !!nextStage,
|
|
72
|
+
nextStage: nextStage,
|
|
73
|
+
};
|
|
39
74
|
}
|
|
40
75
|
|
|
41
76
|
/**
|
|
@@ -44,31 +79,53 @@ export class WorkflowMetaService {
|
|
|
44
79
|
async moveToNextStage(
|
|
45
80
|
mapped_entity_type: string,
|
|
46
81
|
mapped_entity_id: number,
|
|
47
|
-
|
|
82
|
+
loggedInUser: UserData,
|
|
48
83
|
): Promise<string> {
|
|
49
84
|
const now = new Date();
|
|
50
|
-
|
|
85
|
+
let currentStage = await this.getCurrentStage(
|
|
86
|
+
mapped_entity_type,
|
|
87
|
+
mapped_entity_id,
|
|
88
|
+
loggedInUser,
|
|
89
|
+
);
|
|
51
90
|
|
|
52
91
|
// Case 1: First stage – initialize
|
|
92
|
+
// If no current stage movement found, create one from the first stage
|
|
53
93
|
if (!currentStage) {
|
|
54
|
-
const
|
|
94
|
+
const getAllResult = await this.getFirstStage(
|
|
95
|
+
loggedInUser,
|
|
96
|
+
mapped_entity_type,
|
|
97
|
+
mapped_entity_id,
|
|
98
|
+
);
|
|
55
99
|
|
|
56
|
-
|
|
100
|
+
const { mappingUsed, stageGroup, firstStage } = getAllResult;
|
|
101
|
+
|
|
102
|
+
// Create a new current stage movement record
|
|
103
|
+
currentStage = await this.stageMovementRepo.save({
|
|
104
|
+
entity_type: 'STGM',
|
|
57
105
|
mapped_entity_type,
|
|
58
106
|
mapped_entity_id,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
107
|
+
name: firstStage.name,
|
|
108
|
+
status: firstStage.status,
|
|
109
|
+
current_user_id: loggedInUser.id,
|
|
110
|
+
stage_action_mapping_id: firstStage.id,
|
|
111
|
+
stage_group_id: stageGroup.id,
|
|
112
|
+
stage_id: firstStage.id,
|
|
113
|
+
start_date: new Date(),
|
|
62
114
|
is_current: 'Y',
|
|
63
115
|
});
|
|
64
116
|
|
|
65
|
-
|
|
117
|
+
this.populateActionService(currentStage.stage_id, loggedInUser);
|
|
118
|
+
|
|
119
|
+
return `Initialized workflow with first stage (Stage ID: ${firstStage.id}).`;
|
|
66
120
|
}
|
|
67
121
|
|
|
122
|
+
//idhr
|
|
123
|
+
|
|
68
124
|
// Case 2: Has next stage – move forward
|
|
69
|
-
const
|
|
125
|
+
const stageDate = await this.getNextStage(currentStage);
|
|
70
126
|
|
|
71
|
-
if (
|
|
127
|
+
if (stageDate.hasNextStage) {
|
|
128
|
+
const { nextStage } = stageDate;
|
|
72
129
|
// Close current stage
|
|
73
130
|
currentStage.end_date = now;
|
|
74
131
|
currentStage.is_current = 'N';
|
|
@@ -76,18 +133,24 @@ export class WorkflowMetaService {
|
|
|
76
133
|
|
|
77
134
|
// Insert next stage
|
|
78
135
|
await this.stageMovementRepo.save({
|
|
79
|
-
entity_type: '
|
|
136
|
+
entity_type: 'STGM',
|
|
80
137
|
mapped_entity_type,
|
|
81
138
|
mapped_entity_id,
|
|
82
|
-
|
|
83
|
-
|
|
139
|
+
name: nextStage.name,
|
|
140
|
+
status: nextStage.status,
|
|
141
|
+
current_user_id: loggedInUser.id,
|
|
142
|
+
stage_action_mapping_id: nextStage.id,
|
|
84
143
|
start_date: now,
|
|
144
|
+
stage_group_id: nextStage.stage_group_id,
|
|
145
|
+
stage_id: nextStage.id,
|
|
85
146
|
is_current: 'Y',
|
|
86
147
|
});
|
|
87
148
|
|
|
88
|
-
return `Moved to next stage (Stage ID: ${
|
|
149
|
+
return `Moved to next stage (Stage ID: ${nextStage.id}).`;
|
|
89
150
|
}
|
|
90
151
|
|
|
152
|
+
//idhr
|
|
153
|
+
|
|
91
154
|
// Case 3: No next stage – mark workflow as done
|
|
92
155
|
currentStage.end_date = now;
|
|
93
156
|
currentStage.is_current = 'N';
|
|
@@ -95,4 +158,46 @@ export class WorkflowMetaService {
|
|
|
95
158
|
|
|
96
159
|
return 'Workflow completed. No next stage available.';
|
|
97
160
|
}
|
|
161
|
+
|
|
162
|
+
async populateActionService(stage_id: number, loggedInUser: UserData) {
|
|
163
|
+
const actions =
|
|
164
|
+
await this.stageMovementRepository.getAllActionByStageId(stage_id);
|
|
165
|
+
// Populate the action service with the retrieved actions
|
|
166
|
+
|
|
167
|
+
if (!actions || actions.length === 0) {
|
|
168
|
+
return 'No actions found for this stage.';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
await this.stageMovementRepository.saveActionData(actions, loggedInUser);
|
|
172
|
+
await this.stageMovementRepository.saveTaskData(actions, loggedInUser);
|
|
173
|
+
|
|
174
|
+
// // loop through each action and get the action data and populate the task data
|
|
175
|
+
// for (const action of actions) {
|
|
176
|
+
// const actionData = await super.getEntityData(
|
|
177
|
+
// 'STAGE_ACTION',
|
|
178
|
+
// action.id,
|
|
179
|
+
// loggedInUser,
|
|
180
|
+
// );
|
|
181
|
+
|
|
182
|
+
// await super.createEntity(
|
|
183
|
+
// {
|
|
184
|
+
// user_id: loggedInUser.id,
|
|
185
|
+
// stage_id: action.stage_id,
|
|
186
|
+
// action_id: action.id,
|
|
187
|
+
// } as any,
|
|
188
|
+
// loggedInUser,
|
|
189
|
+
// );
|
|
190
|
+
|
|
191
|
+
// await super.createEntity(
|
|
192
|
+
// {
|
|
193
|
+
// user_id: loggedInUser.id,
|
|
194
|
+
// stage_id: action.stage_id,
|
|
195
|
+
// action_id: action.id,
|
|
196
|
+
// mapped_entity_type: actionData?.entity_type,
|
|
197
|
+
// mapped_entity_id: actionData?.entity_id,
|
|
198
|
+
// } as any,
|
|
199
|
+
// loggedInUser,
|
|
200
|
+
// );
|
|
201
|
+
// }
|
|
202
|
+
}
|
|
98
203
|
}
|
|
@@ -39,6 +39,13 @@ import { WorkflowListMasterService } from './service/workflow-list-master.servic
|
|
|
39
39
|
import { WorkflowMetaService } from './service/workflow-meta.service';
|
|
40
40
|
import { WorkflowService } from './service/workflow.service';
|
|
41
41
|
import { ActionCategoryController } from './controller/action-category.controller';
|
|
42
|
+
import { StageMovementRepository } from './repository/stage-movement.repository';
|
|
43
|
+
import { WorkflowLevelMappingEntity } from './entity/workflow-level-mapping.entity';
|
|
44
|
+
import { TaskDataEntity } from './entity/task-data.entity';
|
|
45
|
+
import { ActionDataEntity } from './entity/action-data.entity';
|
|
46
|
+
import { TaskController } from './controller/task.controller';
|
|
47
|
+
import { TaskService } from './service/task.service';
|
|
48
|
+
import { TaskRepository } from './repository/task.repository';
|
|
42
49
|
|
|
43
50
|
@Module({
|
|
44
51
|
imports: [
|
|
@@ -54,6 +61,9 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
54
61
|
StageMovementData,
|
|
55
62
|
EntityModification,
|
|
56
63
|
TemplateAttach,
|
|
64
|
+
WorkflowLevelMappingEntity,
|
|
65
|
+
TaskDataEntity,
|
|
66
|
+
ActionDataEntity,
|
|
57
67
|
]),
|
|
58
68
|
EntityModule,
|
|
59
69
|
ListMasterModule,
|
|
@@ -67,6 +77,7 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
67
77
|
},
|
|
68
78
|
{ provide: 'ActionService', useClass: ActionService },
|
|
69
79
|
{ provide: 'StageService', useClass: StageService },
|
|
80
|
+
{ provide: 'TaskService', useClass: TaskService },
|
|
70
81
|
{ provide: 'StageGroupService', useClass: StageGroupService },
|
|
71
82
|
{ provide: 'WorkflowService', useClass: WorkflowService },
|
|
72
83
|
{
|
|
@@ -83,6 +94,8 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
83
94
|
WorkflowService,
|
|
84
95
|
WorkflowMetaService,
|
|
85
96
|
PopulateWorkflowService,
|
|
97
|
+
StageMovementRepository,
|
|
98
|
+
TaskRepository,
|
|
86
99
|
],
|
|
87
100
|
exports: [
|
|
88
101
|
'ActionCategoryService',
|
|
@@ -109,6 +122,7 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
109
122
|
WorkflowMetaController,
|
|
110
123
|
EntityModificationController,
|
|
111
124
|
ActionCategoryController,
|
|
125
|
+
TaskController,
|
|
112
126
|
],
|
|
113
127
|
})
|
|
114
128
|
export class WorkflowModule {}
|