no message

This commit is contained in:
Bright 2024-03-06 17:03:24 +07:00
parent 0598f8fd34
commit 18c75fc3cc

View file

@ -20,7 +20,7 @@ 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 { In, IsNull, Not, MoreThan } from "typeorm";
import { SalaryProfile } from "../entities/SalaryProfile";
import { SalaryPeriod } from "../entities/SalaryPeriod";
import { SalaryOrg } from "../entities/SalaryOrg";
@ -40,18 +40,33 @@ export class Report_1_Controller extends Controller {
private salaryProfile = AppDataSource.getRepository(SalaryProfile);
/**
* API 1
* API 1
*
* @summary 1
* @summary 1
*
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("{rootId}/{salaryPeriodId}")
@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 = "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,
@ -63,21 +78,14 @@ export class Report_1_Controller extends Controller {
}
// 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"]
where: { salaryOrgId: salaryOrg?.id},
select: [
"id", "prefix" , "firstName", "lastName", "root",
"position", "posType", "posLevel", "orgShortName",
"posMasterNo", "amount", "amountSpecial"
]
});
const mapData = {
@ -86,16 +94,186 @@ export class Report_1_Controller extends Controller {
profile: salaryProfile.map((item, index) => ({
no: index+1,
fullname: item.prefix + item.firstName +" "+ item.lastName,
position: item.position + " / " + item.posType,
position: item.position + "/" + item.posType,
posLevel: item.posLevel,
orgShortName: item.orgShortName+item.posMasterNo,
amount: item.amount,
amountSpecial: item.amountSpecial,
root: item.root,
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;
}
}