เพิ่ม promose all ก่อน return
This commit is contained in:
parent
0272361d36
commit
c5ca718b9f
2 changed files with 61 additions and 63 deletions
|
|
@ -46,11 +46,8 @@ export class kpiLinkController extends Controller {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
@Post()
|
@Post()
|
||||||
async createKpiLink(
|
async createKpiLink(@Body() requestBody: createKpiLink, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: createKpiLink,
|
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
|
|
||||||
const chkkpiGroup = await this.kpiGroupRepository.findOne({
|
const chkkpiGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: requestBody.kpiGroupId,
|
id: requestBody.kpiGroupId,
|
||||||
|
|
@ -71,7 +68,7 @@ export class kpiLinkController extends Controller {
|
||||||
await this.kpiLinkRepository.save(kpiLink);
|
await this.kpiLinkRepository.save(kpiLink);
|
||||||
|
|
||||||
if (requestBody.positions != null) {
|
if (requestBody.positions != null) {
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
requestBody.positions.map(async (positionName) => {
|
requestBody.positions.map(async (positionName) => {
|
||||||
let position = new Position();
|
let position = new Position();
|
||||||
position.name = positionName;
|
position.name = positionName;
|
||||||
|
|
@ -110,7 +107,7 @@ export class kpiLinkController extends Controller {
|
||||||
@Body() requestBody: createKpiLink,
|
@Body() requestBody: createKpiLink,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||||
const chkKpiLink = await this.kpiLinkRepository.findOne({
|
const chkKpiLink = await this.kpiLinkRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
|
|
@ -134,7 +131,7 @@ export class kpiLinkController extends Controller {
|
||||||
chkKpiLink.lastUpdateFullName = request.user.name;
|
chkKpiLink.lastUpdateFullName = request.user.name;
|
||||||
|
|
||||||
if (requestBody.positions != null) {
|
if (requestBody.positions != null) {
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
requestBody.positions.map(async (positionName) => {
|
requestBody.positions.map(async (positionName) => {
|
||||||
let position = new Position();
|
let position = new Position();
|
||||||
position.name = positionName;
|
position.name = positionName;
|
||||||
|
|
@ -203,7 +200,7 @@ export class kpiLinkController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiLink(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteKpiLink(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
|
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiLink = await this.kpiLinkRepository.findOne({
|
const kpiLink = await this.kpiLinkRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["kpiCapacitys"],
|
relations: ["kpiCapacitys"],
|
||||||
|
|
|
||||||
|
|
@ -945,65 +945,66 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
await list.forEach(async (item) => {
|
await Promise.all(
|
||||||
let role = "EVALUATOR";
|
list.map(async (item) => {
|
||||||
if (profileId == item.commanderId) {
|
let role = "EVALUATOR";
|
||||||
role = "COMMANDER";
|
if (profileId == item.commanderId) {
|
||||||
} else if (profileId == item.commanderHighId) {
|
role = "COMMANDER";
|
||||||
role = "COMMANDERHIGH";
|
} else if (profileId == item.commanderHighId) {
|
||||||
}
|
role = "COMMANDERHIGH";
|
||||||
if (requestBody.status.trim().toUpperCase() == "APPROVE") {
|
}
|
||||||
if (role == "EVALUATOR") {
|
if (requestBody.status.trim().toUpperCase() == "APPROVE") {
|
||||||
if (item.evaluationStatus == "NEW_EVALUATOR") {
|
if (role == "EVALUATOR") {
|
||||||
if (item.commanderId == null || item.commanderId == "") {
|
if (item.evaluationStatus == "NEW_EVALUATOR") {
|
||||||
item.evaluationStatus = "APPROVE";
|
if (item.commanderId == null || item.commanderId == "") {
|
||||||
} else {
|
item.evaluationStatus = "APPROVE";
|
||||||
await new CallAPI()
|
} else {
|
||||||
.PostData(request, "/placement/noti/profile", {
|
await new CallAPI()
|
||||||
subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`,
|
.PostData(request, "/placement/noti/profile", {
|
||||||
body: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`,
|
subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`,
|
||||||
receiverUserId: item.commanderId,
|
body: `${item.prefix}${item.firstName} ${item.lastName} ผู้ประเมินอนุมัติข้อตกลง`,
|
||||||
payload: "",
|
receiverUserId: item.commanderId,
|
||||||
isSendMail: true,
|
payload: "",
|
||||||
isSendInbox: true,
|
isSendMail: true,
|
||||||
isSendNotification: true,
|
isSendInbox: true,
|
||||||
})
|
isSendNotification: true,
|
||||||
.then((x) => {})
|
})
|
||||||
.catch((x) => {});
|
.then((x) => {})
|
||||||
item.evaluationStatus = "NEW_COMMANDER";
|
.catch((x) => {});
|
||||||
|
item.evaluationStatus = "NEW_COMMANDER";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (role == "COMMANDER") {
|
||||||
} else if (role == "COMMANDER") {
|
if (item.evaluationStatus == "NEW_COMMANDER") {
|
||||||
if (item.evaluationStatus == "NEW_COMMANDER") {
|
if (item.commanderHighId == null || item.commanderHighId == "") {
|
||||||
if (item.commanderHighId == null || item.commanderHighId == "") {
|
item.evaluationStatus = "APPROVE";
|
||||||
item.evaluationStatus = "APPROVE";
|
} else {
|
||||||
} else {
|
await new CallAPI()
|
||||||
await new CallAPI()
|
.PostData(request, "/placement/noti/profile", {
|
||||||
.PostData(request, "/placement/noti/profile", {
|
subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`,
|
||||||
subject: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`,
|
body: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`,
|
||||||
body: `${item.prefix}${item.firstName} ${item.lastName} ผู้บังคับบัญชาเหนือขึ้นไปอนุมัติข้อตกลง`,
|
receiverUserId: item.commanderHighId,
|
||||||
receiverUserId: item.commanderHighId,
|
payload: "",
|
||||||
payload: "",
|
isSendMail: true,
|
||||||
isSendMail: true,
|
isSendInbox: true,
|
||||||
isSendInbox: true,
|
isSendNotification: true,
|
||||||
isSendNotification: true,
|
})
|
||||||
})
|
.then((x) => {})
|
||||||
.then((x) => {})
|
.catch((x) => {});
|
||||||
.catch((x) => {});
|
item.evaluationStatus = "NEW_COMMANDER_HIGH";
|
||||||
item.evaluationStatus = "NEW_COMMANDER_HIGH";
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
}
|
}
|
||||||
} else {
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.evaluationStatus = requestBody.status.trim().toUpperCase();
|
item.lastUpdateFullName = request.user.name;
|
||||||
}
|
await this.kpiUserEvalutionRepository.save(item);
|
||||||
item.lastUpdateUserId = request.user.sub;
|
}),
|
||||||
item.lastUpdateFullName = request.user.name;
|
);
|
||||||
await this.kpiUserEvalutionRepository.save(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1396,7 +1397,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
where: { id: In(requestBody.id) },
|
where: { id: In(requestBody.id) },
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
kpiUserEvaluations.map(async (kpiUserEvaluation) => {
|
kpiUserEvaluations.map(async (kpiUserEvaluation) => {
|
||||||
kpiUserEvaluation.evaluationStatus = "KP7";
|
kpiUserEvaluation.evaluationStatus = "KP7";
|
||||||
new CallAPI()
|
new CallAPI()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue