rez_core 2.1.149 → 2.1.151

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.
Files changed (37) hide show
  1. package/dist/module/workflow/controller/task.controller.d.ts +12 -0
  2. package/dist/module/workflow/controller/task.controller.js +45 -0
  3. package/dist/module/workflow/controller/task.controller.js.map +1 -0
  4. package/dist/module/workflow/entity/action-data.entity.d.ts +12 -0
  5. package/dist/module/workflow/entity/action-data.entity.js +58 -0
  6. package/dist/module/workflow/entity/action-data.entity.js.map +1 -0
  7. package/dist/module/workflow/entity/action.entity.d.ts +2 -1
  8. package/dist/module/workflow/entity/action.entity.js +5 -1
  9. package/dist/module/workflow/entity/action.entity.js.map +1 -1
  10. package/dist/module/workflow/entity/task-data.entity.d.ts +15 -0
  11. package/dist/module/workflow/entity/task-data.entity.js +70 -0
  12. package/dist/module/workflow/entity/task-data.entity.js.map +1 -0
  13. package/dist/module/workflow/repository/stage-movement.repository.d.ts +4 -0
  14. package/dist/module/workflow/repository/stage-movement.repository.js +17 -0
  15. package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -1
  16. package/dist/module/workflow/repository/task.repository.d.ts +7 -0
  17. package/dist/module/workflow/repository/task.repository.js +42 -0
  18. package/dist/module/workflow/repository/task.repository.js.map +1 -0
  19. package/dist/module/workflow/service/task.service.d.ts +8 -0
  20. package/dist/module/workflow/service/task.service.js +31 -0
  21. package/dist/module/workflow/service/task.service.js.map +1 -0
  22. package/dist/module/workflow/service/workflow-meta.service.d.ts +1 -0
  23. package/dist/module/workflow/service/workflow-meta.service.js +10 -0
  24. package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
  25. package/dist/module/workflow/workflow.module.js +10 -0
  26. package/dist/module/workflow/workflow.module.js.map +1 -1
  27. package/dist/tsconfig.build.tsbuildinfo +1 -1
  28. package/package.json +1 -1
  29. package/src/module/workflow/controller/task.controller.ts +40 -0
  30. package/src/module/workflow/entity/action-data.entity.ts +34 -0
  31. package/src/module/workflow/entity/action.entity.ts +4 -1
  32. package/src/module/workflow/entity/task-data.entity.ts +43 -0
  33. package/src/module/workflow/repository/stage-movement.repository.ts +34 -0
  34. package/src/module/workflow/repository/task.repository.ts +30 -0
  35. package/src/module/workflow/service/task.service.ts +25 -0
  36. package/src/module/workflow/service/workflow-meta.service.ts +50 -0
  37. package/src/module/workflow/workflow.module.ts +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.149",
