add วันที่มีผลคำสั่ง

This commit is contained in:
mamoss 2025-05-09 12:39:07 +07:00
parent a61825eb57
commit dbdf136d97

View file

@ -27,9 +27,7 @@ import { Insignia } from "../entities/Insignia";
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
import { PosMaster } from "../entities/PosMaster";
import { EmployeePosDict } from "../entities/EmployeePosDict";
import {
calculateRetireLaw
} from "../interfaces/utils";
import { calculateRetireLaw } from "../interfaces/utils";
import Extension from "../interfaces/extension";
@Route("api/v1/org/dotnet")
@Tags("Dotnet")
@ -2012,31 +2010,36 @@ export class OrganizationDotnetController extends Controller {
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4Id ?? null,
rootDnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.ancestorDNA ?? null,
child1DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild1?.ancestorDNA ?? null,
child2DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild2?.ancestorDNA ?? null,
child3DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild3?.ancestorDNA ?? null,
child4DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.ancestorDNA ?? null,
rootDnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.ancestorDNA ?? null,
child1DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild1?.ancestorDNA ?? null,
child2DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild2?.ancestorDNA ?? null,
child3DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild3?.ancestorDNA ?? null,
child4DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.ancestorDNA ?? null,
commander: fullname,
posLevel: profile.posLevel?.posLevelName ?? null,
posType: profile.posType?.posTypeName ?? null,
@ -2304,31 +2307,36 @@ export class OrganizationDotnetController extends Controller {
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4Id ?? null,
rootDnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.ancestorDNA ?? null,
child1DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild1?.ancestorDNA ?? null,
child2DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild2?.ancestorDNA ?? null,
child3DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild3?.ancestorDNA ?? null,
child4DnaId: profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.ancestorDNA ?? null,
rootDnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.ancestorDNA ?? null,
child1DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild1?.ancestorDNA ?? null,
child2DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild2?.ancestorDNA ?? null,
child3DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild3?.ancestorDNA ?? null,
child4DnaId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.ancestorDNA ?? null,
commander: fullname,
posLevel: profile.posLevel?.posLevelName ?? null,
posType: profile.posType?.posTypeName ?? null,
@ -2819,7 +2827,9 @@ export class OrganizationDotnetController extends Controller {
// dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel?.posLevelName ?? "",
posType: profile.posType?.posTypeName ?? "",
profileSalary: profile.profileSalary,
profileSalary: profile.profileSalary.map((x) => {
return { ...x, date: x.commandDateAffect ?? new Date() };
}),
profileInsignia: profile.profileInsignias.map((x) => {
return { ...x, insignia: x.insignia.name };
}),
@ -4210,13 +4220,13 @@ export class OrganizationDotnetController extends Controller {
"currentDistrict",
"currentSubDistrict",
],
where: {
where: {
keycloak: keycloakId,
},
order: {
profileEducations: {
level: "ASC"
}
level: "ASC",
},
},
});
@ -4237,13 +4247,13 @@ export class OrganizationDotnetController extends Controller {
"currentDistrict",
"currentSubDistrict",
],
where: {
where: {
keycloak: keycloakId,
},
order: {
profileEducations: {
level: "ASC"
}
level: "ASC",
},
},
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -4267,33 +4277,42 @@ export class OrganizationDotnetController extends Controller {
oc = `${_profileCurrent.orgChild4?.orgChild4Name}`;
}
}
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [profile.id]);
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
profile.id,
]);
const _position = position.length > 0 ? position[0] : [];
const mapEmpProfile = {
birthDate: profile.birthDate ?? "-",
retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : "-",
govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "-",
govAge: profile.dateAppoint
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
: "-",
age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "-",
dateAppoint: profile.dateAppoint,
dateCurrent: new Date(),
amount: profile.amount ?? "-",
telephoneNumber: profile.telephoneNumber ?? "-",
positionName: profile.position ?? "-",
posLevel: profile.posType && profile.posLevel
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
: "-",
posLevel:
profile.posType && profile.posLevel
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
: "-",
posType: profile.posType?.posTypeName ?? "-",
currentAddress: profile && profile.currentAddress
? profile.currentAddress +
(profile.currentSubDistrict && profile.currentSubDistrict.name
? " ตำบล/แขวง " + profile.currentSubDistrict.name : "") +
(profile.currentDistrict && profile.currentDistrict.name
? " อำเภอ/เขต " + profile.currentDistrict.name : "") +
(profile.currentProvince && profile.currentProvince.name
? " จังหวัด " + profile.currentProvince.name : "") +
profile.currentZipCode
: "-",
currentAddress:
profile && profile.currentAddress
? profile.currentAddress +
(profile.currentSubDistrict && profile.currentSubDistrict.name
? " ตำบล/แขวง " + profile.currentSubDistrict.name
: "") +
(profile.currentDistrict && profile.currentDistrict.name
? " อำเภอ/เขต " + profile.currentDistrict.name
: "") +
(profile.currentProvince && profile.currentProvince.name
? " จังหวัด " + profile.currentProvince.name
: "") +
profile.currentZipCode
: "-",
oc: oc ?? "-",
root:
profile?.current_holders?.find(
@ -4325,37 +4344,36 @@ export class OrganizationDotnetController extends Controller {
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.orgChild4Name ?? null,
positions: _position && _position.length > 0
? _position
.slice(0, -1)
.map((x:any, idx: number) => ({
positionName: x.positionName,
dateStart: x.commandDateAffect ?? null,
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
positionType: x.positionType,
positionLevel: x.positionLevel,
orgRoot: x.orgRoot,
orgChild1: x.orgChild1,
orgChild2: x.orgChild2,
orgChild3: x.orgChild3,
orgChild4: x.orgChild4,
}))
: [],
educations: profile.profileEducations && profile.profileEducations.length > 0
? profile.profileEducations.map(x => ({
educationLevel: x.educationLevel,
institute: x.institute ?? "-",
country: x.country ?? "-",
finishDate: x.finishDate,
}))
: []
positions:
_position && _position.length > 0
? _position.slice(0, -1).map((x: any, idx: number) => ({
positionName: x.positionName,
dateStart: x.commandDateAffect ?? null,
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
positionType: x.positionType,
positionLevel: x.positionLevel,
orgRoot: x.orgRoot,
orgChild1: x.orgChild1,
orgChild2: x.orgChild2,
orgChild3: x.orgChild3,
orgChild4: x.orgChild4,
}))
: [],
educations:
profile.profileEducations && profile.profileEducations.length > 0
? profile.profileEducations.map((x) => ({
educationLevel: x.educationLevel,
institute: x.institute ?? "-",
country: x.country ?? "-",
finishDate: x.finishDate,
}))
: [],
};
return new HttpSuccess(mapEmpProfile);
}
const _profileCurrent = profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft === false &&
x.orgRevision?.orgRevisionIsCurrent === true,
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
);
let oc = "";
if (_profileCurrent != null) {
@ -4377,7 +4395,9 @@ export class OrganizationDotnetController extends Controller {
const mapProfile = {
birthDate: profile.birthDate ?? "-",
retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : "-",
govAge: profile.dateAppoint ? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี` : "-",
govAge: profile.dateAppoint
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
: "-",
age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0) : "-",
dateAppoint: profile.dateAppoint,
dateCurrent: new Date(),
@ -4386,16 +4406,20 @@ export class OrganizationDotnetController extends Controller {
positionName: profile.position ?? "-",
posLevel: profile.posLevel?.posLevelName ?? "-",
posType: profile.posType?.posTypeName ?? "-",
currentAddress: profile && profile.currentAddress
? profile.currentAddress +
(profile.currentSubDistrict && profile.currentSubDistrict.name
? " ตำบล/แขวง " + profile.currentSubDistrict.name : "") +
(profile.currentDistrict && profile.currentDistrict.name
? " อำเภอ/เขต " + profile.currentDistrict.name : "") +
(profile.currentProvince && profile.currentProvince.name
? " จังหวัด " + profile.currentProvince.name : "") +
profile.currentZipCode
: "-",
currentAddress:
profile && profile.currentAddress
? profile.currentAddress +
(profile.currentSubDistrict && profile.currentSubDistrict.name
? " ตำบล/แขวง " + profile.currentSubDistrict.name
: "") +
(profile.currentDistrict && profile.currentDistrict.name
? " อำเภอ/เขต " + profile.currentDistrict.name
: "") +
(profile.currentProvince && profile.currentProvince.name
? " จังหวัด " + profile.currentProvince.name
: "") +
profile.currentZipCode
: "-",
oc: oc ?? "-",
root:
profile?.current_holders?.find(
@ -4427,30 +4451,30 @@ export class OrganizationDotnetController extends Controller {
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgChild4?.orgChild4Name ?? null,
positions: _position && _position.length > 0
? _position
.slice(0, -1)
.map((x:any, idx: number) => ({
positionName: x.positionName,
dateStart: x.commandDateAffect ?? null,
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
positionType: x.positionType,
positionLevel: x.positionLevel,
orgRoot: x.orgRoot,
orgChild1: x.orgChild1,
orgChild2: x.orgChild2,
orgChild3: x.orgChild3,
orgChild4: x.orgChild4,
}))
: [],
educations: profile.profileEducations && profile.profileEducations.length > 0
? profile.profileEducations.map(x => ({
educationLevel: x.educationLevel,
institute: x.institute ?? "-",
country: x.country ?? "-",
finishDate: x.finishDate,
}))
: []
positions:
_position && _position.length > 0
? _position.slice(0, -1).map((x: any, idx: number) => ({
positionName: x.positionName,
dateStart: x.commandDateAffect ?? null,
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
positionType: x.positionType,
positionLevel: x.positionLevel,
orgRoot: x.orgRoot,
orgChild1: x.orgChild1,
orgChild2: x.orgChild2,
orgChild3: x.orgChild3,
orgChild4: x.orgChild4,
}))
: [],
educations:
profile.profileEducations && profile.profileEducations.length > 0
? profile.profileEducations.map((x) => ({
educationLevel: x.educationLevel,
institute: x.institute ?? "-",
country: x.country ?? "-",
finishDate: x.finishDate,
}))
: [],
};
return new HttpSuccess(mapProfile);
}