อนุมัติ kpi
This commit is contained in:
parent
996549864e
commit
7877b591ce
1 changed files with 150 additions and 35 deletions
|
|
@ -517,6 +517,15 @@ export class KpiUserEvaluationController extends Controller {
|
|||
id: string[];
|
||||
},
|
||||
) {
|
||||
let profileId: any = null;
|
||||
await new CallAPI()
|
||||
.GetData(request, "org/profile/keycloak/position")
|
||||
.then((x) => {
|
||||
profileId = x.profileId;
|
||||
})
|
||||
.catch((x) => {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
const list = await this.kpiUserEvalutionRepository.find({
|
||||
where: { id: In(requestBody.id) },
|
||||
});
|
||||
|
|
@ -531,7 +540,35 @@ export class KpiUserEvaluationController extends Controller {
|
|||
}
|
||||
|
||||
list.forEach(async (item) => {
|
||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||
let role = "EVALUATOR";
|
||||
if (profileId == item.commanderId) {
|
||||
role = "COMMANDER";
|
||||
} else if (profileId == item.commanderHighId) {
|
||||
role = "COMMANDERHIGH";
|
||||
}
|
||||
if (requestBody.status.trim().toUpperCase() == "APPROVE") {
|
||||
if (role == "EVALUATOR") {
|
||||
if (item.evaluationStatus == "NEW_EVALUATOR") {
|
||||
if (item.commanderId == null) {
|
||||
item.evaluationStatus = "APPROVE";
|
||||
} else {
|
||||
item.evaluationStatus = "NEW_COMMANDER";
|
||||
}
|
||||
}
|
||||
} else if (role == "COMMANDER") {
|
||||
if (item.evaluationStatus == "NEW_COMMANDER") {
|
||||
if (item.commanderHighId == null) {
|
||||
item.evaluationStatus = "APPROVE";
|
||||
} else {
|
||||
item.evaluationStatus = "NEW_COMMANDER_HIGH";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
} else {
|
||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(item);
|
||||
|
|
@ -556,6 +593,16 @@ export class KpiUserEvaluationController extends Controller {
|
|||
id: string[];
|
||||
},
|
||||
) {
|
||||
let profileId: any = null;
|
||||
await new CallAPI()
|
||||
.GetData(request, "org/profile/keycloak/position")
|
||||
.then((x) => {
|
||||
profileId = x.profileId;
|
||||
})
|
||||
.catch((x) => {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
|
||||
const list = await this.kpiUserEvalutionRepository.find({
|
||||
where: { id: In(requestBody.id) },
|
||||
});
|
||||
|
|
@ -568,9 +615,38 @@ export class KpiUserEvaluationController extends Controller {
|
|||
if (!hasAllData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
||||
}
|
||||
|
||||
|
||||
list.forEach(async (item) => {
|
||||
item.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
||||
let role = "EVALUATOR";
|
||||
if (profileId == item.commanderId) {
|
||||
role = "COMMANDER";
|
||||
} else if (profileId == item.commanderHighId) {
|
||||
role = "COMMANDERHIGH";
|
||||
}
|
||||
if (requestBody.status.trim().toUpperCase() == "DONE") {
|
||||
if (role == "EVALUATOR") {
|
||||
if (item.evaluationReqEdit == "EVALUATOR") {
|
||||
if (item.commanderId == null) {
|
||||
item.evaluationReqEdit = "DONE";
|
||||
} else {
|
||||
item.evaluationReqEdit = "COMMANDER";
|
||||
}
|
||||
}
|
||||
} else if (role == "COMMANDER") {
|
||||
if (item.evaluationReqEdit == "COMMANDER") {
|
||||
if (item.commanderHighId == null) {
|
||||
item.evaluationReqEdit = "DONE";
|
||||
} else {
|
||||
item.evaluationReqEdit = "COMMANDER_HIGH";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
} else {
|
||||
item.evaluationReqEdit = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(item);
|
||||
|
|
@ -579,42 +655,81 @@ export class KpiUserEvaluationController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* API แก้ไขสถานะผลการประเมิน
|
||||
*
|
||||
* @summary แก้ไขสถานะผลการประเมิน
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Post("admin/result-status")
|
||||
async ResultStatus(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Body()
|
||||
requestBody: {
|
||||
status: string;
|
||||
id: string[];
|
||||
},
|
||||
) {
|
||||
const list = await this.kpiUserEvalutionRepository.find({
|
||||
where: { id: In(requestBody.id) },
|
||||
});
|
||||
if (!list || list.length === 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const hasAllData = requestBody.id.every((id) => list.some((item) => item.id === id));
|
||||
|
||||
if (!hasAllData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
||||
}
|
||||
|
||||
list.forEach(async (item) => {
|
||||
item.evaluationResults = requestBody.status.trim().toUpperCase();
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(item);
|
||||
});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Post("admin/result-status")
|
||||
async ResultStatus(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Body()
|
||||
requestBody: {
|
||||
status: string;
|
||||
id: string[];
|
||||
},
|
||||
) {
|
||||
let profileId: any = null;
|
||||
await new CallAPI()
|
||||
.GetData(request, "org/profile/keycloak/position")
|
||||
.then((x) => {
|
||||
profileId = x.profileId;
|
||||
})
|
||||
.catch((x) => {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
|
||||
const list = await this.kpiUserEvalutionRepository.find({
|
||||
where: { id: In(requestBody.id) },
|
||||
});
|
||||
if (!list || list.length === 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const hasAllData = requestBody.id.every((id) => list.some((item) => item.id === id));
|
||||
|
||||
if (!hasAllData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
||||
}
|
||||
|
||||
list.forEach(async (item) => {
|
||||
let role = "EVALUATOR";
|
||||
if (profileId == item.commanderId) {
|
||||
role = "COMMANDER";
|
||||
} else if (profileId == item.commanderHighId) {
|
||||
role = "COMMANDERHIGH";
|
||||
}
|
||||
if (requestBody.status.trim().toUpperCase() == "DONE") {
|
||||
if (role == "EVALUATOR") {
|
||||
if (item.evaluationStatus == "EVALUATING_EVALUATOR") {
|
||||
if (item.commanderId == null) {
|
||||
item.evaluationStatus = "COMPLETE";
|
||||
} else {
|
||||
item.evaluationStatus = "EVALUATING_COMMANDER";
|
||||
}
|
||||
item.evaluationResults = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
} else if (role == "COMMANDER") {
|
||||
if (item.evaluationStatus == "EVALUATING_COMMANDER") {
|
||||
if (item.commanderHighId == null) {
|
||||
item.evaluationStatus = "COMPLETE";
|
||||
} else {
|
||||
item.evaluationStatus = "EVALUATING_COMMANDER_HIGH";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.evaluationStatus = "COMPLETE";
|
||||
}
|
||||
} else {
|
||||
// item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||
}
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(item);
|
||||
});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue