filter case call leave server error #2304 & เพิ่มตัวเลือกการครอง-ไม่ครองตำแหน่ง #2311

This commit is contained in:
harid 2026-02-19 09:32:17 +07:00
parent 9382482f06
commit c8ed816a1f
2 changed files with 32 additions and 125 deletions

View file

@ -87,6 +87,7 @@ export class ReportController extends Controller {
@Query() isProbation?: boolean,
@Query() isRetire?: boolean,
@Query() isRetireLaw?: boolean,
@Query() isCurrent?: boolean,
@Query() retireType?: string,
@Query() tenureType?: string,
@Query() tenureMin?: number,
@ -253,62 +254,16 @@ export class ReportController extends Controller {
.andWhere(field != null && field != "" ? "registryOfficer.fields LIKE :fields" : "1=1", {
fields: `%${field}%`,
})
.andWhere(
isCurrent === undefined || isCurrent === null
? "1=1"
: isCurrent === true
? "registryOfficer.posMasterNo IS NOT NULL"
: "registryOfficer.posMasterNo IS NULL",
)
.orderBy(`registryOfficer.${sortBy}`, sort)
.getManyAndCount();
// const mapData1 = await Promise.all(
// lists.map(async (x) => {
// return {
// profileId: x.profileId,
// citizenId: x.citizenId,
// prefix: x.prefix,
// firstName: x.firstName,
// lastName: x.lastName,
// isProbation: x.isProbation,
// isLeave: x.isLeave,
// isRetirement: x.isRetirement,
// leaveType: x.leaveType,
// posMasterNo: x.posMasterNo,
// orgRootId: x.orgRootId,
// orgChild1Id: x.orgChild1Id,
// orgChild2Id: x.orgChild2Id,
// orgChild3Id: x.orgChild3Id,
// orgChild4Id: x.orgChild4Id,
// orgRootName: x.orgRootName,
// orgChild1Name: x.orgChild1Name,
// orgChild2Name: x.orgChild2Name,
// orgChild3Name: x.orgChild3Name,
// orgChild4Name: x.orgChild4Name,
// org: x.org,
// searchShortName: x.searchShortName,
// posExecutiveName: x.posExecutiveName,
// position: x.position,
// posTypeName: x.posTypeName,
// posLevelName: x.posLevelName,
// gender: x.gender,
// relationship: x.relationship,
// dateAppoint: x.dateAppoint,
// dateRetire: x.dateRetire,
// dateRetireLaw: x.dateRetireLaw,
// birthdate: x.birthdate,
// degree: x.degrees,
// age: x.age,
// currentPosition: null,
// lengthPosition: null,
// positionDate: {
// Years: x.Years ? x.Years : 0,
// Months: x.Months ? x.Months : 0,
// Days: x.Days ? x.Days : 0,
// },
// levelDate: {
// posExecutiveYears: x.levelYears,
// posExecutiveMonths: x.levelMonths,
// posExecutiveDays: x.levelDays,
// },
// };
// }),
// );
const mapData = [];
for await (const x of lists) {
let _educations: any = [];
@ -322,11 +277,6 @@ export class ReportController extends Controller {
Array.isArray(x.Educations) && x.Educations != null
? (x.Educations as any[]).filter((i: any) => i.isHigh == true)
: [];
// if(_educations.length == 0) {
// _educations = Array.isArray(x.Educations) && x.Educations != null
// ? (x.Educations as any[])[0]
// : []
// }
}
} else {
_educations =
@ -379,9 +329,6 @@ export class ReportController extends Controller {
dateRetireLaw: x.dateRetireLaw,
birthdate: x.birthdate,
Educations: _educations,
// degree: x.degrees,
// educationLevel: x.educationLevels,
// field: x.fields,
age: x.age,
currentPosition: null,
lengthPosition: null,
@ -429,6 +376,7 @@ export class ReportController extends Controller {
@Query() isProbation?: boolean,
@Query() isRetire?: boolean,
@Query() isRetireLaw?: boolean,
@Query() isCurrent?: boolean,
@Query() retireType?: string,
@Query() ageMin?: number,
@Query() ageMax?: number,
@ -581,6 +529,13 @@ export class ReportController extends Controller {
.andWhere(field != null && field != "" ? "registryEmployee.fields LIKE :fields" : "1=1", {
fields: `%${field}%`,
})
.andWhere(
isCurrent === undefined || isCurrent === null
? "1=1"
: isCurrent === true
? "registryEmployee.posMasterNo IS NOT NULL"
: "registryEmployee.posMasterNo IS NULL",
)
.orderBy(`registryEmployee.${sortBy}`, sort)
.getManyAndCount();