ปรับ การทดลองปฏิบัติหน้าที่ราชการ
This commit is contained in:
parent
ee80702930
commit
fc3f40722e
5 changed files with 624 additions and 434 deletions
|
|
@ -1,429 +1,543 @@
|
|||
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa"
|
||||
import HttpSuccess from "../interfaces/http-success"
|
||||
import HttpStatusCode from "../interfaces/http-status"
|
||||
import { RequestWithUser } from "../middlewares/user"
|
||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils"
|
||||
import { AppDataSource } from "../database/data-source"
|
||||
import { AssignDirector } from "../entities/AssignDirector"
|
||||
import HttpError from "../interfaces/http-error"
|
||||
import { Assign } from "../entities/Assign"
|
||||
import { Personal } from "../entities/Personal"
|
||||
import CallAPI from "../interfaces/call-api"
|
||||
import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman"
|
||||
import permission from "../interfaces/permission"
|
||||
import {
|
||||
Controller,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Query,
|
||||
Put,
|
||||
} from "tsoa";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { AssignDirector } from "../entities/AssignDirector";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import { Personal } from "../entities/Personal";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import {
|
||||
CreateEvaluateChairman,
|
||||
EvaluateChairman,
|
||||
} from "../entities/EvaluateChairman";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/probation/evaluate-chairman")
|
||||
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
||||
@Security("bearerAuth")
|
||||
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
)
|
||||
export class EvaluateChairmanController extends Controller {
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||
private assignRepository = AppDataSource.getRepository(Assign)
|
||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||
private personalRepository = AppDataSource.getRepository(Personal)
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private evaluateChairmanRepository =
|
||||
AppDataSource.getRepository(EvaluateChairman);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
|
||||
/**
|
||||
* API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
* @summary ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION")
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||
/**
|
||||
* API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
* @summary ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
})
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||
}
|
||||
const director_id = director.personal_id
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
});
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||
}
|
||||
const director_id = director.personal_id;
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
})
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||
}
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const profile = await (assign.profile
|
||||
? {
|
||||
...assign.profile,
|
||||
id: assign.profile.personal_id,
|
||||
name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||
Oc: assign.profile.organization,
|
||||
}
|
||||
: null)
|
||||
const profile = await (assign.profile
|
||||
? {
|
||||
...assign.profile,
|
||||
id: assign.profile.personal_id,
|
||||
name:
|
||||
assign.profile.prefixName +
|
||||
assign.profile.firstName +
|
||||
" " +
|
||||
assign.profile.lastName,
|
||||
Oc: assign.profile.organization,
|
||||
}
|
||||
: null);
|
||||
|
||||
const evaluate_amount = await this.evaluateChairmanRepository.count({
|
||||
where: {
|
||||
assign_id,
|
||||
director_id,
|
||||
},
|
||||
})
|
||||
const evaluate_no = await (evaluate_amount + 1)
|
||||
const start_date = evaluate_amount == 0 ? assign.date_start : findEndDate(evaluate_amount * 3, assign.date_start)
|
||||
const evaluate_amount = await this.evaluateChairmanRepository.count({
|
||||
where: {
|
||||
assign_id,
|
||||
director_id,
|
||||
},
|
||||
});
|
||||
const evaluate_no = await (evaluate_amount + 1);
|
||||
const start_date =
|
||||
evaluate_amount == 0
|
||||
? assign.date_start
|
||||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
||||
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
})
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||
}
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
}
|
||||
|
||||
let mentors = []
|
||||
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index]
|
||||
let mentors = [];
|
||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index];
|
||||
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
})
|
||||
}
|
||||
}
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label:
|
||||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
return new HttpSuccess({
|
||||
person: profile ? profile : null,
|
||||
assign,
|
||||
evaluate_no: evaluate_no,
|
||||
start_date: start_date,
|
||||
end_date: findEndDate(3, start_date),
|
||||
commander,
|
||||
mentors,
|
||||
chairman,
|
||||
})
|
||||
}
|
||||
return new HttpSuccess({
|
||||
person: profile ? profile : null,
|
||||
assign,
|
||||
evaluate_no: evaluate_no,
|
||||
start_date: start_date,
|
||||
end_date: findEndDate(3, start_date),
|
||||
commander,
|
||||
mentors,
|
||||
chairman,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API ข้อมูลแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
* @summary ข้อมูลแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
})
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||
}
|
||||
const director_id = director.personal_id
|
||||
let evaluate: any = null
|
||||
if (evaluate_no) {
|
||||
evaluate = await this.evaluateChairmanRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
no: evaluate_no,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
evaluate = await this.evaluateChairmanRepository.find({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
},
|
||||
})
|
||||
/**
|
||||
* API ข้อมูลแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
* @summary ข้อมูลแบบประเมินผล (คณะกรรมการ)
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetEvaluate(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string
|
||||
) {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
});
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||
}
|
||||
const director_id = director.personal_id;
|
||||
let evaluate: any = null;
|
||||
if (evaluate_no) {
|
||||
evaluate = await this.evaluateChairmanRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
no: evaluate_no,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
evaluate = await this.evaluateChairmanRepository.find({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
},
|
||||
});
|
||||
|
||||
if (evaluate)
|
||||
evaluate = await evaluate.map((element: EvaluateChairman) => ({
|
||||
...element,
|
||||
no: Number(element.no),
|
||||
}))
|
||||
}
|
||||
if (evaluate)
|
||||
evaluate = await evaluate.map((element: EvaluateChairman) => ({
|
||||
...element,
|
||||
no: Number(element.no),
|
||||
}));
|
||||
}
|
||||
|
||||
if (!evaluate) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน")
|
||||
}
|
||||
if (!evaluate) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||
}
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
where: { id: assign_id },
|
||||
})
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||
}
|
||||
const assign = await this.assignRepository.findOne({
|
||||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"],
|
||||
where: { personal_id: assign.personal_id },
|
||||
})
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
select: [
|
||||
"personal_id",
|
||||
"prefixName",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"positionName",
|
||||
"positionLevelName",
|
||||
"organization",
|
||||
],
|
||||
where: { personal_id: assign.personal_id },
|
||||
});
|
||||
|
||||
const experimentee = await experimenteeData.map(element => ({
|
||||
...element,
|
||||
name: element.prefixName + element.firstName + " " + element.lastName,
|
||||
Oc: element.organization,
|
||||
}))
|
||||
const experimentee = await experimenteeData.map((element) => ({
|
||||
...element,
|
||||
name: element.prefixName + element.firstName + " " + element.lastName,
|
||||
Oc: element.organization,
|
||||
}));
|
||||
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
})
|
||||
const directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||
}
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
}
|
||||
|
||||
let mentors = []
|
||||
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index]
|
||||
let mentors = [];
|
||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
||||
if (mentorList.length > 0) {
|
||||
for (let index = 0; index < mentorList.length; index++) {
|
||||
const e = await mentorList[index];
|
||||
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
})
|
||||
}
|
||||
}
|
||||
mentors.push({
|
||||
personal_id: e.personal_id,
|
||||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null
|
||||
const commander =
|
||||
commanderData != null
|
||||
? {
|
||||
personal_id: commanderData.personal_id,
|
||||
dated: commanderData.dated,
|
||||
name: commanderData.fullname,
|
||||
label:
|
||||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
posLevel: commanderData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
personal_id: chairmanData.personal_id,
|
||||
dated: chairmanData.dated,
|
||||
name: chairmanData.fullname,
|
||||
label:
|
||||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
return new HttpSuccess({
|
||||
experimentee: experimentee,
|
||||
mentors: mentors,
|
||||
commander: commander,
|
||||
chairman: chairman,
|
||||
assign,
|
||||
evaluate,
|
||||
})
|
||||
}
|
||||
return new HttpSuccess({
|
||||
experimentee: experimentee,
|
||||
mentors: mentors,
|
||||
commander: commander,
|
||||
chairman: chairman,
|
||||
assign,
|
||||
evaluate,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
* @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
*/
|
||||
@Post("")
|
||||
async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateChairman, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||
/**
|
||||
* API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
* @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
*/
|
||||
@Post("")
|
||||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
})
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||
}
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
});
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||
}
|
||||
|
||||
const director_id = director.personal_id
|
||||
const director_id = director.personal_id;
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
})
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||
}
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
where: { id: assign_id },
|
||||
});
|
||||
if (!assign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||
}
|
||||
|
||||
const postData: any = await {
|
||||
assign_id,
|
||||
...requestBody,
|
||||
director_id,
|
||||
no: requestBody.evaluate_no,
|
||||
date_start: requestBody.start_date,
|
||||
personal_id: assign.personal_id,
|
||||
const postData: any = await {
|
||||
assign_id,
|
||||
...requestBody,
|
||||
director_id,
|
||||
no: requestBody.evaluate_no,
|
||||
date_start: requestBody.start_date,
|
||||
personal_id: assign.personal_id,
|
||||
|
||||
achievement_other_desc: requestBody.achievement_other ? requestBody.achievement_other.text : "",
|
||||
achievement_other_level: requestBody.achievement_other ? Number(requestBody.achievement_other.level) : 0,
|
||||
behavior_other_desc: requestBody.behavior_orther.text,
|
||||
behavior_other_level: requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||
achievement_other_desc: requestBody.achievement_other
|
||||
? requestBody.achievement_other.text
|
||||
: "",
|
||||
achievement_other_level: requestBody.achievement_other
|
||||
? Number(requestBody.achievement_other.level)
|
||||
: 0,
|
||||
behavior_other_desc: requestBody.behavior_orther.text,
|
||||
behavior_other_level:
|
||||
requestBody.behavior_orther.text != ""
|
||||
? Number(requestBody.behavior_orther.level)
|
||||
: 0,
|
||||
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
}
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
updateUserId: request.user.sub,
|
||||
updateFullName: request.user.name,
|
||||
};
|
||||
|
||||
await this.evaluateChairmanRepository.save(postData, {
|
||||
data: request,
|
||||
})
|
||||
setLogDataDiff(request, { before: null, after: postData })
|
||||
await this.evaluateChairmanRepository.save(postData, {
|
||||
data: request,
|
||||
});
|
||||
setLogDataDiff(request, { before: null, after: postData });
|
||||
|
||||
if (Number(requestBody.evaluate_no) < 2) {
|
||||
// #noted cronjob
|
||||
// แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
||||
var dateSend = await findEndDate(3, requestBody.start_date)
|
||||
const nextNo = await (Number(requestBody.evaluate_no) + 1)
|
||||
await new CallAPI()
|
||||
.PostData(request, "/placement/noti", {
|
||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||
body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับคณะกรรมการ) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||
receiverUserId: director_id,
|
||||
payload: "",
|
||||
isSendMail: true,
|
||||
isSendInbox: true,
|
||||
receiveDate: dateSend,
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error calling API:", error)
|
||||
})
|
||||
}
|
||||
if (Number(requestBody.evaluate_no) < 2) {
|
||||
// #noted cronjob
|
||||
// แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
||||
var dateSend = await findEndDate(3, requestBody.start_date);
|
||||
const nextNo = await (Number(requestBody.evaluate_no) + 1);
|
||||
await new CallAPI()
|
||||
.PostData(request, "/placement/noti", {
|
||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||
body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับคณะกรรมการ) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||
receiverUserId: director_id,
|
||||
payload: "",
|
||||
isSendMail: true,
|
||||
isSendInbox: true,
|
||||
receiveDate: dateSend,
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
});
|
||||
}
|
||||
|
||||
return new HttpSuccess()
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
* @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
*/
|
||||
@Put("")
|
||||
async UpdateData(
|
||||
// @Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||
/**
|
||||
* API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
* @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา)
|
||||
*
|
||||
*/
|
||||
@Put("")
|
||||
async UpdateData(
|
||||
// @Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
||||
let evaluate = await this.evaluateChairmanRepository.findOne({
|
||||
where: { id: evaluate_id },
|
||||
})
|
||||
let evaluate = await this.evaluateChairmanRepository.findOne({
|
||||
where: { id: evaluate_id },
|
||||
});
|
||||
|
||||
const before = evaluate
|
||||
const before = evaluate;
|
||||
|
||||
if (!evaluate) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน")
|
||||
}
|
||||
if (!evaluate) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||
}
|
||||
|
||||
evaluate.chairman_dated = requestBody.chairman_dated
|
||||
evaluate.director1_dated = requestBody.director1_dated
|
||||
evaluate.director2_dated = requestBody.director2_dated
|
||||
evaluate.knowledge_level = requestBody.knowledge_level
|
||||
evaluate.apply_level = requestBody.apply_level
|
||||
evaluate.success_level = requestBody.success_level
|
||||
evaluate.achievement_other_desc = requestBody.achievement_other ? requestBody.achievement_other.text : ""
|
||||
evaluate.achievement_other_level = requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0
|
||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
||||
evaluate.director1_dated = requestBody.director1_dated;
|
||||
evaluate.director2_dated = requestBody.director2_dated;
|
||||
evaluate.knowledge_level = requestBody.knowledge_level;
|
||||
evaluate.apply_level = requestBody.apply_level;
|
||||
evaluate.success_level = requestBody.success_level;
|
||||
evaluate.achievement_other_desc = requestBody.achievement_other
|
||||
? requestBody.achievement_other.text
|
||||
: "";
|
||||
evaluate.achievement_other_level =
|
||||
requestBody.achievement_other.text != ""
|
||||
? Number(requestBody.achievement_other.level)
|
||||
: 0;
|
||||
|
||||
evaluate.conduct1_level = requestBody.conduct1_level
|
||||
evaluate.conduct2_level = requestBody.conduct2_level
|
||||
evaluate.conduct3_level = requestBody.conduct3_level
|
||||
evaluate.conduct4_level = requestBody.conduct4_level
|
||||
evaluate.moral1_level = requestBody.moral1_level
|
||||
evaluate.moral2_level = requestBody.moral2_level
|
||||
evaluate.moral3_level = requestBody.moral3_level
|
||||
evaluate.discipline1_level = requestBody.discipline1_level
|
||||
evaluate.discipline2_level = requestBody.discipline2_level
|
||||
evaluate.discipline3_level = requestBody.discipline3_level
|
||||
evaluate.discipline4_level = requestBody.discipline4_level
|
||||
evaluate.discipline5_level = requestBody.discipline5_level
|
||||
evaluate.behavior_other_desc = requestBody.behavior_orther.text
|
||||
evaluate.behavior_other_level = requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0
|
||||
evaluate.develop_orientation_score = requestBody.develop_orientation_score
|
||||
evaluate.develop_self_learning_score = requestBody.develop_self_learning_score
|
||||
evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score
|
||||
evaluate.develop_other_training_score = requestBody.develop_other_training_score
|
||||
evaluate.develop_orientation_percent = requestBody.develop_orientation_percent
|
||||
evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent
|
||||
evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent
|
||||
evaluate.develop_other_training_percent = requestBody.develop_other_training_percent
|
||||
evaluate.develop_result = requestBody.develop_result
|
||||
evaluate.achievement_score = requestBody.achievement_score
|
||||
evaluate.achievement_score_total = requestBody.achievement_score_total
|
||||
evaluate.achievement_percent = requestBody.achievement_percent
|
||||
evaluate.achievement_result = requestBody.achievement_result
|
||||
evaluate.behavior_score = requestBody.behavior_score
|
||||
evaluate.behavior_score_total = requestBody.behavior_score_total
|
||||
evaluate.behavior_percent = requestBody.behavior_percent
|
||||
evaluate.behavior_result = requestBody.behavior_result
|
||||
evaluate.sum_score = requestBody.sum_score
|
||||
evaluate.sum_percent = requestBody.sum_percent
|
||||
evaluate.evaluate_result = requestBody.evaluate_result
|
||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
||||
evaluate.conduct3_level = requestBody.conduct3_level;
|
||||
evaluate.conduct4_level = requestBody.conduct4_level;
|
||||
evaluate.moral1_level = requestBody.moral1_level;
|
||||
evaluate.moral2_level = requestBody.moral2_level;
|
||||
evaluate.moral3_level = requestBody.moral3_level;
|
||||
evaluate.discipline1_level = requestBody.discipline1_level;
|
||||
evaluate.discipline2_level = requestBody.discipline2_level;
|
||||
evaluate.discipline3_level = requestBody.discipline3_level;
|
||||
evaluate.discipline4_level = requestBody.discipline4_level;
|
||||
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||
evaluate.behavior_other_desc = requestBody.behavior_orther.text;
|
||||
evaluate.behavior_other_level =
|
||||
requestBody.behavior_orther.text != ""
|
||||
? Number(requestBody.behavior_orther.level)
|
||||
: 0;
|
||||
evaluate.develop_orientation_score = requestBody.develop_orientation_score;
|
||||
evaluate.develop_self_learning_score =
|
||||
requestBody.develop_self_learning_score;
|
||||
evaluate.develop_training_seminar_score =
|
||||
requestBody.develop_training_seminar_score;
|
||||
evaluate.develop_other_training_score =
|
||||
requestBody.develop_other_training_score;
|
||||
evaluate.develop_orientation_percent =
|
||||
requestBody.develop_orientation_percent;
|
||||
evaluate.develop_self_learning_percent =
|
||||
requestBody.develop_self_learning_percent;
|
||||
evaluate.develop_training_seminar_percent =
|
||||
requestBody.develop_training_seminar_percent;
|
||||
evaluate.develop_other_training_percent =
|
||||
requestBody.develop_other_training_percent;
|
||||
evaluate.develop_result = requestBody.develop_result;
|
||||
evaluate.achievement_score = requestBody.achievement_score;
|
||||
evaluate.achievement_score_total = requestBody.achievement_score_total;
|
||||
evaluate.achievement_percent = requestBody.achievement_percent;
|
||||
evaluate.achievement_result = requestBody.achievement_result;
|
||||
evaluate.behavior_score = requestBody.behavior_score;
|
||||
evaluate.behavior_score_total = requestBody.behavior_score_total;
|
||||
evaluate.behavior_percent = requestBody.behavior_percent;
|
||||
evaluate.behavior_result = requestBody.behavior_result;
|
||||
evaluate.sum_score = requestBody.sum_score;
|
||||
evaluate.sum_percent = requestBody.sum_percent;
|
||||
evaluate.evaluate_result = requestBody.evaluate_result;
|
||||
|
||||
evaluate.updateUserId = request.user.sub
|
||||
evaluate.updateFullName = request.user.name
|
||||
evaluate.updateUserId = request.user.sub;
|
||||
evaluate.updateFullName = request.user.name;
|
||||
|
||||
await this.evaluateChairmanRepository.save(evaluate, { data: request })
|
||||
setLogDataDiff(request, { before, after: evaluate })
|
||||
await this.evaluateChairmanRepository.save(evaluate, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluate });
|
||||
|
||||
return new HttpSuccess()
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export class EvaluateController extends Controller {
|
|||
const commander = await {
|
||||
...commanderData,
|
||||
name: commanderData.fullname,
|
||||
label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`,
|
||||
label: `${commanderData.fullname} (${commanderData.position}${commanderData.posLevel})`,
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -183,7 +183,7 @@ export class EvaluateController extends Controller {
|
|||
const directors = await directorData.map(element => ({
|
||||
...element,
|
||||
name: element.fullname,
|
||||
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
||||
label: `${element.fullname} (${element.position}${element.posLevel})`,
|
||||
}))
|
||||
|
||||
const experimenteeData = await this.personalRepository.find({
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export class EvaluateRecordController extends Controller {
|
|||
const commander = await {
|
||||
...commanderData,
|
||||
name: commanderData.fullname,
|
||||
label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`,
|
||||
label: `${commanderData.fullname} (${commanderData.position}${commanderData.posLevel})`,
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -331,7 +331,7 @@ export class EvaluateRecordController extends Controller {
|
|||
const directors = await directorData.map(element => ({
|
||||
...element,
|
||||
name: element.fullname,
|
||||
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
||||
label: `${element.fullname} (${element.position}${element.posLevel})`,
|
||||
}))
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -578,7 +578,7 @@ export class EvaluateRecordController extends Controller {
|
|||
const director = await {
|
||||
...directorData,
|
||||
name: directorData.fullname,
|
||||
label: `${directorData.fullname} (${directorData.position}, ${directorData.posType}: ${directorData.posLevel})`,
|
||||
label: `${directorData.fullname} (${directorData.position}${directorData.posLevel})`,
|
||||
}
|
||||
|
||||
const director_id = director.personal_id
|
||||
|
|
@ -843,7 +843,7 @@ export class EvaluateRecordController extends Controller {
|
|||
const directors = await directorData.map(element => ({
|
||||
...element,
|
||||
name: element.fullname,
|
||||
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
||||
label: `${element.fullname} (${element.position}${element.posLevel})`,
|
||||
}))
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ import { Assign } from "../entities/Assign";
|
|||
import { Personal } from "../entities/Personal";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
||||
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult";
|
||||
import {
|
||||
CreateEvaluateResult,
|
||||
EvaluateResult,
|
||||
} from "../entities/EvaluateResult";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/probation/evaluate-result")
|
||||
|
|
@ -31,14 +34,17 @@ import permission from "../interfaces/permission";
|
|||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
)
|
||||
export class EvaluateResultController extends Controller {
|
||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||
private assignDirectorRepository =
|
||||
AppDataSource.getRepository(AssignDirector);
|
||||
private assignRepository = AppDataSource.getRepository(Assign);
|
||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
||||
private evaluateChairmanRepository =
|
||||
AppDataSource.getRepository(EvaluateChairman);
|
||||
private personalRepository = AppDataSource.getRepository(Personal);
|
||||
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
|
||||
private evaluateResultRepository =
|
||||
AppDataSource.getRepository(EvaluateResult);
|
||||
|
||||
/**
|
||||
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
||||
|
|
@ -47,9 +53,17 @@ export class EvaluateResultController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("create")
|
||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
|
||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
async CreateEvaluate(
|
||||
@Query() assign_id: string,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
assign_id,
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
const assign = await this.assignRepository.findOne({
|
||||
relations: ["profile"],
|
||||
|
|
@ -64,7 +78,10 @@ export class EvaluateResultController extends Controller {
|
|||
...assign.profile,
|
||||
id: assign.profile.personal_id,
|
||||
name:
|
||||
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||
assign.profile.prefixName +
|
||||
assign.profile.firstName +
|
||||
" " +
|
||||
assign.profile.lastName,
|
||||
Oc: assign.profile.organization,
|
||||
}
|
||||
: null);
|
||||
|
|
@ -75,7 +92,10 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -89,7 +109,9 @@ export class EvaluateResultController extends Controller {
|
|||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -97,7 +119,9 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
|
|
@ -109,7 +133,7 @@ export class EvaluateResultController extends Controller {
|
|||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||
? `(${commanderData.position}${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position,
|
||||
posType: commanderData.posType,
|
||||
|
|
@ -117,7 +141,9 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -128,7 +154,7 @@ export class EvaluateResultController extends Controller {
|
|||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
|
|
@ -136,7 +162,7 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const resultData = await this.evaluateChairmanRepository.findOne({
|
||||
const resultData = await this.evaluateChairmanRepository.find({
|
||||
select: [
|
||||
"develop_orientation_score",
|
||||
"develop_self_learning_score",
|
||||
|
|
@ -152,18 +178,34 @@ export class EvaluateResultController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล");
|
||||
}
|
||||
|
||||
const develop_complete = await (resultData.develop_orientation_score > 0 &&
|
||||
resultData.develop_self_learning_score > 0 &&
|
||||
resultData.develop_training_seminar_score > 0
|
||||
? 1
|
||||
: 2);
|
||||
const result = resultData.map((e) => {
|
||||
const develop_complete =
|
||||
e.develop_orientation_score > 0 &&
|
||||
e.develop_self_learning_score > 0 &&
|
||||
e.develop_training_seminar_score
|
||||
? 1
|
||||
: 2;
|
||||
|
||||
const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2);
|
||||
const evaluate_result = e.evaluate_result === 1 ? 1 : 2;
|
||||
|
||||
const result = await {
|
||||
develop_complete: develop_complete,
|
||||
evaluate_result: evaluate_result,
|
||||
};
|
||||
return {
|
||||
develop_complete,
|
||||
evaluate_result,
|
||||
};
|
||||
});
|
||||
|
||||
// const develop_complete = await (resultData.develop_orientation_score > 0 &&
|
||||
// resultData.develop_self_learning_score > 0 &&
|
||||
// resultData.develop_training_seminar_score > 0
|
||||
// ? 1
|
||||
// : 2);
|
||||
|
||||
// const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2);
|
||||
|
||||
// const result = await {
|
||||
// develop_complete: develop_complete,
|
||||
// evaluate_result: evaluate_result,
|
||||
// };
|
||||
|
||||
return new HttpSuccess({
|
||||
person: profile,
|
||||
|
|
@ -185,7 +227,7 @@ export class EvaluateResultController extends Controller {
|
|||
async GetEvaluate(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() assign_id: string,
|
||||
@Query() evaluate_no?: string,
|
||||
@Query() evaluate_no?: string
|
||||
) {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
|
|
@ -201,14 +243,26 @@ export class EvaluateResultController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||
}
|
||||
const director_id = director.personal_id;
|
||||
|
||||
const evaluate = await this.evaluateResultRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
},
|
||||
});
|
||||
|
||||
let evaluate: any = null;
|
||||
if (evaluate_no) {
|
||||
evaluate = await this.evaluateResultRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
no: evaluate_no,
|
||||
},
|
||||
});
|
||||
// if (!evaluate) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||
// }
|
||||
} else {
|
||||
evaluate = await this.evaluateResultRepository.findOne({
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (!evaluate) {
|
||||
return new HttpSuccess(null);
|
||||
}
|
||||
|
|
@ -243,10 +297,15 @@ export class EvaluateResultController extends Controller {
|
|||
const experimentee = await {
|
||||
...experimenteeData,
|
||||
name:
|
||||
experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
|
||||
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
|
||||
experimenteeData.prefixName +
|
||||
experimenteeData.firstName +
|
||||
" " +
|
||||
experimenteeData.lastName,
|
||||
PositionLevel:
|
||||
experimenteeData.positionName + experimenteeData.positionLevelName,
|
||||
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
|
||||
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
OrganizationOrganization:
|
||||
splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
|
||||
Oc: experimenteeData.orgRootName,
|
||||
};
|
||||
|
||||
|
|
@ -256,7 +315,10 @@ export class EvaluateResultController extends Controller {
|
|||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
);
|
||||
}
|
||||
|
||||
let mentors = [];
|
||||
|
|
@ -270,7 +332,9 @@ export class EvaluateResultController extends Controller {
|
|||
dated: e.dated,
|
||||
name: e.fullname,
|
||||
label:
|
||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||
e.fullname +
|
||||
" " +
|
||||
(e.position ? `(${e.position}${e.posLevel})` : ""),
|
||||
position: e.position + e.posLevel,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
|
|
@ -278,7 +342,9 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||
const commanderData = await (directorData.find(
|
||||
(x) => x.role == "commander"
|
||||
) ?? null);
|
||||
|
||||
const commander =
|
||||
commanderData != null
|
||||
|
|
@ -290,7 +356,7 @@ export class EvaluateResultController extends Controller {
|
|||
commanderData.fullname +
|
||||
" " +
|
||||
(commanderData.position
|
||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||
? `(${commanderData.position}${commanderData.posLevel})`
|
||||
: ""),
|
||||
position: commanderData.position + commanderData.posLevel,
|
||||
posType: commanderData.posType,
|
||||
|
|
@ -298,7 +364,9 @@ export class EvaluateResultController extends Controller {
|
|||
}
|
||||
: null;
|
||||
|
||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||
const chairmanData = await (directorData.find(
|
||||
(x) => x.role == "chairman"
|
||||
) ?? null);
|
||||
const chairman =
|
||||
chairmanData != null
|
||||
? {
|
||||
|
|
@ -309,7 +377,7 @@ export class EvaluateResultController extends Controller {
|
|||
chairmanData.fullname +
|
||||
" " +
|
||||
(chairmanData.position
|
||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||
? `(${chairmanData.position}${chairmanData.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position + chairmanData.posLevel,
|
||||
posType: chairmanData.posType,
|
||||
|
|
@ -323,7 +391,7 @@ export class EvaluateResultController extends Controller {
|
|||
mentors,
|
||||
experimentee,
|
||||
assign,
|
||||
evaluate: evaluate,
|
||||
evaluate: evaluate ? evaluate : null,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +405,7 @@ export class EvaluateResultController extends Controller {
|
|||
async PostData(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
||||
|
|
@ -366,10 +434,11 @@ export class EvaluateResultController extends Controller {
|
|||
assign_id,
|
||||
...requestBody,
|
||||
director_id,
|
||||
no: 1,
|
||||
no: requestBody.evaluate_no,
|
||||
personal_id: assign.personal_id,
|
||||
date_start: requestBody.start_date,
|
||||
expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
||||
expand_month:
|
||||
requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
||||
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
|
|
@ -430,7 +499,7 @@ export class EvaluateResultController extends Controller {
|
|||
@Query() assign_id: string,
|
||||
@Query() evaluate_id: string,
|
||||
@Body() requestBody: CreateEvaluateResult,
|
||||
@Request() request: RequestWithUser,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
PrimaryGeneratedColumn,
|
||||
} from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Assign } from "./Assign";
|
||||
|
||||
|
|
@ -102,6 +108,7 @@ export class CreateEvaluateResult {
|
|||
chairman_dated: Date | null;
|
||||
director1_dated: Date | null;
|
||||
director2_dated: Date | null;
|
||||
evaluate_no: number;
|
||||
}
|
||||
|
||||
export type UpdateEvaluateResult = Partial<CreateEvaluateResult>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue