แก้ format ฟิว posMasterNo (2)

This commit is contained in:
Adisak 2026-05-21 14:23:59 +07:00
parent 6afac07f74
commit 69a7ddaaa3
3 changed files with 27 additions and 27 deletions

View file

@ -1058,11 +1058,11 @@ export class EmployeePositionController extends Controller {
let checkChildConditions: any = {}; let checkChildConditions: any = {};
let keywordAsInt: any; let keywordAsInt: any;
let searchShortName = "1=1"; let searchShortName = "1=1";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`; let searchShortName0 = `CONCAT_WS(" ",orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`; let searchShortName1 = `CONCAT_WS(" ",orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`; let searchShortName2 = `CONCAT_WS(" ",orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`; let searchShortName3 = `CONCAT_WS(" ",orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`; let searchShortName4 = `CONCAT_WS(" ",orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_EMP"); let _data = await new permission().PermissionOrgList(request, "SYS_ORG_EMP");
if (body.type === 0) { if (body.type === 0) {
typeCondition = { typeCondition = {
@ -1072,7 +1072,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild1Id: IsNull(), orgChild1Id: IsNull(),
}; };
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; searchShortName = `CONCAT_WS(" ",orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
} else if (body.type === 1) { } else if (body.type === 1) {
@ -1083,7 +1083,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild2Id: IsNull(), orgChild2Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; searchShortName = `CONCAT_WS(" ",orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
} else if (body.type === 2) { } else if (body.type === 2) {
@ -1094,7 +1094,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild3Id: IsNull(), orgChild3Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; searchShortName = `CONCAT_WS(" ",orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
} else if (body.type === 3) { } else if (body.type === 3) {
@ -1105,14 +1105,14 @@ export class EmployeePositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild4Id: IsNull(), orgChild4Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; searchShortName = `CONCAT_WS(" ",orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else { } else {
} }
} else if (body.type === 4) { } else if (body.type === 4) {
typeCondition = { typeCondition = {
orgChild4Id: body.id, orgChild4Id: body.id,
}; };
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`; searchShortName = `CONCAT_WS(" ",orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
let findPosition: any; let findPosition: any;
let masterId = new Array(); let masterId = new Array();

View file

@ -2853,11 +2853,11 @@ export class ProfileEmployeeController extends Controller {
} else if (searchField == "posNo") { } else if (searchField == "posNo") {
queryLike = ` queryLike = `
CASE CASE
WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT_WS(" ", orgChild4.orgChild4ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT_WS(" ", orgChild3.orgChild3ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT_WS(" ", orgChild2.orgChild2ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT_WS(" ", orgChild1.orgChild1ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) ELSE CONCAT_WS(" ", orgRoot.orgRootShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
END LIKE :keyword END LIKE :keyword
`; `;
} }
@ -3212,11 +3212,11 @@ export class ProfileEmployeeController extends Controller {
} else if (searchField == "posNo") { } else if (searchField == "posNo") {
queryLike = ` queryLike = `
CASE CASE
WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT_WS(" ", orgChild4.orgChild4ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT_WS(" ", orgChild3.orgChild3ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT_WS(" ", orgChild2.orgChild2ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, " ", current_holders.posMasterNo) WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT_WS(" ", orgChild1.orgChild1ShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
ELSE CONCAT(orgRoot.orgRootShortName, " ", current_holders.posMasterNo) ELSE CONCAT_WS(" ", orgRoot.orgRootShortName, current_holders.posMasterNoPrefix, current_holders.posMasterNo, current_holders.posMasterNoSuffix)
END LIKE :keyword END LIKE :keyword
`; `;
} }
@ -3369,7 +3369,7 @@ export class ProfileEmployeeController extends Controller {
const data = await Promise.all( const data = await Promise.all(
record.map((_data) => { record.map((_data) => {
const holder = _data.current_holders.find((x) => x.orgRevisionId == findRevision.id); const holder = _data.current_holders.find((x) => x.orgRevisionId == findRevision.id);
const numPart = holder ? `${holder.posMasterNoPrefix ?? ''}${holder.posMasterNo ?? ''}${holder.posMasterNoSuffix ?? ''}` : ''; const numPart = holder ? [holder.posMasterNoPrefix, holder.posMasterNo, holder.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
const shortName = !holder const shortName = !holder
? null ? null
: holder.orgChild4 != null : holder.orgChild4 != null
@ -3846,7 +3846,7 @@ export class ProfileEmployeeController extends Controller {
holder.orgChild2?.orgChild2ShortName || holder.orgChild2?.orgChild2ShortName ||
holder.orgChild1?.orgChild1ShortName || holder.orgChild1?.orgChild1ShortName ||
holder.orgRoot?.orgRootShortName; holder.orgRoot?.orgRootShortName;
return `${shortName || ""} ${holder.posMasterNo || ""}`; return `${shortName || ""} ${[holder.posMasterNoPrefix, holder.posMasterNo, holder.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ')}`;
}); });
return profile.current_holders.map((holder, index) => { return profile.current_holders.map((holder, index) => {
const position = holder.positions.find((position) => position.posMasterId === holder.id); const position = holder.positions.find((position) => position.posMasterId === holder.id);

View file

@ -115,7 +115,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
record.posType == null && record.posLevel == null record.posType == null && record.posLevel == null
? null ? null
: `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ : `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNoPrefix ?? ''}${posMaster.posMasterNo ?? ''}${posMaster.posMasterNoSuffix ?? ''}`, //เลขที่ตำแหน่ง posMasterNo: posMaster == null ? null : `${orgShortName} ${[posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ')}`, //เลขที่ตำแหน่ง
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
dateRetireLaw: record.dateRetireLaw ?? null, dateRetireLaw: record.dateRetireLaw ?? null,
@ -281,7 +281,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
record?.isLeave == false record?.isLeave == false
? posMaster == null ? posMaster == null
? null ? null
: `${orgShortName} ${posMaster.posMasterNoPrefix ?? ''}${posMaster.posMasterNo ?? ''}${posMaster.posMasterNoSuffix ?? ''}` : `${orgShortName} ${[posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ')}`
: posNoLeave /*record && record?.profileSalary.length > 0 : posNoLeave /*record && record?.profileSalary.length > 0
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}` ? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
: null*/, // : null*/, //
@ -441,7 +441,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
record?.isLeave == false record?.isLeave == false
? posMaster == null ? posMaster == null
? null ? null
: `${orgShortName} ${posMaster.posMasterNoPrefix ?? ''}${posMaster.posMasterNo ?? ''}${posMaster.posMasterNoSuffix ?? ''}` : `${orgShortName} ${[posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ')}`
: posNoLeave /*record && record.profileSalary.length > 0 : posNoLeave /*record && record.profileSalary.length > 0
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}` ? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
: null*/, // : null*/, //