rez_core 2.1.110 → 2.1.111

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 (52) hide show
  1. package/dist/constant/global.constant.d.ts +2 -0
  2. package/dist/constant/global.constant.js +3 -1
  3. package/dist/constant/global.constant.js.map +1 -1
  4. package/dist/module/master/controller/master.controller.d.ts +1 -1
  5. package/dist/module/master/service/master.service.d.ts +1 -1
  6. package/dist/module/master/service/master.service.js +3 -2
  7. package/dist/module/master/service/master.service.js.map +1 -1
  8. package/dist/module/workflow/controller/workflow-list-master.controller.d.ts +11 -0
  9. package/dist/module/workflow/controller/workflow-list-master.controller.js +52 -0
  10. package/dist/module/workflow/controller/workflow-list-master.controller.js.map +1 -0
  11. package/dist/module/workflow/entity/action-category.entity.d.ts +2 -0
  12. package/dist/module/workflow/entity/action-category.entity.js +8 -0
  13. package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
  14. package/dist/module/workflow/entity/action-template-mapping.entity.d.ts +1 -1
  15. package/dist/module/workflow/entity/action-template-mapping.entity.js +3 -3
  16. package/dist/module/workflow/entity/action-template-mapping.entity.js.map +1 -1
  17. package/dist/module/workflow/entity/stage-movement-data.entity.d.ts +9 -0
  18. package/dist/module/workflow/entity/stage-movement-data.entity.js +47 -0
  19. package/dist/module/workflow/entity/stage-movement-data.entity.js.map +1 -0
  20. package/dist/module/workflow/entity/stage.entity.d.ts +1 -0
  21. package/dist/module/workflow/entity/stage.entity.js +4 -0
  22. package/dist/module/workflow/entity/stage.entity.js.map +1 -1
  23. package/dist/module/workflow/entity/workflow-data.entity.d.ts +4 -0
  24. package/dist/module/workflow/entity/workflow-data.entity.js +27 -0
  25. package/dist/module/workflow/entity/workflow-data.entity.js.map +1 -0
  26. package/dist/module/workflow/service/action.service.d.ts +3 -2
  27. package/dist/module/workflow/service/action.service.js +19 -9
  28. package/dist/module/workflow/service/action.service.js.map +1 -1
  29. package/dist/module/workflow/service/stage.service.d.ts +6 -0
  30. package/dist/module/workflow/service/stage.service.js +25 -1
  31. package/dist/module/workflow/service/stage.service.js.map +1 -1
  32. package/dist/module/workflow/service/workflow-list-master.service.d.ts +8 -0
  33. package/dist/module/workflow/service/workflow-list-master.service.js +51 -0
  34. package/dist/module/workflow/service/workflow-list-master.service.js.map +1 -0
  35. package/dist/module/workflow/service/workflow.service.js.map +1 -1
  36. package/dist/module/workflow/workflow.module.js +4 -1
  37. package/dist/module/workflow/workflow.module.js.map +1 -1
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/package.json +2 -2
  40. package/src/constant/global.constant.ts +2 -0
  41. package/src/module/master/service/master.service.ts +3 -2
  42. package/src/module/workflow/controller/workflow-list-master.controller.ts +25 -0
  43. package/src/module/workflow/entity/action-category.entity.ts +7 -1
  44. package/src/module/workflow/entity/action-template-mapping.entity.ts +2 -2
  45. package/src/module/workflow/entity/stage-movement-data.entity.ts +26 -0
  46. package/src/module/workflow/entity/stage.entity.ts +3 -0
  47. package/src/module/workflow/entity/workflow-data.entity.ts +11 -0
  48. package/src/module/workflow/service/action.service.ts +61 -32
  49. package/src/module/workflow/service/stage.service.ts +43 -1
  50. package/src/module/workflow/service/workflow-list-master.service.ts +44 -0
  51. package/src/module/workflow/service/workflow.service.ts +3 -3
  52. package/src/module/workflow/workflow.module.ts +4 -1
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.110",
3
+ "version": "2.1.111",
4
4
  "description": "",
5
- "author": "",
5
+ "author": "",
6
6
  "private": false,
7
7
  "license": "UNLICENSED",
