no message
This commit is contained in:
parent
b85de85d7e
commit
31fbfaed3b
3 changed files with 93 additions and 23 deletions
|
|
@ -188,7 +188,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNow = _workflow.stateOperatorUsers
|
||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -313,7 +313,15 @@ export class WorkflowController extends Controller {
|
|||
system: string;
|
||||
},
|
||||
) {
|
||||
const stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
let stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -325,13 +333,20 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
relations: ["workflow"],
|
||||
});
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
if (stateOperatorUser) {
|
||||
stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
},
|
||||
relations: ["workflow"],
|
||||
});
|
||||
}
|
||||
const operator = await this.stateOperatorRepo.findOne({
|
||||
where: {
|
||||
operator: stateOperatorUser?.operator || "",
|
||||
|
|
@ -424,7 +439,16 @@ export class WorkflowController extends Controller {
|
|||
system: string;
|
||||
},
|
||||
) {
|
||||
const stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
relations: ["stateOperatorUsers"],
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
let stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -435,7 +459,20 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
},
|
||||
});
|
||||
const stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
if (stateOperatorUserNow == null) {
|
||||
stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
let stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
|
|
@ -447,17 +484,22 @@ export class WorkflowController extends Controller {
|
|||
operator: stateOperatorUserNow?.operator || "",
|
||||
},
|
||||
});
|
||||
if (stateOperatorUser == null) {
|
||||
stateOperatorUser = await this.stateOperatorUserRepo.find({
|
||||
where: {
|
||||
workflow: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
profileEmployee: {
|
||||
keycloak: Not(req.user.sub),
|
||||
},
|
||||
operator: stateOperatorUserNow?.operator || "",
|
||||
},
|
||||
});
|
||||
}
|
||||
await this.stateOperatorUserRepo.remove(stateOperatorUser);
|
||||
|
||||
const workflow = await this.workflowRepo.findOne({
|
||||
where: {
|
||||
refId: body.refId,
|
||||
sysName: body.system,
|
||||
},
|
||||
relations: ["stateOperatorUsers"],
|
||||
});
|
||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||
|
||||
const state = await this.stateRepo.findOne({
|
||||
where: {
|
||||
id: workflow.stateId,
|
||||
|
|
@ -476,7 +518,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNow = workflow.stateOperatorUsers
|
||||
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -496,7 +538,7 @@ export class WorkflowController extends Controller {
|
|||
let profileNext = workflow.stateOperatorUsers
|
||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
@ -656,7 +698,7 @@ export class WorkflowController extends Controller {
|
|||
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
||||
)
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||
notiLink: "",
|
||||
}));
|
||||
await new CallAPI()
|
||||
|
|
|
|||
14
src/migration/1732085607231-update_workflow_add_employee.ts
Normal file
14
src/migration/1732085607231-update_workflow_add_employee.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateWorkflowAddEmployee1732085607231 implements MigrationInterface {
|
||||
name = 'UpdateWorkflowAddEmployee1732085607231'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/migration/1732087058773-update_workflow_add_employee1.ts
Normal file
14
src/migration/1732087058773-update_workflow_add_employee1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateWorkflowAddEmployee11732087058773 implements MigrationInterface {
|
||||
name = 'UpdateWorkflowAddEmployee11732087058773'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue