รายงานแบบ 1 กท

This commit is contained in:
Bright 2024-03-05 18:30:47 +07:00
parent 161099dbe7
commit 5af1ef281a

View file

@ -0,0 +1,100 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Patch,
Route,
Security,
Tags,
Body,
Path,
Request,
Example,
SuccessResponse,
Response,
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { In, IsNull, Not } from "typeorm";
import { SalaryProfile } from "../entities/SalaryProfile";
import { SalaryPeriod } from "../entities/SalaryPeriod";
import { SalaryOrg } from "../entities/SalaryOrg";
import Extension from "../interfaces/extension";
@Route("api/v1/salary/report/1")
@Tags("Report")
// @Security("bearerAuth")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class Report_1_Controller extends Controller {
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
private salaryProfile = AppDataSource.getRepository(SalaryProfile);
/**
* API 1
*
* @summary 1
*
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("{rootId}/{salaryPeriodId}")
async SalaryReport4(
@Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
@Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
) {
const salaryOrg = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
},
order: {
group: "ASC"
}
// relations: ["salaryProfiles"],
});
if (!salaryOrg) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: String(salaryOrg.salaryPeriodId),
period: "APR",
isActive: true
},
});
const salaryProfile = await this.salaryProfile.find({
where: { salaryOrgId: salaryOrg.id},
select: ["id", "prefix" , "firstName", "lastName", "root",
"position", "posType", "posLevel", "orgShortName", "posMasterNo", "amount", "amountSpecial"]
});
const mapData = {
effectiveDate : salaryPeriod?.effectiveDate,
profile: salaryProfile.map((item, index) => ({
no: index+1,
fullname: item.prefix + item.firstName +" "+ item.lastName,
position: item.position + " / " + item.posType,
posLevel: item.posLevel,
orgShortName: item.orgShortName+item.posMasterNo,
amount: item.amount,
amountSpecial: item.amountSpecial,
root: item.root,
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
remark: null //หมายเหตุ
}))
}
return mapData
}
}