2024-09-06 09:41:47 +07:00
import { Entity , Column , ManyToOne , JoinColumn , OneToMany } from "typeorm" ;
2024-01-30 15:00:56 +07:00
import { EntityBase } from "./base/Base" ;
2024-01-31 11:00:51 +07:00
import { CreatePosDict } from "./PosDict" ;
2024-01-31 14:29:39 +07:00
import { OrgRevision } from "./OrgRevision" ;
import { Position } from "./Position" ;
2024-01-31 15:31:20 +07:00
import { OrgRoot } from "./OrgRoot" ;
import { OrgChild1 } from "./OrgChild1" ;
import { OrgChild2 } from "./OrgChild2" ;
import { OrgChild3 } from "./OrgChild3" ;
import { OrgChild4 } from "./OrgChild4" ;
2024-02-06 10:12:41 +07:00
import { Profile } from "./Profile" ;
2024-06-13 14:18:20 +07:00
import { AuthRole } from "./AuthRole" ;
2024-06-19 23:03:54 +07:00
import { PosMasterAct } from "./PosMasterAct" ;
2024-10-07 17:00:54 +07:00
import { PosMasterAssign } from "./PosMasterAssign" ;
2024-01-30 15:00:56 +07:00
enum PosMasterLine {
MAIN = "MAIN" ,
SUPPORT = "SUPPORT" ,
}
@Entity ( "posMaster" )
export class PosMaster extends EntityBase {
@Column ( {
nullable : true ,
comment : "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)" ,
length : 16 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterNoPrefix : string ;
@Column ( {
nullable : true ,
comment : "เลขที่ตำแหน่ง เป็นตัวเลข" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-01-31 18:02:50 +07:00
posMasterNo : number ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
comment : "Suffix หลังเลขที่ตำแหน่ง เช่น ช." ,
length : 16 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterNoSuffix : string ;
@Column ( {
nullable : true ,
type : "datetime" ,
comment : "วัน-เวลาที่สร้าง" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterCreatedAt : Date ;
@Column ( {
nullable : true ,
comment :
"รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้" ,
length : 40 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 13:29:15 +07:00
ancestorDNA : string ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
comment : "ลำดับที่แสดงผล" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterOrder : number ;
@Column ( {
nullable : true ,
comment : "ลำดับความสำคัญ" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterPriority : number ;
@Column ( {
nullable : true ,
comment : "สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง" ,
type : "enum" ,
enum : PosMasterLine ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
posMasterLine : PosMasterLine ;
2024-02-07 18:53:15 +07:00
@Column ( {
comment : "นั่งทับตำแหน่งไหม" ,
default : false ,
} )
isSit : boolean ;
2024-06-12 10:41:48 +07:00
@Column ( {
comment : "เป็นผู้อำนวยการ" ,
default : false ,
} )
isDirector : boolean ;
@Column ( {
comment : "เป็นเจ้าหน้าที่" ,
default : false ,
} )
2024-09-12 22:53:58 +07:00
isStaff : boolean ;
2024-09-13 10:29:08 +07:00
// @Column({
// comment: "เป็นสกจ",
// default: false,
// })
// isOfficer: boolean;
2024-06-12 10:41:48 +07:00
2024-09-12 22:53:58 +07:00
@Column ( {
nullable : true ,
comment : "ตำแหน่งใต้ลายเซ็นต์" ,
type : "text" ,
default : null ,
} )
positionSign : string ;
2024-04-09 12:18:52 +07:00
@Column ( {
nullable : true ,
comment : "หมายเหตุ" ,
type : "text" ,
default : null ,
} )
reason : string ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgRoot" ,
2024-01-31 17:20:08 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 20:05:26 +07:00
orgRootId? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgChild1" ,
2024-01-31 17:20:08 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 20:05:26 +07:00
orgChild1Id? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgChild2" ,
2024-01-31 17:20:08 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 20:05:26 +07:00
orgChild2Id? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgChild3" ,
2024-01-31 17:20:08 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 20:05:26 +07:00
orgChild3Id? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgChild4" ,
2024-01-31 17:20:08 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-01 20:05:26 +07:00
orgChild4Id? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-01-31 11:00:51 +07:00
comment :
"คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-08 14:53:04 +07:00
current_holderId? : string | null ;
2024-01-30 15:00:56 +07:00
@Column ( {
nullable : true ,
length : 40 ,
2024-01-31 11:00:51 +07:00
comment :
"คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-30 15:00:56 +07:00
} )
2024-02-08 14:53:04 +07:00
next_holderId? : string | null ;
2024-02-06 11:30:41 +07:00
2024-01-30 15:00:56 +07:00
@Column ( {
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgRevision" ,
2024-01-30 15:00:56 +07:00
} )
2024-01-31 11:00:51 +07:00
orgRevisionId : string ; //fk
2024-01-31 14:29:39 +07:00
2024-06-13 14:18:20 +07:00
@Column ( {
2024-06-13 23:56:49 +07:00
nullable : true ,
default : null ,
2024-06-13 14:18:20 +07:00
length : 40 ,
comment : "คีย์นอก(FK)ของตาราง authRole" ,
} )
authRoleId : string ;
2024-10-17 22:11:54 +07:00
@Column ( {
comment : "สถานะออกคำสั่ง" ,
default : "PENDING" ,
length : 20 ,
} )
statusReport : string ;
2024-10-31 20:59:14 +07:00
@Column ( {
comment : "ตำแหน่งติดเงื่อนไข" ,
default : false ,
} )
isCondition : boolean ;
@Column ( {
nullable : true ,
comment : "หมายเหตุตำแหน่งติดเงื่อนไข" ,
type : "text" ,
default : null ,
} )
conditionReason : string ;
2024-07-25 09:54:44 +07:00
@ManyToOne ( ( ) = > AuthRole , ( authRole ) = > authRole . posMasters )
2024-06-13 14:18:20 +07:00
@JoinColumn ( { name : "authRoleId" } )
authRole : AuthRole ;
2024-01-31 15:31:20 +07:00
@ManyToOne ( ( ) = > OrgRevision , ( orgRevision ) = > orgRevision . posMasters )
2024-01-31 14:29:39 +07:00
@JoinColumn ( { name : "orgRevisionId" } )
orgRevision : OrgRevision ;
2024-01-31 15:31:20 +07:00
@ManyToOne ( ( ) = > OrgRoot , ( orgRoot ) = > orgRoot . posMasters )
@JoinColumn ( { name : "orgRootId" } )
orgRoot : OrgRoot ;
@ManyToOne ( ( ) = > OrgChild1 , ( orgChild1 ) = > orgChild1 . posMasters )
@JoinColumn ( { name : "orgChild1Id" } )
orgChild1 : OrgChild1 ;
@ManyToOne ( ( ) = > OrgChild2 , ( orgChild2 ) = > orgChild2 . posMasters )
2024-01-31 17:22:45 +07:00
@JoinColumn ( { name : "orgChild2Id" } )
2024-01-31 15:31:20 +07:00
orgChild2 : OrgChild2 ;
@ManyToOne ( ( ) = > OrgChild3 , ( orgChild3 ) = > orgChild3 . posMasters )
2024-01-31 17:22:45 +07:00
@JoinColumn ( { name : "orgChild3Id" } )
2024-01-31 15:31:20 +07:00
orgChild3 : OrgChild3 ;
@ManyToOne ( ( ) = > OrgChild4 , ( orgChild4 ) = > orgChild4 . posMasters )
2024-01-31 17:22:45 +07:00
@JoinColumn ( { name : "orgChild4Id" } )
2024-01-31 15:31:20 +07:00
orgChild4 : OrgChild4 ;
2024-02-06 16:23:06 +07:00
@ManyToOne ( ( ) = > Profile , ( posMaster ) = > posMaster . current_holders )
2024-02-06 15:18:20 +07:00
@JoinColumn ( { name : "current_holderId" } )
2024-02-06 16:23:06 +07:00
current_holder : Profile ;
2024-02-06 10:12:41 +07:00
2024-02-06 16:23:06 +07:00
@ManyToOne ( ( ) = > Profile , ( posMaster ) = > posMaster . next_holders )
2024-02-06 15:18:20 +07:00
@JoinColumn ( { name : "next_holderId" } )
2024-02-06 16:23:06 +07:00
next_holder : Profile ;
2024-02-06 10:12:41 +07:00
2024-01-31 14:29:39 +07:00
@OneToMany ( ( ) = > Position , ( position ) = > position . posMaster )
positions : Position [ ] ;
2024-06-19 23:03:54 +07:00
@OneToMany ( ( ) = > PosMasterAct , ( posMasterAct ) = > posMasterAct . posMaster )
posMasterActs : PosMasterAct [ ] ;
@OneToMany ( ( ) = > PosMasterAct , ( posMasterAct ) = > posMasterAct . posMasterChild )
posMasterActChilds : PosMasterAct [ ] ;
2024-10-07 17:00:54 +07:00
@OneToMany ( ( ) = > PosMasterAssign , ( posMasterAssign ) = > posMasterAssign . posMaster )
posMasterAssigns : PosMasterAssign [ ] ;
2024-01-30 15:00:56 +07:00
}
2024-01-31 11:00:51 +07:00
export class CreatePosMaster {
@Column ( )
2025-03-19 10:18:03 +07:00
posMasterNoPrefix : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( )
2024-01-31 18:02:50 +07:00
posMasterNo : number ;
2024-01-31 11:00:51 +07:00
@Column ( )
2025-03-19 10:18:03 +07:00
posMasterNoSuffix : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( "uuid" )
positions : CreatePosDict [ ] ;
@Column ( "uuid" )
2024-01-31 18:02:50 +07:00
orgRootId? : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( "uuid" )
2024-01-31 18:02:50 +07:00
orgChild1Id? : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( "uuid" )
2024-01-31 18:02:50 +07:00
orgChild2Id? : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( "uuid" )
2024-01-31 18:02:50 +07:00
orgChild3Id? : string | null ;
2024-01-31 11:00:51 +07:00
@Column ( "uuid" )
2024-01-31 18:02:50 +07:00
orgChild4Id? : string | null ;
2024-04-09 12:18:52 +07:00
@Column ( )
2024-04-09 21:59:01 +07:00
reason : string | null ;
2024-06-12 14:41:16 +07:00
@Column ( )
isDirector : boolean ;
2024-09-12 22:53:58 +07:00
@Column ( )
isStaff : boolean ;
@Column ( )
positionSign : string | null ;
2024-01-31 11:00:51 +07:00
}
export type UpdatePosMaster = Partial < PosMaster > ;