3
+ "version": "2.1.151",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -0,0 +1,40 @@
1
+ import {
2
+ Body,
3
+ Controller,
4
+ HttpCode,
5
+ HttpStatus,
6
+ Inject,
7
+ Post,
8
+ Req,
9
+ UseGuards,
10
+ } from '@nestjs/common';
11
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
12
+ import { TaskService } from '../service/task.service';
13
+
14
+ @Controller('/task')
15
+ @UseGuards(JwtAuthGuard)
16
+ export class TaskController {
17
+ constructor(
18
+ @Inject('TaskService')
19
+ private readonly taskService: TaskService,
20
+ ) {}
21
+
22
+ @Post('/getTasksbyUserAndStage')
23
+ @HttpCode(HttpStatus.OK)
24
+ async getTasksbyUserAndStage(
25
+ @Req() req: Request & { user: any },
26
+ @Body()
27
+ body: {
28
+ mapped_entity_type: string;
29
+ mapped_entity_id: number;
30
+ stage_id: number;
31
+ },
32
+ ) {
33
+ const loggedInUser = req.user.userData;
34
+ const result = this.taskService.getAllTaskByUserIdandStageId(
35
+ loggedInUser,
36
+ body,
37
+ );
38
+ return result;
39
+ }
40
+ }
@@ -0,0 +1,34 @@
1
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
2
+ import { Column, Entity } from 'typeorm';
3
+
4
+ @Entity({ name: 'cr_wf_action_data' })
5
+ export class ActionDataEntity extends BaseEntity {
6
+ constructor() {
7
+ super();
8
+ this.entity_type = 'ACTION_DATA';
9
+ }
10
+
11
+ @Column({ nullable: true })
12
+ action_id: number;
13
+
14
+ @Column({ nullable: true })
15
+ user_id: number;
16
+
17
+ @Column({ nullable: true })
18
+ stage_id: number;
19
+
20
+ @Column({ nullable: true })
21
+ start_time: Date;
22
+
23
+ @Column({ nullable: true })
24
+ end_time: Date;
25
+
26
+ @Column({ nullable: true })
27
+ is_mandatory: boolean;
28
+
29
+ @Column({ nullable: true })
30
+ mapped_entity_id: number;
31
+
32
+ @Column({ nullable: true })
33
+ mapped_entity_type: string;
34
+ }
@@ -13,7 +13,7 @@ export class ActionEntity extends BaseEntity {
13
13
  workflow_id: number;
14
14
 
15
15
  @Column({ type: 'int', nullable: true })
16
- action_cat_id: number;
16
+ action_category: number;
17
17
 
18
18
  @Column({ type: 'varchar', nullable: true })
19
19
  action_requirement: string;
@@ -29,4 +29,7 @@ export class ActionEntity extends BaseEntity {
29
29
 
30
30
  @Column({ default: 0, type: 'boolean' })
31
31
  default_value: boolean;
32
+
33
+ @Column({ nullable: true })
34
+ user_id: number;
32
35
  }
@@ -0,0 +1,43 @@
1
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
2
+ import { Column, Entity } from 'typeorm';
3
+
4
+ @Entity({ name: 'cr_wf_task_data' })
5
+ export class TaskDataEntity extends BaseEntity {
6
+ constructor() {
7
+ super();
8
+ this.entity_type = 'TASK_DATA';
9
+ }
10
+
11
+ @Column({ nullable: true })
12
+ task_id: number;
13
+
14
+ @Column({ nullable: true })
15
+ user_id: number;
16
+
17
+ @Column({ nullable: true })
18
+ stage_id: number;
19
+
20
+ @Column({ nullable: true })
21
+ action_id: number;
22
+
23
+ @Column({ nullable: true })
24
+ start_time: Date;
25
+
26
+ @Column({ nullable: true })
27
+ end_time: Date;
28
+
29
+ @Column({ nullable: true })
30
+ is_completed: boolean;
31
+
32
+ @Column({ default: 0 })
33
+ is_system: boolean;
34
+
35
+ @Column({ nullable: true })
36
+ is_mandatory: boolean;
37
+
38
+ @Column({ nullable: true })
39
+ mapped_entity_id: number;
40
+
41
+ @Column({ nullable: true })
42
+ mapped_entity_type: string;
43
+ }
@@ -6,6 +6,7 @@ import { WorkflowLevelMappingEntity } from '../entity/workflow-level-mapping.ent
6
6
  import { StageGroup } from '../entity/stage-group.entity';
7
7
  import { Stage } from '../entity/stage.entity';
8
8
  import { log } from 'console';
9
+ import { UserData } from 'src/module/user/entity/user.entity';
9
10
 
10
11
  @Injectable()
11
12
  export class StageMovementRepository {
@@ -178,4 +179,37 @@ export class StageMovementRepository {
178
179
  );
179
180
  return nextStageGroupFirstStage || null;
180
181
  }
182
+
183
+ async getAllActionByStageId(stageId: number): Promise<any[]> {
184
+ return this.dataSource.query(
185
+ `SELECT * FROM cr_wf_stage_action_mapping WHERE stage_id = ?`,
186
+ [stageId],
187
+ );
188
+ }
189
+
190
+ async saveActionData(action: any, loggedInUser: UserData): Promise<any> {
191
+ // Implement the logic to save action data
192
+
193
+ if (action.length > 0) {
194
+ for (const act of action) {
195
+ await this.dataSource.query(
196
+ `INSERT INTO cr_wf_action_data (stage_id, user_id, action_id) VALUES (?, ?, ?)`,
197
+ [act.stage_id, loggedInUser.id, act.id],
198
+ );
199
+ }
200
+ }
201
+ }
202
+
203
+ async saveTaskData(actionData: any, loggedInUser: UserData): Promise<any> {
204
+ // Implement the logic to save task data
205
+
206
+ if (actionData.length > 0) {
207
+ for (const action of actionData) {
208
+ await this.dataSource.query(
209
+ `INSERT INTO cr_wf_task_data (action_id, user_id) VALUES (?, ?)`,
210
+ [action.id, loggedInUser.id],
211
+ );
212
+ }
213
+ }
214
+ }
181
215
  }
