ptath workflow

This commit is contained in:
kittapath 2024-10-21 10:22:39 +07:00
parent ed134d87f7
commit b2ccdfdf30
5 changed files with 43 additions and 94 deletions

View file

@ -37,7 +37,6 @@ import {
calculateRetireDate,
calculateRetireLaw,
commandTypePath,
commandTypePathLink,
removeProfileInOrganize,
setLogDataDiff,
} from "../interfaces/utils";
@ -1019,7 +1018,7 @@ export class CommandController extends Controller {
.filter((x) => x.profileId != null)
.map((x) => ({
receiverUserId: x.profileId,
notiLink: `${commandTypePathLink(command.commandType.code)}/${x.refId}`,
notiLink: "",
}))
: [];

View file

@ -16,6 +16,7 @@ import { MetaState } from "../entities/MetaState";
import { MetaStateOperator } from "../entities/MetaStateOperator";
import { PosMaster } from "../entities/PosMaster";
import { IsNull, Not } from "typeorm";
import { Assign } from "../entities/Assign";
@Route("api/v1/org/workflow")
@Tags("Workflow")
@ -32,6 +33,7 @@ export class WorkflowController extends Controller {
private metaStateRepo = AppDataSource.getRepository(MetaState);
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
private posMasterRepo = AppDataSource.getRepository(PosMaster);
private assignRepo = AppDataSource.getRepository(Assign);
@Post("add-workflow")
public async checkWorkflow(
@ -505,7 +507,7 @@ export class WorkflowController extends Controller {
where: {
id: body.stateId,
},
relations: ["stateUserComments"],
relations: ["stateUserComments", "workflow"],
});
if (!state) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
@ -523,12 +525,23 @@ export class WorkflowController extends Controller {
stateUserComment.lastUpdateFullName = req.user.name;
stateUserComment.lastUpdatedAt = new Date();
await this.stateUserCommentRepo.save(stateUserComment);
state.workflow.sysName;
const assign = await this.assignRepo.findOne({
where: {
id: state.workflow.sysName,
},
});
if (!assign) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
await new CallAPI()
.PostData(req, "/placement/noti/profiles", {
subject: `ได้รับรายการ`,
body: `ได้รับรายการ`,
receiverUserIds: [body.profileId],
receiverUserIds: [
{
receiverUserId: body.profileId,
notiLink: `${assign.path}/${state.workflow.refId}`,
},
],
payload: "", //แนบไฟล์
isSendMail: true,
isSendInbox: true,

View file

@ -61,6 +61,14 @@ export class Assign {
})
description: string;
@Column({
nullable: true,
comment: "path link",
type: "text",
default: null,
})
path: string;
@OneToMany(() => PosMasterAssign, (posMasterAssign) => posMasterAssign.assign)
posMasterAssigns: PosMasterAssign[];

View file

@ -298,92 +298,3 @@ export function commandTypePath(commandCode: string): string | null {
return null;
}
}
export function commandTypePathLink(commandCode: string): string | null {
switch (commandCode) {
case "C-PM-01":
return "placement/personal-detail";
case "C-PM-02":
return "placement/personal-detail";
case "C-PM-03":
return "placement/personal-detail";
case "C-PM-04":
return "placement/personal-detail";
case "C-PM-05":
return "xxxxxx";
case "C-PM-06":
return "placement/personal-detail";
case "C-PM-07":
return "xxxxxx";
case "C-PM-08":
return "xxxxxx";
case "C-PM-09":
return "xxxxxx";
case "C-PM-10":
return "xxxxxx";
case "C-PM-11":
return "xxxxxx";
case "C-PM-12":
return "xxxxxx";
case "C-PM-13":
return "placement/transfer";
case "C-PM-14":
return "xxxxxx";
case "C-PM-15":
return "xxxxxx";
case "C-PM-16":
return "xxxxxx";
case "C-PM-17":
return "xxxxxx";
case "C-PM-18":
return "xxxxxx";
case "C-PM-19":
return "xxxxxx";
case "C-PM-20":
return "xxxxxx";
case "C-PM-21":
return "xxxxxx";
case "C-PM-22":
return "xxxxxx";
case "C-PM-23":
return "xxxxxx";
case "C-PM-24":
return "xxxxxx";
case "C-PM-25":
return "xxxxxx";
case "C-PM-26":
return "xxxxxx";
case "C-PM-27":
return "xxxxxx";
case "C-PM-28":
return "xxxxxx";
case "C-PM-29":
return "xxxxxx";
case "C-PM-30":
return "xxxxxx";
case "C-PM-31":
return "xxxxxx";
case "C-PM-32":
return "xxxxxx";
case "C-PM-33":
return "xxxxxx";
case "C-PM-34":
return "xxxxxx";
case "C-PM-35":
return "xxxxxx";
case "C-PM-36":
return "xxxxxx";
case "C-PM-37":
return "xxxxxx";
case "C-PM-38":
return "xxxxxx";
case "C-PM-39":
return "xxxxxx";
case "C-PM-40":
return "xxxxxx";
case "C-PM-41":
return "xxxxxx";
default:
return null;
}
}

View file

@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateWorkflowAddPath1729480130391 implements MigrationInterface {
name = 'UpdateWorkflowAddPath1729480130391'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`assign\` ADD \`path\` text NULL COMMENT 'path link'`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD CONSTRAINT \`FK_8ba1f49c8315bf86848ebcb29f5\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP FOREIGN KEY \`FK_8ba1f49c8315bf86848ebcb29f5\``);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandId\``);
await queryRunner.query(`ALTER TABLE \`assign\` DROP COLUMN \`path\``);
}
}