rez_core 2.2.7 → 2.2.9
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/constant/global.constant.d.ts +2 -1
- package/dist/constant/global.constant.js +3 -2
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/enterprise/repository/school.repository.js +18 -2
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +1 -1
- package/dist/module/filter/controller/filter.controller.js +7 -4
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/dto/filter-request.dto.d.ts +1 -0
- package/dist/module/filter/service/filter.service.js +26 -4
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/layout_preference/controller/layout_preference.controller.js +4 -4
- package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
- package/dist/module/layout_preference/entity/layout_preference.entity.d.ts +2 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js +13 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js.map +1 -1
- package/dist/module/layout_preference/repository/layout_preference.repository.d.ts +1 -1
- package/dist/module/layout_preference/repository/layout_preference.repository.js +4 -2
- package/dist/module/layout_preference/repository/layout_preference.repository.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.d.ts +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +17 -4
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/listmaster/entity/list-master-items.entity.js +5 -5
- package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -1
- package/dist/module/meta/controller/media.controller.d.ts +1 -1
- package/dist/module/meta/controller/media.controller.js +1 -1
- package/dist/module/meta/controller/media.controller.js.map +1 -1
- package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +1 -1
- package/dist/module/module/controller/module-access.controller.js +6 -6
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +2 -1
- package/dist/module/module/service/module-access.service.js +5 -3
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/workflow/controller/action-category.controller.d.ts +8 -0
- package/dist/module/workflow/controller/action-category.controller.js +45 -0
- package/dist/module/workflow/controller/action-category.controller.js.map +1 -0
- package/dist/module/workflow/controller/action.controller.d.ts +28 -0
- package/dist/module/workflow/controller/action.controller.js +88 -0
- package/dist/module/workflow/controller/action.controller.js.map +1 -0
- package/dist/module/workflow/controller/comm-template.controller.d.ts +11 -0
- package/dist/module/workflow/controller/comm-template.controller.js +44 -0
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -0
- package/dist/module/workflow/controller/entity-modification.controller.d.ts +8 -0
- package/dist/module/workflow/controller/entity-modification.controller.js +44 -0
- package/dist/module/workflow/controller/entity-modification.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage-group.controller.d.ts +10 -0
- package/dist/module/workflow/controller/stage-group.controller.js +43 -0
- package/dist/module/workflow/controller/stage-group.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage.controller.d.ts +13 -0
- package/dist/module/workflow/controller/stage.controller.js +56 -0
- package/dist/module/workflow/controller/stage.controller.js.map +1 -0
- package/dist/module/workflow/controller/task.controller.d.ts +21 -0
- package/dist/module/workflow/controller/task.controller.js +58 -0
- package/dist/module/workflow/controller/task.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow-meta.controller.d.ts +15 -0
- package/dist/module/workflow/controller/workflow-meta.controller.js +70 -0
- package/dist/module/workflow/controller/workflow-meta.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow.controller.d.ts +25 -10
- package/dist/module/workflow/controller/workflow.controller.js +32 -15
- package/dist/module/workflow/controller/workflow.controller.js.map +1 -1
- package/dist/module/workflow/entity/action-category.entity.d.ts +1 -0
- package/dist/module/workflow/entity/action-category.entity.js +4 -0
- package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
- package/dist/module/workflow/entity/action-data.entity.d.ts +15 -0
- package/dist/module/workflow/entity/action-data.entity.js +70 -0
- package/dist/module/workflow/entity/action-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/action.entity.d.ts +7 -2
- package/dist/module/workflow/entity/action.entity.js +30 -10
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/entity/comm-template.entity.d.ts +5 -0
- package/dist/module/workflow/entity/comm-template.entity.js +21 -1
- package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
- package/dist/module/workflow/entity/entity-modification.entity.d.ts +13 -0
- package/dist/module/workflow/entity/entity-modification.entity.js +63 -0
- package/dist/module/workflow/entity/entity-modification.entity.js.map +1 -0
- package/dist/module/workflow/entity/stage-group.entity.d.ts +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage-movement-data.entity.d.ts +4 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js +16 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage.entity.d.ts +2 -2
- package/dist/module/workflow/entity/stage.entity.js +5 -5
- package/dist/module/workflow/entity/stage.entity.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +25 -0
- package/dist/module/workflow/entity/task-data.entity.js +110 -0
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/template-attach-mapper.entity.d.ts +11 -0
- package/dist/module/workflow/entity/template-attach-mapper.entity.js +54 -0
- package/dist/module/workflow/entity/template-attach-mapper.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/entity/workflow.entity.d.ts +2 -0
- package/dist/module/workflow/entity/workflow.entity.js +8 -0
- package/dist/module/workflow/entity/workflow.entity.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +10 -0
- package/dist/module/workflow/repository/action-data.repository.js +85 -0
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -0
- package/dist/module/workflow/repository/action.repository.d.ts +17 -0
- package/dist/module/workflow/repository/action.repository.js +97 -0
- package/dist/module/workflow/repository/action.repository.js.map +1 -0
- package/dist/module/workflow/repository/comm-template.repository.d.ts +14 -0
- package/dist/module/workflow/repository/comm-template.repository.js +87 -0
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage-group.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage-group.repository.js +50 -0
- package/dist/module/workflow/repository/stage-group.repository.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 +142 -0
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage.repository.js +50 -0
- package/dist/module/workflow/repository/stage.repository.js.map +1 -0
- package/dist/module/workflow/repository/task.repository.d.ts +10 -0
- package/dist/module/workflow/repository/task.repository.js +77 -0
- package/dist/module/workflow/repository/task.repository.js.map +1 -0
- package/dist/module/workflow/repository/workflow.repository.d.ts +9 -1
- package/dist/module/workflow/repository/workflow.repository.js +38 -6
- package/dist/module/workflow/repository/workflow.repository.js.map +1 -1
- package/dist/module/workflow/service/action-category.service.d.ts +5 -0
- package/dist/module/workflow/service/action-category.service.js +23 -1
- package/dist/module/workflow/service/action-category.service.js.map +1 -1
- package/dist/module/workflow/service/action-data.service.d.ts +11 -0
- package/dist/module/workflow/service/action-data.service.js +36 -0
- package/dist/module/workflow/service/action-data.service.js.map +1 -0
- package/dist/module/workflow/service/action.service.d.ts +19 -1
- package/dist/module/workflow/service/action.service.js +159 -10
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +11 -0
- package/dist/module/workflow/service/comm-template.service.js +59 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.d.ts +8 -0
- package/dist/module/workflow/service/entity-modification.service.js +52 -0
- package/dist/module/workflow/service/entity-modification.service.js.map +1 -0
- package/dist/module/workflow/service/populate-workflow.service.d.ts +21 -0
- package/dist/module/workflow/service/populate-workflow.service.js +124 -0
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -0
- package/dist/module/workflow/service/stage-group.service.d.ts +13 -0
- package/dist/module/workflow/service/stage-group.service.js +39 -1
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.d.ts +14 -4
- package/dist/module/workflow/service/stage.service.js +57 -13
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +18 -0
- package/dist/module/workflow/service/task.service.js +63 -0
- package/dist/module/workflow/service/task.service.js.map +1 -0
- package/dist/module/workflow/service/workflow-list-master.service.js +4 -4
- package/dist/module/workflow/service/workflow-meta.service.d.ts +20 -0
- package/dist/module/workflow/service/workflow-meta.service.js +137 -0
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -0
- package/dist/module/workflow/service/workflow.service.d.ts +28 -5
- package/dist/module/workflow/service/workflow.service.js +108 -41
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +82 -15
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/constant/global.constant.ts +3 -1
- package/src/module/enterprise/repository/school.repository.ts +23 -2
- package/src/module/filter/controller/filter.controller.ts +10 -4
- package/src/module/filter/dto/filter-request.dto.ts +1 -0
- package/src/module/filter/service/filter.service.ts +39 -5
- package/src/module/layout_preference/controller/layout_preference.controller.ts +6 -4
- package/src/module/layout_preference/entity/layout_preference.entity.ts +11 -0
- package/src/module/layout_preference/repository/layout_preference.repository.ts +6 -2
- package/src/module/layout_preference/service/layout_preference.service.ts +31 -6
- package/src/module/listmaster/entity/list-master-items.entity.ts +5 -5
- package/src/module/meta/controller/media.controller.ts +5 -7
- package/src/module/meta/entity/base-entity.entity.ts +1 -1
- package/src/module/module/controller/module-access.controller.ts +9 -4
- package/src/module/module/service/module-access.service.ts +15 -8
- package/src/module/workflow/controller/action-category.controller.ts +35 -0
- package/src/module/workflow/controller/action.controller.ts +73 -0
- package/src/module/workflow/controller/comm-template.controller.ts +32 -0
- package/src/module/workflow/controller/entity-modification.controller.ts +35 -0
- package/src/module/workflow/controller/stage-group.controller.ts +33 -0
- package/src/module/workflow/controller/stage.controller.ts +50 -0
- package/src/module/workflow/controller/task.controller.ts +57 -0
- package/src/module/workflow/controller/workflow-meta.controller.ts +76 -0
- package/src/module/workflow/controller/workflow.controller.ts +32 -12
- package/src/module/workflow/entity/action-category.entity.ts +3 -0
- package/src/module/workflow/entity/action-data.entity.ts +43 -0
- package/src/module/workflow/entity/action.entity.ts +18 -3
- package/src/module/workflow/entity/comm-template.entity.ts +18 -1
- package/src/module/workflow/entity/entity-modification.entity.ts +38 -0
- package/src/module/workflow/entity/stage-group.entity.ts +1 -1
- package/src/module/workflow/entity/stage-movement-data.entity.ts +12 -0
- package/src/module/workflow/entity/stage.entity.ts +4 -4
- package/src/module/workflow/entity/task-data.entity.ts +73 -0
- package/src/module/workflow/entity/template-attach-mapper.entity.ts +30 -0
- package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -0
- package/src/module/workflow/entity/workflow.entity.ts +6 -0
- package/src/module/workflow/repository/action-data.repository.ts +93 -0
- package/src/module/workflow/repository/action.repository.ts +104 -0
- package/src/module/workflow/repository/comm-template.repository.ts +102 -0
- package/src/module/workflow/repository/stage-group.repository.ts +46 -0
- package/src/module/workflow/repository/stage-movement.repository.ts +219 -0
- package/src/module/workflow/repository/stage.repository.ts +47 -0
- package/src/module/workflow/repository/task.repository.ts +85 -0
- package/src/module/workflow/repository/workflow.repository.ts +40 -2
- package/src/module/workflow/service/action-category.service.ts +26 -1
- package/src/module/workflow/service/action-data.service.ts +45 -0
- package/src/module/workflow/service/action-template-mapping.service.ts +1 -1
- package/src/module/workflow/service/action.service.ts +279 -19
- package/src/module/workflow/service/comm-template.service.ts +90 -1
- package/src/module/workflow/service/entity-modification.service.ts +67 -0
- package/src/module/workflow/service/populate-workflow.service.ts +189 -0
- package/src/module/workflow/service/stage-group.service.ts +67 -2
- package/src/module/workflow/service/stage.service.ts +104 -28
- package/src/module/workflow/service/task.service.ts +95 -0
- package/src/module/workflow/service/workflow-list-master.service.ts +4 -4
- package/src/module/workflow/service/workflow-meta.service.ts +231 -0
- package/src/module/workflow/service/workflow.service.ts +181 -50
- package/src/module/workflow/workflow.module.ts +82 -15
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { ActionDataEntity } from '../entity/action-data.entity';
|
|
4
|
+
import { DataSource, Repository } from 'typeorm';
|
|
5
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ActionDataRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectRepository(ActionDataEntity)
|
|
11
|
+
private readonly actionDataRepo: Repository<ActionDataEntity>,
|
|
12
|
+
private readonly dataSource: DataSource,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
async saveActionData(
|
|
16
|
+
action: any,
|
|
17
|
+
loggedInUser: UserData,
|
|
18
|
+
mapped_entity_id,
|
|
19
|
+
mapped_entity_type,
|
|
20
|
+
): Promise<any> {
|
|
21
|
+
if (!action?.length) return;
|
|
22
|
+
|
|
23
|
+
// Find the action with the lowest sequence
|
|
24
|
+
const minSequence = Math.min(...action.map((a) => a.sequence));
|
|
25
|
+
|
|
26
|
+
if (action.length > 0) {
|
|
27
|
+
for (const act of action) {
|
|
28
|
+
const isFirst = act.sequence == minSequence;
|
|
29
|
+
const actionData = this.actionDataRepo.create({
|
|
30
|
+
stage_id: act.stage_id,
|
|
31
|
+
user_id: loggedInUser.id,
|
|
32
|
+
action_id: act.id,
|
|
33
|
+
sequence: act.sequence,
|
|
34
|
+
mapped_entity_id,
|
|
35
|
+
mapped_entity_type,
|
|
36
|
+
is_current: isFirst ? 'Y' : null,
|
|
37
|
+
start_time: isFirst ? new Date() : null,
|
|
38
|
+
} as ActionDataEntity);
|
|
39
|
+
await this.actionDataRepo.save(actionData);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async updateActionStatus(
|
|
45
|
+
loggedInUser: UserData,
|
|
46
|
+
mapped_entity_type: string,
|
|
47
|
+
mapped_entity_id: number,
|
|
48
|
+
stage_id: number,
|
|
49
|
+
action_id: number,
|
|
50
|
+
): Promise<any> {
|
|
51
|
+
const actionData = await this.actionDataRepo.findOne({
|
|
52
|
+
where: {
|
|
53
|
+
mapped_entity_type,
|
|
54
|
+
mapped_entity_id,
|
|
55
|
+
stage_id,
|
|
56
|
+
action_id,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (!actionData) return;
|
|
61
|
+
|
|
62
|
+
actionData.end_time = new Date();
|
|
63
|
+
actionData.modified_by = loggedInUser.id;
|
|
64
|
+
actionData.modified_date = new Date();
|
|
65
|
+
actionData.is_done = true;
|
|
66
|
+
actionData.is_current = 'N'; // Mark as not current
|
|
67
|
+
|
|
68
|
+
// Save the updated action
|
|
69
|
+
await this.actionDataRepo.update(actionData.id, actionData);
|
|
70
|
+
|
|
71
|
+
// NOW, ACTIVATE THE NEXT ACTION (moveNextActionData logic here)
|
|
72
|
+
// Find next sequence action for the same entity/stage
|
|
73
|
+
const allActionData = await this.actionDataRepo.find({
|
|
74
|
+
where: { mapped_entity_type, mapped_entity_id, stage_id },
|
|
75
|
+
order: { sequence: 'ASC' },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Find the action with the next higher sequence number
|
|
79
|
+
const nextAction = allActionData.find(
|
|
80
|
+
(a) => a.sequence > actionData.sequence,
|
|
81
|
+
);
|
|
82
|
+
if (nextAction && nextAction.is_current !== 'Y') {
|
|
83
|
+
nextAction.is_current = 'Y';
|
|
84
|
+
nextAction.start_time = new Date();
|
|
85
|
+
nextAction.modified_by = loggedInUser.id;
|
|
86
|
+
nextAction.modified_date = new Date();
|
|
87
|
+
await this.actionDataRepo.update(nextAction.id, nextAction);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Optionally return both for audit
|
|
91
|
+
return { finished: actionData, activated: nextAction ?? null };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
8
|
+
import { DataSource, Repository } from 'typeorm';
|
|
9
|
+
import { ActionEntity } from '../entity/action.entity';
|
|
10
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class ActionRepository {
|
|
14
|
+
constructor(
|
|
15
|
+
@InjectRepository(ActionEntity)
|
|
16
|
+
private readonly actionRepository: Repository<ActionEntity>,
|
|
17
|
+
private readonly dataSource: DataSource,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
async getAction(
|
|
21
|
+
organization_id: number,
|
|
22
|
+
stage_id: number,
|
|
23
|
+
mapped_entity_id: number,
|
|
24
|
+
mapped_entity_type: string,
|
|
25
|
+
) {
|
|
26
|
+
// Step 1: Get all action mappings for the stage
|
|
27
|
+
const stageActions = await this.dataSource.query(
|
|
28
|
+
`SELECT id, action_id FROM cr_wf_stage_action_mapping WHERE stage_id = ?`,
|
|
29
|
+
[stage_id],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (!stageActions?.length) return [];
|
|
33
|
+
|
|
34
|
+
const actionIds = stageActions.map((sa) => sa.action_id);
|
|
35
|
+
|
|
36
|
+
// Step 2: Fetch all actions from cr_wf_action
|
|
37
|
+
const actions = await this.dataSource
|
|
38
|
+
.createQueryBuilder()
|
|
39
|
+
.select([
|
|
40
|
+
'a.id AS action_id',
|
|
41
|
+
'a.name AS action_name',
|
|
42
|
+
'ac.modalName AS modalName',
|
|
43
|
+
'ac.logo AS logo',
|
|
44
|
+
'ac.name AS action_category_name',
|
|
45
|
+
])
|
|
46
|
+
.from('cr_wf_action', 'a')
|
|
47
|
+
.leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
|
|
48
|
+
.where('a.organization_id = :orgId', { orgId: organization_id })
|
|
49
|
+
.andWhere('a.id IN (:...actionIds)', { actionIds })
|
|
50
|
+
.getRawMany();
|
|
51
|
+
|
|
52
|
+
// Step 3: Fetch action_data for the matched stage and entity
|
|
53
|
+
const actionData = await this.dataSource
|
|
54
|
+
.createQueryBuilder()
|
|
55
|
+
.select([
|
|
56
|
+
'ad.action_id AS action_id',
|
|
57
|
+
'ad.is_current AS is_current',
|
|
58
|
+
'ad.is_mandatory AS is_mandatory',
|
|
59
|
+
'ad.is_done AS is_done',
|
|
60
|
+
])
|
|
61
|
+
.from('cr_wf_action_data', 'ad')
|
|
62
|
+
.where('ad.stage_id = :stageId', { stageId: stage_id })
|
|
63
|
+
.andWhere('ad.action_id IN (:...actionIds)', { actionIds })
|
|
64
|
+
.andWhere('ad.mapped_entity_id = :mapped_entity_id', {
|
|
65
|
+
mapped_entity_id,
|
|
66
|
+
})
|
|
67
|
+
.andWhere('ad.mapped_entity_type = :mapped_entity_type', {
|
|
68
|
+
mapped_entity_type,
|
|
69
|
+
})
|
|
70
|
+
.getRawMany();
|
|
71
|
+
|
|
72
|
+
// Step 4: Build map of action_id to data
|
|
73
|
+
const actionIdToData = actionData.reduce((acc, row) => {
|
|
74
|
+
acc[row.action_id] = {
|
|
75
|
+
is_current: row.is_current === 'Y',
|
|
76
|
+
is_mandatory: row.is_mandatory === 1,
|
|
77
|
+
is_done: row.is_done === 1,
|
|
78
|
+
};
|
|
79
|
+
return acc;
|
|
80
|
+
}, {});
|
|
81
|
+
|
|
82
|
+
// Step 5: Enrich actions and set default current = false (N)
|
|
83
|
+
const enrichedResult = actions.map((row) => {
|
|
84
|
+
const data = actionIdToData[row.action_id];
|
|
85
|
+
return {
|
|
86
|
+
value: row.action_id,
|
|
87
|
+
label: row.action_name,
|
|
88
|
+
modalName: row.modalName,
|
|
89
|
+
logo: row.logo,
|
|
90
|
+
name: row.action_category_name,
|
|
91
|
+
is_current: data?.is_current ?? false,
|
|
92
|
+
is_done: data?.is_done ?? false,
|
|
93
|
+
is_mandatory: data?.is_mandatory ?? false,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
enrichedResult.push({
|
|
98
|
+
value: 0,
|
|
99
|
+
label: 'Generic',
|
|
100
|
+
} as any);
|
|
101
|
+
|
|
102
|
+
return enrichedResult;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { Workflow } from '../entity/workflow.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
import { CommTemplate } from '../entity/comm-template.entity';
|
|
6
|
+
import { TemplateAttach } from '../entity/template-attach-mapper.entity';
|
|
7
|
+
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class CommTemplateRepository {
|
|
11
|
+
constructor(
|
|
12
|
+
@InjectRepository(CommTemplate)
|
|
13
|
+
private readonly commTemplateRepository: Repository<CommTemplate>,
|
|
14
|
+
@InjectRepository(TemplateAttach)
|
|
15
|
+
private readonly templateAttachEntity: Repository<TemplateAttach>,
|
|
16
|
+
private readonly mediaDataService: MediaDataService,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
async getAllCommTemplate(entity_type: string, loggedInUser) {
|
|
20
|
+
const { organization_id } = loggedInUser;
|
|
21
|
+
return this.commTemplateRepository.find({
|
|
22
|
+
select: ['name', 'code'],
|
|
23
|
+
where: {
|
|
24
|
+
mapped_entity_type: entity_type,
|
|
25
|
+
organization_id: organization_id,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async save(commTemplate: any): Promise<any> {
|
|
31
|
+
// // delete existing mapper
|
|
32
|
+
// for (const attachment of commTemplate || []) {
|
|
33
|
+
// await this.templateAttachEntity.delete({
|
|
34
|
+
// entity_type: attachment.entity_type,
|
|
35
|
+
// template_id: attachment.template_id,
|
|
36
|
+
// });
|
|
37
|
+
// }
|
|
38
|
+
|
|
39
|
+
return this.templateAttachEntity.save(commTemplate);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async delete(id: any): Promise<any> {
|
|
43
|
+
// delete existing mapper
|
|
44
|
+
return await this.templateAttachEntity.delete(id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getTemplateByCode(
|
|
48
|
+
entity_type: string,
|
|
49
|
+
id: number,
|
|
50
|
+
loggedInUser,
|
|
51
|
+
): Promise<any | null> {
|
|
52
|
+
const template = await this.commTemplateRepository.findOne({
|
|
53
|
+
where: { entity_type, id },
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (!template) {
|
|
57
|
+
throw new NotFoundException(`Template with id ${id} not found`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (template.format_type === 'markup') {
|
|
61
|
+
const media = await this.mediaDataService.getMediaDownloadUrl(
|
|
62
|
+
template.markup_id,
|
|
63
|
+
loggedInUser,
|
|
64
|
+
);
|
|
65
|
+
template.markup_id = media as any;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (template.format_type === 'richtext') {
|
|
69
|
+
return template;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Get attachments for this template
|
|
73
|
+
const attachments = await this.templateAttachEntity.find({
|
|
74
|
+
select: ['media_id'],
|
|
75
|
+
where: {
|
|
76
|
+
entity_type,
|
|
77
|
+
template_id: template.id,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// If there are attachments, return array of media JSONs
|
|
82
|
+
let attachmentsMedia: any[] = [];
|
|
83
|
+
if (attachments.length > 0) {
|
|
84
|
+
attachmentsMedia = await Promise.all(
|
|
85
|
+
attachments.map(async (att) => {
|
|
86
|
+
// Fetch media details for each media_id
|
|
87
|
+
const media = await this.mediaDataService.getMediaDownloadUrl(
|
|
88
|
+
att.media_id,
|
|
89
|
+
loggedInUser,
|
|
90
|
+
);
|
|
91
|
+
return media; // return full media info (e.g., { id, url, ... })
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Return template with attachments array
|
|
97
|
+
return {
|
|
98
|
+
...template,
|
|
99
|
+
attachments: attachmentsMedia, // [] or array of media JSONs
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { StageGroup } from '../entity/stage-group.entity';
|
|
8
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
|
+
import { Repository } from 'typeorm';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class StageGroupRepository {
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectRepository(StageGroup)
|
|
15
|
+
private readonly stageGroupRepository: Repository<StageGroup>,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
async getAllStageGroup(
|
|
19
|
+
workflow_id: number,
|
|
20
|
+
level_id: string,
|
|
21
|
+
level_type: string,
|
|
22
|
+
) {
|
|
23
|
+
if (!workflow_id) {
|
|
24
|
+
throw new BadRequestException('workflow_id is required');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = await this.stageGroupRepository.find({
|
|
28
|
+
where: {
|
|
29
|
+
workflow_id,
|
|
30
|
+
level_id,
|
|
31
|
+
level_type,
|
|
32
|
+
},
|
|
33
|
+
order: {
|
|
34
|
+
sequence: 'ASC',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!result || result.length === 0) {
|
|
39
|
+
throw new NotFoundException(
|
|
40
|
+
'No stage groups found for the given workflow ID',
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { get } from 'http';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
4
|
+
import { Repository, DataSource, MoreThan } from 'typeorm';
|
|
5
|
+
import { WorkflowLevelMappingEntity } from '../entity/workflow-level-mapping.entity';
|
|
6
|
+
import { StageGroup } from '../entity/stage-group.entity';
|
|
7
|
+
import { Stage } from '../entity/stage.entity';
|
|
8
|
+
import { log } from 'console';
|
|
9
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class StageMovementRepository {
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectRepository(WorkflowLevelMappingEntity)
|
|
15
|
+
private readonly workflowLevelMappingRepo: Repository<WorkflowLevelMappingEntity>,
|
|
16
|
+
@InjectRepository(StageGroup)
|
|
17
|
+
private readonly stageGroupRepo: Repository<StageGroup>,
|
|
18
|
+
@InjectRepository(Stage)
|
|
19
|
+
private readonly stageRepo: Repository<Stage>,
|
|
20
|
+
private readonly dataSource: DataSource,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
async getFirstStage({
|
|
24
|
+
loggedInUser,
|
|
25
|
+
mapped_entity_type,
|
|
26
|
+
mapped_entity_id,
|
|
27
|
+
}: {
|
|
28
|
+
loggedInUser: any;
|
|
29
|
+
mapped_entity_type: string;
|
|
30
|
+
mapped_entity_id: string | number;
|
|
31
|
+
}): Promise<any | null> {
|
|
32
|
+
// Try finding mapping at user's level
|
|
33
|
+
let workflowLevelMapping = await this.workflowLevelMappingRepo.findOne({
|
|
34
|
+
where: {
|
|
35
|
+
mapped_level_type: loggedInUser.level_type,
|
|
36
|
+
mapped_level_id: loggedInUser.level_id,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// If not found, fallback to organization-level mapping
|
|
41
|
+
if (!workflowLevelMapping) {
|
|
42
|
+
workflowLevelMapping = await this.workflowLevelMappingRepo.findOne({
|
|
43
|
+
where: {
|
|
44
|
+
mapped_level_type: 'ORG',
|
|
45
|
+
mapped_level_id: loggedInUser.organization_id,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If still not found, return null
|
|
51
|
+
if (!workflowLevelMapping) return null;
|
|
52
|
+
|
|
53
|
+
// Find the stage group for this workflow
|
|
54
|
+
const stageGroup = await this.stageGroupRepo.findOne({
|
|
55
|
+
where: {
|
|
56
|
+
workflow_id: workflowLevelMapping.workflow_id,
|
|
57
|
+
},
|
|
58
|
+
order: { id: 'ASC' }, // Ensure you get the earliest/first group if needed
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (!stageGroup) return null;
|
|
62
|
+
|
|
63
|
+
// Find the first stage within this group
|
|
64
|
+
const firstStage = await this.stageRepo.findOne({
|
|
65
|
+
where: {
|
|
66
|
+
stage_group_id: stageGroup.id,
|
|
67
|
+
},
|
|
68
|
+
order: { id: 'ASC' }, // Change ordering as per your "first" logic
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!firstStage) return null;
|
|
72
|
+
|
|
73
|
+
// Return comprehensive result
|
|
74
|
+
return {
|
|
75
|
+
mappingUsed: workflowLevelMapping,
|
|
76
|
+
stageGroup,
|
|
77
|
+
firstStage,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// async getNextStage(
|
|
82
|
+
// stageGroupId: number,
|
|
83
|
+
// currentStageId: number,
|
|
84
|
+
// ): Promise<any | null> {
|
|
85
|
+
// // 1. Get current stage to find its sequence number
|
|
86
|
+
// const currentStage = await this.stageRepo.findOne({
|
|
87
|
+
// where: { id: currentStageId, stage_group_id: stageGroupId },
|
|
88
|
+
// });
|
|
89
|
+
// if (!currentStage) return null;
|
|
90
|
+
|
|
91
|
+
// // 2. Find the next stage with sequence just after the current one
|
|
92
|
+
// const nextStage = await this.stageRepo.findOne({
|
|
93
|
+
// where: {
|
|
94
|
+
// stage_group_id: stageGroupId,
|
|
95
|
+
// sequence: MoreThan(currentStage.sequence),
|
|
96
|
+
// },
|
|
97
|
+
// order: { sequence: 'ASC' },
|
|
98
|
+
// });
|
|
99
|
+
|
|
100
|
+
// return nextStage || null;
|
|
101
|
+
// }
|
|
102
|
+
|
|
103
|
+
// async getNextStageGroup(
|
|
104
|
+
// currentStageGroupId: number,
|
|
105
|
+
// ): Promise<StageGroup | null> {
|
|
106
|
+
// // 1. Get current stage group
|
|
107
|
+
// const currentStageGroup = await this.stageGroupRepo.findOne({
|
|
108
|
+
// where: { id: currentStageGroupId },
|
|
109
|
+
// });
|
|
110
|
+
// if (!currentStageGroup) return null;
|
|
111
|
+
// // 2. Find the next stage group with a higher sequence
|
|
112
|
+
// const nextStageGroup = await this.stageGroupRepo.findOne({
|
|
113
|
+
// where: {
|
|
114
|
+
// sequence: MoreThan(currentStageGroup.sequence),
|
|
115
|
+
// },
|
|
116
|
+
// order: { sequence: 'ASC' }, // Get the immediate next
|
|
117
|
+
// });
|
|
118
|
+
// return nextStageGroup || null;
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
async getNextStage(
|
|
122
|
+
stageGroupId: number,
|
|
123
|
+
currentStageId: number,
|
|
124
|
+
): Promise<any | null> {
|
|
125
|
+
const allStages = await this.stageRepo.find({
|
|
126
|
+
where: { stage_group_id: stageGroupId },
|
|
127
|
+
order: { sequence: 'ASC' },
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (currentStageId === 0) return allStages.length > 0 ? allStages[0] : null;
|
|
131
|
+
|
|
132
|
+
const currentStage = allStages.find((s) => s.id == currentStageId);
|
|
133
|
+
if (!currentStage) return null;
|
|
134
|
+
|
|
135
|
+
// Filter for stages with a greater sequence, then pick the smallest one
|
|
136
|
+
const higherStages = allStages
|
|
137
|
+
.filter((s) => s.sequence > currentStage.sequence)
|
|
138
|
+
.sort((a, b) => a.sequence - b.sequence);
|
|
139
|
+
|
|
140
|
+
return higherStages.length > 0 ? higherStages[0] : null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async getNextStageGroup(currentStageGroupId: number): Promise<any | null> {
|
|
144
|
+
const currentStageGroup = await this.stageGroupRepo.findOne({
|
|
145
|
+
where: { id: currentStageGroupId },
|
|
146
|
+
});
|
|
147
|
+
if (!currentStageGroup) return null;
|
|
148
|
+
|
|
149
|
+
//get workflow id of current stage group
|
|
150
|
+
const workflowId = currentStageGroup.workflow_id;
|
|
151
|
+
|
|
152
|
+
// Find the next stage group with a higher sequence
|
|
153
|
+
const nextStageGroup = await this.stageGroupRepo.findOne({
|
|
154
|
+
where: {
|
|
155
|
+
workflow_id: workflowId,
|
|
156
|
+
sequence: MoreThan(currentStageGroup.sequence),
|
|
157
|
+
},
|
|
158
|
+
order: { sequence: 'ASC' }, // Get the immediate next
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return nextStageGroup || null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async getNextStageOrFirstOfNextGroup(
|
|
165
|
+
stageGroupId: number,
|
|
166
|
+
currentStageId: number,
|
|
167
|
+
): Promise<any | null> {
|
|
168
|
+
// 1. Try to get the next stage in same group
|
|
169
|
+
const nextStage = await this.getNextStage(stageGroupId, currentStageId);
|
|
170
|
+
if (nextStage) return nextStage;
|
|
171
|
+
|
|
172
|
+
// 2. No next stage. Try to get next stage group
|
|
173
|
+
const nextStageGroup = await this.getNextStageGroup(stageGroupId);
|
|
174
|
+
if (!nextStageGroup) return null;
|
|
175
|
+
|
|
176
|
+
const nextStageGroupFirstStage = await this.getNextStage(
|
|
177
|
+
nextStageGroup.id,
|
|
178
|
+
0,
|
|
179
|
+
);
|
|
180
|
+
return nextStageGroupFirstStage || null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async getAllActionByStageId(stageId: number): Promise<any> {
|
|
184
|
+
const result = await this.dataSource.query(
|
|
185
|
+
`SELECT a.*, m.stage_id
|
|
186
|
+
FROM cr_wf_action a
|
|
187
|
+
INNER JOIN cr_wf_stage_action_mapping m ON a.id = m.action_id
|
|
188
|
+
WHERE m.stage_id = ?`,
|
|
189
|
+
[stageId],
|
|
190
|
+
);
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async saveActionData(action: any, loggedInUser: UserData): Promise<any> {
|
|
195
|
+
// Implement the logic to save action data
|
|
196
|
+
|
|
197
|
+
if (action.length > 0) {
|
|
198
|
+
for (const act of action) {
|
|
199
|
+
await this.dataSource.query(
|
|
200
|
+
`INSERT INTO cr_wf_action_data (stage_id, user_id, action_id) VALUES (?, ?, ?)`,
|
|
201
|
+
[act.stage_id, loggedInUser.id, act.id],
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async saveTaskData(actionData: any, loggedInUser: UserData): Promise<any> {
|
|
208
|
+
// Implement the logic to save task data
|
|
209
|
+
|
|
210
|
+
if (actionData.length > 0) {
|
|
211
|
+
for (const action of actionData) {
|
|
212
|
+
await this.dataSource.query(
|
|
213
|
+
`INSERT INTO cr_wf_task_data (action_id, user_id) VALUES (?, ?)`,
|
|
214
|
+
[action.id, loggedInUser.id],
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { StageGroup } from '../entity/stage-group.entity';
|
|
8
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
|
+
import { Repository } from 'typeorm';
|
|
10
|
+
import { Stage } from '../entity/stage.entity';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class StageRepository {
|
|
14
|
+
constructor(
|
|
15
|
+
@InjectRepository(Stage)
|
|
16
|
+
private readonly stageRepository: Repository<Stage>,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
async getAllStage(
|
|
20
|
+
stage_group_id: number,
|
|
21
|
+
level_id: string,
|
|
22
|
+
level_type: string,
|
|
23
|
+
) {
|
|
24
|
+
if (!stage_group_id) {
|
|
25
|
+
throw new BadRequestException('stage_group_id is required');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = await this.stageRepository.find({
|
|
29
|
+
where: {
|
|
30
|
+
stage_group_id,
|
|
31
|
+
level_id,
|
|
32
|
+
level_type,
|
|
33
|
+
},
|
|
34
|
+
order: {
|
|
35
|
+
sequence: 'ASC',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!result || result.length === 0) {
|
|
40
|
+
throw new NotFoundException(
|
|
41
|
+
'No stage found for the given stage group ID',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { TaskDataEntity } from '../entity/task-data.entity';
|
|
4
|
+
import { DataSource, Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class TaskRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(TaskDataEntity)
|
|
10
|
+
private readonly TaskRepository: Repository<TaskDataEntity>,
|
|
11
|
+
private readonly dataSource: DataSource,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async getAllTaskByUserIdAndStageId(condition) {
|
|
15
|
+
const result = await this.TaskRepository.find({
|
|
16
|
+
where: {
|
|
17
|
+
...condition,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async saveActionDataInTask(
|
|
25
|
+
action: any,
|
|
26
|
+
loggedInUser,
|
|
27
|
+
mapped_entity_id: number,
|
|
28
|
+
mapped_entity_type: string,
|
|
29
|
+
): Promise<any> {
|
|
30
|
+
if (!action?.length) return;
|
|
31
|
+
|
|
32
|
+
const todoListMasterItemId = await this.dataSource.query(
|
|
33
|
+
`SELECT id FROM cr_list_master_items WHERE code = 'todo' and organization_id = ? and listtype = 'TKST' LIMIT 1;`,
|
|
34
|
+
[loggedInUser.organization_id],
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Find the action with the lowest sequence
|
|
38
|
+
|
|
39
|
+
if (action.length > 0) {
|
|
40
|
+
for (const act of action) {
|
|
41
|
+
const taskData = this.TaskRepository.create({
|
|
42
|
+
stage_id: act.stage_id,
|
|
43
|
+
user_id: loggedInUser.id,
|
|
44
|
+
action_id: act.id,
|
|
45
|
+
sequence: act.sequence,
|
|
46
|
+
mapped_entity_id,
|
|
47
|
+
mapped_entity_type,
|
|
48
|
+
is_system: true,
|
|
49
|
+
task_status: todoListMasterItemId[0]?.id,
|
|
50
|
+
} as TaskDataEntity);
|
|
51
|
+
await this.TaskRepository.save(taskData);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// update task status
|
|
57
|
+
async updateTaskStatus(
|
|
58
|
+
loggedInUser,
|
|
59
|
+
mapped_entity_type,
|
|
60
|
+
mapped_entity_id,
|
|
61
|
+
stage_id,
|
|
62
|
+
action_id,
|
|
63
|
+
): Promise<any> {
|
|
64
|
+
const task = await this.TaskRepository.findOneBy({
|
|
65
|
+
action_id,
|
|
66
|
+
mapped_entity_type,
|
|
67
|
+
mapped_entity_id,
|
|
68
|
+
stage_id,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!task) return;
|
|
72
|
+
|
|
73
|
+
const completedListMasterItemId = await this.dataSource.query(
|
|
74
|
+
`SELECT id FROM cr_list_master_items WHERE code = 'completed' and organization_id = ? and listtype = 'TKST' LIMIT 1;`,
|
|
75
|
+
[loggedInUser.organization_id],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
task.modified_by = loggedInUser.id;
|
|
79
|
+
task.modified_date = new Date();
|
|
80
|
+
task.is_done = true;
|
|
81
|
+
task.task_status = completedListMasterItemId[0]?.id;
|
|
82
|
+
|
|
83
|
+
await this.TaskRepository.update(task.id, task);
|
|
84
|
+
}
|
|
85
|
+
}
|