From 19703a4f0b29ec0bcfd781b592dc12e4fd9eb42a Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 9 Jul 2024 17:03:35 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 4 +- .../KpiUserEvaluationController.ts | 154 ++++++++++++++---- src/interfaces/call-api.ts | 4 +- 3 files changed, 123 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4f4bfa4..ab39d00 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,8 +9,8 @@ env: REGISTRY: docker.frappet.com IMAGE_NAME: ehr/bma-ehr-kpi-service DEPLOY_HOST: frappet.com - COMPOSE_PATH: /home/frappet/docker/bma-ehr - # COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-kpi + # COMPOSE_PATH: /home/frappet/docker/bma-ehr + COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-kpi jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 release-test: diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 6542172..d142d86 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -690,6 +690,33 @@ export class KpiUserEvaluationController extends Controller { "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", ); } + if (requestBody.status.trim().toUpperCase() == "NEW_EVALUATOR") { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ส่งข้อตกลงการประเมินผลการปฏิบัติราชการระดับบุคคลให้อนุมัติ`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ส่งข้อตกลงการประเมินผลการปฏิบัติราชการระดับบุคคลให้อนุมัติ`, + receiverUserId: kpiUserEvaluation.evaluatorId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); + } else if (requestBody.status.trim().toUpperCase() == "EVALUATING_EVALUATOR") { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} สรุปการประเมินผลการปฏิบัติราชการระดับบุคคล`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} สรุปการประเมินผลการปฏิบัติราชการระดับบุคคล`, + receiverUserId: kpiUserEvaluation.evaluatorId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); + } kpiUserEvaluation.evaluationStatus = requestBody.status.trim().toUpperCase(); kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateFullName = request.user.name; @@ -890,6 +917,18 @@ export class KpiUserEvaluationController extends Controller { if (item.commanderId == null || item.commanderId == "") { item.evaluationStatus = "APPROVE"; } else { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`, + body: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`, + receiverUserId: item.commanderId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); item.evaluationStatus = "NEW_COMMANDER"; } } @@ -898,6 +937,18 @@ export class KpiUserEvaluationController extends Controller { if (item.commanderHighId == null || item.commanderHighId == "") { item.evaluationStatus = "APPROVE"; } else { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`, + body: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`, + receiverUserId: item.commanderHighId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); item.evaluationStatus = "NEW_COMMANDER_HIGH"; } } @@ -1131,21 +1182,32 @@ export class KpiUserEvaluationController extends Controller { } const _null: any = null; if (kpiUserEvaluation.commanderId == null) { - kpiUserEvaluation.evaluationStatus = "COMPLETE"; await new CallAPI() - .PostData(request, "org/profile/assessments", { - date: new Date(), - name: kpiUserEvaluation.evaluationResults, - point1Total: kpiUserEvaluation.weightPoint1, - point1: kpiUserEvaluation.totalPoint1, - point2Total: kpiUserEvaluation.weightPoint2, - point2: kpiUserEvaluation.totalPoint2_1 + kpiUserEvaluation.totalPoint2_2, - pointSumTotal: kpiUserEvaluation.summaryWeight, - pointSum: kpiUserEvaluation.summaryPoint, - profileId: kpiUserEvaluation.profileId, + .PostData(request, "placement/noti/keycloak", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + receiverUserId: "aec26ac3-417c-4cf9-9cbe-874939f99ecc", + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, }) - .then(async (x) => {}); + .then((x) => {}) + .catch((x) => {}); + kpiUserEvaluation.evaluationStatus = "COMPLETE"; } else { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + receiverUserId: kpiUserEvaluation.commanderId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER"; } kpiUserEvaluation.topicEvaluator = @@ -1190,21 +1252,32 @@ export class KpiUserEvaluationController extends Controller { } const _null: any = null; if (kpiUserEvaluation.commanderHighId == null) { - kpiUserEvaluation.evaluationStatus = "COMPLETE"; await new CallAPI() - .PostData(request, "org/profile/assessments", { - date: new Date(), - name: kpiUserEvaluation.evaluationResults, - point1Total: kpiUserEvaluation.weightPoint1, - point1: kpiUserEvaluation.totalPoint1, - point2Total: kpiUserEvaluation.weightPoint2, - point2: kpiUserEvaluation.totalPoint2_1 + kpiUserEvaluation.totalPoint2_2, - pointSumTotal: kpiUserEvaluation.summaryWeight, - pointSum: kpiUserEvaluation.summaryPoint, - profileId: kpiUserEvaluation.profileId, + .PostData(request, "placement/noti/keycloak", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + receiverUserId: "aec26ac3-417c-4cf9-9cbe-874939f99ecc", + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, }) - .then(async (x) => {}); + .then((x) => {}) + .catch((x) => {}); + kpiUserEvaluation.evaluationStatus = "COMPLETE"; } else { + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + receiverUserId: kpiUserEvaluation.commanderHighId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH"; } kpiUserEvaluation.isReasonCommander = requestBody.isReason; @@ -1244,18 +1317,17 @@ export class KpiUserEvaluationController extends Controller { const _null: any = null; kpiUserEvaluation.evaluationStatus = "COMPLETE"; await new CallAPI() - .PostData(request, "org/profile/assessments", { - date: new Date(), - name: kpiUserEvaluation.evaluationResults, - point1Total: kpiUserEvaluation.weightPoint1, - point1: kpiUserEvaluation.totalPoint1, - point2Total: kpiUserEvaluation.weightPoint2, - point2: kpiUserEvaluation.totalPoint2_1 + kpiUserEvaluation.totalPoint2_2, - pointSumTotal: kpiUserEvaluation.summaryWeight, - pointSum: kpiUserEvaluation.summaryPoint, - profileId: kpiUserEvaluation.profileId, + .PostData(request, "placement/noti/keycloak", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`, + receiverUserId: "aec26ac3-417c-4cf9-9cbe-874939f99ecc", + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, }) - .then(async (x) => {}); + .then((x) => {}) + .catch((x) => {}); kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason; kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason; kpiUserEvaluation.lastUpdateUserId = request.user.sub; @@ -1298,6 +1370,18 @@ export class KpiUserEvaluationController extends Controller { profileId: kpiUserEvaluation.profileId, }) .then(async (x) => {}); + await new CallAPI() + .PostData(request, "placement/noti/profile", { + subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ระดับผลการประเมินการปฏิบัติราชการระดับบุคคลของคุณอยู่ในเกณฑ์ ${kpiUserEvaluation.summaryPoint}`, + body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ระดับผลการประเมินการปฏิบัติราชการระดับบุคคลของคุณอยู่ในเกณฑ์ ${kpiUserEvaluation.summaryPoint}`, + receiverUserId: kpiUserEvaluation.profileId, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateFullName = request.user.name; await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); diff --git a/src/interfaces/call-api.ts b/src/interfaces/call-api.ts index 4cbd1a5..d6498fa 100644 --- a/src/interfaces/call-api.ts +++ b/src/interfaces/call-api.ts @@ -17,7 +17,7 @@ class CallAPI { //Get public async GetData(request: any, @Path() path: any) { const token = request.headers.authorization; - const url = process.env.API + path; + const url = process.env.API_URL + path; try { const response = await axios.get(url, { headers: { @@ -33,7 +33,7 @@ class CallAPI { //Post public async PostData(request: any, @Path() path: any, sendData: any) { const token = request.headers.authorization; - const url = process.env.API + path; + const url = process.env.API_URL + path; try { const response = await axios.post(url, sendData, { headers: {