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
|
let profileNow = _workflow.stateOperatorUsers
|
||||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
receiverUserId: x.profileId,
|
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||||
notiLink: "",
|
notiLink: "",
|
||||||
}));
|
}));
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
|
|
@ -313,7 +313,15 @@ export class WorkflowController extends Controller {
|
||||||
system: string;
|
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: {
|
where: {
|
||||||
workflow: {
|
workflow: {
|
||||||
refId: body.refId,
|
refId: body.refId,
|
||||||
|
|
@ -325,13 +333,20 @@ export class WorkflowController extends Controller {
|
||||||
},
|
},
|
||||||
relations: ["workflow"],
|
relations: ["workflow"],
|
||||||
});
|
});
|
||||||
const workflow = await this.workflowRepo.findOne({
|
if (stateOperatorUser) {
|
||||||
where: {
|
stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||||
refId: body.refId,
|
where: {
|
||||||
sysName: body.system,
|
workflow: {
|
||||||
},
|
refId: body.refId,
|
||||||
});
|
sysName: body.system,
|
||||||
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
},
|
||||||
|
profileEmployee: {
|
||||||
|
keycloak: req.user.sub,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
relations: ["workflow"],
|
||||||
|
});
|
||||||
|
}
|
||||||
const operator = await this.stateOperatorRepo.findOne({
|
const operator = await this.stateOperatorRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
operator: stateOperatorUser?.operator || "",
|
operator: stateOperatorUser?.operator || "",
|
||||||
|
|
@ -424,7 +439,16 @@ export class WorkflowController extends Controller {
|
||||||
system: string;
|
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: {
|
where: {
|
||||||
workflow: {
|
workflow: {
|
||||||
refId: body.refId,
|
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: {
|
where: {
|
||||||
workflow: {
|
workflow: {
|
||||||
refId: body.refId,
|
refId: body.refId,
|
||||||
|
|
@ -447,17 +484,22 @@ export class WorkflowController extends Controller {
|
||||||
operator: stateOperatorUserNow?.operator || "",
|
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);
|
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({
|
const state = await this.stateRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: workflow.stateId,
|
id: workflow.stateId,
|
||||||
|
|
@ -476,7 +518,7 @@ export class WorkflowController extends Controller {
|
||||||
let profileNow = workflow.stateOperatorUsers
|
let profileNow = workflow.stateOperatorUsers
|
||||||
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
.filter((x) => state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
receiverUserId: x.profileId,
|
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||||
notiLink: "",
|
notiLink: "",
|
||||||
}));
|
}));
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
|
|
@ -496,7 +538,7 @@ export class WorkflowController extends Controller {
|
||||||
let profileNext = workflow.stateOperatorUsers
|
let profileNext = workflow.stateOperatorUsers
|
||||||
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
.filter((x) => _state.stateOperators.map((s) => s.operator).includes(x.operator))
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
receiverUserId: x.profileId,
|
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||||
notiLink: "",
|
notiLink: "",
|
||||||
}));
|
}));
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
|
|
@ -656,7 +698,7 @@ export class WorkflowController extends Controller {
|
||||||
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
||||||
)
|
)
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
receiverUserId: x.profileId,
|
receiverUserId: x.profileType == "OFFICER" ? x.profileId : x.profileEmployeeId,
|
||||||
notiLink: "",
|
notiLink: "",
|
||||||
}));
|
}));
|
||||||
await new CallAPI()
|
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