From 81ee387cababb9ee07c872c8c76e21f4c56288a5 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Mon, 21 Jul 2025 23:30:38 +0700 Subject: [PATCH] test import --- src/controllers/ImportDataController.ts | 996 ++++++++++++++++++++ src/entities/HR_CHANGENAME_EMPTEMP.ts | 62 ++ src/entities/HR_DISCIPLINE_EMPTEMP.ts | 27 + src/entities/HR_EDUCATION_EMPTEMP.ts | 76 ++ src/entities/HR_PERSONAL_EMPTEMP_ADDRESS.ts | 83 ++ src/entities/HR_PERSONAL_EMPTEMP_FAMILY.ts | 90 ++ src/entities/HR_POSITION_EMPLOYEETEMP.ts | 205 ++++ 7 files changed, 1539 insertions(+) create mode 100644 src/entities/HR_CHANGENAME_EMPTEMP.ts create mode 100644 src/entities/HR_DISCIPLINE_EMPTEMP.ts create mode 100644 src/entities/HR_EDUCATION_EMPTEMP.ts create mode 100644 src/entities/HR_PERSONAL_EMPTEMP_ADDRESS.ts create mode 100644 src/entities/HR_PERSONAL_EMPTEMP_FAMILY.ts create mode 100644 src/entities/HR_POSITION_EMPLOYEETEMP.ts diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 538ada90..25532954 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -96,6 +96,12 @@ import { ProfileSalaryTemp } from "../entities/ProfileSalaryTemp"; import { ProfileTraining } from "../entities/ProfileTraining"; import { ProfileTrainings } from "../entities/ProfileTrainings"; import { EMPLOYEETEMP } from "../entities/EMPLOYEETEMP"; +import { HR_CHANGENAME_EMPTEMP } from "../entities/HR_CHANGENAME_EMPTEMP"; +import { HR_DISCIPLINE_EMPTEMP } from "../entities/HR_DISCIPLINE_EMPTEMP"; +import { HR_EDUCATION_EMPTEMP } from "../entities/HR_EDUCATION_EMPTEMP"; +import { HR_PERSONAL_EMPTEMP_ADDRESS } from "../entities/HR_PERSONAL_EMPTEMP_ADDRESS"; +import { HR_PERSONAL_EMPTEMP_FAMILY } from "../entities/HR_PERSONAL_EMPTEMP_FAMILY"; +import { HR_POSITION_EMPLOYEETEMP } from "../entities/HR_POSITION_EMPLOYEETEMP"; @Route("api/v1/org/upload") @Tags("UPLOAD") @Security("bearerAuth") @@ -134,12 +140,21 @@ export class ImportDataController extends Controller { private HR_PERSONAL_EMP_ADDRESSRepo = AppDataSource.getRepository(HR_PERSONAL_EMP_ADDRESS); private HR_PERSONAL_EMP_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_EMP_FAMILY); + private HR_DISCIPLINE_EMPTEMPRepo = AppDataSource.getRepository(HR_DISCIPLINE_EMPTEMP); + private HR_CHANGENAME_EMPTEMPRepo = AppDataSource.getRepository(HR_CHANGENAME_EMPTEMP); + private HR_EDUCATION_EMPTEMPRepo = AppDataSource.getRepository(HR_EDUCATION_EMPTEMP); + private HR_PERSONAL_EMPTEMP_ADDRESSRepo = AppDataSource.getRepository( + HR_PERSONAL_EMPTEMP_ADDRESS, + ); + private HR_PERSONAL_EMPTEMP_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_EMPTEMP_FAMILY); + private educationMisRepo = AppDataSource.getRepository(EducationMis); private educationLevelRepo = AppDataSource.getRepository(EducationLevel); private HR_MAJOR_CODERepo = AppDataSource.getRepository(HR_MAJOR_CODE); private HR_FUND_COURSE_CODERepo = AppDataSource.getRepository(HR_FUND_COURSE_CODE); private HR_POSITION_OFFICERRepo = AppDataSource.getRepository(HR_POSITION_OFFICER); private HR_POSITION_EMPLOYEERepo = AppDataSource.getRepository(HR_POSITION_EMPLOYEE); + private HR_POSITION_EMPLOYEETEMPRepo = AppDataSource.getRepository(HR_POSITION_EMPLOYEETEMP); private provincsRepo = AppDataSource.getRepository(ProvinceImport); private amphurRepo = AppDataSource.getRepository(AmphurImport); private subDistrictRepo = AppDataSource.getRepository(SubDistrictImport); @@ -1516,6 +1531,425 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } + /** + * @summary เงินเดือน ลูกจ้างชั่วคราว + */ + @Post("uploadProfileSalary-EmployeeTemp") + async UploadFileSQLSalaryEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let _null: any = null; + // let sqlStatements: string[] = []; + + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .leftJoinAndSelect("profile.profileSalary", "profileSalary") + .where({ employeeClass: "TEMP" }) + .where("profileSalary.id IS NULL") + .getManyAndCount(); + // var _profiles: ProfileSalary[] = []; + // const filePath = path.join(__dirname, "salaryProfile1.csv"); + // CSV Header + // let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`; + + // fs.appendFile(filePath, csvData, (err) => { + // if (err) { + // console.error("Error writing CSV file:", err); + // } else { + // console.log("Salary profiles successfully written to salaryProfile.csv"); + // } + // }); + for await (const _item of profiles) { + const existingProfile = await this.HR_POSITION_EMPLOYEETEMPRepo.find({ + where: { CIT: _item.citizenId, FLAG_PERSON_TYPE: "7" }, + }); + + // sort ด้วย JavaScript + existingProfile.sort((a, b) => { + let dateA = new Date().getTime(); + let dateB = new Date().getTime(); + + if (a.MP_POS_DATE) { + const [datePart] = a.MP_POS_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + dateA = new Date(`${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`).getTime(); + } + if (b.MP_POS_DATE) { + const [datePart] = b.MP_POS_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + dateB = new Date(`${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`).getTime(); + } + if (dateA !== dateB) { + return dateA - dateB; // ASC + } + return a.ORDER_MOVE_POSITION - b.ORDER_MOVE_POSITION; // ASC + }); + let order = 1; + for await (const item of existingProfile) { + rowCount++; + const profileSalary: any = new ProfileSalary(); + profileSalary.profileEmployeeId = _item.id; + profileSalary.order = order; + order = order + 1; + profileSalary.commandNo = isNaN(item.MP_COMMAND_NUM) ? null : item.MP_COMMAND_NUM; + profileSalary.commandYear = isNaN(item.MP_COMMAND_NUM) + ? null + : item.CUR_YEAR > 2500 + ? item.CUR_YEAR - 543 + : item.CUR_YEAR; + + let MP_COMMAND_DATE = ""; + if (item.MP_COMMAND_DATE) { + const [datePart] = item.MP_COMMAND_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + MP_COMMAND_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`; + } + let MP_POS_DATE = ""; + if (item.MP_POS_DATE) { + const [datePart] = item.MP_POS_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + MP_POS_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`; + } + profileSalary.commandDateSign = MP_COMMAND_DATE == null ? _null : new Date(MP_COMMAND_DATE); + profileSalary.commandDateAffect = MP_POS_DATE == null ? _null : new Date(MP_POS_DATE); + if ( + [ + "0", + "11", + "22", + "31", + "39", + "45", + "46", + "47", + "49", + "50", + "51", + "60", + "61", + "62", + "99", + ].includes(item.FLAG_TO_NAME_CODE) + ) { + profileSalary.commandCode = "0"; + profileSalary.commandName = "อื่น ๆ"; + } else if (["1", "58"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "1"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้"; + } else if (["23"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "2"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก"; + } else if (["3", "6", "34", "36", "37"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "3"; + profileSalary.commandName = "แต่งตั้ง ย้าย"; + } else if (["10", "55", "56"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "4"; + profileSalary.commandName = "เลื่อน"; + } else if (["14"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "5"; + profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ"; + } else if ( + ["8", "20", "24", "25", "43", "44", "52", "66", "67"].includes(item.FLAG_TO_NAME_CODE) + ) { + profileSalary.commandCode = "6"; + profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"; + } else if (["-"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "7"; + profileSalary.commandName = "เงินพิเศษอื่น ๆ"; + } else if (["38", "40", "53", "54"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "8"; + profileSalary.commandName = "ปรับโครงสร้าง"; + } else if (["12"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "9"; + profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ"; + } else if (["2", "18"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "10"; + profileSalary.commandName = "บรรจุกลับ"; + } else if (["4", "32", "33"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "11"; + profileSalary.commandName = "รับโอน"; + } else if (["5"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "12"; + profileSalary.commandName = "ให้โอน"; + } else if (["15", "95"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "13"; + profileSalary.commandName = "แก้ไขคำสั่ง"; + } else if (["19"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "14"; + profileSalary.commandName = "ยกเลิกคำสั่ง"; + } else if (["27", "35"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "15"; + profileSalary.commandName = "ลาออกจากราชการ"; + } else if (["13", "17", "21", "28", "29", "30", "59"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "16"; + profileSalary.commandName = "พ้นจากราชการ"; + } else if (["7", "9", "16", "26", "63", "68"].includes(item.FLAG_TO_NAME_CODE)) { + profileSalary.commandCode = "17"; + profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; + } + if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ลาศึกษาต่อ") { + profileSalary.commandCode = "0"; + profileSalary.commandName = "อื่น ๆ"; + } else if ( + item.FLAG_TO_NAME_CODE == null && + (item.FLAG_TO_NAME == "เลื่อน 1 ขั้นและเลื่อนระดับ" || + item.FLAG_TO_NAME == "เลื่อน 0.5 ขั้นและเลื่อนระดับ") + ) { + profileSalary.commandCode = "4"; + profileSalary.commandName = "เลื่อน"; + } else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "เลื่อนเงินเดือน") { + profileSalary.commandCode = "5"; + profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ"; + } else if ( + item.FLAG_TO_NAME_CODE == null && + (item.FLAG_TO_NAME == "ปรับตามบัญชีเงินเดือนใหม่" || + item.FLAG_TO_NAME == "เลื่อนเงินเดือน" || + item.FLAG_TO_NAME == "ปรับเงินเดือนตาม กพ.") + ) { + profileSalary.commandCode = "6"; + profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"; + } else if ( + item.FLAG_TO_NAME_CODE == null && + item.FLAG_TO_NAME == "แต่งตั้งตามการปรับปรุงโครงฯ" + ) { + profileSalary.commandCode = "8"; + profileSalary.commandName = "ปรับโครงสร้าง"; + } else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "พ้นทดลองปฏิบัติราชการ") { + profileSalary.commandCode = "9"; + profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ"; + } else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ให้โอนมา") { + profileSalary.commandCode = "11"; + profileSalary.commandName = "รับโอน"; + } else if ( + item.FLAG_TO_NAME_CODE == null && + item.FLAG_TO_NAME == "โอนไปปฏิบัติราชการที่อื่น" + ) { + profileSalary.commandCode = "12"; + profileSalary.commandName = "ให้โอน"; + } else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "ยกเลิกคำสั่ง") { + profileSalary.commandCode = "14"; + profileSalary.commandName = "ยกเลิกคำสั่ง"; + } else if (item.FLAG_TO_NAME_CODE == null && item.FLAG_TO_NAME == "รักษาการในตำแหน่ง") { + profileSalary.commandCode = "17"; + profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; + } + if ( + (profileSalary.commandCode == null || profileSalary.commandCode == undefined) && + (profileSalary.commandName == null || profileSalary.commandName == undefined) + ) { + if ( + [ + "อื่นๆ", + "กลับไปปฏิบัติงานทางต้นสังกัด", + "เปลี่ยนประเภทข้าราชการ", + "โอนสับเปลี่ยน", + "เข้ารับฝึกอบรม", + "ดูงาน", + "ศึกษาต่อ", + "ขยายเวลาเข้ารับการฝึกอบรม", + "ขยายเวลาศึกษาต่อ", + "รายงานตัวกลับเข้าปฏิบัติราชการ", + "ไม่ได้เลื่อนขั้น", + "ตัดเงินเดือน", + "ลดขั้นเงินเดือน", + "ให้ข้าราชการกลับเข้ารับราชการ", + "ไม่ระบุ", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "0"; + profileSalary.commandName = "อื่น ๆ"; + } else if ( + [ + "บรรจุและแต่งตั้งผู้สอบแข่งขันได้", + "ทดลองปฎิบัติราชการ", + "ทดลองปฏิบัติราชการและปรับวุฒิ", + "บรรจุใหม่", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "1"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้"; + } else if (["บรรจุและแต่งตั้งผู้ได้รับการคัดเลือก"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "2"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก"; + } else if ( + [ + "แต่งตั้ง (ย้ายสับเปลี่ยน)", + "แต่งตั้ง (ย้าย)", + "แต่งตั้ง", + "เปลี่ยนสายงาน", + "เปลี่ยนตำแหน่ง", + "ตัดโอนตำแหน่ง", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "3"; + profileSalary.commandName = "แต่งตั้ง ย้าย"; + } else if ( + ["เลื่อนและแต่งตั้ง", "เลื่อนระดับ", "เลื่อนเงินเดือนและระดับ"].includes( + item.FLAG_TO_NAME, + ) + ) { + profileSalary.commandCode = "4"; + profileSalary.commandName = "เลื่อน"; + } else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "5"; + profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ"; + } else if ( + [ + "ปรับเงินเดือนตามคุณวุฒิ", + "ได้รับเงินตอบแทนพิเศษ", + "เงินเพิ่มการครองชีพชั่วคราว", + "เลื่อนขั้นเงินเดือนกรณีพิเศษ", + "ปรับอัตราเงินเดือนตามบัญชีอัตราเงินเดือนใหม่ ท้าย พ.ร.บ. เงินเดือนและเงินประจำตำ", + "ปรับอัตราเงินเดือนตามพระราชกฤษฎีกา การปรับอัตราเงินเดือนของข้าราชการ", + "เลื่อนขั้นเงินเดือน (เพิ่มเติม)", + "ปรับอัตราเงินเดือน", + "ให้ข้าราชการได้รับเงินเดือนตามคุณวุฒิ", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "6"; + profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"; + } else if (["--"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "7"; + profileSalary.commandName = "เงินพิเศษอื่น ๆ"; + } else if ( + ["ปรับโครงสร้าง", "แต่งตั้ง (จัดคนลงกรอบ)", "แต่งตั้งตามแผนอัตรากำลังฯ"].includes( + item.FLAG_TO_NAME, + ) + ) { + profileSalary.commandCode = "8"; + profileSalary.commandName = "ปรับโครงสร้าง"; + } else if (["พ้นทดลองปฏิบัติราชการ"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "9"; + profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ"; + } else if ( + [ + "บรรจุกลับ", + "บรรจุกลับข้าราชการ", + "บรรจุและแต่งตั้งผู้ไปรับราชการทหารกลับเข้ารับราชการ", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "10"; + profileSalary.commandName = "บรรจุกลับ"; + } else if ( + [ + "รับโอนข้าราชการตามกฎหมายอื่น", + "รับโอนข้าราชการตามกฎหมายอื่น ผู้สอบแข่งขันได้", + "รับโอนข้าราชการตามกฏหมายอื่น โดยการคัดเลือก", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "11"; + profileSalary.commandName = "รับโอน"; + } else if (["ให้โอน"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "12"; + profileSalary.commandName = "ให้โอน"; + } else if (["แก้ไขคำสั่ง"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "13"; + profileSalary.commandName = "แก้ไขคำสั่ง"; + } else if (["ยกเลิกคำสั่ง"].includes(item.FLAG_TO_NAME)) { + profileSalary.commandCode = "14"; + profileSalary.commandName = "ยกเลิกคำสั่ง"; + } else if ( + [ + "ลาออกจากราชการ", + "พ้นจากราชการ/ลาออกจากราชการตามมาตรการพัฒนาและบริหารกำลังคน", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "15"; + profileSalary.commandName = "ลาออกจากราชการ"; + } else if ( + [ + "พ้นจากราชการ/เพื่อไปปฏิบัติราชการทหาร", + "เกษียณ", + "ไม่พ้นทดลองปฏิบัติราชการ", + "พ้นจากราชการ/ให้ออก", + "พ้นจากราชการ/ไล่ออก", + "พ้นจากราชการ/เสียชีวิต", + "พ้นจากราชการ/ปลดออก", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "16"; + profileSalary.commandName = "พ้นจากราชการ"; + } else if ( + [ + "แต่งตั้งข้าราชการรักษาราชการแทน", + "ช่วยราชการ", + "รักษาการ", + "รักษาราชการแทน", + "มอบหมายให้ปฏิบัติหน้าที่", + "มอบหมายข้าราชการปฏิบัติหน้าที่แทน", + ].includes(item.FLAG_TO_NAME) + ) { + profileSalary.commandCode = "17"; + profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; + } else { + profileSalary.commandCode = "0"; + profileSalary.commandName = item.FLAG_TO_NAME; + } + } + profileSalary.posNoAbb = item.POS_NUM_NAME; + profileSalary.posNo = item.POS_NUM_CODE; + profileSalary.positionName = item.WORK_LINE_NAME_F; + var positionType = _null; + var positionLevel = _null; + if (item.CATEGORY_SAL_CODE == "11") { + positionType = "บริการพื้นฐาน"; + } else if (item.CATEGORY_SAL_CODE == "12") { + positionType = "สนับสนุน"; + } else if (item.CATEGORY_SAL_CODE == "13") { + positionType = "ช่าง"; + } + + profileSalary.positionType = positionType; + profileSalary.positionLevel = item.LEVEL_NAME; + profileSalary.orgRoot = item.DEPARTMENT_NAME; + profileSalary.orgChild1 = item.DIVISION_NAME; + profileSalary.orgChild2 = item.SECTION_NAME; + profileSalary.orgChild3 = item.JOB_NAME; + if (item.DEPARTMENT_CODE == "50") { + profileSalary.orgRoot = item.DIVISION_NAME; + profileSalary.orgChild1 = item.SECTION_NAME; + profileSalary.orgChild2 = item.JOB_NAME; + } + // profileSalary.positionExecutive = item.ADMIN_NAME ?? _null; + profileSalary.amount = isNaN(item.SALARY) ? null : item.SALARY; + profileSalary.remark = item.REMARK; + profileSalary.refId = item.id; + profileSalary.isEntry = false; + // const sal_pos_amount_1: any = + // item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == "" + // ? _null + // : Number(item.SAL_POS_AMOUNT_1); + // const sal_pos_amount_2: any = + // item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == "" + // ? _null + // : Number(item.SAL_POS_AMOUNT_2); + // profileSalary.positionSalaryAmount = sal_pos_amount_1 ?? sal_pos_amount_2; + const special_amt: any = + item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? _null : Number(item.SPECIAL_AMT); + profileSalary.amountSpecial = special_amt; + profileSalary.posNumCodeSit = item.POS_NUM_CODE_SIT; + profileSalary.posNumCodeSitAbb = item.POS_NUM_CODE_SIT_ABB; + + profileSalary.createdUserId = request.user.sub; + profileSalary.createdFullName = request.user.name; + profileSalary.lastUpdateUserId = request.user.sub; + profileSalary.lastUpdateFullName = request.user.name; + profileSalary.createdAt = new Date().toISOString().split("T")[0]; + profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + + try { + await this.salaryRepo.save(profileSalary); + } catch (error) { + console.error("Error executing function from controller:", item.CIT); + } + } + order = 1; + } + return new HttpSuccess(); + } + /** * @summary ครอบครัว ข้าราชการ */ @@ -1772,6 +2206,135 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } + /** + * @summary ครอบครัว ลูกจ้างชั่วคราว + */ + @Post("uploadProfileFamily-EmployeeTemp") + async UploadFileSQLFamilyEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let fathers: any = []; + let mothers: any = []; + let couples: any = []; + + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .where({ employeeClass: "TEMP" }) + // .skip(0) + // .take(20) + .getManyAndCount(); + // for (var i = 1; i <= total / BATCH_SIZE; i++) { + // const profiles = await AppDataSource.getRepository(ProfileEmployee) + // .createQueryBuilder("profile") + // .select(["profile.citizenId", "profile.id"]) + // .orderBy("profile.citizenId", "ASC") + // .skip((i - 1) * BATCH_SIZE) + // .take(BATCH_SIZE) + // .getMany(); + + for await (const _item of profiles) { + const existingProfile = await this.HR_PERSONAL_EMPTEMP_FAMILYRepo.findOne({ + where: { CIT: _item.citizenId }, + select: [ + "CIT", + "FATHER_RANK_NAME", + "FATHER_FNAME", + "FATHER_LNAME", + "MOTHER_RANK_NAME", + "MOTHER_FNAME", + "MOTHER_LNAME", + "SPOUSE_RANK_NAME", + "SPOUSE_FNAME", + "SPOUSE_LNAME", + "SPOUSE_ID", + "MARRIAGE_STATE", + ], + }); + if (!existingProfile) { + continue; + } + + rowCount++; + const profileFather = new ProfileFamilyFather(); + const profileMother = new ProfileFamilyMother(); + const profileCouple = new ProfileFamilyCouple(); + + profileFather.profileEmployeeId = _item.id; + profileFather.fatherPrefix = existingProfile.FATHER_RANK_NAME ?? ""; + profileFather.fatherFirstName = existingProfile.FATHER_FNAME ?? ""; + profileFather.fatherLastName = existingProfile.FATHER_LNAME ?? ""; + profileFather.createdUserId = request.user.sub; + profileFather.createdFullName = request.user.name; + profileFather.lastUpdateUserId = request.user.sub; + profileFather.lastUpdateFullName = request.user.name; + profileFather.createdAt = new Date(); + profileFather.lastUpdatedAt = new Date(); + + profileMother.profileEmployeeId = _item.id; + profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME ?? ""; + profileMother.motherFirstName = existingProfile.MOTHER_FNAME ?? ""; + profileMother.motherLastName = existingProfile.MOTHER_LNAME ?? ""; + profileMother.createdUserId = request.user.sub; + profileMother.createdFullName = request.user.name; + profileMother.lastUpdateUserId = request.user.sub; + profileMother.lastUpdateFullName = request.user.name; + profileMother.createdAt = new Date(); + profileMother.lastUpdatedAt = new Date(); + + profileCouple.profileEmployeeId = _item.id; + profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME ?? ""; + profileCouple.coupleFirstName = existingProfile.SPOUSE_FNAME ?? ""; + profileCouple.coupleLastName = existingProfile.SPOUSE_LNAME ?? ""; + profileCouple.coupleCitizenId = existingProfile.SPOUSE_ID ?? ""; + profileCouple.relationship = + existingProfile.MARRIAGE_STATE == "1" + ? "โสด" + : existingProfile.MARRIAGE_STATE == "2" + ? "สมรส" + : existingProfile.MARRIAGE_STATE == "3" + ? "หย่าร้าง" + : existingProfile.MARRIAGE_STATE == "4" + ? "หม้าย" + : "-"; + // profileCouple.coupleLive = existingProfile.LIFE_SPOUSE; + profileCouple.createdUserId = request.user.sub; + profileCouple.createdFullName = request.user.name; + profileCouple.lastUpdateUserId = request.user.sub; + profileCouple.lastUpdateFullName = request.user.name; + profileCouple.createdAt = new Date(); + profileCouple.lastUpdatedAt = new Date(); + + // fathers.push(profileFather); + // mothers.push(profileMother); + // couples.push(profileCouple); + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + + // if (fathers.length === BATCH_SIZE) { + await this.profileFamilyFatherRepository.save(profileFather); + // fathers = await []; + // } + // if (mothers.length === BATCH_SIZE) { + await this.profileFamilyMotherRepository.save(profileMother); + // mothers = await []; + // } + // if (couples.length === BATCH_SIZE) { + await this.profileFamilyCoupleRepository.save(profileCouple); + // couples = await []; + // } + } + // } + // console.log(rowCount); + + // await Promise.all([ + // this.profileFamilyFatherRepository.save(fathers), + // this.profileFamilyMotherRepository.save(mothers), + // this.profileFamilyCoupleRepository.save(couples), + // ]); + + return new HttpSuccess(); + } + /** * @summary Import Education */ @@ -2070,6 +2633,139 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } + /** + * @summary ประวัติการศึกษา ลูกจ้างชั่วคราว + */ + @Post("uploadProfileEducation-EmployeeTemp") + async UploadFileSQLEducationEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let educations: any = []; + let _null: any = null; + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .where({ employeeClass: "TEMP" }) + // .skip(0) + // .take(20) + .getManyAndCount(); + // for (var i = 1; i <= total / BATCH_SIZE; i++) { + // const profiles = await AppDataSource.getRepository(ProfileEmployee) + // .createQueryBuilder("profile") + // .select(["profile.citizenId", "profile.id"]) + // .orderBy("profile.citizenId", "ASC") + // .skip((i - 1) * BATCH_SIZE) + // .take(BATCH_SIZE) + // .getMany(); + + for (const _item of profiles) { + const existingProfile = await this.HR_EDUCATION_EMPTEMPRepo.find({ + where: { CIT: _item.citizenId }, + // select: [ + // "CIT", + // "EDUCATION_CODE", + // "START_EDUCATION_YEAR", + // "EDUCATION_YEAR", + // "INSTITUE", + // "EDUCATION_SEQ", + // ], + order: { EDUCATION_SEQ: "ASC" }, + }); + + const educationLevel = await this.profileEducationRepo.findOne({ + select: ["id", "level", "profileEmployeeId"], + where: { profileEmployeeId: _item.id }, + order: { level: "DESC" }, + }); + + // educations = await []; + for (const item of existingProfile) { + rowCount++; + const education = new ProfileEducation(); + const educationCode = await this.educationMisRepo.findOne({ + where: { EDUCATION_CODE: item.EDUCATION_CODE }, + }); + const hrMajorCode = await this.HR_MAJOR_CODERepo.findOne({ + where: { MAJOR_CODE: item.MAJOR_CODE }, + }); + const hrFundCourseCode = await this.HR_FUND_COURSE_CODERepo.findOne({ + where: { FUND_COURSE_CODE: item.FUND_COURSE_CODE }, + }); + + // let startDate = item.START_EDUCATION_YEAR + // ? Extension.ConvertToDateTimeV2(item.START_EDUCATION_YEAR) + // : _null; + let startDate = + item.START_EDUCATION_YEAR != "" && Number(item.START_EDUCATION_YEAR) > 2500 + ? new Date(Number(item.START_EDUCATION_YEAR) - 543, 0, 1) + : _null; + + // let endDate = item.EDUCATION_YEAR + // ? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR) + // : _null; + let endDate = + item.EDUCATION_YEAR != "" && Number(item.EDUCATION_YEAR) > 2500 + ? new Date(Number(item.EDUCATION_YEAR) - 543, 0, 1) + : _null; + if (item.FLAG_EDUCATION == "1") { + const checkData = await this.HR_EDUCATIONRepo.find({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "1" }, + order: { EDUCATION_SEQ: "DESC" }, + }); + if ((checkData.length > 1 && checkData[0].id == item.id) || checkData.length == 1) { + education.isEducation = true; + const findIsHigh = await this.HR_EDUCATIONRepo.findOne({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "3" }, + }); + if (findIsHigh == null) { + education.isHigh = true; + } + } + } else if (item.FLAG_EDUCATION == "2") { + } else if (item.FLAG_EDUCATION == "3") { + const checkData = await this.HR_EDUCATIONRepo.find({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "3" }, + order: { EDUCATION_SEQ: "DESC" }, + }); + if ((checkData.length > 1 && checkData[0].id == item.id) || checkData.length == 1) { + education.isHigh = true; + const findIsEducation = await this.HR_EDUCATIONRepo.findOne({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "1" }, + }); + if (findIsEducation == null) { + education.isEducation = true; + } + } + } + education.level = educationLevel == null ? 1 : educationLevel.level + 1; + education.profileEmployeeId = _item.id; + education.degree = educationCode ? educationCode.EDUCATION_NAME : _null; + education.field = hrMajorCode ? hrMajorCode.MAJOR_NAME : _null; + education.educationLevel = hrFundCourseCode ? hrFundCourseCode.FUND_COURSE_NAME : _null; + education.educationLevelId = hrFundCourseCode ? hrFundCourseCode.refId : _null; + education.institute = item.INSTITUE; + education.level = item.EDUCATION_SEQ ? Number(item.EDUCATION_SEQ) : _null; + education.startDate = startDate; + education.endDate = endDate; + education.createdUserId = request.user.sub; + education.createdFullName = request.user.name; + education.lastUpdateUserId = request.user.sub; + education.lastUpdateFullName = request.user.name; + education.createdAt = new Date(); + education.lastUpdatedAt = new Date(); + // await educations.push(await education); + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + await this.profileEducationRepo.save(await education); + } + // await this.profileEducationRepo.save(educations); + // educations = await []; + } + // } + // console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + // await this.profileEducationRepo.save(educations); + return new HttpSuccess(); + } + /** * @summary Import Province */ @@ -2584,6 +3280,214 @@ export class ImportDataController extends Controller { } return new HttpSuccess(); } + + /** + * @summary ที่อยู่ตามทะเบียนบ้าน-ปัจจุบัน ลูกจ้างชั่วคราว + */ + @Post("uploadProfileAddress-EmployeeTemp") + async UploadFileSQLAddressEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let profileDatas: any = []; + let _null: any = null; + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .where({ employeeClass: "TEMP" }) + // .where("profile.citizenId = '3610700119735'") + // .skip(0) + // .take(20) + .getManyAndCount(); + const meta = { + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }; + for (const _item of profiles) { + const existingProfile = await this.HR_PERSONAL_EMPTEMP_ADDRESSRepo.findOne({ + where: { CIT: _item.citizenId }, + }); + + if (!existingProfile) { + continue; + } + let PROVINCE_CODE = Number(existingProfile.PROVINCE_CODE).toString(); + let DISTRICT_CODE = Number(existingProfile.DISTRICT_CODE).toString(); + let AMPHUR_CODE = Number(existingProfile.AMPHUR_CODE).toString(); + let CONTACT_PROVINCE_CODE = Number(existingProfile.CONTACT_PROVINCE_CODE).toString(); + let CONTACT_DISTRICT_CODE = Number(existingProfile.CONTACT_DISTRICT_CODE).toString(); + let CONTACT_AMPHUR_CODE = Number(existingProfile.CONTACT_AMPHUR_CODE).toString(); + rowCount++; + //registration address + if (PROVINCE_CODE) { + let provinceRegis_ = await this.provincsRepo.findOne({ + where: { PROVINCE_CODE: PROVINCE_CODE }, + }); + if (provinceRegis_) { + let provinceId = await this.provinceIdRepo.findOne({ + where: { + name: provinceRegis_.PROVINCE_NAME, + }, + }); + if (provinceId == null) { + provinceId = new Province(); + Object.assign(provinceId, { + ...meta, + name: provinceRegis_.PROVINCE_NAME, + }); + await this.provinceIdRepo.save(provinceId); + } + _item.registrationProvinceId = provinceId ? provinceId.id : _null; + if (AMPHUR_CODE) { + let districtRegis_ = await this.amphurRepo.findOne({ + where: { + AMPHUR_CODE: AMPHUR_CODE, + PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, + }, + }); + if (districtRegis_) { + let districtId = await this.districtIdRepo.findOne({ + where: { + name: districtRegis_.AMPHUR_NAME, + provinceId: provinceId.id, + }, + }); + if (districtId == null) { + districtId = new District(); + Object.assign(districtId, { + ...meta, + name: districtRegis_.AMPHUR_NAME, + provinceId: provinceId.id, + }); + await this.districtIdRepo.save(districtId); + } + _item.registrationDistrictId = districtId ? districtId.id : _null; + if (DISTRICT_CODE) { + let subDistrictRegis_ = await this.subDistrictRepo.findOne({ + where: { + DISTRICT_CODE: DISTRICT_CODE, + AMPHUR_CODE: districtRegis_.AMPHUR_CODE, + PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, + }, + }); + if (subDistrictRegis_) { + let subDistrictId = await this.subDistrictIdRepo.findOne({ + where: { + name: subDistrictRegis_.DISTRICT_NAME, + districtId: districtId.id, + }, + }); + if (subDistrictId == null) { + subDistrictId = new SubDistrict(); + Object.assign(subDistrictId, { + ...meta, + name: subDistrictRegis_.DISTRICT_NAME, + zipCode: existingProfile.ZIPCODE, + districtId: districtId.id, + }); + await this.subDistrictIdRepo.save(subDistrictId); + } + _item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : _null; + } + } + } + } + } + } + //current address + if (CONTACT_PROVINCE_CODE) { + let provinceCurr_ = await this.provincsRepo.findOne({ + where: { PROVINCE_CODE: CONTACT_PROVINCE_CODE }, + }); + if (provinceCurr_) { + let provinceId = await this.provinceIdRepo.findOne({ + where: { + name: provinceCurr_.PROVINCE_NAME, + }, + }); + if (provinceId == null) { + provinceId = new Province(); + Object.assign(provinceId, { + ...meta, + name: provinceCurr_.PROVINCE_NAME, + }); + await this.provinceIdRepo.save(provinceId); + } + _item.currentProvinceId = provinceId ? provinceId.id : _null; + if (CONTACT_AMPHUR_CODE) { + let districtCurr_ = await this.amphurRepo.findOne({ + where: { + AMPHUR_CODE: CONTACT_AMPHUR_CODE, + PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, + }, + }); + if (districtCurr_) { + let districtId = await this.districtIdRepo.findOne({ + where: { + name: districtCurr_.AMPHUR_NAME, + provinceId: provinceId.id, + }, + }); + if (districtId == null) { + districtId = new District(); + Object.assign(districtId, { + ...meta, + name: districtCurr_.AMPHUR_NAME, + provinceId: provinceId.id, + }); + await this.districtIdRepo.save(districtId); + } + _item.currentDistrictId = districtId ? districtId.id : _null; + if (CONTACT_DISTRICT_CODE) { + let subDistrictCurr_ = await this.subDistrictRepo.findOne({ + where: { + DISTRICT_CODE: CONTACT_DISTRICT_CODE, + AMPHUR_CODE: districtCurr_.AMPHUR_CODE, + PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, + }, + }); + if (subDistrictCurr_) { + let subDistrictId = await this.subDistrictIdRepo.findOne({ + where: { + name: subDistrictCurr_.DISTRICT_NAME, + districtId: districtId.id, + }, + }); + if (subDistrictId == null) { + subDistrictId = new SubDistrict(); + Object.assign(subDistrictId, { + ...meta, + name: subDistrictCurr_.DISTRICT_NAME, + zipCode: existingProfile.CONTACT_ZIPCODE, + districtId: districtId.id, + }); + await this.subDistrictIdRepo.save(subDistrictId); + } + _item.currentSubDistrictId = subDistrictId ? subDistrictId.id : _null; + } + } + } + } + } + } + _item.registrationAddress = existingProfile.H_NUMBER; + _item.registrationZipCode = existingProfile.ZIPCODE; + _item.currentAddress = existingProfile.CONTACT_H_NUMBER; + _item.currentZipCode = existingProfile.CONTACT_ZIPCODE; + _item.createdUserId = request.user.sub; + _item.createdFullName = request.user.name; + _item.lastUpdateUserId = request.user.sub; + _item.lastUpdateFullName = request.user.name; + _item.createdAt = new Date(); + _item.lastUpdatedAt = new Date(); + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + await this.profileEmpRepo.save(_item); + } + return new HttpSuccess(); + } /** * @summary ทะเบียนประวัติ ข้าราชการ */ @@ -3991,6 +4895,51 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } + /** + * @summary วินัย ลูกจ้างชั่วคราว + */ + @Post("uploadProfileDiscipline-EmployeeTemp") + async UploadFileSQLDisciplineEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let _null: any = null; + + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .where({ employeeClass: "TEMP" }) + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .getManyAndCount(); + + for (const _item of profiles) { + const existingProfile = await this.HR_DISCIPLINE_EMPTEMPRepo.find({ + where: { CIT: _item.citizenId }, + }); + + for (const item of existingProfile) { + let CREATE_DATE = ""; + if (item.CREATE_DATE) { + const [datePart] = item.CREATE_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + CREATE_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`; + } + rowCount++; + const discipline = new ProfileDiscipline(); + discipline.profileEmployeeId = _item.id; + discipline.detail = item.REASON_FLAW; + discipline.date = CREATE_DATE == "" ? _null : new Date(CREATE_DATE); + discipline.createdUserId = request.user.sub; + discipline.createdFullName = request.user.name; + discipline.lastUpdateUserId = request.user.sub; + discipline.lastUpdateFullName = request.user.name; + discipline.createdAt = new Date(); + discipline.lastUpdatedAt = new Date(); + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + await this.profileDisciplineRepo.save(await discipline); + } + } + return new HttpSuccess(); + } + /** * @summary เครื่องราช ข้าราชการ */ @@ -4217,6 +5166,53 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } + /** + * @summary เปลี่ยนชื่อ ลูกจ้างชั่วคราว + */ + @Post("uploadProfileChangeName-EmployeeTemp") + async UploadFileSQLChangeNameEmpTemp(@Request() request: { user: Record }) { + let rowCount = 0; + let _null: any = null; + + const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee) + .createQueryBuilder("profile") + .where({ employeeClass: "TEMP" }) + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .getManyAndCount(); + + for (const _item of profiles) { + const existingProfile = await this.HR_CHANGENAME_EMPTEMPRepo.find({ + where: { CIT: _item.citizenId }, + // order: { SEQ: "ASC" }, + }); + + for (const item of existingProfile) { + let EFFECT_DATE = ""; + if (item.EFFECT_DATE) { + const [datePart] = item.EFFECT_DATE.split(" "); + const [day, month, year] = datePart.split("/"); + EFFECT_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`; + } + rowCount++; + const changeName = new ProfileChangeName(); + changeName.profileEmployeeId = _item.id; + changeName.prefix = item.NEW_RANK_NAME == "" ? item.LAST_RANK_NAME : item.NEW_RANK_NAME; + changeName.firstName = item.NEW_FNAME == "" ? item.LAST_FNAME : item.NEW_FNAME; + changeName.lastName = item.NEW_LNAME == "" ? item.LAST_LNAME : item.NEW_LNAME; + changeName.createdUserId = request.user.sub; + changeName.createdFullName = request.user.name; + changeName.lastUpdateUserId = request.user.sub; + changeName.lastUpdateFullName = request.user.name; + changeName.createdAt = EFFECT_DATE == "" ? new Date() : new Date(EFFECT_DATE); + changeName.lastUpdatedAt = EFFECT_DATE == "" ? new Date() : new Date(EFFECT_DATE); + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + await this.profileChangeNameRepo.save(await changeName); + } + } + return new HttpSuccess(); + } + /** * @summary บุตร ข้าราชการ */ diff --git a/src/entities/HR_CHANGENAME_EMPTEMP.ts b/src/entities/HR_CHANGENAME_EMPTEMP.ts new file mode 100644 index 00000000..c59e48b7 --- /dev/null +++ b/src/entities/HR_CHANGENAME_EMPTEMP.ts @@ -0,0 +1,62 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_CHANGENAME_EMPTEMP") +export class HR_CHANGENAME_EMPTEMP { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + NEW_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + NEW_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + NEW_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + LAST_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + LAST_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + LAST_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EFFECT_DATE: string; +} diff --git a/src/entities/HR_DISCIPLINE_EMPTEMP.ts b/src/entities/HR_DISCIPLINE_EMPTEMP.ts new file mode 100644 index 00000000..4484ae3d --- /dev/null +++ b/src/entities/HR_DISCIPLINE_EMPTEMP.ts @@ -0,0 +1,27 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_DISCIPLINE_EMPTEMP") +export class HR_DISCIPLINE_EMPTEMP { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + REASON_FLAW: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CREATE_DATE: string; +} diff --git a/src/entities/HR_EDUCATION_EMPTEMP.ts b/src/entities/HR_EDUCATION_EMPTEMP.ts new file mode 100644 index 00000000..660e6736 --- /dev/null +++ b/src/entities/HR_EDUCATION_EMPTEMP.ts @@ -0,0 +1,76 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_EDUCATION_EMPTEMP") +export class HR_EDUCATION_EMPTEMP { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + START_EDUCATION_YEAR: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_YEAR: string; + + // @Column({ + // nullable: true, + // type: "text", + // default: null, + // }) + // EDUCATION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + INSTITUE: string; + + @Column({ + nullable: true, + length: 255, + default: null, + }) + EDUCATION_SEQ: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FUND_COURSE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MAJOR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_EDUCATION: string; +} diff --git a/src/entities/HR_PERSONAL_EMPTEMP_ADDRESS.ts b/src/entities/HR_PERSONAL_EMPTEMP_ADDRESS.ts new file mode 100644 index 00000000..5f335600 --- /dev/null +++ b/src/entities/HR_PERSONAL_EMPTEMP_ADDRESS.ts @@ -0,0 +1,83 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_PERSONAL_EMPTEMP_ADDRESS") +export class HR_PERSONAL_EMPTEMP_ADDRESS { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + ZIPCODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_ZIPCODE: string; +} diff --git a/src/entities/HR_PERSONAL_EMPTEMP_FAMILY.ts b/src/entities/HR_PERSONAL_EMPTEMP_FAMILY.ts new file mode 100644 index 00000000..7abf64db --- /dev/null +++ b/src/entities/HR_PERSONAL_EMPTEMP_FAMILY.ts @@ -0,0 +1,90 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_PERSONAL_EMPTEMP_FAMILY") +export class HR_PERSONAL_EMPTEMP_FAMILY { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_ID: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MARRIAGE_STATE: string; +} diff --git a/src/entities/HR_POSITION_EMPLOYEETEMP.ts b/src/entities/HR_POSITION_EMPLOYEETEMP.ts new file mode 100644 index 00000000..170db661 --- /dev/null +++ b/src/entities/HR_POSITION_EMPLOYEETEMP.ts @@ -0,0 +1,205 @@ +import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_POSITION_EMPLOYEETEMP") +export class HR_POSITION_EMPLOYEETEMP { + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_PERSON_TYPE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + ORDER_MOVE_POSITION: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + POS_NUM_CODE_SIT: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + POS_NUM_CODE_SIT_ABB: string; + + @Column({ + nullable: true, + default: null, + }) + MP_COMMAND_NUM: number; + + @Column({ + nullable: true, + default: null, + }) + CUR_YEAR: number; + + @Column({ + nullable: true, + default: null, + }) + MP_COMMAND_DATE: string; + + @Column({ + nullable: true, + default: null, + }) + MP_POS_DATE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_TO_NAME_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_TO_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + POS_NUM_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + POS_NUM_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + WORK_LINE_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + LEVEL_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + WORK_LINE_NAME_F: string; + + // @Column({ + // nullable: true, + // type: "text", + // default: null, + // }) + // MP_CEE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + JOB_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SECTION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DIVISION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DEPARTMENT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DEPARTMENT_NAME: string; + + // @Column({ + // nullable: true, + // type: "text", + // default: null, + // }) + // ADMIN_NAME: string; + + @Column({ + nullable: true, + default: null, + }) + SALARY: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + REMARK: string; + + // @Column({ + // nullable: true, + // type: "text", + // default: null, + // }) + // SAL_POS_AMOUNT_1: string; + + // @Column({ + // nullable: true, + // type: "text", + // default: null, + // }) + // SAL_POS_AMOUNT_2: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPECIAL_AMT: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CATEGORY_SAL_CODE: string; +}