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