report ข้อมูลการทดลองงาน
This commit is contained in:
parent
dcc9ef5afd
commit
ee80702930
2 changed files with 250 additions and 3 deletions
|
|
@ -28,7 +28,7 @@ import { AssignDirector } from "../entities/AssignDirector";
|
|||
import { EvaluateAchievement } from "../entities/EvaluateAchievement";
|
||||
import { EvaluateCommander } from "../entities/EvaluateCommander";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { Between, Double, In } from "typeorm";
|
||||
import { Between, Double, In, IsNull, Not } from "typeorm";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { Appoint } from "../entities/Appoint";
|
||||
import { AppointDirector } from "../entities/AppointDirector";
|
||||
|
|
@ -1590,14 +1590,220 @@ export class ReportController extends Controller {
|
|||
public async report2(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query("nodeId") nodeId?: string,
|
||||
@Query("node") node?: string,
|
||||
@Query("node") node?: number,
|
||||
@Query("startDate") startDate?: Date,
|
||||
@Query("endDate") endDate?: Date,
|
||||
) {
|
||||
let personal = null;
|
||||
let result: Array<any> = [];
|
||||
switch (node) {
|
||||
case 0: {
|
||||
personal = await this.personalRepository.find({
|
||||
where: {
|
||||
root: nodeId,
|
||||
createdAt: startDate && endDate ? Between(new Date(startDate), new Date(endDate)) : Not(IsNull()),
|
||||
},
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
personal = await this.personalRepository.find({
|
||||
where: {
|
||||
child1: nodeId,
|
||||
createdAt: startDate && endDate ? Between(new Date(startDate), new Date(endDate)) : Not(IsNull()),
|
||||
},
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
personal = await this.personalRepository.find({
|
||||
where: {
|
||||
child2: nodeId,
|
||||
createdAt: startDate && endDate ? Between(new Date(startDate), new Date(endDate)) : Not(IsNull()),
|
||||
},
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
personal = await this.personalRepository.find({
|
||||
where: {
|
||||
child3: nodeId,
|
||||
createdAt: startDate && endDate ? Between(new Date(startDate), new Date(endDate)) : Not(IsNull()),
|
||||
},
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
personal = await this.personalRepository.find({
|
||||
where: {
|
||||
child4: nodeId,
|
||||
createdAt: startDate && endDate ? Between(new Date(startDate), new Date(endDate)) : Not(IsNull()),
|
||||
},
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
personal = await this.personalRepository.find({
|
||||
});
|
||||
personal = await Promise.all(personal.map(async (p, idx) => {
|
||||
const assigns = await this.assignRepository.find({
|
||||
where: { personal_id: p.personal_id }
|
||||
});
|
||||
const no = (idx+1);
|
||||
return {
|
||||
no: no,
|
||||
fullName: `${p.prefixName}${p.firstName} ${p.lastName}`,
|
||||
positionName: p.positionName,
|
||||
organization: p.organization,
|
||||
probation_status: p.probation_status,
|
||||
idcard: p.idcard,
|
||||
assigns: assigns
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
result = await Promise.all(
|
||||
personal.flatMap(x =>
|
||||
(x.assigns.length > 0 ? x.assigns : [{ id: null, date_start: null, date_finish: null }])
|
||||
.map(async (assign) => {
|
||||
|
||||
let accExam: string = "";
|
||||
let dateAppoint: Date | any = null;
|
||||
await new CallAPI()
|
||||
.GetData(req, `/placement/exam-probation/${x.idcard}`)
|
||||
.then(async (x) => {
|
||||
accExam = x.examName;
|
||||
dateAppoint = x.dateAppoint;
|
||||
})
|
||||
.catch((errr) => {
|
||||
});
|
||||
|
||||
const evaluateComman = await this.evaluateCommanderRepository.findOne({
|
||||
where: { assign_id: assign.id ?? "" },
|
||||
});
|
||||
|
||||
return {
|
||||
no: Extension.ToThaiNumber(x.no.toString()),
|
||||
accExam: accExam,
|
||||
fullName: x.fullName,
|
||||
positionName: x.positionName,
|
||||
organization: x.organization,
|
||||
dateAppoint: dateAppoint
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(dateAppoint))
|
||||
: "",
|
||||
dateStart: (x.assigns.length > 0 && assign.date_start != null)
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(assign.date_start))
|
||||
: "",
|
||||
dateFinish: (x.assigns.length > 0 && assign.date_finish != null)
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(assign.date_finish))
|
||||
: "",
|
||||
day: (x.assigns.length > 0 && assign.date_start != null && assign.date_finish != null)
|
||||
? Extension.ToThaiNumber(`${Math.ceil((new Date(assign.date_finish).getTime() - new Date(assign.date_start).getTime()) / (1000 * 60 * 60 * 24))} วัน`)
|
||||
: "",
|
||||
status: x.probation_status
|
||||
? Extension.probationStatus(x.probation_status)
|
||||
: "",
|
||||
orientation: evaluateComman && evaluateComman?.orientation == 1
|
||||
? "☑"
|
||||
: "☐",
|
||||
learning: evaluateComman && evaluateComman?.self_learning == 1
|
||||
? "☑"
|
||||
: "☐",
|
||||
seminar: evaluateComman && evaluateComman?.training_seminar == 1
|
||||
? "☑"
|
||||
: "☐",
|
||||
other: evaluateComman && evaluateComman?.other_training == 1
|
||||
? "☑"
|
||||
: "☐",
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "placementProbation02",
|
||||
reportName: "xlsx-report",
|
||||
data: "",
|
||||
data: {
|
||||
date: `ตั้งแต่${Extension.ToThaiNumber(Extension.ToThaiNoprefixDate2(startDate ?? new Date))} ถึง ${Extension.ToThaiNumber(Extension.ToThaiNoprefixDate2(endDate ?? new Date))}`,
|
||||
dateCurrent: `ณ ${Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date()))}`,
|
||||
data: result
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,23 @@ class Extension {
|
|||
);
|
||||
}
|
||||
|
||||
public static ToThaiNoprefixDate2(value: Date) {
|
||||
if(value && typeof value === "string")
|
||||
value = new Date(value)
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return (
|
||||
"วันที่ " +
|
||||
value.getDate() +
|
||||
" " +
|
||||
Extension.ToThaiMonth(value.getMonth() + 1) +
|
||||
" " +
|
||||
yy.toString()
|
||||
);
|
||||
}
|
||||
|
||||
public static ToThaiFullDate2(value: Date) {
|
||||
if(value && typeof value === "string")
|
||||
value = new Date(value)
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " " + yy;
|
||||
}
|
||||
|
|
@ -140,6 +156,31 @@ class Extension {
|
|||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static probationStatus(value: number) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return "อยู่ระหว่างการทดลองปฏิบัติหน้าที่ราชการ";
|
||||
case 2:
|
||||
return "พ้นการทดลองปฏิบัติหน้าที่ราชการ";
|
||||
case 3:
|
||||
return "ไม่พ้นการทดลองปฏิบัติหน้าที่ราชการ";
|
||||
case 4:
|
||||
return "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากเปลี่ยนตำแหน่ง";
|
||||
case 5:
|
||||
return "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากลาออก";
|
||||
case 6:
|
||||
return "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากถึงแก่กรรม";
|
||||
case 7:
|
||||
return "ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการ";
|
||||
case 8:
|
||||
return "ส่งรายชื่อไปออกคำสั่ง";
|
||||
case 9:
|
||||
return "ออกคำสั่งเสร็จแล้ว";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Extension;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue