diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 1c704bad..dbeb0f12 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1653,32 +1653,32 @@ export class CommandController extends Controller { null && profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ?.orgChild4 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null && profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ?.orgChild3 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, ) != null && profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ?.orgChild2 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, ) != null && profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, )?.orgChild1 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, ) != null && profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, )?.orgRoot != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : null; const root = @@ -1722,18 +1722,19 @@ export class CommandController extends Controller { ?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { no: Extension.ToThaiNumber((idx + 1).toString()), - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), fullName: `${x.prefix}${x.firstName} ${x.lastName}`, citizenId: Extension.ToThaiNumber(x.citizenId), position: profile?.position ? profile?.position : "-", @@ -3579,7 +3580,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), - status: command.commandType.code == "C-PM-15" ? "PENDING" : "DONE" + status: command.commandType.code == "C-PM-15" ? "PENDING" : "DONE", }; Object.assign(dataAssis, metaAssis); @@ -5459,7 +5460,7 @@ export class CommandController extends Controller { commandNo: body.refIds[0].commandNo, refCommandNo: `${body.refIds[0].commandNo}/${body.refIds[0].commandYear}`, commandYear: body.refIds[0].commandYear, - posNo: `${shortName}${item.posMaster.posMasterNo}`, + posNo: `${shortName} ${item.posMaster.posMasterNo}`, posNoAbb: shortName, commandDateAffect: body.refIds[0].commandDateAffect, commandDateSign: body.refIds[0].commandDateSign, diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index e9d035bf..d3d70b0c 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -972,11 +972,11 @@ export class EmployeePositionController extends Controller { let checkChildConditions: any = {}; let keywordAsInt: any; let searchShortName = ""; - let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; if (body.type === 0) { typeCondition = { @@ -986,7 +986,7 @@ export class EmployeePositionController extends Controller { checkChildConditions = { orgChild1Id: IsNull(), }; - searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 1) { @@ -997,7 +997,7 @@ export class EmployeePositionController extends Controller { checkChildConditions = { orgChild2Id: IsNull(), }; - searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 2) { @@ -1008,7 +1008,7 @@ export class EmployeePositionController extends Controller { checkChildConditions = { orgChild3Id: IsNull(), }; - searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 3) { @@ -1019,14 +1019,14 @@ export class EmployeePositionController extends Controller { checkChildConditions = { orgChild4Id: IsNull(), }; - searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; - searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } let findPosition: any; let masterId = new Array(); @@ -1149,7 +1149,12 @@ export class EmployeePositionController extends Controller { .andWhere(revisionCondition); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); @@ -1596,7 +1601,7 @@ export class EmployeePositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgRootShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgRootId == org.id && @@ -1625,7 +1630,7 @@ export class EmployeePositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild1ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgChild1Id == org.id && @@ -1653,7 +1658,7 @@ export class EmployeePositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild2ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgChild2Id == org.id && @@ -1680,7 +1685,7 @@ export class EmployeePositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild3ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if (posMaster.orgChild3Id == org.id && posMaster.orgChild4Id == null) change = false; posMaster.orgRootId = org.orgRootId; @@ -1702,7 +1707,7 @@ export class EmployeePositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild4ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if (posMaster.orgChild4Id == org.id) change = false; posMaster.orgRootId = org.orgRootId; diff --git a/src/controllers/EmployeeTempPositionController.ts b/src/controllers/EmployeeTempPositionController.ts index 56bf5ea2..46939932 100644 --- a/src/controllers/EmployeeTempPositionController.ts +++ b/src/controllers/EmployeeTempPositionController.ts @@ -736,11 +736,11 @@ export class EmployeeTempPositionController extends Controller { let checkChildConditions: any = {}; let keywordAsInt: any; let searchShortName = ""; - let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; if (body.type === 0) { typeCondition = { @@ -750,7 +750,7 @@ export class EmployeeTempPositionController extends Controller { checkChildConditions = { orgChild1Id: IsNull(), }; - searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 1) { @@ -761,7 +761,7 @@ export class EmployeeTempPositionController extends Controller { checkChildConditions = { orgChild2Id: IsNull(), }; - searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 2) { @@ -772,7 +772,7 @@ export class EmployeeTempPositionController extends Controller { checkChildConditions = { orgChild3Id: IsNull(), }; - searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 3) { @@ -783,14 +783,14 @@ export class EmployeeTempPositionController extends Controller { checkChildConditions = { orgChild4Id: IsNull(), }; - searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; - searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } let findPosition: any; let masterId = new Array(); @@ -913,7 +913,12 @@ export class EmployeeTempPositionController extends Controller { .andWhere(revisionCondition); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 8f953df6..4bf9d4b0 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -2487,24 +2487,31 @@ export class ImportDataController extends Controller { let _null: any = null; let sqlStatements: string[] = []; - const [profiles, total] = await AppDataSource.getRepository(Profile) - .createQueryBuilder("profile") - .select(["profile.citizenId", "profile.id"]) - .orderBy("profile.citizenId", "ASC") - // .skip(0) - // .take(1000) - .getManyAndCount(); - 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","isEntry"\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"); - } + // const [profiles, total] = await AppDataSource.getRepository(Profile) + // .createQueryBuilder("profile") + // .select(["profile.citizenId", "profile.id"]) + // .orderBy("profile.citizenId", "ASC") + // // .skip(0) + // // .take(1000) + // .getManyAndCount(); + const profiles = await this.profileRepo.find({ + where: { profileSalary: { isEntry: Not(true) } }, + order: { + citizenId: "ASC", + }, + select: ["citizenId", "id"], }); + // 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","isEntry"\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"); + // } + // }); // await Promise.all( // profiles.map(async (_item) => { for await (const _item of profiles) { diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index d0ef4e2c..9af0480c 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -3313,7 +3313,7 @@ export class OrganizationController extends Controller { ? `${x00.current_holder.avatar}/${x00.current_holder.avatarName}` : null, positionName: x00.current_holder ? x00.current_holder.position : "", - positionNum: x00.orgRoot.orgRootShortName + x00.posMasterNo, + positionNum: `${x00.orgRoot.orgRootShortName} ${x00.posMasterNo}`, positionNumInt: x00.posMasterNo, departmentName: x00.orgRoot.orgRootName, organizationId: x00.orgRoot.id, @@ -3347,7 +3347,7 @@ export class OrganizationController extends Controller { ? `${x11.current_holder.avatar}/${x11.current_holder.avatarName}` : null, positionName: x11.current_holder ? x11.current_holder.position : "", - positionNum: x11.orgChild1.orgChild1ShortName + x11.posMasterNo, + positionNum: `${x11.orgChild1.orgChild1ShortName} ${x11.posMasterNo}`, positionNumInt: x11.posMasterNo, departmentName: x11.orgChild1.orgChild1Name, organizationId: x11.orgChild1.id, @@ -3413,7 +3413,7 @@ export class OrganizationController extends Controller { positionName: x33.current_holder ? x33.current_holder.position : "", - positionNum: x33.orgChild3.orgChild3ShortName + x33.posMasterNo, + positionNum: `${x33.orgChild3.orgChild3ShortName} ${x33.posMasterNo}`, positionNumInt: x33.posMasterNo, departmentName: x33.orgChild3.orgChild3Name, organizationId: x33.orgChild3.id, @@ -3444,8 +3444,7 @@ export class OrganizationController extends Controller { positionName: x44.current_holder ? x44.current_holder.position : "", - positionNum: - x44.orgChild4.orgChild4ShortName + x44.posMasterNo, + positionNum: `${x44.orgChild4.orgChild4ShortName} ${x44.posMasterNo}`, positionNumInt: x44.posMasterNo, departmentName: x44.orgChild4.orgChild4Name, organizationId: x44.orgChild4.id, @@ -3467,7 +3466,7 @@ export class OrganizationController extends Controller { positionName: x4.current_holder ? x4.current_holder.position : "", - positionNum: x4.orgChild4.orgChild4ShortName + x4.posMasterNo, + positionNum: `${x4.orgChild4.orgChild4ShortName} ${x4.posMasterNo}`, positionNumInt: x4.posMasterNo, departmentName: x4.orgChild4.orgChild4Name, organizationId: x4.orgChild4.id, @@ -3511,7 +3510,7 @@ export class OrganizationController extends Controller { ? `${x2.current_holder.avatar}/${x2.current_holder.avatarName}` : null, positionName: x2.current_holder ? x2.current_holder.position : "", - positionNum: x2.orgChild2.orgChild2ShortName + x2.posMasterNo, + positionNum: `${x2.orgChild2.orgChild2ShortName} ${x2.posMasterNo}`, positionNumInt: x2.posMasterNo, departmentName: x2.orgChild2.orgChild2Name, organizationId: x2.orgChild2.id, @@ -3533,7 +3532,7 @@ export class OrganizationController extends Controller { ? `${x1.current_holder.avatar}/${x1.current_holder.avatarName}` : null, positionName: x1.current_holder ? x1.current_holder.position : "", - positionNum: x1.orgChild1.orgChild1ShortName + x1.posMasterNo, + positionNum: `${x1.orgChild1.orgChild1ShortName} ${x1.posMasterNo}`, positionNumInt: x1.posMasterNo, departmentName: x1.orgChild1.orgChild1Name, organizationId: x1.orgChild1.id, @@ -3554,7 +3553,7 @@ export class OrganizationController extends Controller { ? `${x0.current_holder.avatar}/${x0.current_holder.avatarName}` : null, positionName: x0.current_holder.position, - positionNum: x0.orgRoot.orgRootShortName + x0.posMasterNo, + positionNum: `${x0.orgRoot.orgRootShortName} ${x0.posMasterNo}`, positionNumInt: x0.posMasterNo, departmentName: x0.orgRoot.orgRootName, organizationId: x0.orgRoot.id, @@ -3642,7 +3641,7 @@ export class OrganizationController extends Controller { ? `${x00.next_holder.avatar}/${x00.next_holder.avatarName}` : null, positionName: x00.next_holder ? x00.next_holder.position : "", - positionNum: x00.orgRoot.orgRootShortName + x00.posMasterNo, + positionNum: `${x00.orgRoot.orgRootShortName} ${x00.posMasterNo}`, positionNumInt: x00.posMasterNo, departmentName: x00.orgRoot.orgRootName, organizationId: x00.orgRoot.id, @@ -3674,7 +3673,7 @@ export class OrganizationController extends Controller { ? `${x11.next_holder.avatar}/${x11.next_holder.avatarName}` : null, positionName: x11.next_holder ? x11.next_holder.position : "", - positionNum: x11.orgChild1.orgChild1ShortName + x11.posMasterNo, + positionNum: `${x11.orgChild1.orgChild1ShortName} ${x11.posMasterNo}`, positionNumInt: x11.posMasterNo, departmentName: x11.orgChild1.orgChild1Name, organizationId: x11.orgChild1.id, @@ -3738,7 +3737,7 @@ export class OrganizationController extends Controller { ? `${x33.next_holder.avatar}/${x33.next_holder.avatarName}` : null, positionName: x33.next_holder ? x33.next_holder.position : "", - positionNum: x33.orgChild3.orgChild3ShortName + x33.posMasterNo, + positionNum: `${x33.orgChild3.orgChild3ShortName} ${x33.posMasterNo}`, positionNumInt: x33.posMasterNo, departmentName: x33.orgChild3.orgChild3Name, organizationId: x33.orgChild3.id, @@ -3767,8 +3766,7 @@ export class OrganizationController extends Controller { ? `${x44.next_holder.avatar}/${x44.next_holder.avatarName}` : null, positionName: x44.next_holder ? x44.next_holder.position : "", - positionNum: - x44.orgChild4.orgChild4ShortName + x44.posMasterNo, + positionNum: `${x44.orgChild4.orgChild4ShortName} ${x44.posMasterNo}`, positionNumInt: x44.posMasterNo, departmentName: x44.orgChild4.orgChild4Name, organizationId: x44.orgChild4.id, @@ -3788,7 +3786,7 @@ export class OrganizationController extends Controller { ? `${x4.next_holder.avatar}/${x4.next_holder.avatarName}` : null, positionName: x4.next_holder ? x4.next_holder.position : "", - positionNum: x4.orgChild4.orgChild4ShortName + x4.posMasterNo, + positionNum: `${x4.orgChild4.orgChild4ShortName} ${x4.posMasterNo}`, positionNumInt: x4.posMasterNo, departmentName: x4.orgChild4.orgChild4Name, organizationId: x4.orgChild4.id, @@ -3832,7 +3830,7 @@ export class OrganizationController extends Controller { ? `${x2.next_holder.avatar}/${x2.next_holder.avatarName}` : null, positionName: x2.next_holder ? x2.next_holder.position : "", - positionNum: x2.orgChild2.orgChild2ShortName + x2.posMasterNo, + positionNum: `${x2.orgChild2.orgChild2ShortName} ${x2.posMasterNo}`, positionNumInt: x2.posMasterNo, departmentName: x2.orgChild2.orgChild2Name, organizationId: x2.orgChild2.id, @@ -3854,7 +3852,7 @@ export class OrganizationController extends Controller { ? `${x1.next_holder.avatar}/${x1.next_holder.avatarName}` : null, positionName: x1.next_holder ? x1.next_holder.position : "", - positionNum: x1.orgChild1.orgChild1ShortName + x1.posMasterNo, + positionNum: `${x1.orgChild1.orgChild1ShortName} ${x1.posMasterNo}`, positionNumInt: x1.posMasterNo, departmentName: x1.orgChild1.orgChild1Name, organizationId: x1.orgChild1.id, @@ -3873,7 +3871,7 @@ export class OrganizationController extends Controller { ? `${x0.next_holder.avatar}/${x0.next_holder.avatarName}` : null, positionName: x0.next_holder.position, - positionNum: x0.orgRoot.orgRootShortName + x0.posMasterNo, + positionNum: `${x0.orgRoot.orgRootShortName} ${x0.posMasterNo}`, positionNumInt: x0.posMasterNo, departmentName: x0.orgRoot.orgRootName, organizationId: x0.orgRoot.id, @@ -5888,7 +5886,7 @@ export class OrganizationController extends Controller { // .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, - posNo: orgRoot.orgRootShortName + x.posMasterNo, + posNo: `${orgRoot.orgRootShortName} ${x.posMasterNo}`, orgTreeId: orgRoot.id, orgLevel: 0, fullNameCurrentHolder: @@ -5936,7 +5934,7 @@ export class OrganizationController extends Controller { // .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, - posNo: orgChild1.orgChild1ShortName + x.posMasterNo, + posNo: `${orgChild1.orgChild1ShortName} ${x.posMasterNo}`, orgTreeId: orgChild1.id, orgLevel: 1, fullNameCurrentHolder: @@ -5992,7 +5990,7 @@ export class OrganizationController extends Controller { // .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, - posNo: orgChild2.orgChild2ShortName + x.posMasterNo, + posNo: `${orgChild2.orgChild2ShortName} ${x.posMasterNo}`, orgTreeId: orgChild2.id, orgLevel: 2, fullNameCurrentHolder: @@ -6055,7 +6053,7 @@ export class OrganizationController extends Controller { // .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, - posNo: orgChild3.orgChild3ShortName + x.posMasterNo, + posNo: `${orgChild3.orgChild3ShortName} ${x.posMasterNo}`, orgTreeId: orgChild3.id, orgLevel: 3, fullNameCurrentHolder: @@ -6124,7 +6122,7 @@ export class OrganizationController extends Controller { // .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, - posNo: orgChild4.orgChild4ShortName + x.posMasterNo, + posNo: `${orgChild4.orgChild4ShortName} ${x.posMasterNo}`, orgTreeId: orgChild4.id, orgLevel: 4, fullNameCurrentHolder: diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 22354c10..c03046f7 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -150,24 +150,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { oc: rootName, @@ -204,7 +204,7 @@ export class OrganizationDotnetController extends Controller { birthDate: item.birthDate ?? new Date(), reasonSameDate: item.reasonSameDate, ethnicity: item.ethnicity, - telephoneNumber: item.telephoneNumber, + telephoneNumber: item.phone, nationality: item.nationality, gender: item.gender, relationship: item.relationship, @@ -500,11 +500,11 @@ export class OrganizationDotnetController extends Controller { } } } - let positionLeaveName = profile.posLevel?.posLevelName ?? null + let positionLeaveName = profile.posLevel?.posLevelName ?? null; const _profileCurrent = profile?.current_holders?.find( (x) => x.orgRevision?.orgRevisionIsDraft === false && - x.orgRevision?.orgRevisionIsCurrent === true + x.orgRevision?.orgRevisionIsCurrent === true, ); let oc = ""; if (_profileCurrent != null) { @@ -515,9 +515,9 @@ export class OrganizationDotnetController extends Controller { } else if (_profileCurrent.orgChild3Id === null) { oc = `${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; } else if (_profileCurrent.orgChild4Id === null) { - oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`;; + oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; } else { - oc = `${_profileCurrent.orgChild4?.orgChild4Name}` + oc = `${_profileCurrent.orgChild4?.orgChild4Name}`; } } const mapProfile = { @@ -545,7 +545,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -815,14 +815,15 @@ export class OrganizationDotnetController extends Controller { } } - let positionLeaveName = profile.posType != null && profile.posLevel != null - && (profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ") + let positionLeaveName = + profile.posType != null && + profile.posLevel != null && + (profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ") ? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}` - : profile.posLevel?.posLevelName ?? null + : profile.posLevel?.posLevelName ?? null; 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) { @@ -833,9 +834,9 @@ export class OrganizationDotnetController extends Controller { } else if (_profileCurrent.orgChild3Id === null) { oc = `${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; } else if (_profileCurrent.orgChild4Id === null) { - oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`;; + oc = `${_profileCurrent.orgChild3?.orgChild3Name} ${_profileCurrent.orgChild2?.orgChild2Name} ${_profileCurrent.orgChild1?.orgChild1Name} ${_profileCurrent.orgRoot?.orgRootName}`; } else { - oc = `${_profileCurrent.orgChild4?.orgChild4Name}` + oc = `${_profileCurrent.orgChild4?.orgChild4Name}`; } } const mapProfile = { @@ -863,7 +864,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1200,7 +1201,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1497,7 +1498,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1853,7 +1854,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -2120,7 +2121,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -2257,25 +2258,25 @@ export class OrganizationDotnetController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { @@ -2304,7 +2305,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender ?? "", relationship: profile.relationship ?? "", @@ -2474,25 +2475,25 @@ export class OrganizationDotnetController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { id: profile.id, @@ -2519,7 +2520,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender ?? "", relationship: profile.relationship ?? "", @@ -2626,25 +2627,25 @@ export class OrganizationDotnetController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { id: profile.id, @@ -2671,7 +2672,7 @@ export class OrganizationDotnetController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate ?? new Date(), reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender ?? "", relationship: profile.relationship ?? "", @@ -3075,24 +3076,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { @@ -3130,7 +3131,7 @@ export class OrganizationDotnetController extends Controller { birthDate: item.birthDate ?? new Date(), reasonSameDate: item.reasonSameDate, ethnicity: item.ethnicity, - telephoneNumber: item.telephoneNumber, + telephoneNumber: item.phone, nationality: item.nationality, gender: item.gender, relationship: item.relationship, @@ -3203,24 +3204,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; return { @@ -3258,7 +3259,7 @@ export class OrganizationDotnetController extends Controller { birthDate: item.birthDate ?? new Date(), reasonSameDate: item.reasonSameDate, ethnicity: item.ethnicity, - telephoneNumber: item.telephoneNumber, + telephoneNumber: item.phone, nationality: item.nationality, gender: item.gender, relationship: item.relationship, @@ -3409,20 +3410,20 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; const Oc = item.current_holders.length == 0 @@ -3575,24 +3576,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; const Oc = item.current_holders.length == 0 @@ -3726,24 +3727,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; const Oc = item.current_holders.length == 0 @@ -3879,24 +3880,24 @@ export class OrganizationDotnetController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}` : null; const Oc = item.current_holders.length == 0 diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index a618574c..684c3bc0 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -252,14 +252,19 @@ export class OrganizationUnauthorizeController extends Controller { amount: amount ? amount : null, rootId: item.orgRootId, root: item.orgRoot?.orgRootName ? item.orgRoot.orgRootName : null, + rootOrder: item.orgRoot?.orgRootOrder ? item.orgRoot.orgRootOrder : null, child1Id: item.orgChild1Id, child1: item.orgChild1?.orgChild1Name ? item.orgChild1.orgChild1Name : null, + child1Order: item.orgChild1?.orgChild1Order ? item.orgChild1.orgChild1Order : null, child2Id: item.orgChild2Id, child2: item.orgChild2?.orgChild2Name ? item.orgChild2.orgChild2Name : null, + child2Order: item.orgChild2?.orgChild2Order ? item.orgChild2.orgChild2Order : null, child3Id: item.orgChild3Id, child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null, + child3Order: item.orgChild3?.orgChild3Order ? item.orgChild3.orgChild3Order : null, child4Id: item.orgChild4Id, child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, + child4Order: item.orgChild4?.orgChild4Order ? item.orgChild4.orgChild4Order : null, result: pointSum, duration: null, isPunish: @@ -467,14 +472,19 @@ export class OrganizationUnauthorizeController extends Controller { amount: amount ? amount : null, rootId: item.orgRootId, root: item.orgRoot?.orgRootName ? item.orgRoot.orgRootName : null, + rootOrder: item.orgRoot?.orgRootOrder ? item.orgRoot.orgRootOrder : null, child1Id: item.orgChild1Id, child1: item.orgChild1?.orgChild1Name ? item.orgChild1.orgChild1Name : null, + child1Order: item.orgChild1?.orgChild1Order ? item.orgChild1.orgChild1Order : null, child2Id: item.orgChild2Id, child2: item.orgChild2?.orgChild2Name ? item.orgChild2.orgChild2Name : null, + child2Order: item.orgChild2?.orgChild2Order ? item.orgChild2.orgChild2Order : null, child3Id: item.orgChild3Id, child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null, + child3Order: item.orgChild3?.orgChild3Order ? item.orgChild3.orgChild3Order : null, child4Id: item.orgChild4Id, child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, + child4Order: item.orgChild4?.orgChild4Order ? item.orgChild4.orgChild4Order : null, result: pointSum, duration: null, isPunish: @@ -768,10 +778,10 @@ export class OrganizationUnauthorizeController extends Controller { : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return new HttpSuccess({ rootId: root == null ? null : root.id, @@ -779,11 +789,12 @@ export class OrganizationUnauthorizeController extends Controller { orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: findRevision.id, profileId: findProfile.id, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), type: "OFFICER", rank: findProfile.rank, prefix: findProfile.prefix, @@ -864,10 +875,10 @@ export class OrganizationUnauthorizeController extends Controller { : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return new HttpSuccess({ rootId: root == null ? null : root.id, @@ -875,11 +886,12 @@ export class OrganizationUnauthorizeController extends Controller { orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: findRevision.id, profileId: findProfile.id, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), type: "EMPLOYEE", rank: findProfile.rank, prefix: findProfile.prefix, @@ -960,10 +972,10 @@ export class OrganizationUnauthorizeController extends Controller { : findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return new HttpSuccess({ rootId: root == null ? null : root.id, @@ -971,11 +983,12 @@ export class OrganizationUnauthorizeController extends Controller { orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: findRevision.id, profileId: findProfile.id, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), type: "EMPLOYEE", rank: findProfile.rank, prefix: findProfile.prefix, @@ -1072,7 +1085,7 @@ export class OrganizationUnauthorizeController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate, reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1151,7 +1164,7 @@ export class OrganizationUnauthorizeController extends Controller { govAgePlus: profile.govAgePlus, birthDate: profile.birthDate, reasonSameDate: profile.reasonSameDate, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, diff --git a/src/controllers/PermissionOrgController.ts b/src/controllers/PermissionOrgController.ts index d9e00d18..a413c9f4 100644 --- a/src/controllers/PermissionOrgController.ts +++ b/src/controllers/PermissionOrgController.ts @@ -108,11 +108,11 @@ export class PermissionOrgController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -138,7 +138,7 @@ export class PermissionOrgController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId}) + .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId }) .andWhere( new Brackets((qb) => { // qb.andWhere(`current_holders.orgRevision = :orgRevisionId`, { @@ -167,24 +167,24 @@ export class PermissionOrgController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -222,10 +222,10 @@ export class PermissionOrgController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -235,11 +235,12 @@ export class PermissionOrgController extends Controller { rank: _data.rank, firstName: _data.firstName, lastName: _data.lastName, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.position, posType: _data.posType == null ? null : _data.posType.posTypeName, @@ -334,7 +335,7 @@ export class PermissionOrgController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - .where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id}) + .where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id }) .andWhere(requestBody.id == null ? "1=1" : `permissionOrg.orgRootId LIKE :rootId`, { rootId: requestBody.id, }) @@ -365,33 +366,33 @@ export class PermissionOrgController extends Controller { null && _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild4 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgChild2 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgChild1 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgRoot != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.profileTree.current_holders.length == 0 || @@ -436,10 +437,10 @@ export class PermissionOrgController extends Controller { ?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -452,11 +453,12 @@ export class PermissionOrgController extends Controller { rank: _data.profileTree.rank, firstName: _data.profileTree.firstName, lastName: _data.profileTree.lastName, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.profileTree.position, posType: _data.profileTree.posType == null ? null : _data.profileTree.posType.posTypeName, @@ -527,7 +529,7 @@ export class PermissionOrgController extends Controller { permission.lastUpdatedAt = new Date(); return permission; }); - + await this.permissionOrgRepository.save(_permissionOrg, { data: request }); setLogDataDiff(request, { before, after: _permissionOrg }); return new HttpSuccess(); diff --git a/src/controllers/PermissionProfileController.ts b/src/controllers/PermissionProfileController.ts index f20d2d9a..4503dc3c 100644 --- a/src/controllers/PermissionProfileController.ts +++ b/src/controllers/PermissionProfileController.ts @@ -108,11 +108,11 @@ export class PermissionProfileController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -167,24 +167,24 @@ export class PermissionProfileController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -221,11 +221,11 @@ export class PermissionProfileController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; - let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _root = root?.orgRootName; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -235,11 +235,12 @@ export class PermissionProfileController extends Controller { rank: _data.rank, firstName: _data.firstName, lastName: _data.lastName, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.position, posType: _data.posType == null ? null : _data.posType.posTypeName, @@ -365,33 +366,33 @@ export class PermissionProfileController extends Controller { null && _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild4 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgChild2 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgChild1 != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, ) != null && _data.profileTree.current_holders.find( (x) => x.orgRevisionId == findRevision.id, )?.orgRoot != null - ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.profileTree.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.profileTree.current_holders.length == 0 || @@ -436,10 +437,10 @@ export class PermissionProfileController extends Controller { ?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -454,11 +455,12 @@ export class PermissionProfileController extends Controller { rank: _data.profileTree.rank, firstName: _data.profileTree.firstName, lastName: _data.profileTree.lastName, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), posNo: shortName, position: _data.profileTree.position, posType: _data.profileTree.posType == null ? null : _data.profileTree.posType.posTypeName, diff --git a/src/controllers/PosMasterActController.ts b/src/controllers/PosMasterActController.ts index e658d122..579c0aa2 100644 --- a/src/controllers/PosMasterActController.ts +++ b/src/controllers/PosMasterActController.ts @@ -222,15 +222,15 @@ export class PosMasterActController extends Controller { .map((item) => { const shortName = item.posMasterChild != null && item.posMasterChild.orgChild4 != null - ? `${item.posMasterChild.orgChild4.orgChild4ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild4.orgChild4ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild3 != null - ? `${item.posMasterChild.orgChild3.orgChild3ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild3.orgChild3ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild2 != null - ? `${item.posMasterChild.orgChild2.orgChild2ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild2.orgChild2ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild1 != null - ? `${item.posMasterChild.orgChild1.orgChild1ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild1.orgChild1ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgRoot != null - ? `${item.posMasterChild.orgRoot.orgRootShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgRoot.orgRootShortName} ${item.posMasterChild.posMasterNo}` : null; return { id: item.id, @@ -364,15 +364,15 @@ export class PosMasterActController extends Controller { .map((item) => { const shortName = item.posMasterChild != null && item.posMasterChild.orgChild4 != null - ? `${item.posMasterChild.orgChild4.orgChild4ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild4.orgChild4ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild3 != null - ? `${item.posMasterChild.orgChild3.orgChild3ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild3.orgChild3ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild2 != null - ? `${item.posMasterChild.orgChild2.orgChild2ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild2.orgChild2ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgChild1 != null - ? `${item.posMasterChild.orgChild1.orgChild1ShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgChild1.orgChild1ShortName} ${item.posMasterChild.posMasterNo}` : item.posMasterChild != null && item.posMasterChild?.orgRoot != null - ? `${item.posMasterChild.orgRoot.orgRootShortName}${item.posMasterChild.posMasterNo}` + ? `${item.posMasterChild.orgRoot.orgRootShortName} ${item.posMasterChild.posMasterNo}` : null; return { id: item.id, @@ -472,15 +472,15 @@ export class PosMasterActController extends Controller { const _posMaster = posMaster.map((x) => { const posMasterNo = x.posMasterChild.orgChild4 != null - ? `${x.posMasterChild.orgChild4.orgChild4ShortName}${x.posMasterChild.posMasterNo}` + ? `${x.posMasterChild.orgChild4.orgChild4ShortName} ${x.posMasterChild.posMasterNo}` : x.posMasterChild != null && x?.posMasterChild?.orgChild3 != null - ? `${x.posMasterChild.orgChild3.orgChild3ShortName}${x.posMasterChild.posMasterNo}` + ? `${x.posMasterChild.orgChild3.orgChild3ShortName} ${x.posMasterChild.posMasterNo}` : x.posMasterChild != null && x?.posMasterChild?.orgChild2 != null - ? `${x.posMasterChild.orgChild2.orgChild2ShortName}${x.posMasterChild.posMasterNo}` + ? `${x.posMasterChild.orgChild2.orgChild2ShortName} ${x.posMasterChild.posMasterNo}` : x.posMasterChild != null && x?.posMasterChild?.orgChild1 != null - ? `${x.posMasterChild.orgChild1.orgChild1ShortName}${x.posMasterChild.posMasterNo}` + ? `${x.posMasterChild.orgChild1.orgChild1ShortName} ${x.posMasterChild.posMasterNo}` : x.posMasterChild != null && x?.posMasterChild?.orgRoot != null - ? `${x.posMasterChild.orgRoot.orgRootShortName}${x.posMasterChild.posMasterNo}` + ? `${x.posMasterChild.orgRoot.orgRootShortName} ${x.posMasterChild.posMasterNo}` : null; const position = x.posMasterChild.positions.filter((x) => x.positionIsSelected == true).length > 0 diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 510e636e..d15450b3 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1526,11 +1526,11 @@ export class PositionController extends Controller { let checkChildConditions: any = {}; let keywordAsInt: any; let searchShortName = "1=1"; - let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; if (body.type != null && body.id != null) { if (body.type === 0) { typeCondition = { @@ -1540,7 +1540,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild1Id: IsNull(), }; - searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 1) { @@ -1551,7 +1551,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild2Id: IsNull(), }; - searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 2) { @@ -1562,7 +1562,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild3Id: IsNull(), }; - searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 3) { @@ -1573,14 +1573,14 @@ export class PositionController extends Controller { checkChildConditions = { orgChild4Id: IsNull(), }; - searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; - searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } } else { body.isAll = true; @@ -1796,7 +1796,12 @@ export class PositionController extends Controller { .andWhere(revisionCondition); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); @@ -1996,11 +2001,11 @@ export class PositionController extends Controller { let checkChildConditions: any = {}; let keywordAsInt: any; let searchShortName = "1=1"; - let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNo)`; - let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNo)`; - let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNo)`; - let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNo)`; - let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNo)`; + let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`; + let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`; + let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`; + let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`; + let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`; let _data = await new permission().PermissionOrgList(request, "SYS_ORG"); if (body.type === 0) { typeCondition = { @@ -2010,7 +2015,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild1Id: IsNull(), }; - searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNo) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; } else { } } else if (body.type === 1) { @@ -2021,7 +2026,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild2Id: IsNull(), }; - searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNo) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; } else { } } else if (body.type === 2) { @@ -2032,7 +2037,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild3Id: IsNull(), }; - searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNo) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; } else { } } else if (body.type === 3) { @@ -2043,14 +2048,14 @@ export class PositionController extends Controller { checkChildConditions = { orgChild4Id: IsNull(), }; - searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNo) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; } else { } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; - searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNo) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; } let findPosition: any; let masterId = new Array(); @@ -2226,7 +2231,12 @@ export class PositionController extends Controller { .andWhere(revisionCondition); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); @@ -2730,7 +2740,7 @@ export class PositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgRootShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgRootId == org.id && @@ -2765,7 +2775,7 @@ export class PositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild1ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgChild1Id == org.id && @@ -2799,7 +2809,7 @@ export class PositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild2ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if ( posMaster.orgChild2Id == org.id && @@ -2832,7 +2842,7 @@ export class PositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild3ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if (posMaster.orgChild3Id == org.id && posMaster.orgChild4Id == null) change = false; posMaster.orgRootId = org.orgRootId; @@ -2859,7 +2869,7 @@ export class PositionController extends Controller { if (_posMaster != null) throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${org.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${org.orgChild4ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); if (posMaster.orgChild4Id == org.id) change = false; @@ -2900,7 +2910,7 @@ export class PositionController extends Controller { if (_posMasterRoot != null) { throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${r.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${r.orgRootShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); } } @@ -2927,7 +2937,7 @@ export class PositionController extends Controller { if (_posMasterChild1 != null) { throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${c1.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${c1.orgChild1ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); } } @@ -2954,7 +2964,7 @@ export class PositionController extends Controller { if (_posMasterChild2 != null) { throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${c2.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${c2.orgChild2ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); } } @@ -2981,7 +2991,7 @@ export class PositionController extends Controller { if (_posMasterChild3 != null) { throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${c3.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${c3.orgChild3ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); } } @@ -3007,7 +3017,7 @@ export class PositionController extends Controller { if (_posMasterChild4 != null) { throw new HttpError( HttpStatusCode.NOT_FOUND, - `เลขที่ตำแหน่ง ${c4.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, + `เลขที่ตำแหน่ง ${c4.orgChild4ShortName} ${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`, ); } } @@ -3701,7 +3711,12 @@ export class PositionController extends Controller { }); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .getManyAndCount(); const _posType = await this.posTypeRepository.find({ @@ -3964,7 +3979,12 @@ export class PositionController extends Controller { }); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .getManyAndCount(); const formattedData = await Promise.all( @@ -4193,7 +4213,12 @@ export class PositionController extends Controller { }); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .getManyAndCount(); const formattedData = await Promise.all( @@ -4395,7 +4420,12 @@ export class PositionController extends Controller { qb.orWhere(typeCondition); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .getManyAndCount(); const formattedData = await Promise.all( @@ -4569,15 +4599,15 @@ export class PositionController extends Controller { .map((item) => { const shortName = item.orgChild4 != null - ? `${item.orgChild4.orgChild4ShortName}${item.posMasterNo}` + ? `${item.orgChild4.orgChild4ShortName} ${item.posMasterNo}` : item?.orgChild3 != null - ? `${item.orgChild3.orgChild3ShortName}${item.posMasterNo}` + ? `${item.orgChild3.orgChild3ShortName} ${item.posMasterNo}` : item?.orgChild2 != null - ? `${item.orgChild2.orgChild2ShortName}${item.posMasterNo}` + ? `${item.orgChild2.orgChild2ShortName} ${item.posMasterNo}` : item?.orgChild1 != null - ? `${item.orgChild1.orgChild1ShortName}${item.posMasterNo}` + ? `${item.orgChild1.orgChild1ShortName} ${item.posMasterNo}` : item?.orgRoot != null - ? `${item.orgRoot.orgRootShortName}${item.posMasterNo}` + ? `${item.orgRoot.orgRootShortName} ${item.posMasterNo}` : null; return { id: item.id, @@ -4732,7 +4762,12 @@ export class PositionController extends Controller { qb.andWhere(conditionGroup); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .select([ "posMaster.id", "posMaster.posMasterNo", @@ -4755,15 +4790,15 @@ export class PositionController extends Controller { const _posMaster = posMaster.map((x) => { const posMasterNo = x.orgChild4 != null - ? `${x.orgChild4.orgChild4ShortName}${x.posMasterNo}` + ? `${x.orgChild4.orgChild4ShortName} ${x.posMasterNo}` : x != null && x?.orgChild3 != null - ? `${x.orgChild3.orgChild3ShortName}${x.posMasterNo}` + ? `${x.orgChild3.orgChild3ShortName} ${x.posMasterNo}` : x != null && x?.orgChild2 != null - ? `${x.orgChild2.orgChild2ShortName}${x.posMasterNo}` + ? `${x.orgChild2.orgChild2ShortName} ${x.posMasterNo}` : x != null && x?.orgChild1 != null - ? `${x.orgChild1.orgChild1ShortName}${x.posMasterNo}` + ? `${x.orgChild1.orgChild1ShortName} ${x.posMasterNo}` : x != null && x?.orgRoot != null - ? `${x.orgRoot.orgRootShortName}${x.posMasterNo}` + ? `${x.orgRoot.orgRootShortName} ${x.posMasterNo}` : null; const position = x.positions.filter((x) => x.positionIsSelected == true).length > 0 @@ -4810,11 +4845,11 @@ export class PositionController extends Controller { let checkChildConditions: any = {}; let keywordAsInt: any; let searchShortName = "1=1"; - let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; - let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; + let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`; let _data = await new permission().PermissionOrgList(request, "SYS_POS_CONDITION"); if (body.type === 0) { typeCondition = { @@ -4824,7 +4859,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild1Id: IsNull(), }; - searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 1) { @@ -4835,7 +4870,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild2Id: IsNull(), }; - searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 2) { @@ -4846,7 +4881,7 @@ export class PositionController extends Controller { checkChildConditions = { orgChild3Id: IsNull(), }; - searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 3) { @@ -4857,14 +4892,14 @@ export class PositionController extends Controller { checkChildConditions = { orgChild4Id: IsNull(), }; - searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } else { } } else if (body.type === 4) { typeCondition = { orgChild4Id: body.id, }; - searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; + searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`; } let findPosition: any; let masterId = new Array(); @@ -5012,7 +5047,12 @@ export class PositionController extends Controller { .andWhere({ current_holderId: IsNull() }); }), ) - .orderBy("posMaster.posMasterOrder", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") + .addOrderBy("orgChild1.orgChild1Order", "ASC") + .addOrderBy("orgChild2.orgChild2Order", "ASC") + .addOrderBy("orgChild3.orgChild3Order", "ASC") + .addOrderBy("orgChild4.orgChild4Order", "ASC") + .addOrderBy("posMaster.posMasterOrder", "ASC") .skip((body.page - 1) * body.pageSize) .take(body.pageSize) .getManyAndCount(); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f8e8bbf2..3b8adf81 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -82,6 +82,7 @@ import { OrgChild1 } from "../entities/OrgChild1"; import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; +import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; @Route("api/v1/org/profile") @Tags("Profile") @@ -118,6 +119,7 @@ export class ProfileController extends Controller { private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private salaryRepo = AppDataSource.getRepository(ProfileSalary); + private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory); private profileEducationRepo = AppDataSource.getRepository(ProfileEducation); private provinceRepo = AppDataSource.getRepository(Province); private districtRepo = AppDataSource.getRepository(District); @@ -241,10 +243,10 @@ export class ProfileController extends Controller { ? ` รหัสไปรษณีย์ ${profile.registrationZipCode}` : ""; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const salary_raw = await this.salaryRepo.find({ // select: [ @@ -400,11 +402,12 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) : "" }`, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), educations: Education, salarys: salarys.map((item) => { return { @@ -554,10 +557,10 @@ export class ProfileController extends Controller { // Construct org path let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileId: id }, @@ -712,11 +715,12 @@ export class ProfileController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -805,11 +809,12 @@ export class ProfileController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", @@ -855,8 +860,7 @@ export class ProfileController extends Controller { profiles.currentProvince != null ? Extension.ToThaiNumber(profiles.currentProvince.name) : "", - telephone: - profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", + telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] @@ -1042,10 +1046,10 @@ export class ProfileController extends Controller { // Construct org path let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileId: id }, @@ -1216,11 +1220,12 @@ export class ProfileController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -1655,11 +1660,12 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(profiles.amountSpecial.toLocaleString()) : "", salarySum: sum, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", @@ -1735,8 +1741,7 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(profiles.registrationZipCode) : "", fullRegistrationAddress: fullRegistrationAddress, - telephone: - profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", + telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] @@ -5275,11 +5280,11 @@ export class ProfileController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -5390,23 +5395,23 @@ export class ProfileController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -5443,10 +5448,10 @@ export class ProfileController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -5468,11 +5473,12 @@ export class ProfileController extends Controller { root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: root == null ? null : root.orgRevisionId, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), }; }), ); @@ -5687,7 +5693,7 @@ export class ProfileController extends Controller { ); }), ) - .andWhere("profile.leaveCommandId Is NOT NULL") + // .andWhere("profile.leaveCommandId Is NOT NULL") .andWhere( "profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileId = profile.id)", ) @@ -5713,6 +5719,10 @@ export class ProfileController extends Controller { ? `profile.isProbation = ${isProbation}` : "1=1", ) + .andWhere( + retireType != undefined && retireType != null ? `profile.leaveType = :retireType` : "1=1", + { retireType: retireType }, + ) .andWhere(pmsCondition, { orgRootPms: orgRootPms ? orgRootPms.orgRootName : "", orgChild1Pms: orgChild1Pms ? orgChild1Pms.orgChild1Name : "", @@ -5741,8 +5751,8 @@ export class ProfileController extends Controller { ) // .orderBy("current_holders.posMasterNo", "ASC") // .orderBy(`${sortBy}`, sort) - .skip((page - 1) * pageSize) - .take(pageSize) + // .skip((page - 1) * pageSize) + // .take(pageSize) .getManyAndCount(); const data = await Promise.all( @@ -6031,11 +6041,11 @@ export class ProfileController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -6215,24 +6225,24 @@ export class ProfileController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -6268,12 +6278,12 @@ export class ProfileController extends Controller { _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; - - let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + + let _root = root?.orgRootName; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -6296,11 +6306,12 @@ export class ProfileController extends Controller { root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: root == null ? null : root.orgRevisionId, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), }; }), ); @@ -6520,11 +6531,11 @@ export class ProfileController extends Controller { ) { let queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; @@ -6567,7 +6578,7 @@ export class ProfileController extends Controller { holder.orgChild2?.orgChild2ShortName || holder.orgChild1?.orgChild1ShortName || holder.orgRoot?.orgRootShortName; - return `${shortName || ""}${holder.posMasterNo || ""}`; + return `${shortName || ""} ${holder.posMasterNo || ""}`; }); return profile.current_holders.map((holder, index) => { const position = holder.positions.find((position) => position.posMasterId === holder.id); @@ -6818,7 +6829,7 @@ export class ProfileController extends Controller { salary: profile.amount, posNo: root?.orgRootShortName && posMaster?.posMasterNo - ? `${root?.orgRootShortName}${posMaster?.posMasterNo}` + ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` : "", }; if (_profile.child4Id != null) { @@ -6975,7 +6986,7 @@ export class ProfileController extends Controller { amountSpecial: profile ? profile.amountSpecial : null, posNo: root?.orgRootShortName && posMaster?.posMasterNo - ? `${root?.orgRootShortName}${posMaster?.posMasterNo}` + ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` : "", }; @@ -7643,26 +7654,26 @@ export class ProfileController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : null; const posMasterActs = await this.posMasterActRepository.find({ relations: [ @@ -7691,15 +7702,15 @@ export class ProfileController extends Controller { .map((item) => { const shortName = item.posMaster != null && item.posMaster.orgChild4 != null - ? `${item.posMaster.orgChild4.orgChild4ShortName}${item.posMaster.posMasterNo}` + ? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}` : item.posMaster != null && item.posMaster?.orgChild3 != null - ? `${item.posMaster.orgChild3.orgChild3ShortName}${item.posMaster.posMasterNo}` + ? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}` : item.posMaster != null && item.posMaster?.orgChild2 != null - ? `${item.posMaster.orgChild2.orgChild2ShortName}${item.posMaster.posMasterNo}` + ? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}` : item.posMaster != null && item.posMaster?.orgChild1 != null - ? `${item.posMaster.orgChild1.orgChild1ShortName}${item.posMaster.posMasterNo}` + ? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}` : item.posMaster != null && item.posMaster?.orgRoot != null - ? `${item.posMaster.orgRoot.orgRootShortName}${item.posMaster.posMasterNo}` + ? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}` : null; return { id: item.id, @@ -8163,19 +8174,19 @@ export class ProfileController extends Controller { const skip = (page - 1) * pageSize; const take = pageSize; let queryLike = `CONCAT( - IFNULL(orgChild4.orgChild4ShortName, ''), + IFNULL(orgChild4.orgChild4ShortName, '')," ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild3.orgChild3ShortName, ''), + IFNULL(orgChild3.orgChild3ShortName, '')," ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild2.orgChild2ShortName, ''), + IFNULL(orgChild2.orgChild2ShortName, '')," ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild1.orgChild1ShortName, ''), + IFNULL(orgChild1.orgChild1ShortName, '')," ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgRoot.orgRootShortName, ''), + IFNULL(orgRoot.orgRootShortName, '')," ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword`; @@ -8390,24 +8401,24 @@ export class ProfileController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -8882,24 +8893,24 @@ export class ProfileController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; return { @@ -8916,7 +8927,7 @@ export class ProfileController extends Controller { : item.profileSalary.sort((a, b) => b.order - a.order)[0].commandNo, posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName, posTypeName: item.posType == null ? null : item.posType.posTypeName, - posNo: posMaster == null ? null : `${posMaster.posMasterNo}${shortName}`, + posNo: posMaster == null ? null : `${shortName} ${posMaster.posMasterNo}`, positionField: position == null ? null : position.positionField, positionArea: position == null ? null : position.positionArea, posExecutiveName: posExecutive, @@ -9188,24 +9199,24 @@ export class ProfileController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; return { @@ -9218,7 +9229,7 @@ export class ProfileController extends Controller { idcard: item.citizenId, posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName, posTypeName: item.posType == null ? null : item.posType.posTypeName, - posNo: `${posMaster == null ? null : posMaster.posMasterNo}${shortName}`, + posNo: `${shortName} ${posMaster == null ? null : posMaster.posMasterNo}`, positionField: position == null ? null : position.positionField, positionArea: position == null ? null : position.positionArea, posExecutiveName: posExecutive, @@ -9765,23 +9776,23 @@ export class ProfileController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holders == null || @@ -9897,8 +9908,106 @@ export class ProfileController extends Controller { ) { const profile = await this.profileRepo.findOne({ where: { id: id }, + relations: [ + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + "current_holders.positions", + "current_holders.positions.posExecutive", + ], }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where: { + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false, + }, + }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; + const shortName = + !profile.current_holders || profile.current_holders.length == 0 + ? null + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild2 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild1 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgRoot != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` + : null; + let position = + profile.current_holders + .filter((x) => x.orgRevisionId == orgRevision?.id)[0] + ?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null; + const dest_item = await this.salaryRepo.findOne({ + where: { profileId: id }, + order: { order: "DESC" }, + }); + const data: any = { + order: dest_item == null ? 1 : dest_item.order + 1, + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, + profileId: profile.id, + posNo: orgRevisionRef?.posMasterNo, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, + positionType: profile.posType?.posTypeName, + positionLevel: profile.posLevel?.posLevelName, + amountSpecial: profile.amountSpecial, + orgRoot: orgRootRef?.orgRootName, + orgChild1: orgChild1Ref?.orgChild1Name, + orgChild2: orgChild2Ref?.orgChild2Name, + orgChild3: orgChild3Ref?.orgChild3Name, + orgChild4: orgChild4Ref?.orgChild4Name, + commandYear: new Date().getFullYear() + 543, + commandDateSign: new Date(), + commandDateAffect: new Date(), + commandCode: "16", + commandName: "พ้นจากราชการ", + posNoAbb: shortName, + isEntry: false, + positionName: profile.position, + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }; + delete data.id; + + const history = new ProfileSalaryHistory(); + Object.assign(history, { ...data, id: undefined }); + data.dateGovernment = data.createdAt; + await this.salaryRepo.save(data); + history.profileSalaryId = data.id; + await this.salaryHistoryRepo.save(history); + const before = structuredClone(profile); let _null: any = null; profile.isLeave = requestBody.isLeave; @@ -9919,6 +10028,7 @@ export class ProfileController extends Controller { profile.isActive = false; } } + await this.profileRepo.save(profile, { data: request }); setLogDataDiff(request, { before, after: profile }); @@ -10010,24 +10120,24 @@ export class ProfileController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index d45f68a9..5b845a59 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -70,6 +70,7 @@ import { Position } from "../entities/Position"; import { EmployeePosition } from "../entities/EmployeePosition"; import { deleteUser } from "../keycloak"; import { PermissionProfile } from "../entities/PermissionProfile"; +import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; @Route("api/v1/org/profile-employee") @Tags("ProfileEmployee") @Security("bearerAuth") @@ -95,6 +96,7 @@ export class ProfileEmployeeController extends Controller { private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private salaryRepo = AppDataSource.getRepository(ProfileSalary); + private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory); private orgRootRepository = AppDataSource.getRepository(OrgRoot); private child1Repository = AppDataSource.getRepository(OrgChild1); private child2Repository = AppDataSource.getRepository(OrgChild2); @@ -224,12 +226,12 @@ export class ProfileEmployeeController extends Controller { profile && profile.registrationZipCode != null ? ` รหัสไปรษณีย์ ${profile.registrationZipCode}` : ""; - + let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const salary_raw = await this.salaryRepo.find({ // select: [ @@ -385,11 +387,12 @@ export class ProfileEmployeeController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) : "" }`, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), educations: Education, salarys: salarys.map((item) => { return { @@ -540,10 +543,10 @@ export class ProfileEmployeeController extends Controller { // Construct org path let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileEmployeeId: id }, @@ -698,11 +701,12 @@ export class ProfileEmployeeController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - OcFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + OcFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -791,11 +795,12 @@ export class ProfileEmployeeController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", @@ -841,8 +846,7 @@ export class ProfileEmployeeController extends Controller { profiles.currentProvince != null ? Extension.ToThaiNumber(profiles.currentProvince.name) : "", - telephone: - profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", + telephone: profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.phone) : "", url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] @@ -1142,15 +1146,15 @@ export class ProfileEmployeeController extends Controller { _data.current_holders.length == 0 ? null : _data.current_holders[0].orgChild4 != null - ? `${_data.current_holders[0].orgChild4.orgChild4ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild4.orgChild4ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild3 != null - ? `${_data.current_holders[0].orgChild3.orgChild3ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild3.orgChild3ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild2 != null - ? `${_data.current_holders[0].orgChild2.orgChild2ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild2.orgChild2ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild1 != null - ? `${_data.current_holders[0].orgChild1.orgChild1ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild1.orgChild1ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgRoot != null - ? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgRoot.orgRootShortName} ${_data.current_holders[0].posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 @@ -1309,24 +1313,24 @@ export class ProfileEmployeeController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -1356,7 +1360,7 @@ export class ProfileEmployeeController extends Controller { salaryLevel: profile.salaryLevel, group: profile.group, ethnicity: profile.ethnicity, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1401,15 +1405,15 @@ export class ProfileEmployeeController extends Controller { const formattedData = profiles.map((profile) => { const shortName = profile.child4Temp != null - ? `${profile.child4ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child4ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child3Temp != null - ? `${profile.child3ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child3ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child2Temp != null - ? `${profile.child2ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child2ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child1Temp != null - ? `${profile.child1ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child1ShortNameTemp} ${profile.posMasterNoTemp}` : profile.rootIdTemp != null - ? `${profile.rootShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.rootShortNameTemp} ${profile.posMasterNoTemp}` : null; return { @@ -1460,11 +1464,11 @@ export class ProfileEmployeeController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -1558,23 +1562,23 @@ export class ProfileEmployeeController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null && _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -1611,11 +1615,11 @@ export class ProfileEmployeeController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4; - let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _root = root?.orgRootName; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -1636,11 +1640,12 @@ export class ProfileEmployeeController extends Controller { root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: root == null ? null : root.orgRevisionId, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), }; }), ); @@ -1669,7 +1674,7 @@ export class ProfileEmployeeController extends Controller { }); return new HttpSuccess(); } - + /** * API ค้นหาและแสดงผู้พ้นจากราชการ ลูกจ้างประจำ กทม. * @@ -1704,10 +1709,10 @@ export class ProfileEmployeeController extends Controller { queryLike = "profileEmployee.citizenId LIKE :keyword"; } else if (searchField == "position") { queryLike = "profileEmployee.position LIKE :keyword"; - } + } // else if (searchField == "posNo") { // queryLike = ` - // CASE + // CASE // WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) // WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) // WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) @@ -1717,81 +1722,81 @@ export class ProfileEmployeeController extends Controller { // `; // } let nodeCondition = "1=1"; - let nodeAll = ""; - let orgRoot = null; - let orgChild1 = null; - let orgChild2 = null; - let orgChild3 = null; - let orgChild4 = null; + let nodeAll = ""; + let orgRoot = null; + let orgChild1 = null; + let orgChild2 = null; + let orgChild3 = null; + let orgChild4 = null; - let pmsCondition = "1=1"; - let orgRootPms = null; - let orgChild1Pms = null; - let orgChild2Pms = null; - let orgChild3Pms = null; - let orgChild4Pms = null; + let pmsCondition = "1=1"; + let orgRootPms = null; + let orgChild1Pms = null; + let orgChild2Pms = null; + let orgChild3Pms = null; + let orgChild4Pms = null; - if (node === 0 && nodeId) { - orgRoot = await this.orgRootRepository.findOne({where: { id: nodeId }}); - if (orgRoot) { + if (node === 0 && nodeId) { + orgRoot = await this.orgRootRepository.findOne({ where: { id: nodeId } }); + if (orgRoot) { nodeCondition = "profileSalary.orgRoot = :orgRoot"; - } - if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL"; - } else if (node === 1 && nodeId) { - orgChild1 = await this.child1Repository.findOne({where: { id: nodeId }}); + } + if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL"; + } else if (node === 1 && nodeId) { + orgChild1 = await this.child1Repository.findOne({ where: { id: nodeId } }); if (orgChild1) { - nodeCondition = "profileSalary.orgChild1 = :orgChild1"; + nodeCondition = "profileSalary.orgChild1 = :orgChild1"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; - } else if (node === 2 && nodeId) { - orgChild2 = await this.child2Repository.findOne({where: { id: nodeId }}); + if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; + } else if (node === 2 && nodeId) { + orgChild2 = await this.child2Repository.findOne({ where: { id: nodeId } }); if (orgChild2) { - nodeCondition = "profileSalary.orgChild2 = :orgChild2"; + nodeCondition = "profileSalary.orgChild2 = :orgChild2"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; - } else if (node === 3 && nodeId) { - orgChild3 = await this.child3Repository.findOne({where: { id: nodeId }}); + if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; + } else if (node === 3 && nodeId) { + orgChild3 = await this.child3Repository.findOne({ where: { id: nodeId } }); if (orgChild3) { - nodeCondition = "profileSalary.orgChild3 = :orgChild3"; + nodeCondition = "profileSalary.orgChild3 = :orgChild3"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; - } else if (node === 4 && nodeId) { - orgChild4 = await this.child4Repository.findOne({where: { id: nodeId }}); + if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; + } else if (node === 4 && nodeId) { + orgChild4 = await this.child4Repository.findOne({ where: { id: nodeId } }); if (orgChild4) { - nodeCondition = "profileSalary.orgChild4Id = :nodeId"; + nodeCondition = "profileSalary.orgChild4Id = :nodeId"; } - } - nodeCondition = nodeCondition + nodeAll; + } + nodeCondition = nodeCondition + nodeAll; - if (_data.root) { - orgRootPms = await this.orgRootRepository.findOne({where: { id: _data.root }}); + if (_data.root) { + orgRootPms = await this.orgRootRepository.findOne({ where: { id: _data.root } }); if (orgRootPms) { - pmsCondition = "profileSalary.orgRoot = :orgRoot"; + pmsCondition = "profileSalary.orgRoot = :orgRoot"; } if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL"; } else if (_data.child1) { - orgChild1Pms = await this.child1Repository.findOne({where: { id: _data.child1 }}); - if (orgChild1Pms) { - pmsCondition = "profileSalary.orgChild1 = :orgChild1"; - } - if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; + orgChild1Pms = await this.child1Repository.findOne({ where: { id: _data.child1 } }); + if (orgChild1Pms) { + pmsCondition = "profileSalary.orgChild1 = :orgChild1"; + } + if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; } else if (_data.child2) { - orgChild2Pms = await this.child2Repository.findOne({where: { id: _data.child2 }}); - if (orgChild2Pms) { - pmsCondition = "profileSalary.orgChild2 = :orgChild2"; - } - if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; + orgChild2Pms = await this.child2Repository.findOne({ where: { id: _data.child2 } }); + if (orgChild2Pms) { + pmsCondition = "profileSalary.orgChild2 = :orgChild2"; + } + if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; } else if (_data.child3) { - orgChild3Pms = await this.child3Repository.findOne({where: { id: _data.child3 }}); - if (orgChild3Pms) { - pmsCondition = "profileSalary.orgChild3 = :orgChild3"; - } - if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; + orgChild3Pms = await this.child3Repository.findOne({ where: { id: _data.child3 } }); + if (orgChild3Pms) { + pmsCondition = "profileSalary.orgChild3 = :orgChild3"; + } + if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; } else if (_data.child4) { - orgChild4Pms = await this.child4Repository.findOne({where: { id: _data.child4 }}); - if (orgChild4Pms) { - pmsCondition = "profileSalary.orgChild4 = :orgChild4"; - } + orgChild4Pms = await this.child4Repository.findOne({ where: { id: _data.child4 } }); + if (orgChild4Pms) { + pmsCondition = "profileSalary.orgChild4 = :orgChild4"; + } } pmsCondition = pmsCondition + nodeAll; // const findRevision = await this.orgRevisionRepo.findOne({ @@ -1819,12 +1824,16 @@ export class ProfileEmployeeController extends Controller { // }) .where( new Brackets((qb) => { - qb.where("profileEmployee.isLeave = :isLeave", { isLeave: true }) - .orWhere("profileEmployee.isRetirement = :isRetirement", { isRetirement: true }); - }) + qb.where("profileEmployee.isLeave = :isLeave", { isLeave: true }).orWhere( + "profileEmployee.isRetirement = :isRetirement", + { isRetirement: true }, + ); + }), + ) + // .andWhere("profileEmployee.leaveCommandId Is NOT NULL") + .andWhere( + "profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileEmployeeId = profileEmployee.id)", ) - .andWhere("profileEmployee.leaveCommandId Is NOT NULL") - .andWhere("profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileEmployeeId = profileEmployee.id)") // .andWhere( // _data.root != undefined && _data.root != null @@ -1897,6 +1906,10 @@ export class ProfileEmployeeController extends Controller { ? `profileEmployee.isProbation = ${isProbation}` : "1=1", ) + .andWhere( + retireType != undefined && retireType != null ? `profile.leaveType = :retireType` : "1=1", + { retireType: retireType }, + ) .andWhere("profileEmployee.employeeClass LIKE :type", { type: "PERM", }) @@ -2018,7 +2031,12 @@ export class ProfileEmployeeController extends Controller { positionId: _data.positionIdTemp, posmasterId: _data.posmasterIdTemp, position: _data.position, - posNo: _data.profileSalary[0].posNoAbb == "" ? "" : _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == "" ? "" : _data.profileSalary[0].posNo, + posNo: + _data.profileSalary[0].posNoAbb == "" + ? "" + : _data.profileSalary[0].posNoAbb + _data.profileSalary[0].posNo == "" + ? "" + : _data.profileSalary[0].posNo, employeeClass: _data.employeeClass == null ? null : _data.employeeClass, govAge: Extension.CalculateGovAge(_data.dateAppoint, 0, 0), age: Extension.CalculateAgeStrV2(_data.birthDate, 0, 0), @@ -2082,11 +2100,20 @@ export class ProfileEmployeeController extends Controller { child4: _data.child4Temp ? _data.child4Temp : null, child4Id: _data.child4IdTemp ? _data.child4IdTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, - org: (_data.profileSalary[0].orgChild4 == null ? "" : _data.profileSalary[0].orgChild4 + "\n") + - (_data.profileSalary[0].orgChild3 == null ? "" : _data.profileSalary[0].orgChild3 + "\n") + - (_data.profileSalary[0].orgChild2 == null ? "" : _data.profileSalary[0].orgChild2 + "\n") + - (_data.profileSalary[0].orgChild1 == null ? "" : _data.profileSalary[0].orgChild1 + "\n") + - (_data.profileSalary[0].orgRoot == null ? "" : _data.profileSalary[0].orgRoot), + org: + (_data.profileSalary[0].orgChild4 == null + ? "" + : _data.profileSalary[0].orgChild4 + "\n") + + (_data.profileSalary[0].orgChild3 == null + ? "" + : _data.profileSalary[0].orgChild3 + "\n") + + (_data.profileSalary[0].orgChild2 == null + ? "" + : _data.profileSalary[0].orgChild2 + "\n") + + (_data.profileSalary[0].orgChild1 == null + ? "" + : _data.profileSalary[0].orgChild1 + "\n") + + (_data.profileSalary[0].orgRoot == null ? "" : _data.profileSalary[0].orgRoot), }; }), ); @@ -2175,11 +2202,11 @@ export class ProfileEmployeeController extends Controller { } else if (searchField == "posNo") { queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; } @@ -2339,24 +2366,24 @@ export class ProfileEmployeeController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 @@ -2400,10 +2427,10 @@ export class ProfileEmployeeController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, prefix: _data.prefix, @@ -2483,11 +2510,12 @@ export class ProfileEmployeeController extends Controller { child4: _data.child4Temp ? _data.child4Temp : null, child4Id: _data.child4IdTemp ? _data.child4IdTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), }; }), ); @@ -2708,11 +2736,11 @@ export class ProfileEmployeeController extends Controller { ) { let queryLike = ` CASE - WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) - WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) - ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) END LIKE :keyword `; @@ -2755,7 +2783,7 @@ export class ProfileEmployeeController extends Controller { holder.orgChild2?.orgChild2ShortName || holder.orgChild1?.orgChild1ShortName || holder.orgRoot?.orgRootShortName; - return `${shortName || ""}${holder.posMasterNo || ""}`; + return `${shortName || ""} ${holder.posMasterNo || ""}`; }); return profile.current_holders.map((holder, index) => { const position = holder.positions.find((position) => position.posMasterId === holder.id); @@ -2933,7 +2961,7 @@ export class ProfileEmployeeController extends Controller { amountSpecial: profile ? profile.amountSpecial : null, posNo: root?.orgRootShortName && posMaster?.posMasterNo - ? `${root?.orgRootShortName}${posMaster?.posMasterNo}` + ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` : "", }; if (_profile.child4Id != null) { @@ -2987,19 +3015,19 @@ export class ProfileEmployeeController extends Controller { const skip = (page - 1) * pageSize; const take = pageSize; let queryLike = `CONCAT( - IFNULL(orgChild4.orgChild4ShortName, ''), + IFNULL(orgChild4.orgChild4ShortName, ''), " ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild3.orgChild3ShortName, ''), + IFNULL(orgChild3.orgChild3ShortName, ''), " ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild2.orgChild2ShortName, ''), + IFNULL(orgChild2.orgChild2ShortName, ''), " ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgChild1.orgChild1ShortName, ''), + IFNULL(orgChild1.orgChild1ShortName, ''), " ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword OR CONCAT( - IFNULL(orgRoot.orgRootShortName, ''), + IFNULL(orgRoot.orgRootShortName, ''), " ", IFNULL(current_holders.posMasterNo , '') ) LIKE :keyword`; @@ -3220,24 +3248,24 @@ export class ProfileEmployeeController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -3943,24 +3971,24 @@ export class ProfileEmployeeController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; return { @@ -3973,7 +4001,7 @@ export class ProfileEmployeeController extends Controller { idcard: item.citizenId, posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName, posTypeName: item.posType == null ? null : item.posType.posTypeName, - posNo: `${posMaster == null ? null : posMaster.posMasterNo}${shortName}`, + posNo: `${shortName} ${posMaster == null ? null : posMaster.posMasterNo}`, isProbation: item.isProbation, orgRootName: item.current_holders == null || @@ -4447,23 +4475,23 @@ export class ProfileEmployeeController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holders == null || @@ -4577,8 +4605,101 @@ export class ProfileEmployeeController extends Controller { ) { const profile = await this.profileRepo.findOne({ where: { id: id }, + relations: [ + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + "current_holders.positions", + ], }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where: { + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false, + }, + }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; + const shortName = + !profile.current_holders || profile.current_holders.length == 0 + ? null + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild2 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild1 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgRoot != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` + : null; + const dest_item = await this.salaryRepo.findOne({ + where: { profileId: id }, + order: { order: "DESC" }, + }); + const data: any = { + order: dest_item == null ? 1 : dest_item.order + 1, + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, + profileEmployeeId: profile.id, + posNo: orgRevisionRef?.posMasterNo, + positionExecutive: "", + positionType: profile.posType?.posTypeName, + positionLevel: profile.posLevel?.posLevelName, + amountSpecial: profile.amountSpecial, + orgRoot: orgRootRef?.orgRootName, + orgChild1: orgChild1Ref?.orgChild1Name, + orgChild2: orgChild2Ref?.orgChild2Name, + orgChild3: orgChild3Ref?.orgChild3Name, + orgChild4: orgChild4Ref?.orgChild4Name, + commandYear: new Date().getFullYear() + 543, + commandDateSign: new Date(), + commandDateAffect: new Date(), + commandCode: "16", + commandName: "พ้นจากราชการ", + posNoAbb: shortName, + isEntry: false, + positionName: profile.position, + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }; + delete data.id; + + const history = new ProfileSalaryHistory(); + Object.assign(history, { ...data, id: undefined }); + data.dateGovernment = data.createdAt; + await this.salaryRepo.save(data); + history.profileSalaryId = data.id; + await this.salaryHistoryRepo.save(history); + let _null: any = null; profile.isLeave = requestBody.isLeave; profile.leaveReason = requestBody.leaveReason; @@ -4597,6 +4718,7 @@ export class ProfileEmployeeController extends Controller { profile.isActive = false; } } + profile.leaveType = "RETIRE_DECEASED"; await this.profileRepo.save(profile); @@ -5068,24 +5190,24 @@ export class ProfileEmployeeController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -5236,26 +5358,26 @@ export class ProfileEmployeeController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : null; const _profile: any = { profileId: profile.id, diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 9e748964..c49d1cbc 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -67,6 +67,7 @@ import { ProfileLeave } from "../entities/ProfileLeave"; import permission from "../interfaces/permission"; import axios from "axios"; import { deleteUser } from "../keycloak"; +import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; @Route("api/v1/org/profile-temp") @Tags("ProfileEmployee") @Security("bearerAuth") @@ -92,6 +93,7 @@ export class ProfileEmployeeTempController extends Controller { private trainingRepository = AppDataSource.getRepository(ProfileTraining); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private salaryRepo = AppDataSource.getRepository(ProfileSalary); + private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory); private orgRootRepository = AppDataSource.getRepository(OrgRoot); private child1Repository = AppDataSource.getRepository(OrgChild1); private child2Repository = AppDataSource.getRepository(OrgChild2); @@ -218,10 +220,10 @@ export class ProfileEmployeeTempController extends Controller { ? ` รหัสไปรษณีย์ ${profile.registrationZipCode}` : ""; let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const salary_raw = await this.salaryRepo.find({ // select: [ @@ -256,17 +258,18 @@ export class ProfileEmployeeTempController extends Controller { : null, position: Extension.ToThaiNumber( Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? (item.positionCee??"") : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee ?? "" : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, ), ), posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", - orgRoot: item.orgRoot != null ? Extension.ToThaiNumber( item.orgRoot) : "", - orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber( item.orgChild1) : "", - orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber( item.orgChild2) : "", - orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber( item.orgChild3) : "", - orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber( item.orgChild4) : "", - positionCee: item.positionCee != null ? Extension.ToThaiNumber( item.positionCee) : "", - positionExecutive: item.positionExecutive != null ? Extension.ToThaiNumber( item.positionExecutive) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber(item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber(item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber(item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber(item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber(item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber(item.positionCee) : "", + positionExecutive: + item.positionExecutive != null ? Extension.ToThaiNumber(item.positionExecutive) : "", })) : [ { @@ -342,7 +345,7 @@ export class ProfileEmployeeTempController extends Controller { salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? (salary_raw[0].positionCee??"") : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee ?? "" : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, ), ) : "", @@ -375,11 +378,12 @@ export class ProfileEmployeeTempController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) : "" }`, - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), educations: Education, salarys: salarys.map((item) => { return { @@ -534,11 +538,10 @@ export class ProfileEmployeeTempController extends Controller { // Construct org path let _root = root?.orgRootName; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; - + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ where: { profileEmployeeId: id }, @@ -693,11 +696,12 @@ export class ProfileEmployeeTempController extends Controller { ? null : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - OcFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + OcFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), })) : [ { @@ -786,11 +790,12 @@ export class ProfileEmployeeTempController extends Controller { prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", - ocFullPath: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), + ocFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) : "", @@ -836,8 +841,7 @@ export class ProfileEmployeeTempController extends Controller { profiles.currentProvince != null ? Extension.ToThaiNumber(profiles.currentProvince.name) : "", - telephone: - profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", + telephone: profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.phone) : "", url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url1: _ImgUrl[0] ? _ImgUrl[0] : null, yearUpload1: profiles.profileAvatars[0] @@ -1074,15 +1078,15 @@ export class ProfileEmployeeTempController extends Controller { _data.current_holders.length == 0 ? null : _data.current_holders[0].orgChild4 != null - ? `${_data.current_holders[0].orgChild4.orgChild4ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild4.orgChild4ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild3 != null - ? `${_data.current_holders[0].orgChild3.orgChild3ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild3.orgChild3ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild2 != null - ? `${_data.current_holders[0].orgChild2.orgChild2ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild2.orgChild2ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgChild1 != null - ? `${_data.current_holders[0].orgChild1.orgChild1ShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgChild1.orgChild1ShortName} ${_data.current_holders[0].posMasterNo}` : _data.current_holders[0].orgRoot != null - ? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}` + ? `${_data.current_holders[0].orgRoot.orgRootShortName} ${_data.current_holders[0].posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 @@ -1241,24 +1245,24 @@ export class ProfileEmployeeTempController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -1288,7 +1292,7 @@ export class ProfileEmployeeTempController extends Controller { salaryLevel: profile.salaryLevel, group: profile.group, ethnicity: profile.ethnicity, - telephoneNumber: profile.telephoneNumber, + telephoneNumber: profile.phone, nationality: profile.nationality, gender: profile.gender, relationship: profile.relationship, @@ -1333,15 +1337,15 @@ export class ProfileEmployeeTempController extends Controller { const formattedData = profiles.map((profile) => { const shortName = profile.child4Temp != null - ? `${profile.child4ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child4ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child3Temp != null - ? `${profile.child3ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child3ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child2Temp != null - ? `${profile.child2ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child2ShortNameTemp} ${profile.posMasterNoTemp}` : profile.child1Temp != null - ? `${profile.child1ShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.child1ShortNameTemp} ${profile.posMasterNoTemp}` : profile.rootIdTemp != null - ? `${profile.rootShortNameTemp}${profile.posMasterNoTemp}` + ? `${profile.rootShortNameTemp} ${profile.posMasterNoTemp}` : null; return { @@ -1540,24 +1544,24 @@ export class ProfileEmployeeTempController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 @@ -1720,39 +1724,39 @@ export class ProfileEmployeeTempController extends Controller { : "1=1", { keyword: `%${requestBody.keyword}%`, - }) - .orWhere( - requestBody.keyword != null && requestBody.keyword != "" - ? "profileEmployee.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${requestBody.keyword}%`, - }, - ) - // .orWhere( - // requestBody.keyword != null && requestBody.keyword != "" - // ? "profileEmployee.position LIKE :keyword" - // : "1=1", - // { - // keyword: `%${requestBody.keyword}%`, - // }, - // ) - // .orWhere( - // requestBody.keyword != null && requestBody.keyword != "" - // ? "posType.posTypeName LIKE :keyword" - // : "1=1", - // { - // keyword: `%${requestBody.keyword}%`, - // }, - // ) - // .orWhere( - // requestBody.keyword != null && requestBody.keyword != "" - // ? `CONCAT(posType.posTypeShortName," ",posLevel.posLevelName) LIKE :keyword` - // : "1=1", - // { - // keyword: `%${requestBody.keyword}%`, - // }, - // ); + }, + ).orWhere( + requestBody.keyword != null && requestBody.keyword != "" + ? "profileEmployee.citizenId LIKE :keyword" + : "1=1", + { + keyword: `%${requestBody.keyword}%`, + }, + ); + // .orWhere( + // requestBody.keyword != null && requestBody.keyword != "" + // ? "profileEmployee.position LIKE :keyword" + // : "1=1", + // { + // keyword: `%${requestBody.keyword}%`, + // }, + // ) + // .orWhere( + // requestBody.keyword != null && requestBody.keyword != "" + // ? "posType.posTypeName LIKE :keyword" + // : "1=1", + // { + // keyword: `%${requestBody.keyword}%`, + // }, + // ) + // .orWhere( + // requestBody.keyword != null && requestBody.keyword != "" + // ? `CONCAT(posType.posTypeShortName," ",posLevel.posLevelName) LIKE :keyword` + // : "1=1", + // { + // keyword: `%${requestBody.keyword}%`, + // }, + // ); }), ) .andWhere( @@ -2130,24 +2134,24 @@ export class ProfileEmployeeTempController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -3087,23 +3091,23 @@ export class ProfileEmployeeTempController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holders == null || @@ -3220,15 +3224,109 @@ export class ProfileEmployeeTempController extends Controller { // await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน const profile = await this.profileRepo.findOne({ where: { id: id }, + relations: [ + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + "current_holders.positions", + ], }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - let _null:any = null; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where: { + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false, + }, + }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; + const orgRootRef = orgRevisionRef?.orgRoot ?? null; + const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; + const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; + const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; + const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; + const shortName = + !profile.current_holders || profile.current_holders.length == 0 + ? null + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 != + null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild2 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild1 != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` + : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgRoot != null + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` + : null; + const dest_item = await this.salaryRepo.findOne({ + where: { profileId: id }, + order: { order: "DESC" }, + }); + const data: any = { + order: dest_item == null ? 1 : dest_item.order + 1, + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, + profileEmployeeId: profile.id, + posNo: orgRevisionRef?.posMasterNo, + positionExecutive: "", + positionType: profile.posType?.posTypeName, + positionLevel: profile.posLevel?.posLevelName, + amountSpecial: profile.amountSpecial, + orgRoot: orgRootRef?.orgRootName, + orgChild1: orgChild1Ref?.orgChild1Name, + orgChild2: orgChild2Ref?.orgChild2Name, + orgChild3: orgChild3Ref?.orgChild3Name, + orgChild4: orgChild4Ref?.orgChild4Name, + commandYear: new Date().getFullYear() + 543, + commandDateSign: new Date(), + commandDateAffect: new Date(), + commandCode: "16", + commandName: "พ้นจากราชการ", + posNoAbb: shortName, + isEntry: false, + positionName: profile.position, + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }; + delete data.id; + + const history = new ProfileSalaryHistory(); + Object.assign(history, { ...data, id: undefined }); + data.dateGovernment = data.createdAt; + await this.salaryRepo.save(data); + history.profileSalaryId = data.id; + await this.salaryHistoryRepo.save(history); + + let _null: any = null; profile.isLeave = requestBody.isLeave; profile.leaveReason = requestBody.leaveReason; profile.dateLeave = requestBody.dateLeave; if (requestBody.isLeave == true) { await removeProfileInOrganize(profile.id, "EMPLOYEE"); } + profile.leaveType = "RETIRE_DECEASED"; profile.position = _null; profile.posLevelId = _null; @@ -3671,24 +3769,24 @@ export class ProfileEmployeeTempController extends Controller { : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && item.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = @@ -3829,26 +3927,26 @@ export class ProfileEmployeeTempController extends Controller { : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild4 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild3 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild2 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgChild1 != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?.orgRoot != null - ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` + ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : null; const _profile: any = { profileId: profile.id, diff --git a/src/controllers/ProfileSalaryTempController.ts b/src/controllers/ProfileSalaryTempController.ts index a8ae1c94..7070913e 100644 --- a/src/controllers/ProfileSalaryTempController.ts +++ b/src/controllers/ProfileSalaryTempController.ts @@ -30,7 +30,10 @@ import { ProfileEmployee } from "../entities/ProfileEmployee"; import permission from "../interfaces/permission"; import { OrgRevision } from "../entities/OrgRevision"; import Extension from "../interfaces/extension"; -import { CreatePositionSalaryEditHistory, PositionSalaryEditHistory } from "../entities/PositionSalaryEditHistory"; +import { + CreatePositionSalaryEditHistory, + PositionSalaryEditHistory, +} from "../entities/PositionSalaryEditHistory"; @Route("api/v1/org/profile/salaryTemp") @Tags("ProfileSalaryTemp") @@ -157,67 +160,67 @@ export class ProfileSalaryTempController extends Controller { ? `profile.citizenId like '%${searchKeyword}%'` : "1=1", ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `profile.position like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `posType.posTypeName like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `posLevel.posLevelName like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT( + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `profile.position like '%${searchKeyword}%'` + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${searchKeyword}%'` + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `posType.posTypeName like '%${searchKeyword}%'` + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `posLevel.posLevelName like '%${searchKeyword}%'` + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT( orgRoot.orgRootShortName, current_holders.posMasterNo ) like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT( + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT( orgRoot.orgRootShortName, orgChild1.orgChild1ShortName, current_holders.posMasterNo ) like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT( + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT( orgRoot.orgRootShortName, orgChild1.orgChild1ShortName, orgChild2.orgChild2ShortName, current_holders.posMasterNo ) like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT( + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT( orgRoot.orgRootShortName, orgChild1.orgChild1ShortName, orgChild2.orgChild2ShortName, orgChild3.orgChild3ShortName, current_holders.posMasterNo ) like '%${searchKeyword}%'` - : "1=1", - ) - .orWhere( - searchKeyword != null && searchKeyword != "" - ? `CONCAT( + : "1=1", + ) + .orWhere( + searchKeyword != null && searchKeyword != "" + ? `CONCAT( orgRoot.orgRootShortName, orgChild1.orgChild1ShortName, orgChild2.orgChild2ShortName, @@ -225,8 +228,8 @@ export class ProfileSalaryTempController extends Controller { orgChild4.orgChild4ShortName, current_holders.posMasterNo ) like '%${searchKeyword}%'` - : "1=1", - ); + : "1=1", + ); }), ) // .andWhere( @@ -251,7 +254,7 @@ export class ProfileSalaryTempController extends Controller { .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); - + const data = await Promise.all( record.map((_data) => { const posExecutive = @@ -277,25 +280,25 @@ export class ProfileSalaryTempController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = _data.current_holders.length == 0 || @@ -333,10 +336,10 @@ export class ProfileSalaryTempController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, @@ -358,11 +361,12 @@ export class ProfileSalaryTempController extends Controller { root: root == null ? null : root.orgRootName, orgRootShortName: root == null ? null : root.orgRootShortName, orgRevisionId: root == null ? null : root.orgRevisionId, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (root?.orgRootName == null ? "" : root?.orgRootName), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (root?.orgRootName == null ? "" : root?.orgRootName), statusCheckEdit: _data.statusCheckEdit, type: "OFFICER", }; @@ -486,25 +490,25 @@ export class ProfileSalaryTempController extends Controller { : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild4 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild3 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild2 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgChild1 != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) ?.orgRoot != null - ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` + ? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 @@ -548,10 +552,10 @@ export class ProfileSalaryTempController extends Controller { ? null : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; - let _child1 =child1?.orgChild1Name; - let _child2 =child2?.orgChild2Name; - let _child3 =child3?.orgChild3Name; - let _child4 =child4?.orgChild4Name; + let _child1 = child1?.orgChild1Name; + let _child2 = child2?.orgChild2Name; + let _child3 = child3?.orgChild3Name; + let _child4 = child4?.orgChild4Name; return { id: _data.id, prefix: _data.prefix, @@ -631,11 +635,12 @@ export class ProfileSalaryTempController extends Controller { child4: _data.child4Temp ? _data.child4Temp : null, child4Id: _data.child4IdTemp ? _data.child4IdTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, - org: (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (root?.orgRootName == null ? "" : root?.orgRootName), + org: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (root?.orgRootName == null ? "" : root?.orgRootName), statusCheckEdit: _data.statusCheckEdit, type: "EMPLOYEE", }; @@ -1149,33 +1154,36 @@ export class ProfileSalaryTempController extends Controller { let profile = null; let profileEmployee = null; profile = await this.profileRepo.findOneBy({ id: profileId }); - + if (!profile) { - profileEmployee = await this.profileEmployeeRepo.findOneBy({ id: profileId }); - if (!profileEmployee) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } + profileEmployee = await this.profileEmployeeRepo.findOneBy({ id: profileId }); + if (!profileEmployee) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } } - + try { - if (profile) { - profile.statusCheckEdit = "PENDING"; - await this.profileRepo.save(profile); - } else if (profileEmployee) { - profileEmployee.statusCheckEdit = "PENDING"; - await this.profileEmployeeRepo.save(profileEmployee); - } - - const history : PositionSalaryEditHistory = Object.assign(new PositionSalaryEditHistory(), body); - if (profile) { - history.profileId = profileId; - } else if (profileEmployee) { - history.profileEmployeeId = profileId; - } - history.returnedDate = new Date(); - history.examinerName = req.user.name; - history.createdFullName = req.user.name; - history.lastUpdateFullName = req.user.name; + if (profile) { + profile.statusCheckEdit = "PENDING"; + await this.profileRepo.save(profile); + } else if (profileEmployee) { + profileEmployee.statusCheckEdit = "PENDING"; + await this.profileEmployeeRepo.save(profileEmployee); + } + + const history: PositionSalaryEditHistory = Object.assign( + new PositionSalaryEditHistory(), + body, + ); + if (profile) { + history.profileId = profileId; + } else if (profileEmployee) { + history.profileEmployeeId = profileId; + } + history.returnedDate = new Date(); + history.examinerName = req.user.name; + history.createdFullName = req.user.name; + history.lastUpdateFullName = req.user.name; await this.positionSalaryEditHistoryRepo.save(history); return new HttpSuccess(); @@ -1191,24 +1199,21 @@ export class ProfileSalaryTempController extends Controller { * */ @Get("return-edit/history/{profileId}") - public async returnEditHistory( - @Path() profileId: string, - ) { - try{ - + public async returnEditHistory(@Path() profileId: string) { + try { let history = await this.positionSalaryEditHistoryRepo.find({ - where:{ profileId: profileId }, - order: { returnedDate: "DESC" } + where: { profileId: profileId }, + order: { returnedDate: "DESC" }, }); //EMP - if(!history){ + if (!history) { history = await this.positionSalaryEditHistoryRepo.find({ - where:{ profileEmployeeId: profileId }, - order: { returnedDate: "DESC" } + where: { profileEmployeeId: profileId }, + order: { returnedDate: "DESC" }, }); } - + return new HttpSuccess(history); } catch { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้"); diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 63564aba..5e10f7bc 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -198,7 +198,7 @@ export class ProfileSalary extends EntityBase { @Column({ nullable: true, - length: 255, + type: "text", comment: "หมายเหตุ", default: null, }) @@ -226,7 +226,7 @@ export class ProfileSalary extends EntityBase { isGovernment: boolean; @Column({ - nullable: true, + nullable: false, comment: "ข้อมูลจาก Entry", default: null, }) diff --git a/src/entities/ProfileSalaryHistory.ts b/src/entities/ProfileSalaryHistory.ts index bd6f54c6..17b8d880 100644 --- a/src/entities/ProfileSalaryHistory.ts +++ b/src/entities/ProfileSalaryHistory.ts @@ -178,7 +178,7 @@ export class ProfileSalaryHistory extends EntityBase { @Column({ nullable: true, - length: 255, + type: "text", comment: "หมายเหตุ", default: null, }) diff --git a/src/entities/ProfileSalaryTemp.ts b/src/entities/ProfileSalaryTemp.ts index f322045b..8be61bd1 100644 --- a/src/entities/ProfileSalaryTemp.ts +++ b/src/entities/ProfileSalaryTemp.ts @@ -211,7 +211,7 @@ export class ProfileSalaryTemp extends EntityBase { @Column({ nullable: true, - length: 255, + type: "text", comment: "หมายเหตุ", default: null, }) @@ -293,7 +293,6 @@ export class ProfileSalaryTemp extends EntityBase { }) posNumCodeSitAbb: string; - @ManyToOne(() => ProfileSalary, (profileSalary) => profileSalary.profileSalaryTemps) @JoinColumn({ name: "salaryId" }) profileSalary: ProfileSalary;