คำสั่ง
This commit is contained in:
parent
8bb7a9c526
commit
a2723ca8ca
1 changed files with 1125 additions and 1068 deletions
|
|
@ -1,48 +1,35 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query, Put, Post } from "tsoa"
|
||||||
Controller,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Route,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Security,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Tags,
|
import HttpError from "../interfaces/http-error"
|
||||||
Body,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Request,
|
import { DataPass, setLogDataDiff } from "../interfaces/utils"
|
||||||
SuccessResponse,
|
import { Personal } from "../entities/Personal"
|
||||||
Response,
|
import { Assign } from "../entities/Assign"
|
||||||
Get,
|
import { EvaluateChairman } from "../entities/EvaluateChairman"
|
||||||
Query,
|
import { EvaluateResult } from "../entities/EvaluateResult"
|
||||||
Put,
|
import { EvaluateAssessor } from "../entities/EvaluateAssessor"
|
||||||
} from "tsoa";
|
import { AssignDirector } from "../entities/AssignDirector"
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { EvaluateAchievement } from "../entities/EvaluateAchievement"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import { EvaluateCommander } from "../entities/EvaluateCommander"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import CallAPI from "../interfaces/call-api"
|
||||||
import HttpError from "../interfaces/http-error";
|
import { Double, In } from "typeorm"
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import Extension from "../interfaces/extension"
|
||||||
import { DataPass, setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
|
||||||
import { EvaluateResult } from "../entities/EvaluateResult";
|
|
||||||
import { EvaluateAssessor } from "../entities/EvaluateAssessor";
|
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
|
||||||
import { EvaluateAchievement } from "../entities/EvaluateAchievement";
|
|
||||||
import { EvaluateCommander } from "../entities/EvaluateCommander";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/report")
|
@Route("api/v1/probation/report")
|
||||||
@Tags("Report")
|
@Tags("Report")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class ReportController extends Controller {
|
export class ReportController extends Controller {
|
||||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||||
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
|
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private evaluateAssessorRepository = AppDataSource.getRepository(EvaluateAssessor);
|
private evaluateAssessorRepository = AppDataSource.getRepository(EvaluateAssessor)
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement);
|
private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement)
|
||||||
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander);
|
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สำหรับออกรายงาน
|
* API สำหรับออกรายงาน
|
||||||
|
|
@ -54,24 +41,24 @@ export class ReportController extends Controller {
|
||||||
async GetReport(@Query() assign_id: string) {
|
async GetReport(@Query() assign_id: string) {
|
||||||
const evaluate = await this.evaluateChairmanRepository.findOne({
|
const evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const result = await this.evaluateResultRepository.findOne({
|
const result = await this.evaluateResultRepository.findOne({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate || !result) {
|
if (!evaluate || !result) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ")
|
||||||
}
|
}
|
||||||
|
|
||||||
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
||||||
Number(evaluate.develop_self_learning_score) +
|
Number(evaluate.develop_self_learning_score) +
|
||||||
Number(evaluate.develop_training_seminar_score) +
|
Number(evaluate.develop_training_seminar_score) +
|
||||||
Number(evaluate.develop_other_training_score));
|
Number(evaluate.develop_other_training_score))
|
||||||
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_orientation_percent) +
|
Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_self_learning_percent) +
|
Number(evaluate.develop_self_learning_percent) +
|
||||||
Number(evaluate.develop_training_seminar_percent));
|
Number(evaluate.develop_training_seminar_percent))
|
||||||
|
|
||||||
const data = await {
|
const data = await {
|
||||||
develop_orientation_score: evaluate.develop_orientation_score,
|
develop_orientation_score: evaluate.develop_orientation_score,
|
||||||
|
|
@ -98,9 +85,9 @@ export class ReportController extends Controller {
|
||||||
reason: result.reson,
|
reason: result.reson,
|
||||||
pass_result: result.pass_result,
|
pass_result: result.pass_result,
|
||||||
evaluate_date: result.chairman_dated,
|
evaluate_date: result.chairman_dated,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -113,15 +100,15 @@ export class ReportController extends Controller {
|
||||||
async GetPass() {
|
async GetPass() {
|
||||||
const lists = await this.personalRepository.find({
|
const lists = await this.personalRepository.find({
|
||||||
where: { probation_status: 2 },
|
where: { probation_status: 2 },
|
||||||
});
|
})
|
||||||
|
|
||||||
let data: DataPass[] = [];
|
let data: DataPass[] = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (list) => {
|
lists.map(async list => {
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["date_start", "date_finish"],
|
select: ["date_start", "date_finish"],
|
||||||
where: { personal_id: list.personal_id },
|
where: { personal_id: list.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (assign)
|
if (assign)
|
||||||
data.push({
|
data.push({
|
||||||
|
|
@ -130,11 +117,11 @@ export class ReportController extends Controller {
|
||||||
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
});
|
})
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,15 +134,15 @@ export class ReportController extends Controller {
|
||||||
async GetDataNotPass() {
|
async GetDataNotPass() {
|
||||||
const lists = await this.personalRepository.find({
|
const lists = await this.personalRepository.find({
|
||||||
where: { probation_status: 3 },
|
where: { probation_status: 3 },
|
||||||
});
|
})
|
||||||
|
|
||||||
let data: DataPass[] = [];
|
let data: DataPass[] = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (list) => {
|
lists.map(async list => {
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["date_start", "date_finish"],
|
select: ["date_start", "date_finish"],
|
||||||
where: { personal_id: list.personal_id },
|
where: { personal_id: list.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (assign)
|
if (assign)
|
||||||
data.push({
|
data.push({
|
||||||
|
|
@ -164,11 +151,11 @@ export class ReportController extends Controller {
|
||||||
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
});
|
})
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,9 +169,9 @@ export class ReportController extends Controller {
|
||||||
const data = await this.personalRepository.find({
|
const data = await this.personalRepository.find({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
where: { probation_status: 7 },
|
where: { probation_status: 7 },
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -194,32 +181,25 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("status")
|
@Put("status")
|
||||||
async UpdateStatus(
|
async UpdateStatus(@Query() personal_id: string, @Body() requestBody: { command_no: string }, @Request() request: RequestWithUser) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Body() requestBody: { command_no: string },
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
const personal = await this.personalRepository.findOne({
|
const personal = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
const before = personal;
|
const before = personal
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
personal.order_number = requestBody.command_no;
|
personal.order_number = requestBody.command_no
|
||||||
personal.probation_status = 8;
|
personal.probation_status = 8
|
||||||
personal.updateFullName = request.user.name;
|
personal.updateFullName = request.user.name
|
||||||
personal.updateUserId = request.user.sub;
|
personal.updateUserId = request.user.sub
|
||||||
|
|
||||||
this.personalRepository.save(personal, { data: request });
|
this.personalRepository.save(personal, { data: request })
|
||||||
setLogDataDiff(request, { before, after: personal });
|
setLogDataDiff(request, { before, after: personal })
|
||||||
|
|
||||||
const resultText =
|
const resultText = (await personal.probation_status) === 2 ? "ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อ" : "ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้ออกจากราชการ"
|
||||||
(await personal.probation_status) === 2
|
|
||||||
? "ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อ"
|
|
||||||
: "ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้ออกจากราชการ";
|
|
||||||
|
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
|
|
@ -231,11 +211,11 @@ export class ReportController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
isSendNotification: true,
|
isSendNotification: true,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -245,28 +225,24 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("change-status")
|
@Put("change-status")
|
||||||
async ChangeStatus(
|
async ChangeStatus(@Query() personal_id: string, @Body() reqBody: { status: number }, @Request() request: RequestWithUser) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Body() reqBody: { status: number },
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
const personal = await this.personalRepository.findOne({
|
const personal = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
const before = personal;
|
const before = personal
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
personal.probation_status = await reqBody.status;
|
personal.probation_status = await reqBody.status
|
||||||
personal.updateFullName = request.user.name;
|
personal.updateFullName = request.user.name
|
||||||
personal.updateUserId = request.user.sub;
|
personal.updateUserId = request.user.sub
|
||||||
|
|
||||||
await this.personalRepository.save(personal, { data: request });
|
await this.personalRepository.save(personal, { data: request })
|
||||||
setLogDataDiff(request, { before, after: personal });
|
setLogDataDiff(request, { before, after: personal })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -279,46 +255,46 @@ export class ReportController extends Controller {
|
||||||
async GetDataFormRecord(@Query() id: string) {
|
async GetDataFormRecord(@Query() id: string) {
|
||||||
const evaluate = await this.evaluateAssessorRepository.findOne({
|
const evaluate = await this.evaluateAssessorRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.findOne({
|
const directorData = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
||||||
where: { personal_id: evaluate.director_id },
|
where: { personal_id: evaluate.director_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await {
|
const director = await {
|
||||||
...directorData,
|
...directorData,
|
||||||
name: directorData.fullname,
|
name: directorData.fullname,
|
||||||
position: directorData.position,
|
position: directorData.position,
|
||||||
};
|
}
|
||||||
|
|
||||||
const achievements = await this.evaluateAchievementRepository.find({
|
const achievements = await this.evaluateAchievementRepository.find({
|
||||||
select: ["evaluate_expect_level", "evaluate_output_level"],
|
select: ["evaluate_expect_level", "evaluate_output_level"],
|
||||||
where: { evaluate_id: evaluate.id },
|
where: { evaluate_id: evaluate.id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!achievements) {
|
if (!achievements) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
let achievement: any = [];
|
let achievement: any = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
achievements.map(async (element) => {
|
achievements.map(async element => {
|
||||||
const evaluate_expect_level = await {
|
const evaluate_expect_level = await {
|
||||||
col1: element.evaluate_expect_level == 1 ? "/" : "",
|
col1: element.evaluate_expect_level == 1 ? "/" : "",
|
||||||
col2: element.evaluate_expect_level == 2 ? "/" : "",
|
col2: element.evaluate_expect_level == 2 ? "/" : "",
|
||||||
col3: element.evaluate_expect_level == 3 ? "/" : "",
|
col3: element.evaluate_expect_level == 3 ? "/" : "",
|
||||||
col4: element.evaluate_expect_level == 4 ? "/" : "",
|
col4: element.evaluate_expect_level == 4 ? "/" : "",
|
||||||
col5: element.evaluate_expect_level == 5 ? "/" : "",
|
col5: element.evaluate_expect_level == 5 ? "/" : "",
|
||||||
};
|
}
|
||||||
|
|
||||||
const evaluate_output_level = await {
|
const evaluate_output_level = await {
|
||||||
col1: element.evaluate_output_level == 1 ? "/" : "",
|
col1: element.evaluate_output_level == 1 ? "/" : "",
|
||||||
|
|
@ -326,15 +302,15 @@ export class ReportController extends Controller {
|
||||||
col3: element.evaluate_output_level == 3 ? "/" : "",
|
col3: element.evaluate_output_level == 3 ? "/" : "",
|
||||||
col4: element.evaluate_output_level == 4 ? "/" : "",
|
col4: element.evaluate_output_level == 4 ? "/" : "",
|
||||||
col5: element.evaluate_output_level == 5 ? "/" : "",
|
col5: element.evaluate_output_level == 5 ? "/" : "",
|
||||||
};
|
}
|
||||||
|
|
||||||
achievement.push({
|
achievement.push({
|
||||||
...element,
|
...element,
|
||||||
evaluate_expect_level,
|
evaluate_expect_level,
|
||||||
evaluate_output_level,
|
evaluate_output_level,
|
||||||
});
|
})
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
|
|
@ -508,25 +484,25 @@ export class ReportController extends Controller {
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
achievements: achievement,
|
achievements: achievement,
|
||||||
role: director.role,
|
role: director.role,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -538,15 +514,15 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const data = await {
|
const data = await {
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
director: director ? director : null,
|
director: director ? director : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
};
|
}
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -559,10 +535,10 @@ export class ReportController extends Controller {
|
||||||
async GetDataEvaluateCommander(@Query() id: string, @Request() request: RequestWithUser) {
|
async GetDataEvaluateCommander(@Query() id: string, @Request() request: RequestWithUser) {
|
||||||
const evaluate = await this.evaluateCommanderRepository.findOne({
|
const evaluate = await this.evaluateCommanderRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
|
|
@ -739,25 +715,25 @@ export class ReportController extends Controller {
|
||||||
other_training: evaluate.other_training,
|
other_training: evaluate.other_training,
|
||||||
createdAt: evaluate.createdAt,
|
createdAt: evaluate.createdAt,
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -769,38 +745,29 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const commanderData = await this.assignDirectorRepository.findOne({
|
const commanderData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "fullname", "position", "position", "posType", "posLevel", "role", "dated"],
|
||||||
"personal_id",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"role",
|
|
||||||
"dated",
|
|
||||||
],
|
|
||||||
where: { personal_id: evaluate.director_id },
|
where: { personal_id: evaluate.director_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!commanderData) {
|
if (!commanderData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const commander = await {
|
const commander = await {
|
||||||
...commanderData,
|
...commanderData,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
Position: commanderData.position,
|
Position: commanderData.position,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
commander: commander ? commander : null,
|
commander: commander ? commander : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -813,20 +780,20 @@ export class ReportController extends Controller {
|
||||||
async GetDataEvaluateChairman(@Query() id: string, @Request() request: RequestWithUser) {
|
async GetDataEvaluateChairman(@Query() id: string, @Request() request: RequestWithUser) {
|
||||||
const evaluate = await this.evaluateChairmanRepository.findOne({
|
const evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
||||||
Number(evaluate.develop_self_learning_score) +
|
Number(evaluate.develop_self_learning_score) +
|
||||||
Number(evaluate.develop_training_seminar_score) +
|
Number(evaluate.develop_training_seminar_score) +
|
||||||
Number(evaluate.develop_other_training_score));
|
Number(evaluate.develop_other_training_score))
|
||||||
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_orientation_percent) +
|
Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_self_learning_percent) +
|
Number(evaluate.develop_self_learning_percent) +
|
||||||
Number(evaluate.develop_training_seminar_percent));
|
Number(evaluate.develop_training_seminar_percent))
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
|
|
@ -1003,25 +970,25 @@ export class ReportController extends Controller {
|
||||||
evaluate_result: evaluate.evaluate_result,
|
evaluate_result: evaluate.evaluate_result,
|
||||||
createdAt: evaluate.createdAt,
|
createdAt: evaluate.createdAt,
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -1033,35 +1000,35 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
||||||
where: { assign_id: assign.id },
|
where: { assign_id: assign.id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await Promise.all(
|
const director = await Promise.all(
|
||||||
directorData.map(async (element) => {
|
directorData.map(async element => {
|
||||||
return {
|
return {
|
||||||
...element,
|
...element,
|
||||||
name: element.fullname,
|
name: element.fullname,
|
||||||
Position: element.position,
|
Position: element.position,
|
||||||
};
|
}
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
const mentorData = await (director.find((x) => x.role == "mentor") ?? null);
|
const mentorData = await (director.find(x => x.role == "mentor") ?? null)
|
||||||
const mentor = mentorData != null ? mentorData : null;
|
const mentor = mentorData != null ? mentorData : null
|
||||||
|
|
||||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (director.find(x => x.role == "commander") ?? null)
|
||||||
const commander = commanderData != null ? commanderData : null;
|
const commander = commanderData != null ? commanderData : null
|
||||||
|
|
||||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (director.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman = chairmanData != null ? chairmanData : null;
|
const chairman = chairmanData != null ? chairmanData : null
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
|
|
@ -1070,6 +1037,96 @@ export class ReportController extends Controller {
|
||||||
director2: mentor ? mentor : null,
|
director2: mentor ? mentor : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("command11/officer/report/excecute")
|
||||||
|
public async command11Excecute(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: {
|
||||||
|
refId: string
|
||||||
|
commandAffectDate: Date | null
|
||||||
|
commandNo: string | null
|
||||||
|
commandYear: number
|
||||||
|
templateDoc: string | null
|
||||||
|
amount: Double | null
|
||||||
|
positionSalaryAmount: Double | null
|
||||||
|
mouthSalaryAmount: Double | null
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/org/command/excexute/salary-probation", {
|
||||||
|
data: body.refIds.map(v => ({
|
||||||
|
profileId: v.refId,
|
||||||
|
date: v.commandAffectDate,
|
||||||
|
refCommandNo: `${v.commandNo}/${Extension.ToThaiYear(v.commandYear)}`,
|
||||||
|
salaryRef: v.templateDoc,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
.then(async res => {})
|
||||||
|
.catch(() => {})
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
@Post("command11/officer/report")
|
||||||
|
public async command11(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: string[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const lists = await this.personalRepository.find({
|
||||||
|
where: { probation_status: 2, personal_id: In(body.refIds) },
|
||||||
|
})
|
||||||
|
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("command12/officer/report/excecute")
|
||||||
|
public async command12Excecute(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: {
|
||||||
|
refId: string
|
||||||
|
commandAffectDate: Date | null
|
||||||
|
commandNo: string | null
|
||||||
|
commandYear: number
|
||||||
|
templateDoc: string | null
|
||||||
|
amount: Double | null
|
||||||
|
positionSalaryAmount: Double | null
|
||||||
|
mouthSalaryAmount: Double | null
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/org/command/excexute/salary-probation-leave", {
|
||||||
|
data: body.refIds.map(v => ({
|
||||||
|
profileId: v.refId,
|
||||||
|
date: v.commandAffectDate,
|
||||||
|
refCommandNo: `${v.commandNo}/${Extension.ToThaiYear(v.commandYear)}`,
|
||||||
|
salaryRef: v.templateDoc,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
.then(async res => {})
|
||||||
|
.catch(() => {})
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
@Post("command12/officer/report")
|
||||||
|
public async command12(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: string[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const lists = await this.personalRepository.find({
|
||||||
|
where: { probation_status: 3, personal_id: In(body.refIds) },
|
||||||
|
})
|
||||||
|
|
||||||
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue