update noti kpi

This commit is contained in:
AdisakKanthawilang 2025-08-18 15:50:35 +07:00
parent 87a32f3a6a
commit 1ffaa99136

View file

@ -1265,10 +1265,15 @@ export class KpiUserEvaluationController extends Controller {
);
}
await new CallAPI()
.PostData(request, "/placement/noti/profile", {
.PostData(request, "/placement/noti/profiles", {
subject: `${kpiUserEvaluation.prefixEvaluator}${kpiUserEvaluation.firstNameEvaluator} ${kpiUserEvaluation.lastNameEvaluator} ไม่อนุมัติเนื่องจาก: ${requestBody.reason}`,
body: `${kpiUserEvaluation.prefixEvaluator}${kpiUserEvaluation.firstNameEvaluator} ${kpiUserEvaluation.lastNameEvaluator} ไม่อนุมัติเนื่องจาก: ${requestBody.reason}`,
receiverUserId: kpiUserEvaluation.evaluatorId,
receiverUserIds: [
{
receiverUserId: kpiUserEvaluation.evaluatorId,
notiLink: `${process.env.USER_NOTI_URL}/KPI-evaluator/${kpiUserEvaluation.id}`,
},
],
payload: "",
isSendMail: true,
isSendInbox: true,
@ -1631,6 +1636,31 @@ export class KpiUserEvaluationController extends Controller {
item.evaluationStatus = "NEW_COMMANDER_HIGH";
}
}
} else if (role == "NEW_COMMANDER_HIGH") {
if (item.evaluationStatus == "NEW_COMMANDER_HIGH") {
if (item.commanderHighId == null || item.commanderHighId == "") {
item.evaluationStatus = "APPROVE";
} else {
await new CallAPI()
.PostData(request, "/placement/noti/profiles", {
subject: `ผู้บังคับบัญชาได้อนุมัติข้อตกลงแล้ว ให้ดำเนินการส่งประเมินต่อไป`,
body: `ผู้บังคับบัญชาได้อนุมัติข้อตกลงแล้ว ให้ดำเนินการส่งประเมินต่อไป`,
receiverUserIds: [
{
receiverUserId: item.profileId,
notiLink: `${process.env.USER_NOTI_URL}/KPI-evaluator/${item.id}`,
},
],
payload: "",
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
})
.then(() => {})
.catch(() => {});
item.evaluationStatus = "NEW_COMMANDER_HIGH";
}
}
} else {
item.evaluationStatus = requestBody.status.trim().toUpperCase();
}
@ -1959,10 +1989,15 @@ export class KpiUserEvaluationController extends Controller {
kpiUserEvaluation.evaluationStatus = "COMPLETE";
} else {
await new CallAPI()
.PostData(request, "/placement/noti/profile", {
.PostData(request, "/placement/noti/profiles", {
subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`,
body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} ผู้ประเมินแสดงความเห็น`,
receiverUserId: kpiUserEvaluation.commanderId,
receiverUserIds: [
{
receiverUserId: kpiUserEvaluation.commanderId,
notiLink: `${process.env.USER_NOTI_URL}/KPI-evaluator/${kpiUserEvaluation.id}`,
},
],
payload: "",
isSendMail: true,
isSendInbox: true,
@ -2094,17 +2129,35 @@ export class KpiUserEvaluationController extends Controller {
const _null: any = null;
kpiUserEvaluation.evaluationStatus = "COMPLETE";
await new CallAPI()
.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(() => {})
.catch(() => {});
if (kpiUserEvaluation.evaluatorId == null) {
await new CallAPI()
.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(() => {})
.catch(() => {});
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.evaluatorId,
payload: "",
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
})
.then(() => {})
.catch(() => {});
kpiUserEvaluation.evaluationStatus = "SUMMARY_COMMANDER_HIGH";
}
const before = structuredClone(kpiUserEvaluation);
kpiUserEvaluation.reasonReject = _null;