8
8
  "scripts": {
@@ -44,3 +44,5 @@ export const ACTION_CATEGORY = 'ACTC';
44
44
  export const STAGE_ACTION_MAPPING = 'STGM';
45
45
  export const COMM_TEMPLATE = 'CTPL';
46
46
  export const ACTION_TEMPLATE_MAPPING = 'ATMP';
47
+ export const WORKFLOW_DATA = 'WFDT';
48
+ export const STAGE_MOVEMENT_DATA = 'STMV';
@@ -161,8 +161,9 @@ export class MasterService {
161
161
  const entityMasterData =
162
162
  await this.entityMasterService.getEntityByTableName(table);
163
163
 
164
- if (!entityMasterData) {
165
- throw new Error(`Entity master not found for table: ${table}`);
164
+ if (!entityMasterData || !entityMasterData.mapped_entity_type) {
165
+ console.error('Entity master data or mapped entity type is missing');
166
+ return;
166
167
  }
167
168
 
168
169
  const attributes =
@@ -0,0 +1,25 @@
1
+ import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
2
+ import { WorkflowListMasterService } from '../service/workflow-list-master.service';
3
+
4
+ @Controller('/workflow-list')
5
+ export class WorkflowListMasterController {
6
+ constructor(private readonly workflowService: WorkflowListMasterService) {}
7
+
8
+ @Post('/getActionsByStage')
9
+ @HttpCode(HttpStatus.OK)
10
+ async getActionsByStage(@Body() body: { stage_id: number }) {
11
+ const result = await this.workflowService.getActionCategoryListByStageId(
12
+ body.stage_id,
13
+ );
14
+ return result;
15
+ }
16
+
17
+ @Post('/getStagesByGroup')
18
+ @HttpCode(HttpStatus.OK)
19
+ async getStagesByGroup(@Body() body: { stage_group_id: number }) {
20
+ const result = await this.workflowService.getStagesByGroup(
21
+ body.stage_group_id,
22
+ );
23
+ return result;
24
+ }
25
+ }
@@ -1,6 +1,6 @@
1
1
  import { ACTION_CATEGORY } from 'src/constant/global.constant';
2
2
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
3
- import { Entity } from 'typeorm';
3
+ import { Column, Entity } from 'typeorm';
4
4
 
5
5
  @Entity({ name: 'cr_wf_action_category' })
6
6
  export class ActionCategory extends BaseEntity {
@@ -8,4 +8,10 @@ export class ActionCategory extends BaseEntity {
8
8
  super();
9
9
  this.entity_type = ACTION_CATEGORY;
10
10
  }
11
+
12
+ @Column({ type: 'varchar', nullable: true })
13
+ logo: string;
14
+
15
+ @Column({ type: 'varchar', nullable: true })
16
+ modalName: string;
11
17
  }
@@ -12,6 +12,6 @@ export class ActionTemplateMapping extends BaseEntity {
12
12
  @Column({ type: 'int', nullable: true })
13
13
  stg_act_mapping_id: number;
14
14
 
15
- @Column({ type: 'int', nullable: true })
16
- template_id: number;
15
+ @Column({ type: 'varchar', nullable: true })
16
+ template_code: string;
17
17
  }
@@ -0,0 +1,26 @@
1
+ import { STAGE_MOVEMENT_DATA } from 'src/constant/global.constant';
2
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
3
+ import { Column, Entity } from 'typeorm';
4
+
5
+ @Entity({ name: 'cr_wf_stage_movement_data' })
6
+ export class StageMovementData extends BaseEntity {
7
+ constructor() {
8
+ super();
9
+ this.entity_type = STAGE_MOVEMENT_DATA;
10
+ }
11
+
12
+ @Column({ type: 'int', nullable: true })
13
+ current_user_id: number;
14
+
15
+ @Column({ type: 'int', nullable: true })
16
+ stage_action_mapping_id: number;
17
+
18
+ @Column({ type: 'date', nullable: true })
19
+ start_date: Date;
20
+
21
+ @Column({ type: 'date', nullable: true })
22
+ end_date: Date;
23
+
24
+ @Column({ type: 'varchar', nullable: true })
25
+ is_current: string;
26
+ }
@@ -12,6 +12,9 @@ export class Stage extends BaseEntity {
12
12
  @Column({ type: 'int', nullable: true })
13
13
  stage_group_id: number;
14
14
 
15
+ @Column({ type: 'varchar', length: 100, nullable: true })
16
+ full_name: string;
17
+
15
18
  @Column({ type: 'int', nullable: true })
16
19
  sortindex: number;
17
20
  }
@@ -0,0 +1,11 @@
1
+ import { WORKFLOW_DATA } from 'src/constant/global.constant';
2
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
3
+ import { Entity } from 'typeorm';
4
+
5
+ @Entity({ name: 'cr_workflow_data' })
6
+ export class WorkFlowData extends BaseEntity {
7
+ constructor() {
8
+ super();
9
+ this.entity_type = WORKFLOW_DATA;
10
+ }
11
+ }
@@ -2,50 +2,79 @@ import { Injectable } from '@nestjs/common';
2
2
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
3
3
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
4
4
  import { UserData } from 'src/module/user/entity/user.entity';
5
- import { EntityManager } from 'typeorm';
5
+ import { DataSource, EntityManager } from 'typeorm';
6
6
 
7
7
  @Injectable()
8
8
  export class ActionService extends EntityServiceImpl {
9
- constructor() {
10
- super();
11
- }
12
-
13
- async createEntity(entityData: BaseEntity, loggedInUser: UserData | null, manager?: EntityManager | null, appcode?: string): Promise<any> {
14
- console.log("entityData", entityData);
15
-
16
- let actionData = entityData as any;
9
+ constructor(private readonly dataSource: DataSource) {
10
+ super();
11
+ }
17
12
 
18
- let action = await super.createEntity(entityData, loggedInUser, manager, appcode)
13
+ async createEntity(
14
+ entityData: BaseEntity,
15
+ loggedInUser: UserData | null,
16
+ manager?: EntityManager | null,
17
+ appcode?: string,
18
+ ): Promise<any> {
19
+ console.log('entityData', entityData);
19
20
 
20
- let stageActionMapping={
21
- action_id: action.id,
22
- stage_id: actionData.stage_id,
23
- entity_type:"STGM",
24
- } as any;
21
+ let actionData = entityData as any;
25
22
 
26
- let stageActionMappingData = await super.createEntity(stageActionMapping, loggedInUser, manager, appcode);
23
+ let action = await super.createEntity(
24
+ entityData,
25
+ loggedInUser,
26
+ manager,
27
+ appcode,
28
+ );
27
29
 
28
- if(actionData.template.length > 0) {
30
+ let stageActionMapping = {
31
+ action_id: action.id,
32
+ stage_id: actionData.stage_id,
33
+ entity_type: 'STGM',
34
+ } as any;
29
35
 
30
- let templates=actionData.template;
36
+ let stageActionMappingData = await super.createEntity(
37
+ stageActionMapping,
38
+ loggedInUser,
39
+ manager,
40
+ appcode,
41
+ );
31
42
 
32
- for (let i = 0; i < templates.length; i++) {
33
-
34
- //templateData = getEntityData
43
+ if (Array.isArray(actionData.template) && actionData.template.length > 0) {
44
+ const templates = actionData.template;
35
45
 
36
- let actionTemplateMapping ={
37
- stg_act_mapping_id: stageActionMappingData.id,
38
- template_code:"",
39
- entity_type: "ACTM",
40
- } as any;
41
-
42
- //creaEntity
43
-
44
- }
46
+ for (let i = 0; i < templates.length; i++) {
47
+ const templateId = templates[i];
45
48
 
49
+ // Fetch the template code from `cr_wf_comm_template`
50
+ const templateResult = await this.dataSource.query(
51
+ `SELECT code FROM cr_wf_comm_template WHERE id = ?`,
52
+ [templateId],
53
+ );
46
54
 
55
+ if (templateResult.length === 0) {
56
+ console.warn(`Template not found for id: ${templateId}`);
57
+ continue;
47
58
  }
48
-
49
- return actionData;
59
+
60
+ const templateCode = templateResult[0].code;
61
+
62
+ // Create Action-Template Mapping
63
+ const actionTemplateMapping = {
64
+ stg_act_mapping_id: stageActionMappingData.id,
65
+ template_code: templateCode,
66
+ entity_type: 'ATMP',
67
+ } as any;
68
+
69
+ await super.createEntity(
70
+ actionTemplateMapping,
71
+ loggedInUser,
72
+ manager,
73
+ appcode,
74
+ );
75
+ }
50
76
  }
77
+
78
+ return actionData;
79
+ }
51
80
  }
@@ -1,5 +1,47 @@
1
1
  import { Injectable } from '@nestjs/common';
2
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
2
3
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
4
+ import { UserData } from 'src/module/user/entity/user.entity';
5
+ import { DataSource, EntityManager } from 'typeorm';
3
6
 
4
7
  @Injectable()
5
- export class StageService extends EntityServiceImpl {}
8
+ export class StageService extends EntityServiceImpl {
9
+ constructor(private readonly dataSource: DataSource) {
10
+ super();
11
+ }
12
+
13
+ async createEntity(
14
+ entityData: BaseEntity,
15
+ loggedInUser: UserData | null,
16
+ manager?: EntityManager | null,
17
+ appcode?: string,
18
+ ): Promise<any> {
19
+ const stageData = entityData as any;
20
+
21
+ // Step 1: Get the stage_group name using stage_group_id
22
+ let stageGroupName = '';
23
+ if (stageData.stage_group_id) {
24
+ const result = await this.dataSource.query(
25
+ `SELECT name FROM cr_wf_stage_group WHERE id = ?`,
26
+ [stageData.stage_group_id],
27
+ );
28
+
29
+ if (result.length > 0) {
30
+ stageGroupName = result[0].name;
31
+ }
32
+ }
33
+
34
+ if (stageGroupName && stageData.name) {
35
+ stageData.full_name = `${stageGroupName}-${stageData.name}`;
36
+ }
37
+
38
+ const savedStage = await super.createEntity(
39
+ stageData,
40
+ loggedInUser,
41
+ manager,
42
+ appcode,
43
+ );
44
+
45
+ return savedStage;
46
+ }
47
+ }
@@ -0,0 +1,44 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
+ import { DataSource } from 'typeorm';
4
+
5
+ @Injectable()
6
+ export class WorkflowListMasterService extends EntityServiceImpl {
7
+ constructor(private readonly dataSource: DataSource) {
8
+ super();
9
+ }
10
+
11
+ async getActionCategoryListByStageId(stageId: number): Promise<any[]> {
12
+ const results = await this.dataSource.query(
13
+ `
14
+ SELECT
15
+ ac.logo AS logo,
16
+ ac.name AS name,
17
+ ac.modalName AS modalName,
18
+ a.action_requirement AS actionRequirement
19
+ FROM cr_wf_stage_action_mapping sam
20
+ JOIN cr_wf_action a ON sam.action_id = a.id
21
+ JOIN cr_wf_action_category ac ON a.action_cat_id = ac.id
22
+ WHERE sam.stage_id = ?
23
+ `,
24
+ [stageId],
25
+ );
26
+
27
+ // Add actionStatus and return formatted output
28
+ return results.map((item: any) => ({
29
+ logo: item.logo,
30
+ name: item.name,
31
+ modalName: item.modalName,
32
+ actionRequirement: item.actionRequirement,
33
+ actionStatus: 'Done',
34
+ }));
35
+ }
36
+
37
+ async getStagesByGroup(stageGroupId: number): Promise<any[]> {
38
+ const results = await this.dataSource.query(
39
+ `SELECT id, full_name FROM cr_wf_stage WHERE stage_group_id = ?`,
40
+ [stageGroupId],
41
+ );
42
+ return results;
43
+ }
44
+ }
@@ -3,7 +3,7 @@ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.s
3
3
 
4
4
  @Injectable()
5
5
  export class WorkflowService extends EntityServiceImpl {
6
- constructor() {
7
- super();
8
- }
6
+ constructor() {
7
+ super();
8
+ }
9
9
  }
@@ -17,6 +17,8 @@ import { StageGroupService } from './service/stage-group.service';
17
17
  import { TypeOrmModule } from '@nestjs/typeorm';
18
18
  import { EntityModule } from '../meta/entity.module';
19
19
  import { Action } from './entity/action.entity';
20
+ import { WorkflowListMasterService } from './service/workflow-list-master.service';
21
+ import { WorkflowListMasterController } from './controller/workflow-list-master.controller';
20
22
 
21
23
  @Module({
22
24
  imports: [
@@ -47,6 +49,7 @@ import { Action } from './entity/action.entity';
47
49
  { provide: 'ActionService', useClass: ActionService },
48
50
  { provide: 'StageService', useClass: StageService },
49
51
  { provide: 'StageGroupService', useClass: StageGroupService },
52
+ WorkflowListMasterService,
50
53
  ],
51
54
  exports: [
52
55
  'WorkflowService',
@@ -58,6 +61,6 @@ import { Action } from './entity/action.entity';
58
61
  'StageService',
59
62
  'StageGroupService',
60
63
  ],
61
- controllers: [],
64
+ controllers: [WorkflowListMasterController],
62
65
  })
63
66
  export class WorkflowModule {}