เปลี่ยนปีคศเป็นพศคำสั่งช่วยราชการ (:4845)

This commit is contained in:
Adisak 2026-05-05 12:02:40 +07:00
parent fd7a2af0a1
commit 8ad480baae

View file

@ -226,7 +226,7 @@ export class CommandController extends Controller {
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
`current_holders.orgChild1Id is null` `current_holders.orgChild1Id is null`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -304,7 +304,7 @@ export class CommandController extends Controller {
status == null || status == undefined || status == "" status == null || status == undefined || status == ""
? null ? null
: status.trim().toLocaleUpperCase() == "NEW" || : status.trim().toLocaleUpperCase() == "NEW" ||
status.trim().toLocaleUpperCase() == "DRAFT" status.trim().toLocaleUpperCase() == "DRAFT"
? ["NEW", "DRAFT"] ? ["NEW", "DRAFT"]
: [status.trim().toLocaleUpperCase()], : [status.trim().toLocaleUpperCase()],
}, },
@ -805,8 +805,8 @@ export class CommandController extends Controller {
.PostData(request, path + "/delete", { .PostData(request, path + "/delete", {
refIds: [commandRecive.refId], refIds: [commandRecive.refId],
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
const commandId = commandRecive.commandId; const commandId = commandRecive.commandId;
await this.commandReciveRepository.delete(commandRecive.id); await this.commandReciveRepository.delete(commandRecive.id);
@ -849,8 +849,8 @@ export class CommandController extends Controller {
.PostData(request, path + "/delete", { .PostData(request, path + "/delete", {
refIds: [commandRecive.refId], refIds: [commandRecive.refId],
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
const commandId = commandRecive.commandId; const commandId = commandRecive.commandId;
await this.commandReciveRepository.delete(commandRecive.id); await this.commandReciveRepository.delete(commandRecive.id);
@ -893,8 +893,8 @@ export class CommandController extends Controller {
.PostData(request, path + "/delete", { .PostData(request, path + "/delete", {
refIds: [commandRecive.refId], refIds: [commandRecive.refId],
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
const commandId = commandRecive.commandId; const commandId = commandRecive.commandId;
await this.commandReciveRepository.delete(commandRecive.id); await this.commandReciveRepository.delete(commandRecive.id);
@ -1178,8 +1178,8 @@ export class CommandController extends Controller {
.PostData(request, path + "/delete", { .PostData(request, path + "/delete", {
refIds: command.commandRecives.map((x) => x.refId), refIds: command.commandRecives.map((x) => x.refId),
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
await this.commandReciveRepository.delete({ commandId: command.id }); await this.commandReciveRepository.delete({ commandId: command.id });
command.status = "CANCEL"; command.status = "CANCEL";
@ -1244,8 +1244,8 @@ export class CommandController extends Controller {
.PostData(request, path + "/delete", { .PostData(request, path + "/delete", {
refIds: command.commandRecives.map((x) => x.refId), refIds: command.commandRecives.map((x) => x.refId),
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) }); await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) });
await this.commandReciveRepository.delete({ commandId: command.id }); await this.commandReciveRepository.delete({ commandId: command.id });
@ -1398,11 +1398,11 @@ export class CommandController extends Controller {
let profiles = let profiles =
command && command.commandRecives.length > 0 command && command.commandRecives.length > 0
? command.commandRecives ? command.commandRecives
.filter((x) => x.profileId != null) .filter((x) => x.profileId != null)
.map((x) => ({ .map((x) => ({
receiverUserId: x.profileId, receiverUserId: x.profileId,
notiLink: "", notiLink: "",
})) }))
: []; : [];
const msgNoti = { const msgNoti = {
@ -1434,8 +1434,8 @@ export class CommandController extends Controller {
refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId), refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId),
status: "WAITING", status: "WAITING",
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
await this.commandRepository.save(command); await this.commandRepository.save(command);
} else { } else {
const path = commandTypePath(command.commandType.code); const path = commandTypePath(command.commandType.code);
@ -1572,7 +1572,7 @@ export class CommandController extends Controller {
); );
await this.profileRepository.save(profiles); await this.profileRepository.save(profiles);
} }
} catch {} } catch { }
type = "EMPLOYEE"; type = "EMPLOYEE";
try { try {
@ -1604,7 +1604,7 @@ export class CommandController extends Controller {
); );
await this.profileEmployeeRepository.save(profiles); await this.profileEmployeeRepository.save(profiles);
} }
} catch {} } catch { }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1670,7 +1670,7 @@ export class CommandController extends Controller {
}), }),
); );
} }
} catch {} } catch { }
type = "EMPLOYEE"; type = "EMPLOYEE";
try { try {
@ -1727,7 +1727,7 @@ export class CommandController extends Controller {
}), }),
); );
} }
} catch {} } catch { }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1940,7 +1940,7 @@ export class CommandController extends Controller {
.then((x) => { .then((x) => {
res = x; res = x;
}) })
.catch((x) => {}); .catch((x) => { });
} }
let _command; let _command;
@ -2018,76 +2018,76 @@ export class CommandController extends Controller {
profile?.current_holders.length == 0 profile?.current_holders.length == 0
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
null && null &&
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild4 != null ?.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) != : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
null && null &&
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild3 != null ?.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( : profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id, (x) => x.orgRevisionId == orgRevisionActive?.id,
) != null && ) != null &&
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
?.orgChild2 != null ?.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( : profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id, (x) => x.orgRevisionId == orgRevisionActive?.id,
) != null && ) != null &&
profile?.current_holders.find( profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id, (x) => x.orgRevisionId == orgRevisionActive?.id,
)?.orgChild1 != null )?.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( : profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id, (x) => x.orgRevisionId == orgRevisionActive?.id,
) != null && ) != null &&
profile?.current_holders.find( profile?.current_holders.find(
(x) => x.orgRevisionId == orgRevisionActive?.id, (x) => x.orgRevisionId == orgRevisionActive?.id,
)?.orgRoot != null )?.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; : null;
const root = const root =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgRoot; ?.orgRoot;
const child1 = const child1 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1; ?.orgChild1;
const child2 = const child2 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2; ?.orgChild2;
const child3 = const child3 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild3; ?.orgChild3;
const child4 = const child4 =
profile?.current_holders == null || profile?.current_holders == null ||
profile?.current_holders.length == 0 || profile?.current_holders.length == 0 ||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
? null ? null
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild4; ?.orgChild4;
let _root = root?.orgRootName; let _root = root?.orgRootName;
let _child1 = child1?.orgChild1Name; let _child1 = child1?.orgChild1Name;
@ -2148,10 +2148,10 @@ export class CommandController extends Controller {
commandCode != "C-PM-21" commandCode != "C-PM-21"
? profile?.isLeave == false ? profile?.isLeave == false
? (_child4 == null ? "" : _child4 + "\n") + ? (_child4 == null ? "" : _child4 + "\n") +
(_child3 == null ? "" : _child3 + "\n") + (_child3 == null ? "" : _child3 + "\n") +
(_child2 == null ? "" : _child2 + "\n") + (_child2 == null ? "" : _child2 + "\n") +
(_child1 == null ? "" : _child1 + "\n") + (_child1 == null ? "" : _child1 + "\n") +
(_root == null ? "" : _root) (_root == null ? "" : _root)
: orgLeave : orgLeave
: profileTemp.org, : profileTemp.org,
fullName: `${x.prefix}${x.firstName} ${x.lastName}`, fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
@ -2166,8 +2166,8 @@ export class CommandController extends Controller {
commandCode != "C-PM-21" commandCode != "C-PM-21"
? profile?.posType && profile?.posLevel ? profile?.posType && profile?.posLevel
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`, `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
) )
: "-" : "-"
: Extension.ToThaiNumber(profileTemp.posLevel), : Extension.ToThaiNumber(profileTemp.posLevel),
posNo: posNo:
@ -2181,19 +2181,19 @@ export class CommandController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
: profile?.birthDate && commandCode == "C-PM-21" : profile?.birthDate && commandCode == "C-PM-21"
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear( Extension.ToThaiShortDate_monthYear(
new Date( new Date(
profile.birthDate.getFullYear() + 60, profile.birthDate.getFullYear() + 60,
profile.birthDate.getMonth(), profile.birthDate.getMonth(),
profile.birthDate.getDate(), profile.birthDate.getDate(),
),
), ),
) ),
)
: "-", : "-",
dateExecute: command.commandExcecuteDate dateExecute: command.commandExcecuteDate
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate), Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate),
) )
: "-", : "-",
remark: x.remarkVertical ? x.remarkVertical : "-", remark: x.remarkVertical ? x.remarkVertical : "-",
}; };
@ -2294,7 +2294,7 @@ export class CommandController extends Controller {
.then(async (res) => { .then(async (res) => {
_command = res; _command = res;
}) })
.catch(() => {}); .catch(() => { });
let issue = let issue =
command.isBangkok == "OFFICE" command.isBangkok == "OFFICE"
@ -2352,15 +2352,15 @@ export class CommandController extends Controller {
operators: operators:
operators.length > 0 operators.length > 0
? operators.map((x) => ({ ? operators.map((x) => ({
fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`, fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`,
roleName: x.roleName, roleName: x.roleName,
})) }))
: [ : [
{ {
fullName: "", fullName: "",
roleName: "เจ้าหน้าที่ดำเนินการ", roleName: "เจ้าหน้าที่ดำเนินการ",
}, },
], ],
}, },
}); });
} }
@ -2696,23 +2696,23 @@ export class CommandController extends Controller {
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
if (!["C-PM-26", "C-PM-25"].includes(commandCode)) { if (!["C-PM-26", "C-PM-25"].includes(commandCode)) {
await new CallAPI() await new CallAPI()
.PostData(request, path, { .PostData(request, path, {
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId), refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
status: "REPORT", status: "REPORT",
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
} }
else { else {
await new CallAPI() await new CallAPI()
.PostData(request, path, { .PostData(request, path, {
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId), refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
status: "REPORT", status: "REPORT",
commandTypeId: requestBody.commandTypeId, commandTypeId: requestBody.commandTypeId,
commandCode: commandCode, commandCode: commandCode,
}) })
.then(async (res) => {}) .then(async (res) => { })
.catch(() => {}); .catch(() => { });
} }
let order = let order =
command.commandRecives == null || command.commandRecives.length <= 0 command.commandRecives == null || command.commandRecives.length <= 0
@ -3486,27 +3486,27 @@ export class CommandController extends Controller {
? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName ? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName
: x.orgChild3 == null : x.orgChild3 == null
? x.orgChild2.orgChild2Name + ? x.orgChild2.orgChild2Name +
"\n" +
x.orgChild1.orgChild1Name +
"\n" +
x.orgRoot.orgRootName
: x.orgChild4 == null
? x.orgChild3.orgChild3Name +
"\n" +
x.orgChild2.orgChild2Name +
"\n" + "\n" +
x.orgChild1.orgChild1Name + x.orgChild1.orgChild1Name +
"\n" + "\n" +
x.orgRoot.orgRootName x.orgRoot.orgRootName
: x.orgChild4 == null
? x.orgChild3.orgChild3Name +
"\n" +
x.orgChild2.orgChild2Name +
"\n" +
x.orgChild1.orgChild1Name +
"\n" +
x.orgRoot.orgRootName
: x.orgChild4.orgChild4Name + : x.orgChild4.orgChild4Name +
"\n" + "\n" +
x.orgChild3.orgChild3Name + x.orgChild3.orgChild3Name +
"\n" + "\n" +
x.orgChild2.orgChild2Name + x.orgChild2.orgChild2Name +
"\n" + "\n" +
x.orgChild1.orgChild1Name + x.orgChild1.orgChild1Name +
"\n" + "\n" +
x.orgRoot.orgRootName, x.orgRoot.orgRootName,
positionName: x?.current_holder.position ?? _null, positionName: x?.current_holder.position ?? _null,
profileId: x?.current_holder.id ?? _null, profileId: x?.current_holder.id ?? _null,
}); });
@ -3725,7 +3725,7 @@ export class CommandController extends Controller {
// อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit // อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
profile.posMasterNo = getPosMasterNo(posMaster); profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster); profile.org = getOrgFullName(posMaster);
if(!posMaster.isSit){ if (!posMaster.isSit) {
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
profile.position = positionNew.positionName; profile.position = positionNew.positionName;
@ -4842,7 +4842,7 @@ export class CommandController extends Controller {
agency: item.officerOrg, agency: item.officerOrg,
dateStart: item.dateStart, dateStart: item.dateStart,
dateEnd: item.dateEnd, dateEnd: item.dateEnd,
commandNo: `${item.commandNo}/${item.commandYear}`, commandNo: `${item.commandNo}/${_commandYear}`,
commandName: item.commandName, commandName: item.commandName,
refId: item.refId, refId: item.refId,
refCommandDate: new Date(), refCommandDate: new Date(),
@ -6169,26 +6169,26 @@ export class CommandController extends Controller {
!profile.current_holders || profile.current_holders.length == 0 !profile.current_holders || profile.current_holders.length == 0
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild4 != null ?.orgChild4 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` ? `${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) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild3 != null ?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` ? `${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) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild2 != null ?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
: null; : null;
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`; const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
@ -6914,7 +6914,7 @@ export class CommandController extends Controller {
// เช็คว่า posMaster ที่หามาอยู่ในโครงสร้างปัจจุบันหรือไม่ // เช็คว่า posMaster ที่หามาอยู่ในโครงสร้างปัจจุบันหรือไม่
const isCurrent = posMaster?.orgRevision?.orgRevisionIsCurrent === true && const isCurrent = posMaster?.orgRevision?.orgRevisionIsCurrent === true &&
posMaster?.orgRevision?.orgRevisionIsDraft === false; posMaster?.orgRevision?.orgRevisionIsDraft === false;
// ถ้าไม่อยู่ในโครงสร้างปัจจุบัน ให้หาตัวใหม่จาก ancestorDNA // ถ้าไม่อยู่ในโครงสร้างปัจจุบัน ให้หาตัวใหม่จาก ancestorDNA
if (!isCurrent && posMaster?.ancestorDNA) { if (!isCurrent && posMaster?.ancestorDNA) {
@ -6927,7 +6927,8 @@ export class CommandController extends Controller {
} }
}, },
relations: { orgRevision: true, orgRoot: true, orgChild1: true, orgChild2: true, orgChild3: true, orgChild4: true } relations: { orgRevision: true, orgRoot: true, orgChild1: true, orgChild2: true, orgChild3: true, orgChild4: true }
}); } });
}
if (posMaster == null) if (posMaster == null)
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
@ -7025,7 +7026,7 @@ export class CommandController extends Controller {
// อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit // อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
profile.posMasterNo = getPosMasterNo(posMaster); profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster); profile.org = getOrgFullName(posMaster);
if(!posMaster.isSit){ if (!posMaster.isSit) {
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
profile.position = positionNew.positionName; profile.position = positionNew.positionName;
@ -7117,8 +7118,8 @@ export class CommandController extends Controller {
prefix: avatar, prefix: avatar,
fileName: fileName, fileName: fileName,
}) })
.then(() => {}) .then(() => { })
.catch(() => {}); .catch(() => { });
} }
} }
}), }),
@ -8229,7 +8230,7 @@ export class CommandController extends Controller {
.then(async (res) => { .then(async (res) => {
_command = res; _command = res;
}) })
.catch(() => {}); .catch(() => { });
let issue = let issue =
command.isBangkok == "OFFICE" command.isBangkok == "OFFICE"