fixing field

This commit is contained in:
Warunee Tamkoo 2025-01-11 13:29:21 +07:00
parent 27e54e914a
commit 97825247d7
3 changed files with 448 additions and 360 deletions

View file

@ -623,6 +623,7 @@ export class AssignController extends Controller {
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
Oc: profileData.orgRootName,
PositionLevel: profileData.positionName + profileData.positionLevelName,
};
const jobs = await this.assignJobRepository.find({

View file

@ -1,419 +1,503 @@
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 { 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 { EvaluateChairman } from "../entities/EvaluateChairman"
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult"
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 { 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 { EvaluateChairman } from "../entities/EvaluateChairman";
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult";
import permission from "../interfaces/permission";
@Route("api/v1/probation/evaluate-result")
@Tags("แบบรายงานการประเมินฯ")
@Security("bearerAuth")
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
export class EvaluateResultController extends Controller {
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
private assignRepository = AppDataSource.getRepository(Assign)
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
private personalRepository = AppDataSource.getRepository(Personal)
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
private assignRepository = AppDataSource.getRepository(Assign);
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
private personalRepository = AppDataSource.getRepository(Personal);
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
/**
* 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 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 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.posType}: ${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.posType}: ${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.posType}: ${chairmanData.posLevel})`
: ""),
position: chairmanData.position,
posType: chairmanData.posType,
posLevel: chairmanData.posLevel,
}
: null;
const resultData = await this.evaluateChairmanRepository.findOne({
select: ["develop_orientation_score", "develop_self_learning_score", "develop_training_seminar_score", "evaluate_result"],
where: {
assign_id,
},
})
const resultData = await this.evaluateChairmanRepository.findOne({
select: [
"develop_orientation_score",
"develop_self_learning_score",
"develop_training_seminar_score",
"evaluate_result",
],
where: {
assign_id,
},
});
if (!resultData) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล")
}
if (!resultData) {
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 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 evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2);
const result = await {
develop_complete: develop_complete,
evaluate_result: evaluate_result,
}
const result = await {
develop_complete: develop_complete,
evaluate_result: evaluate_result,
};
return new HttpSuccess({
person: profile,
assign,
result,
mentors,
commander,
chairman,
})
}
return new HttpSuccess({
person: profile,
assign,
result,
mentors,
commander,
chairman,
});
}
/**
* API
*
* @summary
*
*/
@Get("")
async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) {
await new permission().PermissionGet(request, "SYS_PROBATION")
/**
* 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
// ต้องปรับเป็น 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;
const evaluate = await this.evaluateResultRepository.findOne({
where: {
director_id,
assign_id,
},
})
const evaluate = await this.evaluateResultRepository.findOne({
where: {
director_id,
assign_id,
},
});
if (!evaluate) {
return new HttpSuccess(null)
}
if (!evaluate) {
return new HttpSuccess(null);
}
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.findOne({
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"],
where: { personal_id: assign.personal_id },
})
const experimenteeData = await this.personalRepository.findOne({
select: [
"personal_id",
"prefixName",
"firstName",
"lastName",
"positionName",
"positionLevelName",
"organization",
],
where: { personal_id: assign.personal_id },
});
if (!experimenteeData) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
}
const experimentee = await {
...experimenteeData,
name: experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
Oc: experimenteeData.organization,
}
if (!experimenteeData) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
}
const experimentee = await {
...experimenteeData,
name:
experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
Oc: experimenteeData.organization,
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
};
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.posType}: ${e.posLevel})` : ""),
position: e.position + e.posLevel,
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.posType}: ${commanderData.posLevel})`
: ""),
position: commanderData.position + commanderData.posLevel,
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.posType}: ${chairmanData.posLevel})`
: ""),
position: chairmanData.position + chairmanData.posLevel,
posType: chairmanData.posType,
posLevel: chairmanData.posLevel,
}
: null;
return new HttpSuccess({
commander,
chairman,
mentors,
experimentee,
assign,
evaluate: evaluate,
})
}
return new HttpSuccess({
commander,
chairman,
mentors,
experimentee,
assign,
evaluate: evaluate,
});
}
/**
* API
*
* @summary
*
*/
@Post("")
async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateResult, @Request() request: RequestWithUser) {
await new permission().PermissionUpdate(request, "SYS_PROBATION")
/**
* API
*
* @summary
*
*/
@Post("")
async PostData(
@Query() assign_id: string,
@Body() requestBody: CreateEvaluateResult,
@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: 1,
personal_id: assign.personal_id,
date_start: requestBody.start_date,
expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
const postData: any = await {
assign_id,
...requestBody,
director_id,
no: 1,
personal_id: assign.personal_id,
date_start: requestBody.start_date,
expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 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.evaluateResultRepository.save(postData, {
data: request,
})
setLogDataDiff(request, { before: null, after: postData })
await this.evaluateResultRepository.save(postData, {
data: request,
});
setLogDataDiff(request, { before: null, after: postData });
const personal = await this.personalRepository.findOne({
where: { personal_id: assign.personal_id },
})
const personal = await this.personalRepository.findOne({
where: { personal_id: assign.personal_id },
});
if (!personal) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
}
personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status
if (!personal) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
}
personal.probation_status =
requestBody.pass_result == 1
? 2
: requestBody.pass_result == 2
? 3
: personal.probation_status;
if (requestBody.pass_result == 3) {
personal.probation_status = 7
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
await new CallAPI()
.PostData(request, "/placement/noti", {
subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ",
body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`,
receiverUserId: assign.personal_id,
payload: "",
isSendMail: false,
isSendInbox: true,
isSendNotification: true,
})
.catch(error => {
console.error("Error calling API:", error)
})
}
if (requestBody.pass_result == 3) {
personal.probation_status = 7;
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
await new CallAPI()
.PostData(request, "/placement/noti", {
subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ",
body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`,
receiverUserId: assign.personal_id,
payload: "",
isSendMail: false,
isSendInbox: true,
isSendNotification: true,
})
.catch((error) => {
console.error("Error calling API:", error);
});
}
await this.personalRepository.save(personal, { data: request })
await this.personalRepository.save(personal, { data: request });
return new HttpSuccess()
}
return new HttpSuccess();
}
/**
* API
*
* @summary
*
*/
@Put("")
async UpdateData(@Query() assign_id: string, @Query() evaluate_id: string, @Body() requestBody: CreateEvaluateResult, @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: CreateEvaluateResult,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_PROBATION");
let evaluate = await this.evaluateResultRepository.findOne({
where: { id: evaluate_id },
})
let evaluate = await this.evaluateResultRepository.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.date_start = requestBody.start_date
evaluate.date_finish = requestBody.date_finish
evaluate.develop_complete = requestBody.develop_complete
evaluate.pass_result = requestBody.pass_result
evaluate.expand_month = requestBody.pass_result && requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0
evaluate.reson = requestBody.reson
evaluate.chairman_dated = requestBody.chairman_dated
evaluate.date_start = requestBody.start_date;
evaluate.date_finish = requestBody.date_finish;
evaluate.develop_complete = requestBody.develop_complete;
evaluate.pass_result = requestBody.pass_result;
evaluate.expand_month =
requestBody.pass_result && requestBody.pass_result == 3
? Number(requestBody.expand_month)
: 0;
evaluate.reson = requestBody.reson;
evaluate.chairman_dated = requestBody.chairman_dated;
evaluate.director1_dated = requestBody.director1_dated
evaluate.director2_dated = requestBody.director2_dated
evaluate.updateUserId = request.user.sub
evaluate.updateFullName = request.user.name
evaluate.director1_dated = requestBody.director1_dated;
evaluate.director2_dated = requestBody.director2_dated;
evaluate.updateUserId = request.user.sub;
evaluate.updateFullName = request.user.name;
await this.evaluateResultRepository.save(evaluate, { data: request })
setLogDataDiff(request, { before, after: evaluate })
await this.evaluateResultRepository.save(evaluate, { data: request });
setLogDataDiff(request, { before, after: evaluate });
const assign = await this.assignRepository.findOne({
relations: ["profile"],
where: { id: assign_id },
})
if (!assign) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
}
const personal = await this.personalRepository.findOne({
where: { personal_id: assign.personal_id },
})
const assign = await this.assignRepository.findOne({
relations: ["profile"],
where: { id: assign_id },
});
if (!assign) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
}
const personal = await this.personalRepository.findOne({
where: { personal_id: assign.personal_id },
});
if (!personal) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
}
personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status
if (!personal) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
}
personal.probation_status =
requestBody.pass_result == 1
? 2
: requestBody.pass_result == 2
? 3
: personal.probation_status;
if (requestBody.pass_result == 3) {
personal.probation_status = 7
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
await new CallAPI()
.PostData(request, "/placement/noti", {
subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ",
body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`,
receiverUserId: assign.personal_id,
payload: "",
isSendMail: false,
isSendInbox: true,
isSendNotification: true,
})
.catch(error => {
console.error("Error calling API:", error)
})
}
if (requestBody.pass_result == 3) {
personal.probation_status = 7;
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
await new CallAPI()
.PostData(request, "/placement/noti", {
subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ",
body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`,
receiverUserId: assign.personal_id,
payload: "",
isSendMail: false,
isSendInbox: true,
isSendNotification: true,
})
.catch((error) => {
console.error("Error calling API:", error);
});
}
await this.personalRepository.save(personal, { data: request })
await this.personalRepository.save(personal, { data: request });
return new HttpSuccess()
}
return new HttpSuccess();
}
}

View file

@ -564,6 +564,7 @@ export class ReportController extends Controller {
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
Oc: experimenteeData.orgRootName,
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
};
const data = await {
@ -800,6 +801,7 @@ export class ReportController extends Controller {
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
Oc: experimenteeData.orgRootName,
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
};
const commanderData = await this.assignDirectorRepository.findOne({
@ -823,7 +825,7 @@ export class ReportController extends Controller {
const commander = await {
...commanderData,
name: commanderData.fullname,
Position: commanderData.position,
Position: commanderData.position + commanderData.posLevel,
};
return new HttpSuccess({
@ -1069,6 +1071,7 @@ export class ReportController extends Controller {
Department: splitOcAmount > 2 ? splitOc[splitOcAmount - 3] : "-",
OrganizationOrganization: splitOcAmount > 1 ? splitOc[splitOcAmount - 2] : "-",
Oc: experimenteeData.orgRootName,
PositionLevel: experimenteeData.positionName + experimenteeData.positionLevelName,
};
const directorData = await this.assignDirectorRepository.find({
@ -1085,7 +1088,7 @@ export class ReportController extends Controller {
return {
...element,
name: element.fullname,
Position: element.position,
Position: element.position + element.posLevel,
};
}),
);