@@ -0,0 +1,30 @@
1
+ import { BadRequestException, Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { TaskDataEntity } from '../entity/task-data.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class TaskRepository {
8
+ constructor(
9
+ @InjectRepository(TaskDataEntity)
10
+ private readonly TaskRepository: Repository<TaskDataEntity>,
11
+ ) {}
12
+
13
+ async getAllTaskByUserIdAndStageId(
14
+ userId: number,
15
+ stageId: number,
16
+ mapped_entity_type: string,
17
+ mapped_entity_id: number,
18
+ ) {
19
+ const result = await this.TaskRepository.find({
20
+ where: {
21
+ user_id: userId,
22
+ stage_id: stageId,
23
+ mapped_entity_type,
24
+ mapped_entity_id,
25
+ },
26
+ });
27
+
28
+ return result;
29
+ }
30
+ }
@@ -0,0 +1,25 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
+ import { UserData } from 'src/module/user/entity/user.entity';
4
+ import { TaskRepository } from '../repository/task.repository';
5
+
6
+ @Injectable()
7
+ export class TaskService extends EntityServiceImpl {
8
+ constructor(private readonly taskRepository: TaskRepository) {
9
+ super();
10
+ }
11
+
12
+ async getAllTaskByUserIdandStageId(
13
+ loggedInUser: UserData,
14
+ data,
15
+ ): Promise<any> {
16
+ const taskData = await this.taskRepository.getAllTaskByUserIdAndStageId(
17
+ loggedInUser.id,
18
+ data.stage_id,
19
+ data.mapped_entity_type,
20
+ data.mapped_entity_id,
21
+ );
22
+
23
+ return taskData;
24
+ }
25
+ }
@@ -113,8 +113,14 @@ export class WorkflowMetaService extends EntityServiceImpl {
113
113
  start_date: new Date(),
114
114
  is_current: 'Y',
115
115
  });
116
+
117
+ this.populateActionService(currentStage.stage_id, loggedInUser);
118
+
119
+ return `Initialized workflow with first stage (Stage ID: ${firstStage.id}).`;
116
120
  }
117
121
 
122
+ //idhr
123
+
118
124
  // Case 2: Has next stage – move forward
119
125
  const stageDate = await this.getNextStage(currentStage);
120
126
 
@@ -143,6 +149,8 @@ export class WorkflowMetaService extends EntityServiceImpl {
143
149
  return `Moved to next stage (Stage ID: ${nextStage.id}).`;
144
150
  }
145
151
 
152
+ //idhr
153
+
146
154
  // Case 3: No next stage – mark workflow as done
147
155
  currentStage.end_date = now;
148
156
  currentStage.is_current = 'N';
@@ -150,4 +158,46 @@ export class WorkflowMetaService extends EntityServiceImpl {
150
158
 
151
159
  return 'Workflow completed. No next stage available.';
152
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
+ }
153
203
  }
@@ -41,6 +41,11 @@ import { WorkflowService } from './service/workflow.service';
41
41
  import { ActionCategoryController } from './controller/action-category.controller';
42
42
  import { StageMovementRepository } from './repository/stage-movement.repository';
43
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';
44
49
 
45
50
  @Module({
46
51
  imports: [
@@ -57,6 +62,8 @@ import { WorkflowLevelMappingEntity } from './entity/workflow-level-mapping.enti
57
62
  EntityModification,
58
63
  TemplateAttach,
59
64
  WorkflowLevelMappingEntity,
65
+ TaskDataEntity,
66
+ ActionDataEntity,
60
67
  ]),
61
68
  EntityModule,
62
69
  ListMasterModule,
@@ -70,6 +77,7 @@ import { WorkflowLevelMappingEntity } from './entity/workflow-level-mapping.enti
70
77
  },
71
78
  { provide: 'ActionService', useClass: ActionService },
72
79
  { provide: 'StageService', useClass: StageService },
80
+ { provide: 'TaskService', useClass: TaskService },
73
81
  { provide: 'StageGroupService', useClass: StageGroupService },
74
82
  { provide: 'WorkflowService', useClass: WorkflowService },
75
83
  {
@@ -87,6 +95,7 @@ import { WorkflowLevelMappingEntity } from './entity/workflow-level-mapping.enti
87
95
  WorkflowMetaService,
88
96
  PopulateWorkflowService,
89
97
  StageMovementRepository,
98
+ TaskRepository,
90
99
  ],
91
100
  exports: [
92
101
  'ActionCategoryService',
@@ -113,6 +122,7 @@ import { WorkflowLevelMappingEntity } from './entity/workflow-level-mapping.enti
113
122
  WorkflowMetaController,
114
123
  EntityModificationController,
115
124
  ActionCategoryController,
125
+ TaskController,
116
126
  ],
117
127
  })
118
128
  export class WorkflowModule {}