Merge branch 'develop' into adiDev
This commit is contained in:
commit
a3ab8c5e30
7 changed files with 92 additions and 116 deletions
|
|
@ -36,6 +36,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
|||
import {
|
||||
calculateRetireDate,
|
||||
calculateRetireLaw,
|
||||
commandTypePath,
|
||||
removeProfileInOrganize,
|
||||
setLogDataDiff,
|
||||
} from "../interfaces/utils";
|
||||
|
|
@ -556,7 +557,7 @@ export class CommandController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||
}
|
||||
|
||||
const path = this.commandTypePath(commandRecive.command.commandType.code);
|
||||
const path = commandTypePath(commandRecive.command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
await new CallAPI()
|
||||
.PostData(request, path + "/delete", {
|
||||
|
|
@ -863,7 +864,7 @@ export class CommandController extends Controller {
|
|||
where: { commandId: id },
|
||||
});
|
||||
|
||||
const path = this.commandTypePath(command.commandType.code);
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
await new CallAPI()
|
||||
.PostData(request, path + "/delete", {
|
||||
|
|
@ -1002,7 +1003,7 @@ export class CommandController extends Controller {
|
|||
) {
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["commandType", "commandRecives"],
|
||||
relations: ["commandType", "commandRecives", "commandSends", "commandSends.commandSendCCs"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
|
|
@ -1013,7 +1014,12 @@ export class CommandController extends Controller {
|
|||
|
||||
let profiles =
|
||||
command && command.commandRecives.length > 0
|
||||
? command.commandRecives.filter((x) => x.profileId != null).map((x) => x.profileId)
|
||||
? command.commandRecives
|
||||
.filter((x) => x.profileId != null)
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
notiLink: "",
|
||||
}))
|
||||
: [];
|
||||
|
||||
await new CallAPI()
|
||||
|
|
@ -1022,7 +1028,6 @@ export class CommandController extends Controller {
|
|||
body: `${command.issue}`,
|
||||
receiverUserIds: profiles,
|
||||
payload: "", //แนบไฟล์
|
||||
notiLink: "", //แนบไฟล์
|
||||
isSendMail: true,
|
||||
isSendInbox: true,
|
||||
isSendNotification: true,
|
||||
|
|
@ -1030,6 +1035,29 @@ export class CommandController extends Controller {
|
|||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
});
|
||||
let profilesSend =
|
||||
command && command.commandSends.length > 0
|
||||
? command.commandSends
|
||||
.filter((x) => x.profileId != null)
|
||||
.map((x) => ({
|
||||
receiverUserId: x.profileId,
|
||||
notiLink: "",
|
||||
isSendMail: x.commandSendCCs.map((x) => x.name == "EMAIL").length > 0 ? true : false,
|
||||
isSendInbox: x.commandSendCCs.map((x) => x.name == "INBOX").length > 0 ? true : false,
|
||||
isSendNotification: true,
|
||||
}))
|
||||
: [];
|
||||
|
||||
await new CallAPI()
|
||||
.PostData(request, "/placement/noti/profiles-send", {
|
||||
subject: `${command.issue}`,
|
||||
body: `${command.issue}`,
|
||||
receiverUserIds: profilesSend,
|
||||
payload: "", //แนบไฟล์
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
});
|
||||
if (
|
||||
new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) <
|
||||
new Date(
|
||||
|
|
@ -1044,7 +1072,7 @@ export class CommandController extends Controller {
|
|||
command.lastUpdatedAt = new Date();
|
||||
await this.commandRepository.save(command);
|
||||
} else {
|
||||
const path = this.commandTypePath(command.commandType.code);
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
const msg = {
|
||||
data: {
|
||||
|
|
@ -1101,7 +1129,7 @@ export class CommandController extends Controller {
|
|||
}
|
||||
|
||||
command.forEach(async (x) => {
|
||||
const path = this.commandTypePath(x.commandType.code);
|
||||
const path = commandTypePath(x.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
const msg = {
|
||||
data: {
|
||||
|
|
@ -1213,7 +1241,7 @@ export class CommandController extends Controller {
|
|||
}
|
||||
|
||||
let _command: any = [];
|
||||
const path = this.commandTypePath(command.commandType.code);
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
await new CallAPI()
|
||||
.PostData(request, path + "/attachment", {
|
||||
|
|
@ -1366,7 +1394,7 @@ export class CommandController extends Controller {
|
|||
await this.commandRepository.save(command);
|
||||
}
|
||||
|
||||
const path = this.commandTypePath(commandCode);
|
||||
const path = commandTypePath(commandCode);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
await new CallAPI()
|
||||
.PostData(request, path, {
|
||||
|
|
@ -2857,93 +2885,4 @@ export class CommandController extends Controller {
|
|||
await this.posMasterRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
commandTypePath(commandCode: string) {
|
||||
switch (commandCode) {
|
||||
case "C-PM-01":
|
||||
return "/placement/recruit/report"; //
|
||||
case "C-PM-02":
|
||||
return "/placement/candidate/report"; //
|
||||
case "C-PM-03":
|
||||
return "/placement/appoint/report";
|
||||
case "C-PM-04":
|
||||
return "/placement/move/report";
|
||||
case "C-PM-05":
|
||||
return "/placement/appointment/appoint/report";
|
||||
case "C-PM-06":
|
||||
return "/placement/slip/report";
|
||||
case "C-PM-07":
|
||||
return "/placement/appointment/move/report";
|
||||
case "C-PM-08":
|
||||
return "/retirement/other/appoint/report";
|
||||
case "C-PM-09":
|
||||
return "/retirement/other/out/report";
|
||||
case "C-PM-10":
|
||||
return "/probation/report/command10/officer/report";
|
||||
case "C-PM-11":
|
||||
return "/probation/report/command11/officer/report";
|
||||
case "C-PM-12":
|
||||
return "/probation/report/command12/officer/report";
|
||||
case "C-PM-13":
|
||||
return "/placement/transfer/command/report";
|
||||
case "C-PM-14":
|
||||
return "/placement/receive/command/report";
|
||||
case "C-PM-15":
|
||||
return "/placement/officer/command/report";
|
||||
case "C-PM-16":
|
||||
return "/placement/repatriation/command/report";
|
||||
case "C-PM-17":
|
||||
return "/retirement/resign/command/report";
|
||||
case "C-PM-18":
|
||||
return "/retirement/out/command/report";
|
||||
case "C-PM-19":
|
||||
return "/discipline/result/command19/report";
|
||||
case "C-PM-20":
|
||||
return "/discipline/result/command20/report";
|
||||
case "C-PM-21":
|
||||
return "/org/command/command21/employee/report";
|
||||
case "C-PM-22":
|
||||
return "/placement/appointment/employee-appoint/report";
|
||||
case "C-PM-23":
|
||||
return "/retirement/resign/employee/report";
|
||||
case "C-PM-24":
|
||||
return "/placement/appointment/employee-move/report";
|
||||
case "C-PM-25":
|
||||
return "/discipline/result/command25/report";
|
||||
case "C-PM-26":
|
||||
return "/discipline/result/command26/report";
|
||||
case "C-PM-27":
|
||||
return "/discipline/result/command27/report";
|
||||
case "C-PM-28":
|
||||
return "/discipline/result/command28/report";
|
||||
case "C-PM-29":
|
||||
return "/discipline/result/command29/report";
|
||||
case "C-PM-30":
|
||||
return "/discipline/result/command30/report";
|
||||
case "C-PM-31":
|
||||
return "/discipline/result/command31/report";
|
||||
case "C-PM-32":
|
||||
return "/discipline/result/command32/report";
|
||||
case "C-PM-33":
|
||||
return "/salary/report/command/officer/report";
|
||||
case "C-PM-34":
|
||||
return "/salary/report/command/officer/report";
|
||||
case "C-PM-35":
|
||||
return "/salary/report/command/officer/report";
|
||||
case "C-PM-36":
|
||||
return "/salary/report/command/employee/report";
|
||||
case "C-PM-37":
|
||||
return "/salary/report/command/employee/report";
|
||||
case "C-PM-38":
|
||||
return "/org/command/command38/officer/report";
|
||||
case "C-PM-39":
|
||||
return "/placement/appointment/slip/report";
|
||||
case "C-PM-40":
|
||||
return "/org/command/command40/officer/report";
|
||||
case "C-PM-41":
|
||||
return "/retirement/resign/leave-cancel/report";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export class ProfileEditController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -117,7 +117,7 @@ export class ProfileEditController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -122,7 +122,7 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -626,8 +639,8 @@ export class WorkflowController extends Controller {
|
|||
*
|
||||
*
|
||||
*/
|
||||
@Get("commander")
|
||||
async getProfilePlacement(@Request() req: RequestWithUser) {
|
||||
@Get("commander/{type}") //xxxxxxxxxxxxxxxxxx
|
||||
async getProfilePlacement(@Request() req: RequestWithUser, @Path() type: string) {
|
||||
const posMasterUser = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
|
|
@ -644,7 +657,7 @@ export class WorkflowController extends Controller {
|
|||
current_holderId: Not(IsNull()),
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
},
|
||||
relations: ["current_holder", "orgRoot"],
|
||||
relations: ["current_holder"],
|
||||
});
|
||||
|
||||
let _posMasters = posMasters.map((data) => ({
|
||||
|
|
@ -655,7 +668,6 @@ export class WorkflowController extends Controller {
|
|||
position: data.current_holder.position,
|
||||
posLevel: data.current_holder.posLevel,
|
||||
posType: data.current_holder.posType,
|
||||
orgRoot: data.orgRoot.orgRootName,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_posMasters);
|
||||
|
|
|
|||
|
|
@ -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[];
|
||||
|
||||
|
|
|
|||
|
|
@ -213,9 +213,9 @@ export function editLogSequence(req: RequestWithUser, index: number, data: LogSe
|
|||
export function commandTypePath(commandCode: string): string | null {
|
||||
switch (commandCode) {
|
||||
case "C-PM-01":
|
||||
return "/placement/recruit/report";
|
||||
return "/placement/recruit/report"; //
|
||||
case "C-PM-02":
|
||||
return "/placement/candidate/report";
|
||||
return "/placement/candidate/report"; //
|
||||
case "C-PM-03":
|
||||
return "/placement/appoint/report";
|
||||
case "C-PM-04":
|
||||
|
|
@ -223,7 +223,7 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
case "C-PM-05":
|
||||
return "/placement/appointment/appoint/report";
|
||||
case "C-PM-06":
|
||||
return "/placement/appointment/slip/report";
|
||||
return "/placement/slip/report";
|
||||
case "C-PM-07":
|
||||
return "/placement/appointment/move/report";
|
||||
case "C-PM-08":
|
||||
|
|
@ -231,7 +231,7 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
case "C-PM-09":
|
||||
return "/retirement/other/out/report";
|
||||
case "C-PM-10":
|
||||
return "/xxxxxx";
|
||||
return "/probation/report/command10/officer/report";
|
||||
case "C-PM-11":
|
||||
return "/probation/report/command11/officer/report";//PROBATION
|
||||
case "C-PM-12":
|
||||
|
|
@ -239,7 +239,7 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
case "C-PM-13":
|
||||
return "/placement/transfer/command/report";
|
||||
case "C-PM-14":
|
||||
return "/placement/Receive/command/report";
|
||||
return "/placement/receive/command/report";
|
||||
case "C-PM-15":
|
||||
return "/placement/officer/command/report";
|
||||
case "C-PM-16":
|
||||
|
|
@ -289,7 +289,7 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
case "C-PM-38":
|
||||
return "/org/command/command38/officer/report";//ORG
|
||||
case "C-PM-39":
|
||||
return "/placement/slip/report";
|
||||
return "/placement/appointment/slip/report";
|
||||
case "C-PM-40":
|
||||
return "/org/command/command40/officer/report";//ORG
|
||||
case "C-PM-41":
|
||||
|
|
@ -298,4 +298,3 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/migration/1729480130391-update_workflow_add_path.ts
Normal file
18
src/migration/1729480130391-update_workflow_add_path.ts
Normal 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\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue