Merge branch 'develop' into adiDev
This commit is contained in:
commit
e23981d2e5
1 changed files with 535 additions and 10 deletions
|
|
@ -15,7 +15,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, Not, IsNull, MoreThan, Double } from "typeorm";
|
||||
import { In, Not, IsNull, MoreThan, Double, Brackets } from "typeorm";
|
||||
import { Salarys } from "../entities/Salarys";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import { PosType } from "../entities/PosType";
|
||||
|
|
@ -6553,11 +6553,15 @@ export class ReportController extends Controller {
|
|||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
profileId: item.profileId,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
|
|
@ -6599,11 +6603,15 @@ export class ReportController extends Controller {
|
|||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
profileId: item.profileId,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
|
|
@ -6639,11 +6647,15 @@ export class ReportController extends Controller {
|
|||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
profileId: item.profileId,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
|
|
@ -6678,11 +6690,15 @@ export class ReportController extends Controller {
|
|||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: `${item.posTypeShort}${item.posLevel}`,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
profileId: item.profileId,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
|
|
@ -6717,11 +6733,454 @@ export class ReportController extends Controller {
|
|||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: `${item.posTypeShort}${item.posLevel}`,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง 33
|
||||
*
|
||||
* @summary ออกคำสั่ง 33
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/C-PM-33/{id}")
|
||||
async SalaryReport33Command(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
let conditionGroup = "";
|
||||
if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')";
|
||||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
}
|
||||
const salary = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryOrgs = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salary.id, snapshot: "SNAP2" },
|
||||
});
|
||||
|
||||
let salaryRank = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.andWhere("salaryProfile.rootId LIKE :rootId", {
|
||||
rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
})
|
||||
.andWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
type: In(["FULLHAFT", "FULL", "HAFT"]),
|
||||
status: "PENDING",
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(conditionGroup);
|
||||
}),
|
||||
)
|
||||
.andWhere("salaryProfile.status = :status", { status: "PENDING" })
|
||||
.select([
|
||||
"salaryProfile.id",
|
||||
"salaryProfile.orgShortName",
|
||||
"salaryProfile.posMasterNo",
|
||||
"salaryProfile.position",
|
||||
"salaryProfile.posType",
|
||||
"salaryProfile.posLevel",
|
||||
"salaryProfile.profileId",
|
||||
"salaryProfile.prefix",
|
||||
"salaryProfile.firstName",
|
||||
"salaryProfile.lastName",
|
||||
"salaryProfile.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง 34
|
||||
*
|
||||
* @summary ออกคำสั่ง 34
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/C-PM-34/{id}")
|
||||
async SalaryReport34Command(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
let conditionGroup = "";
|
||||
if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')";
|
||||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
}
|
||||
const salary = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryOrgs = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salary.id, snapshot: "SNAP2" },
|
||||
});
|
||||
|
||||
let salaryRank = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.andWhere("salaryProfile.rootId LIKE :rootId", {
|
||||
rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
amountSpecial: MoreThan(0),
|
||||
status: "PENDING",
|
||||
}).orWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
type: "NONE",
|
||||
status: "PENDING",
|
||||
});
|
||||
}),
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(conditionGroup);
|
||||
}),
|
||||
)
|
||||
.andWhere("salaryProfile.status = :status", { status: "PENDING" })
|
||||
.select([
|
||||
"salaryProfile.id",
|
||||
"salaryProfile.orgShortName",
|
||||
"salaryProfile.posMasterNo",
|
||||
"salaryProfile.position",
|
||||
"salaryProfile.posType",
|
||||
"salaryProfile.posLevel",
|
||||
"salaryProfile.profileId",
|
||||
"salaryProfile.prefix",
|
||||
"salaryProfile.firstName",
|
||||
"salaryProfile.lastName",
|
||||
"salaryProfile.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง 35
|
||||
*
|
||||
* @summary ออกคำสั่ง 35
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/C-PM-35/{id}")
|
||||
async SalaryReport35Command(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
let conditionGroup = "";
|
||||
if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
conditionGroup =
|
||||
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')";
|
||||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
}
|
||||
const salary = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryOrgs = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salary.id, snapshot: "SNAP2" },
|
||||
});
|
||||
|
||||
let salaryRank = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.andWhere("salaryProfile.rootId LIKE :rootId", {
|
||||
rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
})
|
||||
.andWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
type: In(["FULLHAFT", "FULL", "HAFT"]),
|
||||
status: "PENDING",
|
||||
isRetired: true,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(conditionGroup);
|
||||
}),
|
||||
)
|
||||
.andWhere("salaryProfile.status = :status", { status: "PENDING" })
|
||||
.select([
|
||||
"salaryProfile.id",
|
||||
"salaryProfile.orgShortName",
|
||||
"salaryProfile.posMasterNo",
|
||||
"salaryProfile.position",
|
||||
"salaryProfile.posType",
|
||||
"salaryProfile.posLevel",
|
||||
"salaryProfile.profileId",
|
||||
"salaryProfile.prefix",
|
||||
"salaryProfile.firstName",
|
||||
"salaryProfile.lastName",
|
||||
"salaryProfile.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: item.posLevel,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง 36
|
||||
*
|
||||
* @summary ออกคำสั่ง 36
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/C-PM-36/{id}")
|
||||
async SalaryReport36Command(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
// let conditionGroup = "";
|
||||
// if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')";
|
||||
// } else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')";
|
||||
// } else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')";
|
||||
// } else {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
// }
|
||||
const salary = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryOrgs = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salary.id, snapshot: "SNAP2" },
|
||||
});
|
||||
|
||||
let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee)
|
||||
.createQueryBuilder("salaryProfileEmployee")
|
||||
// .andWhere("salaryProfileEmployee.rootId LIKE :rootId", {
|
||||
// rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
// })
|
||||
.andWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
type: In(["FULLHAFT", "FULL", "HAFT"]),
|
||||
status: "PENDING",
|
||||
})
|
||||
// .andWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(conditionGroup);
|
||||
// }),
|
||||
// )
|
||||
.andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" })
|
||||
.select([
|
||||
"salaryProfileEmployee.id",
|
||||
"salaryProfileEmployee.orgShortName",
|
||||
"salaryProfileEmployee.posMasterNo",
|
||||
"salaryProfileEmployee.position",
|
||||
"salaryProfileEmployee.posType",
|
||||
"salaryProfileEmployee.posLevel",
|
||||
"salaryProfileEmployee.profileId",
|
||||
"salaryProfileEmployee.prefix",
|
||||
"salaryProfileEmployee.firstName",
|
||||
"salaryProfileEmployee.lastName",
|
||||
"salaryProfileEmployee.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: `${item.posTypeShort}${item.posLevel}`,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง 37
|
||||
*
|
||||
* @summary ออกคำสั่ง 37
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/C-PM-37/{id}")
|
||||
async SalaryReport37Command(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
// let conditionGroup = "";
|
||||
// if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')";
|
||||
// } else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')";
|
||||
// } else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
// conditionGroup =
|
||||
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')";
|
||||
// } else {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
// }
|
||||
const salary = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||
}
|
||||
const salaryOrgs = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salary.id, snapshot: "SNAP2" },
|
||||
});
|
||||
|
||||
let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee)
|
||||
.createQueryBuilder("salaryProfileEmployee")
|
||||
// .andWhere("salaryProfileEmployee.rootId LIKE :rootId", {
|
||||
// rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
// })
|
||||
.andWhere({
|
||||
salaryOrgId: In(salaryOrgs.map((x) => x.id)),
|
||||
amountSpecial: MoreThan(0),
|
||||
status: "PENDING",
|
||||
})
|
||||
// .andWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(conditionGroup);
|
||||
// }),
|
||||
// )
|
||||
.andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" })
|
||||
.select([
|
||||
"salaryProfileEmployee.id",
|
||||
"salaryProfileEmployee.orgShortName",
|
||||
"salaryProfileEmployee.posMasterNo",
|
||||
"salaryProfileEmployee.position",
|
||||
"salaryProfileEmployee.posType",
|
||||
"salaryProfileEmployee.posLevel",
|
||||
"salaryProfileEmployee.profileId",
|
||||
"salaryProfileEmployee.prefix",
|
||||
"salaryProfileEmployee.firstName",
|
||||
"salaryProfileEmployee.lastName",
|
||||
"salaryProfileEmployee.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
const _salaryRank = salaryRank.map((item) => ({
|
||||
id: item.id,
|
||||
posMasterNo: `${item.orgShortName}${item.posMasterNo}`,
|
||||
positionName: item.position,
|
||||
posType: item.posType,
|
||||
posLevel: `${item.posTypeShort}${item.posLevel}`,
|
||||
profileId: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: item.citizenId,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_salaryRank);
|
||||
|
|
@ -6871,6 +7330,14 @@ export class ReportController extends Controller {
|
|||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const salaryProfile = await this.salaryProfileRepository.find({
|
||||
where: { id: In(body.refIds) },
|
||||
});
|
||||
const data = salaryProfile.map((_data) => ({
|
||||
..._data,
|
||||
status: "REPORT",
|
||||
}));
|
||||
await this.salaryProfileRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
/**
|
||||
|
|
@ -6888,6 +7355,64 @@ export class ReportController extends Controller {
|
|||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
||||
where: { id: In(body.refIds) },
|
||||
});
|
||||
const data = salaryProfile.map((_data) => ({
|
||||
..._data,
|
||||
status: "REPORT",
|
||||
}));
|
||||
await this.salaryProfileEmployeeRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
/**
|
||||
* API ออกคำสั่ง
|
||||
*
|
||||
* @summary ออกคำสั่ง
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/officer/report/delete")
|
||||
async SalaryOfficerReportCommandDelete(
|
||||
@Body()
|
||||
body: {
|
||||
refIds: string[];
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const salaryProfile = await this.salaryProfileRepository.find({
|
||||
where: { id: In(body.refIds) },
|
||||
});
|
||||
const data = salaryProfile.map((_data) => ({
|
||||
..._data,
|
||||
status: "PENDING",
|
||||
}));
|
||||
await this.salaryProfileRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
/**
|
||||
* API ออกคำสั่ง
|
||||
*
|
||||
* @summary ออกคำสั่ง
|
||||
*
|
||||
* @param {string} id Guid, *Id ผังเงินเดือน
|
||||
*/
|
||||
@Post("command/employee/report/delete")
|
||||
async SalaryEmployeeReportCommandDelete(
|
||||
@Body()
|
||||
body: {
|
||||
refIds: string[];
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const salaryProfile = await this.salaryProfileEmployeeRepository.find({
|
||||
where: { id: In(body.refIds) },
|
||||
});
|
||||
const data = salaryProfile.map((_data) => ({
|
||||
..._data,
|
||||
status: "PENDING",
|
||||
}));
|
||||
await this.salaryProfileEmployeeRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue