From 9da9b812c1dcfa9524a2bab417b624cbe4df40ed Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Thu, 3 Apr 2025 11:17:05 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=AA?= =?UTF-8?q?=E0=B8=96=E0=B9=88=E0=B8=99=E0=B8=B0=E0=B8=AD=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 140 ++++++++++++++++++++++++--- 1 file changed, 128 insertions(+), 12 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index f3487396..81b4da5c 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -658,6 +658,94 @@ export class CommandController extends Controller { return new HttpSuccess(); } + /** + * API ลบรายการผู้ได้รับคำสั่ง + * + * @summary API ลบรายการผู้ได้รับคำสั่ง + * + * @param {string} id Id ผู้ได้รับคำสั่ง + */ + @Delete("tab2Cancel17/{refId}") + async DeleteTab2Cancel17(@Path() refId: string, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "COMMAND"); + const commandRecive = await this.commandReciveRepository.findOne({ + where: { refId: refId, command: { commandType: { commandCode: "C-PM-17" } } }, + relations: ["command", "command.commandType"], + }); + if (!commandRecive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง"); + } + + const path = commandTypePath(commandRecive.command.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + await new CallAPI() + .PostData(request, path + "/delete", { + refIds: [commandRecive.refId], + }) + .then(async (res) => {}) + .catch(() => {}); + + const commandId = commandRecive.commandId; + await this.commandReciveRepository.delete(commandRecive.id); + + const commandReciveList = await this.commandReciveRepository.find({ + where: { + commandId: commandId, + }, + order: { order: "ASC" }, + }); + commandReciveList.map(async (p, i) => { + p.order = i + 1; + await this.commandReciveRepository.save(p); + }); + + return new HttpSuccess(); + } + + /** + * API ลบรายการผู้ได้รับคำสั่ง + * + * @summary API ลบรายการผู้ได้รับคำสั่ง + * + * @param {string} id Id ผู้ได้รับคำสั่ง + */ + @Delete("tab2Cancel23/{refId}") + async DeleteTab2Cancel23(@Path() refId: string, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "COMMAND"); + const commandRecive = await this.commandReciveRepository.findOne({ + where: { refId: refId, command: { commandType: { commandCode: "C-PM-23" } } }, + relations: ["command", "command.commandType"], + }); + if (!commandRecive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง"); + } + + const path = commandTypePath(commandRecive.command.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + await new CallAPI() + .PostData(request, path + "/delete", { + refIds: [commandRecive.refId], + }) + .then(async (res) => {}) + .catch(() => {}); + + const commandId = commandRecive.commandId; + await this.commandReciveRepository.delete(commandRecive.id); + + const commandReciveList = await this.commandReciveRepository.find({ + where: { + commandId: commandId, + }, + order: { order: "ASC" }, + }); + commandReciveList.map(async (p, i) => { + p.order = i + 1; + await this.commandReciveRepository.save(p); + }); + + return new HttpSuccess(); + } + /** * API รายละเอียดรายการคำสั่ง tab3 * @@ -1171,6 +1259,15 @@ export class CommandController extends Controller { command.lastUpdateUserId = request.user.sub; command.lastUpdateFullName = request.user.name; command.lastUpdatedAt = new Date(); + const path = commandTypePath(command.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + await new CallAPI() + .PostData(request, path, { + refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId), + status: "WAITING", + }) + .then(async (res) => {}) + .catch(() => {}); await this.commandRepository.save(command); } else { const path = commandTypePath(command.commandType.code); @@ -2015,6 +2112,7 @@ export class CommandController extends Controller { await new CallAPI() .PostData(request, path, { refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId), + status: "REPORT", }) .then(async (res) => { let order = @@ -2647,11 +2745,10 @@ export class CommandController extends Controller { firstName: _posMasterOfficer?.current_holder.firstName, lastName: _posMasterOfficer?.current_holder.lastName, // organizationName: _posMasterOfficer.orgRoot ? _posMasterOfficer.orgRoot.orgRootName : _null, - organizationName: _posMasterOfficer.orgChild1 - ? _posMasterOfficer.orgChild1.orgChild1Name + "\n" + - _posMasterOfficer.orgRoot.orgRootName + organizationName: _posMasterOfficer.orgChild1 + ? _posMasterOfficer.orgChild1.orgChild1Name + "\n" + _posMasterOfficer.orgRoot.orgRootName : _posMasterOfficer.orgChild1 == null && _posMasterOfficer.orgRoot - ? _posMasterOfficer.orgRoot.orgRootName + ? _posMasterOfficer.orgRoot.orgRootName : _null, positionName: _posMasterOfficer?.current_holder.position ?? _null, profileId: _posMasterOfficer?.current_holder.id ?? _null, @@ -2751,15 +2848,34 @@ export class CommandController extends Controller { firstName: x?.current_holder.firstName, lastName: x?.current_holder.lastName, // organizationName: x.orgRoot ? x.orgRoot.orgRootName : _null, - organizationName: x.orgChild1 == null - ? x.orgRoot.orgRootName - : x.orgChild2 == null + organizationName: + x.orgChild1 == null + ? x.orgRoot.orgRootName + : x.orgChild2 == null ? 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.orgChild4Name + "\n" + x.orgChild3.orgChild3Name + "\n" + x.orgChild2.orgChild2Name + "\n" + x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName, + ? 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, positionName: x?.current_holder.position ?? _null, profileId: x?.current_holder.id ?? _null, }); @@ -3163,7 +3279,7 @@ export class CommandController extends Controller { profile.leaveType = _null; profile.position = item.positionNameNew ?? _null; profile.posTypeId = item.positionTypeNew ?? _null; - profile.posLevelId = item.positionLevelNew ?? _null + profile.posLevelId = item.positionLevelNew ?? _null; } let userKeycloakId; const checkUser = await getUserByUsername(profile.citizenId); From 4b7ca5fbf41c6c9c2bc0c71b07685faf1f286f8c Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Thu, 3 Apr 2025 11:43:43 +0700 Subject: [PATCH 2/5] comment where in gen --- .../OrganizationUnauthorizeController.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 460e762f..103722a5 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -93,14 +93,14 @@ export class OrganizationUnauthorizeController extends Controller { .where({ orgRevisionId: findRevision?.id, current_holderId: Not(IsNull()), - orgRootId: In([ - "4b574414-5faa-438c-829a-3c6444582cfd", - "f4aae002-1c03-4ba2-b70b-64b261fc52fa", - "1e8dba2f-b7d1-43c8-b06a-9b240414fd2b", - "57477ae7-9de8-49cf-af2f-709cfd21dcb5", - "a356d732-4a7f-4329-8c55-075290e3b533", - "a2c0c2b3-c4ca-4451-8e52-04a9e4b02459", - ]), + // orgRootId: In([ + // "4b574414-5faa-438c-829a-3c6444582cfd", + // "f4aae002-1c03-4ba2-b70b-64b261fc52fa", + // "1e8dba2f-b7d1-43c8-b06a-9b240414fd2b", + // "57477ae7-9de8-49cf-af2f-709cfd21dcb5", + // "a356d732-4a7f-4329-8c55-075290e3b533", + // "a2c0c2b3-c4ca-4451-8e52-04a9e4b02459", + // ]), }) .andWhere( new Brackets((qb) => { From bb53d4ef638ff5f6b850db3b2e11a3720356ec37 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 3 Apr 2025 13:06:10 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87+=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=20?= =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B9=80?= =?UTF-8?q?=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/ProfileAssistance.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/entities/ProfileAssistance.ts b/src/entities/ProfileAssistance.ts index 1c92d3f8..568552c0 100644 --- a/src/entities/ProfileAssistance.ts +++ b/src/entities/ProfileAssistance.ts @@ -131,6 +131,7 @@ export class CreateProfileAssistance { refCommandDate?: string | null; commandId?: string | null; isUpload?: boolean | null; + commandName?: string | null; } export class CreateProfileAssistanceEmployee { @@ -143,6 +144,7 @@ export class CreateProfileAssistanceEmployee { refCommandDate?: string | null; commandId?: string | null; isUpload?: boolean | null; + commandName?: string | null; } export type UpdateProfileAssistance = { @@ -154,4 +156,5 @@ export type UpdateProfileAssistance = { isUpload?: boolean | null; refCommandDate?: string | null; commandId?: string | null; + commandName?: string | null; }; From eb2bf96c64ca691e4f9e3a225c134c4dfb613d7c Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 3 Apr 2025 13:26:53 +0700 Subject: [PATCH 4/5] =?UTF-8?q?fix=20=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=87?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=95=E0=B8=B1?= =?UTF-8?q?=E0=B8=A7=E0=B8=81=E0=B8=A5=E0=B8=B1=E0=B8=9A=E0=B8=AA=E0=B8=96?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=B0=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=B1=E0=B8=9E=E0=B9=80=E0=B8=94=E0=B8=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 81b4da5c..81b53ecc 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3575,6 +3575,7 @@ export class CommandController extends Controller { lastUpdateFullName: req.user.name, createdAt: new Date(), lastUpdatedAt: new Date(), + status: "DONE" }; Object.assign(dataAssis, metaAssis); From a17ca1a7d8f720b1523f608defdd2bcfa8f70962 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Thu, 3 Apr 2025 16:40:19 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=E0=B8=A2=E0=B8=81=E0=B9=80=E0=B8=A5=E0=B8=B4?= =?UTF-8?q?=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 8 ++++---- src/controllers/ImportDataController.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 81b4da5c..f4c643b8 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -667,9 +667,9 @@ export class CommandController extends Controller { */ @Delete("tab2Cancel17/{refId}") async DeleteTab2Cancel17(@Path() refId: string, @Request() request: RequestWithUser) { - await new permission().PermissionUpdate(request, "COMMAND"); + // await new permission().PermissionUpdate(request, "COMMAND"); const commandRecive = await this.commandReciveRepository.findOne({ - where: { refId: refId, command: { commandType: { commandCode: "C-PM-17" } } }, + where: { refId: refId, command: { commandType: { code: "C-PM-17" } } }, relations: ["command", "command.commandType"], }); if (!commandRecive) { @@ -711,9 +711,9 @@ export class CommandController extends Controller { */ @Delete("tab2Cancel23/{refId}") async DeleteTab2Cancel23(@Path() refId: string, @Request() request: RequestWithUser) { - await new permission().PermissionUpdate(request, "COMMAND"); + // await new permission().PermissionUpdate(request, "COMMAND"); const commandRecive = await this.commandReciveRepository.findOne({ - where: { refId: refId, command: { commandType: { commandCode: "C-PM-23" } } }, + where: { refId: refId, command: { commandType: { code: "C-PM-23" } } }, relations: ["command", "command.commandType"], }); if (!commandRecive) { diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 42a699c6..8f953df6 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -2530,7 +2530,7 @@ export class ImportDataController extends Controller { .toISOString() .replace("T", " ") .substring(0, 19); - profileSalary.remark = item.SalaryRef + item.PositionName; + profileSalary.remark = `${item.SalaryRef} ${item.PositionName}`; profileSalary.amount = item.Amount; profileSalary.positionSalaryAmount = item.PositionSalaryAmount; // const str = item.PosNoName;