org history employee
This commit is contained in:
parent
82527f0f49
commit
6bfe89b5a3
2 changed files with 275 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ import { EmployeePosDict } from "../entities/EmployeePosDict";
|
|||
import { calculateRetireLaw } from "../interfaces/utils";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||
@Route("api/v1/org/dotnet")
|
||||
@Tags("Dotnet")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -55,6 +56,8 @@ export class OrganizationDotnetController extends Controller {
|
|||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory);
|
||||
private posMasterEmployeeHistoryRepository =
|
||||
AppDataSource.getRepository(PosMasterEmployeeHistory);
|
||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
|
|
@ -5454,6 +5457,230 @@ export class OrganizationDotnetController extends Controller {
|
|||
return new HttpSuccess(profile_);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * รายชื่อขรก. ตามสิทธิ์ admin
|
||||
// *
|
||||
// * @summary รายชื่อขรก. ตามสิทธิ์ admin
|
||||
// *
|
||||
// */
|
||||
// @Post("employee-by-admin-rolev2")
|
||||
// async GetEmployeesByAdminRoleV2(
|
||||
// @Request() req: RequestWithUser,
|
||||
// @Body()
|
||||
// body: {
|
||||
// node: number;
|
||||
// nodeId: string;
|
||||
// role: string;
|
||||
// isRetirement?: boolean;
|
||||
// reqNode?: number;
|
||||
// reqNodeId?: string;
|
||||
// date?: Date;
|
||||
// },
|
||||
// ) {
|
||||
// let typeCondition: any = {};
|
||||
// if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
// if (body.role === "CHILD") {
|
||||
// switch (body.node) {
|
||||
// case 0:
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 1:
|
||||
// typeCondition = {
|
||||
// child1DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 2:
|
||||
// typeCondition = {
|
||||
// child2DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 3:
|
||||
// typeCondition = {
|
||||
// child3DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 4:
|
||||
// typeCondition = {
|
||||
// child4DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// default:
|
||||
// typeCondition = {};
|
||||
// break;
|
||||
// }
|
||||
// } else if (body.role === "BROTHER") {
|
||||
// switch (body.node) {
|
||||
// case 0:
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 1:
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 2:
|
||||
// typeCondition = {
|
||||
// child1DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 3:
|
||||
// typeCondition = {
|
||||
// child2DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 4:
|
||||
// typeCondition = {
|
||||
// child3DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// default:
|
||||
// typeCondition = {};
|
||||
// break;
|
||||
// }
|
||||
// } else if (body.role === "PARENT") {
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.nodeId,
|
||||
// child1DnaId: Not(IsNull()),
|
||||
// };
|
||||
// }
|
||||
// } else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
// switch (body.reqNode) {
|
||||
// case 0:
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.reqNodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 1:
|
||||
// typeCondition = {
|
||||
// child1DnaId: body.reqNodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 2:
|
||||
// typeCondition = {
|
||||
// child2DnaId: body.reqNodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 3:
|
||||
// typeCondition = {
|
||||
// child3DnaId: body.reqNodeId,
|
||||
// };
|
||||
// break;
|
||||
// case 4:
|
||||
// typeCondition = {
|
||||
// child4DnaId: body.reqNodeId,
|
||||
// };
|
||||
// break;
|
||||
// default:
|
||||
// typeCondition = {};
|
||||
// break;
|
||||
// }
|
||||
// } else if (body.role === "NORMAL") {
|
||||
// switch (body.node) {
|
||||
// case 0:
|
||||
// typeCondition = {
|
||||
// rootDnaId: body.nodeId,
|
||||
// child1DnaId: IsNull(),
|
||||
// };
|
||||
// break;
|
||||
// case 1:
|
||||
// typeCondition = {
|
||||
// child1DnaId: body.nodeId,
|
||||
// child2DnaId: IsNull(),
|
||||
// };
|
||||
// break;
|
||||
// case 2:
|
||||
// typeCondition = {
|
||||
// child2DnaId: body.nodeId,
|
||||
// child3DnaId: IsNull(),
|
||||
// };
|
||||
// break;
|
||||
// case 3:
|
||||
// typeCondition = {
|
||||
// child3DnaId: body.nodeId,
|
||||
// child4DnaId: IsNull(),
|
||||
// };
|
||||
// break;
|
||||
// case 4:
|
||||
// typeCondition = {
|
||||
// child4DnaId: body.nodeId,
|
||||
// };
|
||||
// break;
|
||||
// default:
|
||||
// typeCondition = {};
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// const date = body.date ? new Date(body.date) : new Date();
|
||||
// // set เวลาเป็น 23:59:59 ของวันนั้น
|
||||
// date.setHours(23, 59, 59, 999);
|
||||
|
||||
// let profile = await this.posMasterEmployeeHistoryRepository.find({
|
||||
// where: {
|
||||
// ...typeCondition,
|
||||
// createdAt: LessThanOrEqual(date),
|
||||
// // firstName: Not("") && Not(IsNull()),
|
||||
// // lastName: Not("") && Not(IsNull()),
|
||||
// },
|
||||
// order: {
|
||||
// firstName: "ASC",
|
||||
// lastName: "ASC",
|
||||
// createdAt: "DESC", // ให้ createdAt ล่าสุดอยู่ข้างบน
|
||||
// },
|
||||
// });
|
||||
|
||||
// // group by ancestorDNA แล้วเลือก create_at ล่าสุด
|
||||
// const grouped = new Map<string, PosMasterEmployeeHistory>();
|
||||
// for (const item of profile) {
|
||||
// const key = `${item.shortName}-${item.posMasterNo}`;
|
||||
// if (!grouped.has(key)) {
|
||||
// grouped.set(key, item);
|
||||
// } else {
|
||||
// // ถ้าเจอซ้ำ ให้เลือก createdAt ล่าสุด
|
||||
// const exist = grouped.get(key);
|
||||
// if (exist && item.createdAt > exist.createdAt) {
|
||||
// grouped.set(key, item);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// const profile_ = await Promise.all(
|
||||
// Array.from(grouped.values())
|
||||
// .filter((x) => x.profileId != null)
|
||||
// .map(async (item: PosMasterEmployeeHistory) => {
|
||||
// let profile = await this.profileRepo.findOne({
|
||||
// where: { id: item.profileId },
|
||||
// });
|
||||
|
||||
// return {
|
||||
// id: item.profileId,
|
||||
// prefix: item.prefix,
|
||||
// firstName: item.firstName,
|
||||
// lastName: item.lastName,
|
||||
// citizenId: profile?.citizenId ?? null,
|
||||
// dateStart: profile?.dateStart ?? null,
|
||||
// dateAppoint: profile?.dateAppoint ?? null,
|
||||
// keycloak: profile?.keycloak ?? null,
|
||||
// posNo: item.shortName,
|
||||
// position: item.position,
|
||||
// positionLevel: item.posLevel,
|
||||
// positionType: item.posType,
|
||||
// // oc: Oc,
|
||||
// orgRootId: item.rootDnaId,
|
||||
// orgChild1Id: item.child1DnaId,
|
||||
// orgChild2Id: item.child2DnaId,
|
||||
// orgChild3Id: item.child3DnaId,
|
||||
// orgChild4Id: item.child4DnaId,
|
||||
// };
|
||||
// }),
|
||||
// );
|
||||
|
||||
// return new HttpSuccess(profile_);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 4. API Update รอบการลงเวลา ในตาราง profile
|
||||
*
|
||||
|
|
|
|||
|
|
@ -98,4 +98,52 @@ export class PosMasterEmployeeHistory extends EntityBase {
|
|||
default: null,
|
||||
})
|
||||
ancestorDNA: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "คีย์นอก(FK)ของตาราง profile",
|
||||
// default: null,
|
||||
// })
|
||||
// profileId: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "dna ของตาราง orgRoot",
|
||||
// default: null,
|
||||
// })
|
||||
// rootDnaId: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "dna ของตาราง orgChild1",
|
||||
// default: null,
|
||||
// })
|
||||
// child1DnaId: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "dna ของตาราง orgChild2",
|
||||
// default: null,
|
||||
// })
|
||||
// child2DnaId: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "dna ของตาราง orgChild3",
|
||||
// default: null,
|
||||
// })
|
||||
// child3DnaId: string;
|
||||
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// length: 40,
|
||||
// comment: "dna ของตาราง orgChild4",
|
||||
// default: null,
|
||||
// })
|
||||
// child4DnaId: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue