kpi แบบแผน
This commit is contained in:
parent
a840274150
commit
87c7452fa5
3 changed files with 194 additions and 47 deletions
|
|
@ -343,18 +343,30 @@ export class DevelopmentScholarshipController extends Controller {
|
|||
* @param {string} profileId profileId ข้าราชการฯที่ได้รับทุนการศึกษา
|
||||
*/
|
||||
@Get("user/{profileId}")
|
||||
async GetDevelopemtScholarshipUserById(@Path() profileId: string) {
|
||||
const getDevelopment = await this.developmentScholarshipRepository.find({
|
||||
where: { profileId: profileId },
|
||||
});
|
||||
const formattedData = getDevelopment.map((item) => ({
|
||||
id: item.id,
|
||||
scholarshipYear: item.scholarshipYear,
|
||||
scholarshipType: item.scholarshipType,
|
||||
fundType: item.fundType,
|
||||
}));
|
||||
async GetDevelopemtScholarshipUserById(
|
||||
@Path() profileId: string,
|
||||
@Query("type") type?: string | null,
|
||||
@Query("year") year?: number | null,
|
||||
) {
|
||||
const getDevelopment = await AppDataSource.getRepository(DevelopmentScholarship)
|
||||
.createQueryBuilder("developmentScholarship")
|
||||
.andWhere("developmentScholarship.profileId = :profileId", { profileId: profileId })
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined
|
||||
? "developmentScholarship.scholarshipYear = :scholarshipYear"
|
||||
: "1=1",
|
||||
{ scholarshipYear: year },
|
||||
)
|
||||
.andWhere(
|
||||
type != null && type != undefined
|
||||
? "developmentScholarship.scholarshipType = :scholarshipType"
|
||||
: "1=1",
|
||||
{ scholarshipType: type },
|
||||
)
|
||||
.select(["id", "scholarshipYear", "scholarshipYear", "scholarshipType", "fundType"])
|
||||
.getRawMany();
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
return new HttpSuccess(getDevelopment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -251,12 +251,16 @@ export class ReportController extends Controller {
|
|||
firstName: getDevelopment.firstName,
|
||||
lastName: getDevelopment.lastName,
|
||||
position: getDevelopment.position,
|
||||
root: getDevelopment.root,
|
||||
org: getDevelopment.org,
|
||||
degreeLevel: getDevelopment.degreeLevel,
|
||||
course: getDevelopment.course,
|
||||
field: getDevelopment.field,
|
||||
studyPlace: getDevelopment.studyPlace,
|
||||
scholarshipType: getDevelopment.scholarshipType,
|
||||
bookNoDate:
|
||||
getDevelopment.bookNoDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.bookNoDate)),
|
||||
startDate:
|
||||
getDevelopment.startDate == null
|
||||
? ""
|
||||
|
|
|
|||
|
|
@ -55,41 +55,50 @@ export class StrategyController extends Controller {
|
|||
@Get()
|
||||
public async listStrategyChild1() {
|
||||
const listStrategyChild1 = await this.strategy1Repo.find({
|
||||
relations: ["strategyChild2s", "strategyChild2s.strategyChild3s", "strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
||||
if (!listStrategyChild1 || listStrategyChild1.length === 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
||||
const formattedData = listStrategyChild1.map(item => ({
|
||||
id: item.id,
|
||||
level: 1,
|
||||
name: item.strategyChild1Name,
|
||||
children: item.strategyChild2s.map(child2 => ({
|
||||
id: child2.id,
|
||||
level: 2,
|
||||
name: child2.strategyChild2Name,
|
||||
children: child2.strategyChild3s ? child2.strategyChild3s.map(child3 => ({
|
||||
id: child3.id,
|
||||
level: 3,
|
||||
name: child3.strategyChild3Name,
|
||||
children: child3.strategyChild4s ? child3.strategyChild4s.map(child4 => ({
|
||||
id: child4.id,
|
||||
level: 4,
|
||||
name: child4.strategyChild4Name,
|
||||
children: child4.strategyChild5s ? child4.strategyChild5s.map(child5 => ({
|
||||
id: child5.id,
|
||||
level: 5,
|
||||
name: child5.strategyChild5Name,
|
||||
})) : [],
|
||||
})) : [],
|
||||
})) : [],
|
||||
})),
|
||||
}));
|
||||
|
||||
|
||||
relations: [
|
||||
"strategyChild2s",
|
||||
"strategyChild2s.strategyChild3s",
|
||||
"strategyChild2s.strategyChild3s.strategyChild4s",
|
||||
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
||||
if (!listStrategyChild1 || listStrategyChild1.length === 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
||||
const formattedData = listStrategyChild1.map((item) => ({
|
||||
id: item.id,
|
||||
level: 1,
|
||||
name: item.strategyChild1Name,
|
||||
children: item.strategyChild2s.map((child2) => ({
|
||||
id: child2.id,
|
||||
level: 2,
|
||||
name: child2.strategyChild2Name,
|
||||
children: child2.strategyChild3s
|
||||
? child2.strategyChild3s.map((child3) => ({
|
||||
id: child3.id,
|
||||
level: 3,
|
||||
name: child3.strategyChild3Name,
|
||||
children: child3.strategyChild4s
|
||||
? child3.strategyChild4s.map((child4) => ({
|
||||
id: child4.id,
|
||||
level: 4,
|
||||
name: child4.strategyChild4Name,
|
||||
children: child4.strategyChild5s
|
||||
? child4.strategyChild5s.map((child5) => ({
|
||||
id: child5.id,
|
||||
level: 5,
|
||||
name: child5.strategyChild5Name,
|
||||
}))
|
||||
: [],
|
||||
}))
|
||||
: [],
|
||||
}))
|
||||
: [],
|
||||
})),
|
||||
}));
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
|
@ -357,4 +366,126 @@ export class StrategyController extends Controller {
|
|||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API เช็ค node detail
|
||||
*
|
||||
* @summary เช็ค node detail (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("find/all")
|
||||
async findNodeAllDetail(@Body() requestBody: { strategy: number; strategyId: string }) {
|
||||
switch (requestBody.strategy) {
|
||||
case 1: {
|
||||
const data = await this.strategy1Repo.findOne({
|
||||
where: { id: requestBody.strategyId },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found rootId.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
strategyChild1Id: data.id,
|
||||
strategyChild1: data.strategyChild1Name,
|
||||
});
|
||||
}
|
||||
case 2: {
|
||||
const data = await this.strategy2Repo.findOne({
|
||||
where: { id: requestBody.strategyId },
|
||||
relations: {
|
||||
strategyChild1: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found child1.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
strategyChild1Id: data.strategyChild1Id,
|
||||
strategyChild1:
|
||||
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
|
||||
strategyChild2Id: data.id,
|
||||
strategyChild2: data.strategyChild2Name,
|
||||
});
|
||||
}
|
||||
case 3: {
|
||||
const data = await this.strategy3Repo.findOne({
|
||||
where: { id: requestBody.strategyId },
|
||||
relations: {
|
||||
strategyChild1: true,
|
||||
strategyChild2: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found child2.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
strategyChild1Id: data.strategyChild1Id,
|
||||
strategyChild1:
|
||||
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
|
||||
strategyChild2Id: data.strategyChild2Id,
|
||||
strategyChild2:
|
||||
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
|
||||
strategyChild3Id: data.id,
|
||||
strategyChild3: data.strategyChild3Name,
|
||||
});
|
||||
}
|
||||
case 4: {
|
||||
const data = await this.strategy4Repo.findOne({
|
||||
where: { id: requestBody.strategyId },
|
||||
relations: {
|
||||
strategyChild1: true,
|
||||
strategyChild2: true,
|
||||
strategyChild3: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found child3.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
strategyChild1Id: data.strategyChild1Id,
|
||||
strategyChild1:
|
||||
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
|
||||
strategyChild2Id: data.strategyChild2Id,
|
||||
strategyChild2:
|
||||
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
|
||||
strategyChild3Id: data.strategyChild3Id,
|
||||
strategyChild3:
|
||||
data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name,
|
||||
strategyChild4Id: data.id,
|
||||
strategyChild4: data.strategyChild4Name,
|
||||
});
|
||||
}
|
||||
case 5: {
|
||||
const data = await this.strategy5Repo.findOne({
|
||||
where: { id: requestBody.strategyId },
|
||||
relations: {
|
||||
strategyChild1: true,
|
||||
strategyChild2: true,
|
||||
strategyChild3: true,
|
||||
strategyChild4: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found child4.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
strategyChild1Id: data.strategyChild1Id,
|
||||
strategyChild1:
|
||||
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
|
||||
strategyChild2Id: data.strategyChild2Id,
|
||||
strategyChild2:
|
||||
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
|
||||
strategyChild3Id: data.strategyChild3Id,
|
||||
strategyChild3:
|
||||
data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name,
|
||||
strategyChild4Id: data.strategyChild4Id,
|
||||
strategyChild4:
|
||||
data.strategyChild4 == null ? null : data.strategyChild4.strategyChild4Name,
|
||||
strategyChild5Id: data.id,
|
||||
strategyChild5: data.strategyChild5Name,
|
||||
});
|
||||
}
|
||||
default:
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue