rez_core 2.1.147 → 2.1.149
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/action.controller.d.ts +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +1 -1
- 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.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/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/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 +19 -0
- package/dist/module/workflow/repository/stage-movement.repository.js +121 -0
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -0
- 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/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/workflow-meta.service.d.ts +10 -5
- package/dist/module/workflow/service/workflow-meta.service.js +47 -22
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +4 -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/workflow-meta.controller.ts +29 -5
- package/src/module/workflow/entity/action.entity.ts +2 -2
- package/src/module/workflow/entity/stage-movement-data.entity.ts +6 -0
- package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -0
- package/src/module/workflow/repository/stage-movement.repository.ts +181 -0
- package/src/module/workflow/service/action-category.service.ts +4 -1
- package/src/module/workflow/service/action.service.ts +71 -68
- package/src/module/workflow/service/comm-template.service.ts +1 -1
- package/src/module/workflow/service/workflow-meta.service.ts +79 -24
- package/src/module/workflow/workflow.module.ts +4 -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,47 @@ 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
|
-
|
|
65
|
-
return 'Workflow started with the first stage.';
|
|
66
116
|
}
|
|
67
117
|
|
|
68
118
|
// Case 2: Has next stage – move forward
|
|
69
|
-
const
|
|
119
|
+
const stageDate = await this.getNextStage(currentStage);
|
|
70
120
|
|
|
71
|
-
if (
|
|
121
|
+
if (stageDate.hasNextStage) {
|
|
122
|
+
const { nextStage } = stageDate;
|
|
72
123
|
// Close current stage
|
|
73
124
|
currentStage.end_date = now;
|
|
74
125
|
currentStage.is_current = 'N';
|
|
@@ -76,16 +127,20 @@ export class WorkflowMetaService {
|
|
|
76
127
|
|
|
77
128
|
// Insert next stage
|
|
78
129
|
await this.stageMovementRepo.save({
|
|
79
|
-
entity_type: '
|
|
130
|
+
entity_type: 'STGM',
|
|
80
131
|
mapped_entity_type,
|
|
81
132
|
mapped_entity_id,
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
name: nextStage.name,
|
|
134
|
+
status: nextStage.status,
|
|
135
|
+
current_user_id: loggedInUser.id,
|
|
136
|
+
stage_action_mapping_id: nextStage.id,
|
|
84
137
|
start_date: now,
|
|
138
|
+
stage_group_id: nextStage.stage_group_id,
|
|
139
|
+
stage_id: nextStage.id,
|
|
85
140
|
is_current: 'Y',
|
|
86
141
|
});
|
|
87
142
|
|
|
88
|
-
return `Moved to next stage (Stage ID: ${
|
|
143
|
+
return `Moved to next stage (Stage ID: ${nextStage.id}).`;
|
|
89
144
|
}
|
|
90
145
|
|
|
91
146
|
// Case 3: No next stage – mark workflow as done
|
|
@@ -39,6 +39,8 @@ 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';
|
|
42
44
|
|
|
43
45
|
@Module({
|
|
44
46
|
imports: [
|
|
@@ -54,6 +56,7 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
54
56
|
StageMovementData,
|
|
55
57
|
EntityModification,
|
|
56
58
|
TemplateAttach,
|
|
59
|
+
WorkflowLevelMappingEntity,
|
|
57
60
|
]),
|
|
58
61
|
EntityModule,
|
|
59
62
|
ListMasterModule,
|
|
@@ -83,6 +86,7 @@ import { ActionCategoryController } from './controller/action-category.controlle
|
|
|
83
86
|
WorkflowService,
|
|
84
87
|
WorkflowMetaService,
|
|
85
88
|
PopulateWorkflowService,
|
|
89
|
+
StageMovementRepository,
|
|
86
90
|
],
|
|
87
91
|
exports: [
|
|
88
92
|
'ActionCategoryService',
|