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