trycatch
This commit is contained in:
parent
a4dfb3c87c
commit
df74e0226e
13 changed files with 7057 additions and 5877 deletions
|
|
@ -53,145 +53,154 @@ export class EvaluateChairmanController extends Controller {
|
|||
@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: {
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(
|
||||
request,
|
||||
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 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 directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
if (!directorData) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"
|
||||
"SYS_PROBATION"
|
||||
);
|
||||
}
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
|
||||
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.posLevel})` : ""),
|
||||
position: e.position,
|
||||
posType: e.posType,
|
||||
posLevel: e.posLevel,
|
||||
});
|
||||
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 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 directorData = await this.assignDirectorRepository.find({
|
||||
where: { assign_id },
|
||||
order: { ordering: "ASC" },
|
||||
});
|
||||
|
||||
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];
|
||||
|
||||
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 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.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,
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
|
||||
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.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.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,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -206,157 +215,166 @@ export class EvaluateChairmanController extends Controller {
|
|||
@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({
|
||||
try {
|
||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
director_id,
|
||||
assign_id,
|
||||
no: evaluate_no,
|
||||
role: "chairman",
|
||||
},
|
||||
});
|
||||
} 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) {
|
||||
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 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" },
|
||||
});
|
||||
|
||||
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];
|
||||
|
||||
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,
|
||||
});
|
||||
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) {
|
||||
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 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" },
|
||||
});
|
||||
|
||||
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];
|
||||
|
||||
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 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.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
return new HttpSuccess({
|
||||
experimentee: experimentee,
|
||||
mentors: mentors,
|
||||
commander: commander,
|
||||
chairman: chairman,
|
||||
assign,
|
||||
evaluate,
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
|
||||
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.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.posLevel})`
|
||||
: ""),
|
||||
position: chairmanData.position,
|
||||
posType: chairmanData.posType,
|
||||
posLevel: chairmanData.posLevel,
|
||||
}
|
||||
: null;
|
||||
|
||||
return new HttpSuccess({
|
||||
experimentee: experimentee,
|
||||
mentors: mentors,
|
||||
commander: commander,
|
||||
chairman: chairman,
|
||||
assign,
|
||||
evaluate,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -371,81 +389,90 @@ export class EvaluateChairmanController extends Controller {
|
|||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
try {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
|
||||
const director = await this.assignDirectorRepository.findOne({
|
||||
select: ["personal_id"],
|
||||
where: {
|
||||
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 postData: any = await {
|
||||
assign_id,
|
||||
role: "chairman",
|
||||
},
|
||||
});
|
||||
if (!director) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||
}
|
||||
...requestBody,
|
||||
director_id,
|
||||
no: requestBody.evaluate_no,
|
||||
date_start: requestBody.start_date,
|
||||
personal_id: assign.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 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)
|
||||
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();
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -461,83 +488,90 @@ export class EvaluateChairmanController extends Controller {
|
|||
@Body() requestBody: CreateEvaluateChairman,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||
try {
|
||||
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.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;
|
||||
|
||||
await this.evaluateChairmanRepository.save(evaluate, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluate });
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
||||
}
|
||||
|
||||
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.updateUserId = request.user.sub;
|
||||
evaluate.updateFullName = request.user.name;
|
||||
|
||||
await this.evaluateChairmanRepository.save(evaluate, { data: request });
|
||||
setLogDataDiff(request, { before, after: evaluate });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue