Merge branch 'develop' of github.com:Frappet/bma-ehr-salary into develop
This commit is contained in:
commit
972539cc6b
2 changed files with 379 additions and 0 deletions
100
src/controllers/Report2Controller.ts
Normal file
100
src/controllers/Report2Controller.ts
Normal 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 { Salarys } from "../entities/Salarys";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { SalaryPeriod } from "../entities/SalaryPeriod";
|
||||
import { SalaryProfile } from "../entities/SalaryProfile";
|
||||
@Route("api/v1/salary/report")
|
||||
@Tags("Report")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class Report2Controller extends Controller {
|
||||
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
||||
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
||||
private salaryRepository = AppDataSource.getRepository(Salarys);
|
||||
private salaryRankRepository = AppDataSource.getRepository(SalaryRanks);
|
||||
private poTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
|
||||
/**
|
||||
* API รายชื่อข้าราชการผู้ที่ครองตำแหน่ง
|
||||
*
|
||||
* @summary รายชื่อข้าราชการผู้ที่ครองตำแหน่ง
|
||||
*
|
||||
*/
|
||||
@Post("report1")
|
||||
async report1(@Body() body: { rootId: string; salaryPeriodId: string;}) {
|
||||
const salaryPeriodAPR = await this.salaryProfileRepository.find({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: {
|
||||
salaryOrg:{
|
||||
snapshot:"SNAP1",
|
||||
rootId:body.rootId,
|
||||
salaryPeriodId: body.salaryPeriodId,
|
||||
salaryPeriod:{
|
||||
period:"APR"
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriodAPR) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const agency = salaryPeriodAPR[0]?.root;
|
||||
|
||||
const formattedData = salaryPeriodAPR.map((profile, index) => {
|
||||
const fullNameParts = [
|
||||
profile?.child4,
|
||||
profile?.child3,
|
||||
profile?.child2,
|
||||
profile?.child1,
|
||||
profile?.root,
|
||||
`${profile?.prefix}${profile?.firstName} ${profile?.lastName}`
|
||||
];
|
||||
|
||||
const fullName = fullNameParts.filter(part => part !== undefined && part !== null).join('/');
|
||||
|
||||
return {
|
||||
no: index + 1,
|
||||
fullName: fullName?fullName:"",
|
||||
posLevel: profile?.posLevel?profile?.posLevel:"",
|
||||
posNumber: profile?.posMasterNo?profile?.posMasterNo:"",
|
||||
amount: profile?.amount?profile?.amount:"",
|
||||
reason: null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({ agency: agency, data: formattedData });
|
||||
}
|
||||
}
|
||||
|
||||
279
src/controllers/Report_1_Controller.ts
Normal file
279
src/controllers/Report_1_Controller.ts
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
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, MoreThan } 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("04/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport4(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
}
|
||||
// relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
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,
|
||||
root: salaryProfile[0]?.root,
|
||||
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 == null ? 0 : item.amount,
|
||||
amountSpecial: item.amountSpecial == null ? 0 : item.amountSpecial,
|
||||
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
|
||||
remark: null //หมายเหตุ
|
||||
}))
|
||||
}
|
||||
return mapData
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน
|
||||
*
|
||||
* @summary รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("07/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport7(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfile = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: IsNull() || 0,
|
||||
amountUse: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName", "posMasterNo",
|
||||
"amount", "amountUse", "positionSalaryAmount"
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
|
||||
const mapData = salaryProfile.map((item, index) => ({
|
||||
no: index+1,
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
position: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
posMasterNo: item.posMasterNo,
|
||||
amount: item.amount,
|
||||
positionSalaryAmount: item.positionSalaryAmount,
|
||||
remark: null
|
||||
}));
|
||||
|
||||
return mapData;
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายงานคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
||||
*
|
||||
* @summary รายงานคำสั่งคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน
|
||||
*
|
||||
* @param {string} rootId Guid, *Id Root
|
||||
* @param {string} salaryPeriodId Guid, *Id Period
|
||||
*/
|
||||
@Get("08/{rootId}/{salaryPeriodId}")
|
||||
async SalaryReport8(
|
||||
// @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37",
|
||||
// @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2",
|
||||
@Path() rootId : string,
|
||||
@Path() salaryPeriodId: string,
|
||||
) {
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
id: salaryPeriodId,
|
||||
period: "APR",
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (!salaryPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodId,
|
||||
rootId: rootId,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
order: {
|
||||
group: "ASC"
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
|
||||
const salaryProfileSpecial = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountSpecial: MoreThan(1),
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount", "amountSpecial",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
|
||||
const salaryProfileNoAmount = await this.salaryProfile.find({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg?.id,
|
||||
amountUse: IsNull() || 0,
|
||||
positionSalaryAmount: IsNull() || 0,
|
||||
},
|
||||
select: [
|
||||
"id", "prefix" , "firstName", "lastName", "root",
|
||||
"position", "posType", "posLevel", "orgShortName",
|
||||
"posMasterNo", "amount",
|
||||
],
|
||||
order: {
|
||||
posMasterNo: "ASC"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const profileSpecial = salaryProfileSpecial.map((item, index) => ({
|
||||
no: index+1,
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
position: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
posMasterNo: item.posMasterNo,
|
||||
amount: item.amount,
|
||||
amountSpecial: item.amountSpecial,
|
||||
remark: null
|
||||
}));
|
||||
|
||||
const profileNoAmount = salaryProfileNoAmount.map((item, index) => ({
|
||||
no: index+1,
|
||||
fullname: item.prefix + item.firstName +" "+ item.lastName,
|
||||
position: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
posMasterNo: item.posMasterNo,
|
||||
amount: item.amount,
|
||||
remark: null
|
||||
}));
|
||||
|
||||
const mapData = {
|
||||
profileSpecial,
|
||||
profileNoAmount
|
||||
}
|
||||
return mapData;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue