fix
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m11s

This commit is contained in:
Adisak 2026-02-13 16:56:56 +07:00
parent 7029b18a97
commit 0a3deb4293

View file

@ -297,7 +297,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()],
}, },
@ -419,7 +419,7 @@ export class CommandController extends Controller {
orgRevision: true, orgRevision: true,
orgRoot: true, orgRoot: true,
orgChild1: true, orgChild1: true,
orgChild2: true, orgChild2: true,
orgChild3: true, orgChild3: true,
orgChild4: true, orgChild4: true,
}, },
@ -431,20 +431,20 @@ export class CommandController extends Controller {
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsDraft === false &&
x.orgRevision?.orgRevisionIsCurrent === true, x.orgRevision?.orgRevisionIsCurrent === true,
); );
const posNo = const posNo =
currentHolder != null && currentHolder.orgChild4 != null currentHolder != null && currentHolder.orgChild4 != null
? `${currentHolder.orgChild4.orgChild4ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild4.orgChild4ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild3 != null : currentHolder != null && currentHolder.orgChild3 != null
? `${currentHolder.orgChild3.orgChild3ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild3.orgChild3ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild2 != null : currentHolder != null && currentHolder.orgChild2 != null
? `${currentHolder.orgChild2.orgChild2ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild2.orgChild2ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild1 != null : currentHolder != null && currentHolder.orgChild1 != null
? `${currentHolder.orgChild1.orgChild1ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild1.orgChild1ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder?.orgRoot != null : currentHolder != null && currentHolder?.orgRoot != null
? `${currentHolder.orgRoot.orgRootShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgRoot.orgRootShortName} ${currentHolder.posMasterNo}`
: null; : null;
const position = await this.positionRepository.findOne({ const position = await this.positionRepository.findOne({
where: { where: {
positionIsSelected: true, positionIsSelected: true,
@ -751,7 +751,7 @@ export class CommandController extends Controller {
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
) { ) {
await new permission().PermissionUpdate(request, "COMMAND"); await new permission().PermissionUpdate(request, "COMMAND");
if (!Array.isArray(requestBody)) { if (!Array.isArray(requestBody)) {
throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง"); throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง");
} }
@ -801,8 +801,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);
@ -845,8 +845,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);
@ -889,8 +889,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);
@ -1174,8 +1174,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";
@ -1240,8 +1240,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 });
@ -1393,11 +1393,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 = {
@ -1429,8 +1429,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);
@ -1567,7 +1567,7 @@ export class CommandController extends Controller {
); );
await this.profileRepository.save(profiles); await this.profileRepository.save(profiles);
} }
} catch {} } catch { }
type = "EMPLOYEE"; type = "EMPLOYEE";
try { try {
@ -1599,7 +1599,7 @@ export class CommandController extends Controller {
); );
await this.profileEmployeeRepository.save(profiles); await this.profileEmployeeRepository.save(profiles);
} }
} catch {} } catch { }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1663,7 +1663,7 @@ export class CommandController extends Controller {
}), }),
); );
} }
} catch {} } catch { }
type = "EMPLOYEE"; type = "EMPLOYEE";
try { try {
@ -1718,7 +1718,7 @@ export class CommandController extends Controller {
}), }),
); );
} }
} catch {} } catch { }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1931,7 +1931,7 @@ export class CommandController extends Controller {
.then((x) => { .then((x) => {
res = x; res = x;
}) })
.catch((x) => {}); .catch((x) => { });
} }
let _command; let _command;
@ -2009,76 +2009,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;
@ -2139,10 +2139,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}`,
@ -2157,8 +2157,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:
@ -2172,19 +2172,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 : "-",
}; };
@ -2285,7 +2285,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"
@ -2342,13 +2342,13 @@ export class CommandController extends Controller {
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)), : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)),
operators: operators.length > 0 operators: 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: "เจ้าหน้าที่ดำเนินการ"
}] }]
}, },
}); });
} }
@ -2585,7 +2585,7 @@ export class CommandController extends Controller {
orgRevision: true, orgRevision: true,
orgRoot: true, orgRoot: true,
orgChild1: true, orgChild1: true,
orgChild2: true, orgChild2: true,
orgChild3: true, orgChild3: true,
orgChild4: true, orgChild4: true,
}, },
@ -2597,20 +2597,20 @@ export class CommandController extends Controller {
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsDraft === false &&
x.orgRevision?.orgRevisionIsCurrent === true, x.orgRevision?.orgRevisionIsCurrent === true,
); );
const posNo = const posNo =
currentHolder != null && currentHolder.orgChild4 != null currentHolder != null && currentHolder.orgChild4 != null
? `${currentHolder.orgChild4.orgChild4ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild4.orgChild4ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild3 != null : currentHolder != null && currentHolder.orgChild3 != null
? `${currentHolder.orgChild3.orgChild3ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild3.orgChild3ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild2 != null : currentHolder != null && currentHolder.orgChild2 != null
? `${currentHolder.orgChild2.orgChild2ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild2.orgChild2ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder.orgChild1 != null : currentHolder != null && currentHolder.orgChild1 != null
? `${currentHolder.orgChild1.orgChild1ShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgChild1.orgChild1ShortName} ${currentHolder.posMasterNo}`
: currentHolder != null && currentHolder?.orgRoot != null : currentHolder != null && currentHolder?.orgRoot != null
? `${currentHolder.orgRoot.orgRootShortName} ${currentHolder.posMasterNo}` ? `${currentHolder.orgRoot.orgRootShortName} ${currentHolder.posMasterNo}`
: null; : null;
const position = await this.positionRepository.findOne({ const position = await this.positionRepository.findOne({
where: { where: {
positionIsSelected: true, positionIsSelected: true,
@ -2656,8 +2656,8 @@ export class CommandController extends Controller {
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(() => { });
let order = let order =
command.commandRecives == null || command.commandRecives.length <= 0 command.commandRecives == null || command.commandRecives.length <= 0
? 0 ? 0
@ -3430,27 +3430,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,
}); });
@ -3978,7 +3978,7 @@ export class CommandController extends Controller {
// relations: ["roleKeycloaks"], // relations: ["roleKeycloaks"],
relations: { relations: {
roleKeycloaks: true, roleKeycloaks: true,
posType: true , posType: true,
posLevel: true posLevel: true
} }
}); });
@ -4048,18 +4048,18 @@ export class CommandController extends Controller {
const curRevision = await this.orgRevisionRepo.findOne({ const curRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
}); });
let orgRootRef = null; let orgRootRef = null;
let orgChild1Ref = null; let orgChild1Ref = null;
let orgChild2Ref = null; let orgChild2Ref = null;
let orgChild3Ref = null; let orgChild3Ref = null;
let orgChild4Ref = null; let orgChild4Ref = null;
if (curRevision) { if (curRevision) {
const curPosMaster = await this.posMasterRepository.findOne({ const curPosMaster = await this.posMasterRepository.findOne({
where: { where: {
current_holderId: profile.id, current_holderId: profile.id,
orgRevisionId: curRevision.id, orgRevisionId: curRevision.id,
}, },
relations:{ relations: {
orgRoot: true, orgRoot: true,
orgChild1: true, orgChild1: true,
orgChild2: true, orgChild2: true,
@ -4243,7 +4243,7 @@ export class CommandController extends Controller {
profile.isActive = true; profile.isActive = true;
} }
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
// Task #2190 // Task #2190
if (code && ["C-PM-17", "C-PM-18"].includes(code)) { if (code && ["C-PM-17", "C-PM-18"].includes(code)) {
let organizeName = ""; let organizeName = "";
if (orgRootRef) { if (orgRootRef) {
@ -4377,7 +4377,7 @@ export class CommandController extends Controller {
// relations: ["roleKeycloaks"], // relations: ["roleKeycloaks"],
relations: { relations: {
roleKeycloaks: true, roleKeycloaks: true,
posType: true , posType: true,
posLevel: true posLevel: true
} }
}); });
@ -4448,18 +4448,18 @@ export class CommandController extends Controller {
const curRevision = await this.orgRevisionRepo.findOne({ const curRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
}); });
let orgRootRef = null; let orgRootRef = null;
let orgChild1Ref = null; let orgChild1Ref = null;
let orgChild2Ref = null; let orgChild2Ref = null;
let orgChild3Ref = null; let orgChild3Ref = null;
let orgChild4Ref = null; let orgChild4Ref = null;
if (curRevision) { if (curRevision) {
const curPosMaster = await this.employeePosMasterRepository.findOne({ const curPosMaster = await this.employeePosMasterRepository.findOne({
where: { where: {
current_holderId: profile.id, current_holderId: profile.id,
orgRevisionId: curRevision.id, orgRevisionId: curRevision.id,
}, },
relations:{ relations: {
orgRoot: true, orgRoot: true,
orgChild1: true, orgChild1: true,
orgChild2: true, orgChild2: true,
@ -4494,7 +4494,7 @@ export class CommandController extends Controller {
// profile.posLevelId = _null; // profile.posLevelId = _null;
} }
await this.profileEmployeeRepository.save(profile); await this.profileEmployeeRepository.save(profile);
// Task #2190 // Task #2190
if (code && ["C-PM-23", "C-PM-43"].includes(code)) { if (code && ["C-PM-23", "C-PM-43"].includes(code)) {
let organizeName = ""; let organizeName = "";
if (orgRootRef) { if (orgRootRef) {
@ -5024,14 +5024,14 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
}, },
}); });
let orgRootRef = null; let orgRootRef = null;
let orgChild1Ref = null; let orgChild1Ref = null;
let orgChild2Ref = null; let orgChild2Ref = null;
let orgChild3Ref = null; let orgChild3Ref = null;
let orgChild4Ref = null; let orgChild4Ref = null;
let profile; let profile;
let isEmployee:boolean = false; let isEmployee: boolean = false;
let retireTypeName:string = ""; let retireTypeName: string = "";
// ขรก. // ขรก.
if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") { if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") {
profile = await this.profileRepository.findOne({ profile = await this.profileRepository.findOne({
@ -5073,11 +5073,11 @@ export class CommandController extends Controller {
const orgRevisionRef = const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
orgRootRef = orgRevisionRef?.orgRoot ?? null; orgRootRef = orgRevisionRef?.orgRoot ?? null;
orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
let position = let position =
profile.current_holders profile.current_holders
@ -5216,7 +5216,7 @@ export class CommandController extends Controller {
} }
await this.profileRepository.save(_profile); await this.profileRepository.save(_profile);
} }
} }
// ลูกจ้าง // ลูกจ้าง
else { else {
isEmployee = true; isEmployee = true;
@ -5251,12 +5251,12 @@ export class CommandController extends Controller {
const nextOrder = lastSalary ? lastSalary.order + 1 : 1; const nextOrder = lastSalary ? lastSalary.order + 1 : 1;
const orgRevisionRef = const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
orgRootRef = orgRevisionRef?.orgRoot ?? null; orgRootRef = orgRevisionRef?.orgRoot ?? null;
orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
// ประวัติตำแหน่ง // ประวัติตำแหน่ง
const data = new ProfileSalary(); const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit; data.posNumCodeSit = _posNumCodeSit;
@ -5407,9 +5407,9 @@ export class CommandController extends Controller {
].filter(Boolean); ].filter(Boolean);
organizeName = names.join(" "); organizeName = names.join(" ");
} }
let _posLevelName: string = !isEmployee let _posLevelName: string = !isEmployee
? `${profile.posLevel?.posLevelName}` ? `${profile.posLevel?.posLevelName}`
: `${profile.posType?.posTypeName} ${profile.posLevel?.posLevelName}`; : `${profile.posType?.posTypeName} ${profile.posLevel?.posLevelName}`;
await PostRetireToExprofile( await PostRetireToExprofile(
// profile.citizenId ?? "", // profile.citizenId ?? "",
// profile.prefix ?? "", // profile.prefix ?? "",
@ -5814,8 +5814,8 @@ export class CommandController extends Controller {
} }
} }
const leaveType = await this.leaveType.findOne({ const leaveType = await this.leaveType.findOne({
select:{ id: true, limit: true, code: true }, select: { id: true, limit: true, code: true },
where:{ code: "LV-005" } where: { code: "LV-005" }
}); });
await Promise.all( await Promise.all(
body.data.map(async (item) => { body.data.map(async (item) => {
@ -5865,26 +5865,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}`;
@ -6118,26 +6118,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}`;
@ -6899,7 +6899,7 @@ export class CommandController extends Controller {
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
profile.position = positionNew.positionName; profile.position = positionNew.positionName;
profile.dateStart = new Date(); // profile.dateStart = new Date();
await this.profileRepository.save(profile, { data: req }); await this.profileRepository.save(profile, { data: req });
setLogDataDiff(req, { before, after: profile }); setLogDataDiff(req, { before, after: profile });
await this.positionRepository.save(positionNew, { data: req }); await this.positionRepository.save(positionNew, { data: req });
@ -6979,8 +6979,8 @@ export class CommandController extends Controller {
prefix: avatar, prefix: avatar,
fileName: fileName, fileName: fileName,
}) })
.then(() => {}) .then(() => { })
.catch(() => {}); .catch(() => { });
} }
} }
}), }),
@ -8091,7 +8091,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"