Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2025-03-04 10:53:20 +07:00
commit dd33feef99
15 changed files with 1742 additions and 597 deletions

View file

@ -1,4 +1,4 @@
version: 37
version: 38
jobs:
- name: CI for UAT
steps:
@ -40,7 +40,7 @@ jobs:
name: build docker image
dockerfile: ./docker/Dockerfile
output: !RegistryOutput
tags: hrms-git.chin.in.th/bma-hrms/hrms-api-org:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-org:latest
tags: '@server@/bma-hrms/hrms-api-org:@build_version@ @server@/bma-hrms/hrms-api-org:latest'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !TagCreateTrigger
@ -90,7 +90,7 @@ jobs:
name: build docker image
dockerfile: ./docker/Dockerfile
output: !RegistryOutput
tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-org:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-org:latest
tags: '@server@/bma-hrms/hrms-api-org:@build_version@ @server@/bma-hrms/hrms-api-org:latest'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !TagCreateTrigger

View file

@ -47,6 +47,10 @@ import { OFFICER } from "../entities/OFFICER";
import { Position } from "../entities/Position";
import { PosMaster } from "../entities/PosMaster";
import { positionOfficer } from "../entities/positionOfficer";
import { PosExecutive } from "../entities/PosExecutive";
import { EducationLevel } from "../entities/EducationLevel";
import { HR_FUND_COURSE_CODE } from "../entities/HR_FUND_COURSE_CODE";
import { HR_MAJOR_CODE } from "../entities/HR_MAJOR_CODE";
// import { uuidv7 } from "uuidv7";
// import { ProfileSalaries } from "../entities/ProfileSalaries";
@Route("api/v1/org/upload")
@ -74,6 +78,9 @@ export class ImportDataController extends Controller {
private HR_PERSONAL_EMP_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_EMP_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 provincsRepo = AppDataSource.getRepository(ProvinceImport);
private amphurRepo = AppDataSource.getRepository(AmphurImport);
private subDistrictRepo = AppDataSource.getRepository(SubDistrictImport);
@ -91,6 +98,7 @@ export class ImportDataController extends Controller {
private OFFICERRepo = AppDataSource.getRepository(OFFICER);
private positionRepo = AppDataSource.getRepository(Position);
private posMasterRepo = AppDataSource.getRepository(PosMaster);
private posExecutiveRepo = AppDataSource.getRepository(PosExecutive);
/**
* @summary
*/
@ -199,7 +207,7 @@ export class ImportDataController extends Controller {
// where: { posTypeName: item.MP_Type },
// });
// profile.posTypeId = type?.id ?? null_;
profile.amount = item.SALARY == "" ? 0 : Number(Extension.CheckRelationship(item.SALARY));
profile.amount = item.SALARY == "" ? 0 : Number(item.SALARY);
// profile.isLeave =
// item.FLAG_RETIRE_STATUSxxxx == "" || item.FLAG_RETIRE_STATUSxxxx == null ? false : true;
profile.createdUserId = request.user.sub;
@ -409,7 +417,6 @@ export class ImportDataController extends Controller {
"49",
"50",
"51",
"56",
"60",
"61",
"62",
@ -427,7 +434,7 @@ export class ImportDataController extends Controller {
} else if (["3", "6", "34", "36", "37"].includes(item.flag_to_name_code)) {
profileSalary.commandCode = "3";
profileSalary.commandName = "แต่งตั้ง ย้าย";
} else if (["10", "55"].includes(item.flag_to_name_code)) {
} 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)) {
@ -474,14 +481,16 @@ export class ImportDataController extends Controller {
profileSalary.commandCode = "17";
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
}
if (
item.flag_to_name_code == null &&
(item.flag_to_name == "เลื่อน 1 ขั้นและเลื่อนระดับ" ||
item.flag_to_name == "เลื่อน 0.5 ขั้นและเลื่อนระดับ" ||
item.flag_to_name == "ลาศึกษาต่อ")
) {
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 = "เลื่อนเงินเดือนตามปกติ";
@ -538,8 +547,6 @@ export class ImportDataController extends Controller {
"ขยายเวลาศึกษาต่อ",
"รายงานตัวกลับเข้าปฏิบัติราชการ",
"ไม่ได้เลื่อนขั้น",
"เลือนเงินเดือนและระดับ",
"เลื่อนเงินเดือนและระดับ",
"ตัดเงินเดือน",
"ลดขั้นเงินเดือน",
"ให้ข้าราชการกลับเข้ารับราชการ",
@ -573,7 +580,11 @@ export class ImportDataController extends Controller {
) {
profileSalary.commandCode = "3";
profileSalary.commandName = "แต่งตั้ง ย้าย";
} else if (["เลื่อนและแต่งตั้ง", "เลื่อนระดับ"].includes(item.flag_to_name)) {
} else if (
["เลื่อนและแต่งตั้ง", "เลื่อนระดับ", "เลื่อนเงินเดือนและระดับ"].includes(
item.flag_to_name,
)
) {
profileSalary.commandCode = "4";
profileSalary.commandName = "เลื่อน";
} else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.flag_to_name)) {
@ -1228,67 +1239,72 @@ export class ImportDataController extends Controller {
// .take(5)
// .getMany();
await Promise.all(
profiles.map(async (_item) => {
const existingProfile = await this.HR_EDUCATIONRepo.find({
where: { CIT: _item.citizenId },
select: [
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"INSTITUE",
"EDUCATION_SEQ",
],
for (const _item of profiles) {
const existingProfile = await this.HR_EDUCATIONRepo.find({
where: { CIT: _item.citizenId },
select: [
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"INSTITUE",
"EDUCATION_SEQ",
],
});
const educationLevel = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileId: _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 },
});
const educationLevel = await this.profileEducationRepo.findOne({
select: ["id", "level", "profileId"],
where: { profileId: _item.id },
order: { level: "DESC" },
});
let startDate = item.START_EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.START_EDUCATION_YEAR)
: null_;
// startDate = startDate ? new Date(startDate, 0, 1) : null_;
// educations = await [];
await Promise.all(
existingProfile.map(async (item) => {
rowCount++;
const education = new ProfileEducation();
const educationCode = await this.educationMisRepo.findOne({
where: { EDUCATION_CODE: item.EDUCATION_CODE },
});
let endDate = item.EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR)
: null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_;
let startDate = item.START_EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.START_EDUCATION_YEAR)
: null_;
// startDate = startDate ? new Date(startDate, 0, 1) : null_;
let endDate = item.EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR)
: null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_;
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE;
education.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ);
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 [];
}),
);
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileId = _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 ? null_ : Number(item.EDUCATION_SEQ);
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);
@ -1876,11 +1892,50 @@ export class ImportDataController extends Controller {
orgChild3: "",
},
});
let order = 1;
for (const item of IMPORT_CHILD) {
const orgRoot = new OrgRoot();
orgRoot.orgRootOrder = order;
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
order++;
}
//order xxxxxxxxxxxxxxxx
await Promise.all(
IMPORT_CHILD.map(async (item) => {
const orgRoot = new OrgRoot();
//create child1
const IMPORT_CHILD1 = await this.IMPORT_ORGRepo.find({
where: {
orgRoot: Not(""),
orgChild1: Not(""),
orgChild2: "",
orgChild3: "",
},
});
for (const item of IMPORT_CHILD1) {
const orgChild1 = new OrgChild1();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
relations: ["orgChild1s"],
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootOrder = order;
order = order + 1;
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
@ -1898,46 +1953,171 @@ export class ImportDataController extends Controller {
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}),
);
}
//create child1
const IMPORT_CHILD1 = await this.IMPORT_ORGRepo.find({
orgChild1.orgChild1Order =
orgRoot == null || orgRoot.orgChild1s == null || orgRoot.orgChild1s.length == 0
? 1
: orgRoot.orgChild1s.length + 1;
orgChild1.orgRootId = orgRoot.id;
orgChild1.orgChild1Name = item.orgChild1;
orgChild1.orgChild1ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild1.orgChild1Rank = rank;
orgChild1.orgChild1RankSub = item.orgSubRank;
orgChild1.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild1.DIVISION_CODE = item.DIVISION_CODE;
orgChild1.SECTION_CODE = item.SECTION_CODE;
orgChild1.JOB_CODE = item.JOB_CODE;
orgChild1.orgRevisionId = orgRevision.id;
orgChild1.createdUserId = request.user.sub;
orgChild1.createdFullName = request.user.name;
orgChild1.lastUpdateUserId = request.user.sub;
orgChild1.lastUpdateFullName = request.user.name;
orgChild1.createdAt = new Date();
orgChild1.lastUpdatedAt = new Date();
await this.orgChild1Repo.save(orgChild1);
}
//create child2
const IMPORT_CHILD2 = await this.IMPORT_ORGRepo.find({
where: {
orgRoot: Not(""),
orgChild1: Not(""),
orgChild2: "",
orgChild2: Not(""),
orgChild3: "",
},
});
for (const item of IMPORT_CHILD2) {
const orgChild2 = new OrgChild2();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
relations: ["orgChild1s"],
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootOrder = order;
order = order + 1;
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}
let orgChild1 = await this.orgChild1Repo.findOne({
where: { orgChild1Name: item.orgChild1 },
relations: ["orgChild2s"],
});
if (orgChild1 == null) {
orgChild1 = new OrgChild1();
orgChild1.orgRootId = orgRoot.id;
orgChild1.orgChild1Order =
orgRoot == null || orgRoot.orgChild1s == null || orgRoot.orgChild1s.length == 0
? 1
: orgRoot.orgChild1s.length + 1;
orgChild1.orgChild1Name = item.orgChild1;
orgChild1.orgChild1ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild1.orgChild1Rank = rank;
orgChild1.orgChild1RankSub = item.orgSubRank;
orgChild1.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild1.DIVISION_CODE = item.DIVISION_CODE;
orgChild1.SECTION_CODE = item.SECTION_CODE;
orgChild1.JOB_CODE = item.JOB_CODE;
orgChild1.orgRevisionId = orgRevision.id;
orgChild1.createdUserId = request.user.sub;
orgChild1.createdFullName = request.user.name;
orgChild1.lastUpdateUserId = request.user.sub;
orgChild1.lastUpdateFullName = request.user.name;
orgChild1.createdAt = new Date();
orgChild1.lastUpdatedAt = new Date();
await this.orgChild1Repo.save(orgChild1);
}
orgChild2.orgChild2Order =
orgChild1 == null || orgChild1.orgChild2s == null || orgChild1.orgChild2s.length == 0
? 1
: orgChild1.orgChild2s.length + 1;
orgChild2.orgRootId = orgRoot.id;
orgChild2.orgChild1Id = orgChild1.id;
orgChild2.orgChild2Name = item.orgChild2;
orgChild2.orgChild2ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild2.orgChild2Rank = rank;
orgChild2.orgChild2RankSub = item.orgSubRank;
orgChild2.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild2.DIVISION_CODE = item.DIVISION_CODE;
orgChild2.SECTION_CODE = item.SECTION_CODE;
orgChild2.JOB_CODE = item.JOB_CODE;
orgChild2.orgRevisionId = orgRevision.id;
orgChild2.createdUserId = request.user.sub;
orgChild2.createdFullName = request.user.name;
orgChild2.lastUpdateUserId = request.user.sub;
orgChild2.lastUpdateFullName = request.user.name;
orgChild2.createdAt = new Date();
orgChild2.lastUpdatedAt = new Date();
await this.orgChild2Repo.save(orgChild2);
}
await Promise.all(
IMPORT_CHILD1.map(async (item) => {
const orgChild1 = new OrgChild1();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}
//create child3
const IMPORT_CHILD3 = await this.IMPORT_ORGRepo.find({
where: {
orgRoot: Not(""),
orgChild1: Not(""),
orgChild2: Not(""),
orgChild3: Not(""),
},
});
for (const item of IMPORT_CHILD3) {
const orgChild3 = new OrgChild3();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
relations: ["orgChild1s"],
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootOrder = order;
order = order + 1;
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}
let orgChild1 = await this.orgChild1Repo.findOne({
where: { orgChild1Name: item.orgChild1 },
relations: ["orgChild2s"],
});
if (orgChild1 == null) {
orgChild1 = new OrgChild1();
orgChild1.orgChild1Order =
orgRoot == null || orgRoot.orgChild1s == null || orgRoot.orgChild1s.length == 0
? 1
: orgRoot.orgChild1s.length + 1;
orgChild1.orgRootId = orgRoot.id;
orgChild1.orgChild1Name = item.orgChild1;
orgChild1.orgChild1ShortName = item.orgShortname;
@ -1956,68 +2136,17 @@ export class ImportDataController extends Controller {
orgChild1.createdAt = new Date();
orgChild1.lastUpdatedAt = new Date();
await this.orgChild1Repo.save(orgChild1);
}),
);
//create child2
const IMPORT_CHILD2 = await this.IMPORT_ORGRepo.find({
where: {
orgRoot: Not(""),
orgChild1: Not(""),
orgChild2: Not(""),
orgChild3: "",
},
});
await Promise.all(
IMPORT_CHILD2.map(async (item) => {
const orgChild2 = new OrgChild2();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}
let orgChild1 = await this.orgChild1Repo.findOne({
where: { orgChild1Name: item.orgChild1 },
});
if (orgChild1 == null) {
orgChild1 = new OrgChild1();
orgChild1.orgRootId = orgRoot.id;
orgChild1.orgChild1Name = item.orgChild1;
orgChild1.orgChild1ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild1.orgChild1Rank = rank;
orgChild1.orgChild1RankSub = item.orgSubRank;
orgChild1.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild1.DIVISION_CODE = item.DIVISION_CODE;
orgChild1.SECTION_CODE = item.SECTION_CODE;
orgChild1.JOB_CODE = item.JOB_CODE;
orgChild1.orgRevisionId = orgRevision.id;
orgChild1.createdUserId = request.user.sub;
orgChild1.createdFullName = request.user.name;
orgChild1.lastUpdateUserId = request.user.sub;
orgChild1.lastUpdateFullName = request.user.name;
orgChild1.createdAt = new Date();
orgChild1.lastUpdatedAt = new Date();
await this.orgChild1Repo.save(orgChild1);
}
}
let orgChild2 = await this.orgChild2Repo.findOne({
where: { orgChild2Name: item.orgChild2 },
relations: ["orgChild3s"],
});
if (orgChild2 == null) {
orgChild2 = new OrgChild2();
orgChild2.orgChild2Order =
orgChild1 == null || orgChild1.orgChild2s == null || orgChild1.orgChild2s.length == 0
? 1
: orgChild1.orgChild2s.length + 1;
orgChild2.orgRootId = orgRoot.id;
orgChild2.orgChild1Id = orgChild1.id;
orgChild2.orgChild2Name = item.orgChild2;
@ -2037,117 +2166,32 @@ export class ImportDataController extends Controller {
orgChild2.createdAt = new Date();
orgChild2.lastUpdatedAt = new Date();
await this.orgChild2Repo.save(orgChild2);
}),
);
//create child3
const IMPORT_CHILD3 = await this.IMPORT_ORGRepo.find({
where: {
orgRoot: Not(""),
orgChild1: Not(""),
orgChild2: Not(""),
orgChild3: Not(""),
},
});
await Promise.all(
IMPORT_CHILD3.map(async (item) => {
const orgChild3 = new OrgChild3();
let orgRoot = await this.orgRootRepo.findOne({
where: { orgRootName: item.orgRoot },
});
if (orgRoot == null) {
orgRoot = new OrgRoot();
orgRoot.orgRootName = item.orgRoot;
orgRoot.orgRootShortName = item.orgShortname;
const rank: any = item.orgRank;
orgRoot.orgRootRank = rank;
orgRoot.orgRootRankSub = item.orgSubRank;
orgRoot.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgRoot.DIVISION_CODE = item.DIVISION_CODE;
orgRoot.SECTION_CODE = item.SECTION_CODE;
orgRoot.JOB_CODE = item.JOB_CODE;
orgRoot.orgRevisionId = orgRevision.id;
orgRoot.createdUserId = request.user.sub;
orgRoot.createdFullName = request.user.name;
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.createdAt = new Date();
orgRoot.lastUpdatedAt = new Date();
await this.orgRootRepo.save(orgRoot);
}
let orgChild1 = await this.orgChild1Repo.findOne({
where: { orgChild1Name: item.orgChild1 },
});
if (orgChild1 == null) {
orgChild1 = new OrgChild1();
orgChild1.orgRootId = orgRoot.id;
orgChild1.orgChild1Name = item.orgChild1;
orgChild1.orgChild1ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild1.orgChild1Rank = rank;
orgChild1.orgChild1RankSub = item.orgSubRank;
orgChild1.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild1.DIVISION_CODE = item.DIVISION_CODE;
orgChild1.SECTION_CODE = item.SECTION_CODE;
orgChild1.JOB_CODE = item.JOB_CODE;
orgChild1.orgRevisionId = orgRevision.id;
orgChild1.createdUserId = request.user.sub;
orgChild1.createdFullName = request.user.name;
orgChild1.lastUpdateUserId = request.user.sub;
orgChild1.lastUpdateFullName = request.user.name;
orgChild1.createdAt = new Date();
orgChild1.lastUpdatedAt = new Date();
await this.orgChild1Repo.save(orgChild1);
}
let orgChild2 = await this.orgChild2Repo.findOne({
where: { orgChild2Name: item.orgChild2 },
});
if (orgChild2 == null) {
orgChild2 = new OrgChild2();
orgChild2.orgRootId = orgRoot.id;
orgChild2.orgChild1Id = orgChild1.id;
orgChild2.orgChild2Name = item.orgChild2;
orgChild2.orgChild2ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild2.orgChild2Rank = rank;
orgChild2.orgChild2RankSub = item.orgSubRank;
orgChild2.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild2.DIVISION_CODE = item.DIVISION_CODE;
orgChild2.SECTION_CODE = item.SECTION_CODE;
orgChild2.JOB_CODE = item.JOB_CODE;
orgChild2.orgRevisionId = orgRevision.id;
orgChild2.createdUserId = request.user.sub;
orgChild2.createdFullName = request.user.name;
orgChild2.lastUpdateUserId = request.user.sub;
orgChild2.lastUpdateFullName = request.user.name;
orgChild2.createdAt = new Date();
orgChild2.lastUpdatedAt = new Date();
await this.orgChild2Repo.save(orgChild2);
}
orgChild3.orgRootId = orgRoot.id;
orgChild3.orgChild1Id = orgChild1.id;
orgChild3.orgChild2Id = orgChild2.id;
orgChild3.orgChild3Name = item.orgChild3;
orgChild3.orgChild3ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild3.orgChild3Rank = rank;
orgChild3.orgChild3RankSub = item.orgSubRank;
orgChild3.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild3.DIVISION_CODE = item.DIVISION_CODE;
orgChild3.SECTION_CODE = item.SECTION_CODE;
orgChild3.JOB_CODE = item.JOB_CODE;
orgChild3.orgRevisionId = orgRevision.id;
orgChild3.createdUserId = request.user.sub;
orgChild3.createdFullName = request.user.name;
orgChild3.lastUpdateUserId = request.user.sub;
orgChild3.lastUpdateFullName = request.user.name;
orgChild3.createdAt = new Date();
orgChild3.lastUpdatedAt = new Date();
await this.orgChild3Repo.save(orgChild3);
}),
);
}
orgChild3.orgChild3Order =
orgChild2 == null || orgChild2.orgChild3s == null || orgChild2.orgChild3s.length == 0
? 1
: orgChild2.orgChild3s.length + 1;
orgChild3.orgRootId = orgRoot.id;
orgChild3.orgChild1Id = orgChild1.id;
orgChild3.orgChild2Id = orgChild2.id;
orgChild3.orgChild3Name = item.orgChild3;
orgChild3.orgChild3ShortName = item.orgShortname;
const rank: any = item.orgRank;
orgChild3.orgChild3Rank = rank;
orgChild3.orgChild3RankSub = item.orgSubRank;
orgChild3.DEPARTMENT_CODE = item.DEPARTMENT_CODE;
orgChild3.DIVISION_CODE = item.DIVISION_CODE;
orgChild3.SECTION_CODE = item.SECTION_CODE;
orgChild3.JOB_CODE = item.JOB_CODE;
orgChild3.orgRevisionId = orgRevision.id;
orgChild3.createdUserId = request.user.sub;
orgChild3.createdFullName = request.user.name;
orgChild3.lastUpdateUserId = request.user.sub;
orgChild3.lastUpdateFullName = request.user.name;
orgChild3.createdAt = new Date();
orgChild3.lastUpdatedAt = new Date();
await this.orgChild3Repo.save(orgChild3);
}
return new HttpSuccess();
}
/**
@ -2172,7 +2216,7 @@ export class ImportDataController extends Controller {
rowCount++;
const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item.id.toString() },
where: { citizenId: item.CIT },
});
if (existingProfile == null) {
continue;
@ -2268,6 +2312,31 @@ export class ImportDataController extends Controller {
position.lastUpdateFullName = request.user.name;
position.createdAt = new Date();
position.lastUpdatedAt = new Date();
const posExecutive = await this.posExecutiveRepo.findOne({
where: {
posExecutiveName: item.ADMIN_NAME,
},
});
if (posExecutive == null && item.ADMIN_NAME != "" && item.ADMIN_NAME != null) {
const posExecutiveOrder = await this.posExecutiveRepo.findOne({
where: { posExecutivePriority: Not(IsNull()) },
order: { posExecutivePriority: "DESC" },
});
let posExecutive = new PosExecutive();
posExecutive.posExecutivePriority =
posExecutiveOrder == null ? null_ : posExecutiveOrder.posExecutivePriority + 1;
posExecutive.posExecutiveName = item.ADMIN_NAME;
posExecutive.createdUserId = request.user.sub;
posExecutive.createdFullName = request.user.name;
posExecutive.lastUpdateUserId = request.user.sub;
posExecutive.lastUpdateFullName = request.user.name;
posExecutive.createdAt = new Date();
posExecutive.lastUpdatedAt = new Date();
await this.posExecutiveRepo.save(posExecutive);
}
position.posExecutiveId = posExecutive == null ? null_ : posExecutive.id;
position.positionName = item.WORK_LINE_NAME == "" ? null_ : item.WORK_LINE_NAME;
position.posTypeId =
type_ != null && type_.posTypeName == item.MP_CATEGORY && type_ ? type_.id : null;

View file

@ -82,53 +82,51 @@ export class ProfileSalaryController extends Controller {
@Get("tenure/{profileId}")
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
const position = await AppDataSource.query(
"CALL GetProfileSalaryPosition(?)",
[profileId]
const sql_mode = await AppDataSource.query(
"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));",
);
const _position = position.length > 0 ? position[0] : []
const mapPosition = _position.length > 1
? _position
.slice(1)
.map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName
}))
: [];
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [profileId]);
const _position = position.length > 0 ? position[0] : [];
const mapPosition =
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName,
}))
: [];
const posLevel = [{
year: 1,
month: 0,
day: 0,
name: "ต้น",
}];
const posExecutive = await AppDataSource.query(
"CALL GetProfileSalaryExecutive(?)",
[profileId]
);
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : []
const mapPosExecutive = _posExecutive.length > 1
? _posExecutive
.slice(1)
.map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _posExecutive[index]?.positionName
}))
: [];
const posLevel: any = [
// {
// year: 1,
// month: 0,
// day: 0,
// name: "ต้น",
// }
];
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?)", [
profileId,
]);
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
const mapPosExecutive =
_posExecutive.length > 1
? _posExecutive.slice(1).map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _posExecutive[index]?.positionExecutive,
}))
: [];
return new HttpSuccess({
position: mapPosition,
posLevel: posLevel,
posExecutive: mapPosExecutive
posLevel: posLevel,
posExecutive: mapPosExecutive,
});
}
@Get("admin/{profileId}")
public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER");

View file

@ -89,32 +89,31 @@ export class ProfileSalaryEmployeeController extends Controller {
@Get("tenure/{profileId}")
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
const position = await AppDataSource.query(
"CALL GetProfileEmployeeSalaryPosition(?)",
[profileId]
);
const _position = position.length > 0 ? position[0] : []
const mapPosition = _position.length > 1
? _position
.slice(1)
.map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName
}))
: [];
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
profileId,
]);
const _position = position.length > 0 ? position[0] : [];
const mapPosition =
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName,
}))
: [];
const posLevel = [{
year: 3,
month: 0,
day: 0,
name: "ส 1",
}];
const posLevel: any = [
// {
// year: 3,
// month: 0,
// day: 0,
// name: "ส 1",
// }
];
return new HttpSuccess({
position: mapPosition,
posLevel: posLevel
posLevel: posLevel,
});
}

View file

@ -196,11 +196,11 @@ export class ReportController extends Controller {
@Query() sort: "ASC" | "DESC" = "ASC",
) {
const _null: any = null;
if(!dateStart) {
dateStart = _null
if (!dateStart) {
dateStart = _null;
}
if(!dateEnd) {
dateEnd = _null
if (!dateEnd) {
dateEnd = _null;
}
if (ageMin && (ageMin < 18 || ageMin > 60)) {
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
@ -247,18 +247,17 @@ export class ReportController extends Controller {
}
let retireLawCondition = "1=1";
if(isRetireLaw) {
if (isRetireLaw) {
retireLawCondition =
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
}
let tenureTypeCondition = "1=1";
if(tenureType != "" && tenureType == "position") {
if (tenureType != "" && tenureType == "position") {
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax";
} else if (tenureType != "" && tenureType == "level") {
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax"; //xxxxxxxxxxxx
}
else if (tenureType != "" && tenureType == "level") {
tenureTypeCondition = "registryOfficer.posxecutiveYears BETWEEN :tenureMin AND :tenureMax";
}
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
.createQueryBuilder("registryOfficer")
@ -278,36 +277,36 @@ export class ReportController extends Controller {
endDateAppoint: dateEnd?.toISOString().split("T")[0],
})
.andWhere(retireLawCondition, {
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)
?.toISOString()
.split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999)
.toISOString()
.split("T")[0],
})
.andWhere("registryOfficer.isProbation = :isProbation", {
isProbation: isProbation,
})
.andWhere(IsLeavecondition.join(" AND "), parameters)
.andWhere(
posType != null && posType != ""
? "registryOfficer.posTypeName LIKE :posTypeName"
: "1=1",
posType != null && posType != "" ? "registryOfficer.posTypeName LIKE :posTypeName" : "1=1",
{
posTypeName: `%${posType}%`,
}
},
)
.andWhere(
posLevel != null && posLevel != ""
? "registryOfficer.posLevelName LIKE :posLevelName"
posLevel != null && posLevel != ""
? "registryOfficer.posLevelName LIKE :posLevelName"
: "1=1",
{
posLevelName: `%${posLevel}%`,
}
},
)
.andWhere(
position != null && position != ""
? "registryOfficer.position LIKE :position"
: "1=1",
position != null && position != "" ? "registryOfficer.position LIKE :position" : "1=1",
{
position: `%${position}%`,
}
},
)
.andWhere(
positionExecutive != null && positionExecutive != ""
@ -315,31 +314,22 @@ export class ReportController extends Controller {
: "1=1",
{
posExecutiveName: `%${positionExecutive}%`,
}
},
)
.andWhere(gender != null && gender != "" ? "registryOfficer.gender LIKE :gender" : "1=1", {
gender: `%${gender}%`,
})
.andWhere(
gender != null && gender != ""
? "registryOfficer.gender LIKE :gender"
: "1=1",
{
gender: `%${gender}%`,
}
)
.andWhere(
status != null && status != ""
? "registryOfficer.relationship LIKE :relationship"
: "1=1",
status != null && status != "" ? "registryOfficer.relationship LIKE :relationship" : "1=1",
{
relationship: `%${status}%`,
}
},
)
.andWhere(
education != null && education != ""
? "registryOfficer.degree LIKE :degree"
: "1=1",
education != null && education != "" ? "registryOfficer.degree LIKE :degree" : "1=1",
{
degree: `%${education}%`,
}
},
)
.orderBy(`registryOfficer.${sortBy}`, sort)
.getManyAndCount();
@ -381,12 +371,24 @@ export class ReportController extends Controller {
age: x.age,
currentPosition: null,
lengthPosition: null,
Years: x.Years,
Months: x.Months,
Days: x.Days,
// posExecutiveYears: x.posExecutiveYears,
// posExecutiveMonths: x.posExecutiveMonths,
// posExecutiveDays: x.posExecutiveDays
positionDate: {
Years: x.Years,
Months: x.Months,
Days: x.Days,
},
posExcutiveDate: {
Years: x.posExecutiveYears,
Months: x.posExecutiveMonths,
Days: x.posExecutiveDays,
},
posLevelDate: {
// Years: x.levelYears,
// Months: x.levelMonths,
// Days: x.levelDays,
Years: 0,
Months: 0,
Days: 0,
},
}));
return new HttpSuccess({
data: mapData,
@ -536,11 +538,11 @@ export class ReportController extends Controller {
@Query() sort: "ASC" | "DESC" = "ASC",
) {
const _null: any = null;
if(!dateStart) {
dateStart = _null
if (!dateStart) {
dateStart = _null;
}
if(!dateEnd) {
dateEnd = _null
if (!dateEnd) {
dateEnd = _null;
}
if (ageMin && (ageMin < 18 || ageMin > 60)) {
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
@ -587,9 +589,9 @@ export class ReportController extends Controller {
}
let retireLawCondition = "1=1";
if(isRetireLaw) {
if (isRetireLaw) {
retireLawCondition =
"DATE(registryEmployee.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryEmployee.dateRetireLaw) <= :endDateRetireLaw";
"DATE(registryEmployee.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryEmployee.dateRetireLaw) <= :endDateRetireLaw";
}
const [lists, total] = await AppDataSource.getRepository(viewRegistryEmployee)
@ -606,8 +608,12 @@ export class ReportController extends Controller {
endDateAppoint: dateEnd?.toISOString().split("T")[0],
})
.andWhere(retireLawCondition, {
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)
?.toISOString()
.split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999)
.toISOString()
.split("T")[0],
})
.andWhere("registryEmployee.isProbation = :isProbation", {
isProbation: isProbation,
@ -615,52 +621,39 @@ export class ReportController extends Controller {
.andWhere(IsLeavecondition.join(" AND "), parameters)
.andWhere("registryEmployee.employeeClass = 'PERM'")
.andWhere(
posType != null && posType != ""
? "registryEmployee.posTypeName LIKE :posTypeName"
: "1=1",
posType != null && posType != "" ? "registryEmployee.posTypeName LIKE :posTypeName" : "1=1",
{
posTypeName: `%${posType}%`,
}
},
)
.andWhere(
posLevel != null && posLevel != ""
? "registryEmployee.posLevelName LIKE :posLevelName"
posLevel != null && posLevel != ""
? "registryEmployee.posLevelName LIKE :posLevelName"
: "1=1",
{
posLevelName: `%${posLevel}%`,
}
},
)
.andWhere(
position != null && position != ""
? "registryEmployee.position LIKE :position"
: "1=1",
position != null && position != "" ? "registryEmployee.position LIKE :position" : "1=1",
{
position: `%${position}%`,
}
},
)
.andWhere(gender != null && gender != "" ? "registryEmployee.gender LIKE :gender" : "1=1", {
gender: `%${gender}%`,
})
.andWhere(
gender != null && gender != ""
? "registryEmployee.gender LIKE :gender"
: "1=1",
{
gender: `%${gender}%`,
}
)
.andWhere(
status != null && status != ""
? "registryEmployee.relationship LIKE :relationship"
: "1=1",
status != null && status != "" ? "registryEmployee.relationship LIKE :relationship" : "1=1",
{
relationship: `%${status}%`,
}
},
)
.andWhere(
education != null && education != ""
? "registryEmployee.degree LIKE :degree"
: "1=1",
education != null && education != "" ? "registryEmployee.degree LIKE :degree" : "1=1",
{
degree: `%${education}%`,
}
},
)
.orderBy(`registryEmployee.${sortBy}`, sort)
.getManyAndCount();

View file

@ -52,4 +52,18 @@ export class HR_EDUCATION {
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;
}

View file

@ -0,0 +1,35 @@
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
@Entity("HR_FUND_COURSE_CODE")
export class HR_FUND_COURSE_CODE {
@PrimaryGeneratedColumn()
id!: number;
@Column({
nullable: true,
type: "text",
default: null,
})
FUND_COURSE_CODE: string;
@Column({
nullable: true,
type: "text",
default: null,
})
FUND_COURSE_NAME: string;
@Column({
nullable: true,
type: "text",
default: null,
})
LEVEL_SEQ: string;
@Column({
nullable: true,
type: "text",
default: null,
})
refId: string;
}

View file

@ -0,0 +1,28 @@
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
@Entity("HR_MAJOR_CODE")
export class HR_MAJOR_CODE {
@PrimaryGeneratedColumn()
id!: number;
@Column({
nullable: true,
type: "text",
default: null,
})
MAJOR_CODE: string;
@Column({
nullable: true,
type: "text",
default: null,
})
MAJOR_NAME: string;
@Column({
nullable: true,
type: "text",
default: null,
})
MAJOR_ABB_NAME: string;
}

View file

@ -19,6 +19,13 @@ export class OFFICER {
// })
// ID: string;
@Column({
nullable: true,
type: "text",
default: null,
})
CIT: string;
@Column({
nullable: true,
type: "text",
@ -130,4 +137,11 @@ export class OFFICER {
default: null,
})
POS_NUM_NAME: string;
@Column({
nullable: true,
type: "text",
default: null,
})
ADMIN_NAME: string;
}

View file

@ -0,0 +1,65 @@
import { Entity, Column, Double } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("ProfileSalaries")
export class ProfileSalaries extends EntityBase {
@Column({
nullable: true,
default: null,
})
Order: number;
@Column({
nullable: true,
default: null,
})
Date: Date;
@Column({
nullable: true,
default: null,
})
SalaryRef: string;
@Column({
nullable: true,
type: "double",
})
Amount: Double;
@Column({
nullable: true,
type: "double",
})
PositionSalaryAmount: Double;
@Column({
nullable: true,
default: null,
})
PosNoName: string;
@Column({
nullable: true,
default: null,
})
PositionTypeName: string;
@Column({
nullable: true,
default: null,
})
PositionLevelName: string;
@Column({
nullable: true,
default: null,
})
PositionName: string;
@Column({
nullable: true,
default: null,
})
ProfileId: string;
}

View file

@ -2,23 +2,83 @@ import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `
WITH resultData AS (
SELECT
commandDateAffect,
positionName,
positionCee,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) AS days_diff,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 365.2524 AS 'Years',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) % 30.4375 AS 'Days',
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
orgChild1,
orgChild2,
orgChild3,
orgChild4,
commandCode,
commandName,
commandNo,
commandYear,
remark,
profileEmployeeId,
ROW_NUMBER() OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect ASC) AS orderNumber
FROM (
SELECT
commandDateAffect,
commandDateSign,
positionName,
positionCee,
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
orgChild1,
orgChild2,
orgChild3,
orgChild4,
commandCode,
commandName,
commandNo,
commandYear,
remark,
profileEmployeeId,
@group := IF(@prevPosition = positionName, @group, @group + 1) AS groupedId,
@prevPosition := positionName
FROM
profileSalary,
(SELECT @group := 0, @prevPosition := NULL) AS vars
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
ORDER BY
commandDateAffect ASC, commandDateSign ASC
) AS groupedPosition
GROUP BY
profileEmployeeId, groupedId, positionName
)
SELECT
DATE(MIN(commandDateAffect)) AS commandDateAffect,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',
commandDateAffect,
positionName,
positionCee,
days_diff,
Years,
Months,
Days,
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
@ -32,26 +92,21 @@ import { ViewColumn, ViewEntity } from "typeorm";
commandYear,
remark,
profileEmployeeId,
ROW_NUMBER() OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect ASC) AS orderNumber
FROM
profileSalary
WHERE
profileEmployeeId IS NOT NULL AND
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
GROUP BY
profileEmployeeId, positionName
orderNumber
FROM resultData
UNION ALL
SELECT
CURDATE() AS commandDateAffect,
NULL AS positionName,
NULL AS positionCee,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
NULL AS positionName,
NULL AS positionCee,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
NULL AS posNo,
NULL AS positionExecutive,
NULL AS positionType,
NULL AS positionLevel,
NULL AS OrgRoot,
@ -63,89 +118,79 @@ import { ViewColumn, ViewEntity } from "typeorm";
NULL AS commandName,
NULL AS commandNo,
NULL AS commandYear,
'Comparison with current date' AS remark,
NULL AS remark,
profileEmployeeId,
NULL AS orderNumber
FROM
profileSalary
WHERE
profileEmployeeId IS NOT NULL AND
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
GROUP BY
profileEmployeeId
ORDER BY
profileEmployeeId,
commandDateAffect ASC
FROM resultData
`,
})
export class viewCurrentTenureEmployee {
@ViewColumn()
commandDateAffect: Date;
@ViewColumn()
commandDateAffect: Date;
@ViewColumn()
days_diff: number;
@ViewColumn()
days_diff: number;
@ViewColumn()
Years: number;
@ViewColumn()
Years: number;
@ViewColumn()
Months: number;
@ViewColumn()
Months: number;
@ViewColumn()
Days: number;
@ViewColumn()
Days: number;
@ViewColumn()
positionName: string;
@ViewColumn()
positionName: string;
@ViewColumn()
positionCee: string;
@ViewColumn()
positionCee: string;
@ViewColumn()
posNo: string;
@ViewColumn()
posNo: string;
@ViewColumn()
positionExecutive: string;
@ViewColumn()
positionExecutive: string;
@ViewColumn()
positionType: string;
@ViewColumn()
positionType: string;
@ViewColumn()
positionLevel: string;
@ViewColumn()
positionLevel: string;
@ViewColumn()
OrgRoot: string;
@ViewColumn()
OrgRoot: string;
@ViewColumn()
orgChild1: string;
@ViewColumn()
orgChild1: string;
@ViewColumn()
orgChild2: string;
@ViewColumn()
orgChild2: string;
@ViewColumn()
orgChild3: string;
@ViewColumn()
orgChild3: string;
@ViewColumn()
orgChild4: string;
@ViewColumn()
orgChild4: string;
@ViewColumn()
commandCode: number;
@ViewColumn()
commandCode: number;
@ViewColumn()
commandName: string;
@ViewColumn()
commandName: string;
@ViewColumn()
commandNo: string;
@ViewColumn()
commandNo: string;
@ViewColumn()
commandYear: number;
@ViewColumn()
commandYear: number;
@ViewColumn()
remark: string;
@ViewColumn()
remark: string;
@ViewColumn()
profileEmployeeId: string;
@ViewColumn()
profileEmployeeId: string;
@ViewColumn()
orderNumber: number;
}
@ViewColumn()
orderNumber: number;
}

View file

@ -0,0 +1,155 @@
import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `
SELECT
DATE(MIN(commandDateAffect)) AS commandDateAffect,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',
positionName,
positionCee,
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
orgChild1,
orgChild2,
orgChild3,
orgChild4,
commandCode,
commandName,
commandNo,
commandYear,
remark,
profileId,
ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber
FROM
profileSalary
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) AND
positionExecutive <> '' AND
positionExecutive is not null
GROUP BY
profileId, positionExecutive
UNION ALL
SELECT
CURDATE() AS commandDateAffect,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
NULL AS positionName,
NULL AS positionCee,
NULL AS posNo,
NULL AS positionExecutive,
NULL AS positionType,
NULL AS positionLevel,
NULL AS OrgRoot,
NULL AS orgChild1,
NULL AS orgChild2,
NULL AS orgChild3,
NULL AS orgChild4,
NULL AS commandCode,
NULL AS commandName,
NULL AS commandNo,
NULL AS commandYear,
'Comparison with current date' AS remark,
profileId,
NULL AS orderNumber
FROM
profileSalary
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) AND
positionExecutive <> '' AND
positionExecutive is not null
GROUP BY
profileId
ORDER BY
profileId,
commandDateAffect ASC
`,
})
export class viewCurrentTenureExcOfficer {
@ViewColumn()
commandDateAffect: Date;
@ViewColumn()
days_diff: number;
@ViewColumn()
Years: number;
@ViewColumn()
Months: number;
@ViewColumn()
Days: number;
@ViewColumn()
positionName: string;
@ViewColumn()
positionCee: string;
@ViewColumn()
posNo: string;
@ViewColumn()
positionExecutive: string;
@ViewColumn()
positionType: string;
@ViewColumn()
positionLevel: string;
@ViewColumn()
OrgRoot: string;
@ViewColumn()
orgChild1: string;
@ViewColumn()
orgChild2: string;
@ViewColumn()
orgChild3: string;
@ViewColumn()
orgChild4: string;
@ViewColumn()
commandCode: number;
@ViewColumn()
commandName: string;
@ViewColumn()
commandNo: string;
@ViewColumn()
commandYear: number;
@ViewColumn()
remark: string;
@ViewColumn()
profileId: string;
@ViewColumn()
orderNumber: number;
}

View file

@ -2,22 +2,81 @@ import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `
WITH resultData AS (
SELECT
commandDateAffect,
positionName,
positionCee,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) AS days_diff,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 365.2524 AS 'Years',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) % 30.4375 AS 'Days',
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
orgChild1,
orgChild2,
orgChild3,
orgChild4,
commandCode,
commandName,
commandNo,
commandYear,
remark,
profileId,
ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber
FROM (
SELECT
commandDateAffect,
commandDateSign,
positionName,
positionCee,
posNo,
positionExecutive,
positionType,
positionLevel,
OrgRoot,
orgChild1,
orgChild2,
orgChild3,
orgChild4,
commandCode,
commandName,
commandNo,
commandYear,
remark,
profileId,
@group := IF(@prevPosition = positionName, @group, @group + 1) AS groupedId,
@prevPosition := positionName
FROM
profileSalary,
(SELECT @group := 0, @prevPosition := NULL) AS vars
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
ORDER BY
commandDateAffect ASC, commandDateSign ASC
) AS groupedPosition
GROUP BY
profileId, groupedId, positionName
)
SELECT
DATE(MIN(commandDateAffect)) AS commandDateAffect,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff,
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(
DAY,
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',
commandDateAffect,
positionName,
positionCee,
days_diff,
Years,
Months,
Days,
posNo,
positionExecutive,
positionType,
@ -33,24 +92,19 @@ import { ViewColumn, ViewEntity } from "typeorm";
commandYear,
remark,
profileId,
ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber
FROM
profileSalary
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
GROUP BY
profileId, positionName
orderNumber
FROM resultData
UNION ALL
SELECT
CURDATE() AS commandDateAffect,
NULL AS positionName,
NULL AS positionCee,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
NULL AS positionName,
NULL AS positionCee,
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
NULL AS posNo,
NULL AS positionExecutive,
NULL AS positionType,
@ -64,88 +118,79 @@ import { ViewColumn, ViewEntity } from "typeorm";
NULL AS commandName,
NULL AS commandNo,
NULL AS commandYear,
'Comparison with current date' AS remark,
NULL AS remark,
profileId,
NULL AS orderNumber
FROM
profileSalary
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
GROUP BY
profileId
ORDER BY
profileId,
commandDateAffect ASC
FROM resultData
`,
})
export class viewCurrentTenureOfficer {
@ViewColumn()
commandDateAffect: Date;
@ViewColumn()
commandDateAffect: Date;
@ViewColumn()
days_diff: number;
@ViewColumn()
days_diff: number;
@ViewColumn()
Years: number;
@ViewColumn()
Years: number;
@ViewColumn()
Months: number;
@ViewColumn()
Months: number;
@ViewColumn()
Days: number;
@ViewColumn()
Days: number;
@ViewColumn()
positionName: string;
@ViewColumn()
positionName: string;
@ViewColumn()
positionCee: string;
@ViewColumn()
positionCee: string;
@ViewColumn()
posNo: string;
@ViewColumn()
posNo: string;
@ViewColumn()
positionExecutive: string;
@ViewColumn()
positionExecutive: string;
@ViewColumn()
positionType: string;
@ViewColumn()
positionType: string;
@ViewColumn()
positionLevel: string;
@ViewColumn()
positionLevel: string;
@ViewColumn()
OrgRoot: string;
@ViewColumn()
OrgRoot: string;
@ViewColumn()
orgChild1: string;
@ViewColumn()
orgChild1: string;
@ViewColumn()
orgChild2: string;
@ViewColumn()
orgChild2: string;
@ViewColumn()
orgChild3: string;
@ViewColumn()
orgChild3: string;
@ViewColumn()
orgChild4: string;
@ViewColumn()
orgChild4: string;
@ViewColumn()
commandCode: number;
@ViewColumn()
commandCode: number;
@ViewColumn()
commandName: string;
@ViewColumn()
commandName: string;
@ViewColumn()
commandNo: string;
@ViewColumn()
commandNo: string;
@ViewColumn()
commandYear: number;
@ViewColumn()
commandYear: number;
@ViewColumn()
remark: string;
@ViewColumn()
remark: string;
@ViewColumn()
profileId: string;
@ViewColumn()
profileId: string;
@ViewColumn()
orderNumber: number;
@ViewColumn()
orderNumber: number;
}

View file

@ -55,6 +55,26 @@ import { ViewColumn, ViewEntity } from "typeorm";
FROM profileEducation ed
WHERE ed.isUse IS TRUE
ORDER BY ed.level ASC
),
PositionDate AS (
SELECT
vcto.Years,
vcto.Months,
vcto.Days,
vcto.profileId,
ROW_NUMBER() OVER (PARTITION BY vcto.profileId) AS vcto_number
FROM view_current_tenure_officer vcto
WHERE vcto.orderNumber Is Null
),
PositionExcDate AS (
SELECT
vctoExc.Years,
vctoExc.Months,
vctoExc.Days,
vctoExc.profileId,
ROW_NUMBER() OVER (PARTITION BY vctoExc.profileId) AS vctoExc_number
FROM view_current_tenure_exc_officer vctoExc
WHERE vctoExc.orderNumber Is Null
)
SELECT
p.id as profileId,
@ -100,14 +120,17 @@ import { ViewColumn, ViewEntity } from "typeorm";
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
vcto.Years,
vcto.Months,
vcto.Days
vcto.Days,
vctoExc.Years AS posExecutiveYears,
vctoExc.Months AS posExecutiveMonths,
vctoExc.Days AS posExecutiveDays
FROM profile p
LEFT JOIN posLevel ON p.posLevelId = posLevel.id
LEFT JOIN posType ON p.posTypeId = posType.id
LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1
LEFT JOIN Education ed ON p.id = ed.profileId AND ed.ed_number = 1
Inner Join view_current_tenure_officer vcto On p.id = vcto.profileId
Where vcto.orderNumber Is Null
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId AND vcto.vcto_number = 1
LEFT JOIN PositionExcDate vctoExc ON p.id = vctoExc.profileId AND vctoExc.vctoExc_number = 1
`,
})
export class viewRegistryOfficer {
@ -222,13 +245,12 @@ export class viewRegistryOfficer {
@ViewColumn()
Days: number;
// @ViewColumn()
// posExecutiveYears: number;
@ViewColumn()
posExecutiveYears: number;
// @ViewColumn()
// posExecutiveMonths: number;
// @ViewColumn()
// posExecutiveDays: number;
@ViewColumn()
posExecutiveMonths: number;
@ViewColumn()
posExecutiveDays: number;
}

File diff suppressed because one or more lines are too long