checkpoint
This commit is contained in:
parent
f19d3ce70e
commit
e585e41a70
4 changed files with 228 additions and 0 deletions
|
|
@ -293,6 +293,216 @@ export class OrganizationUnauthorizeController extends Controller {
|
||||||
return new HttpSuccess({ data: formattedData, total: total });
|
return new HttpSuccess({ data: formattedData, total: total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API TEST รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
||||||
|
*
|
||||||
|
* @summary TEST รายชื่อราชการที่เลื่อนเงินเดือน #76 (unauthorize)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("testsalary/gen")
|
||||||
|
async testsalaryGen(
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
keyword?: string;
|
||||||
|
year: number;
|
||||||
|
period: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const findRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster)
|
||||||
|
.createQueryBuilder("viewPosMaster")
|
||||||
|
.where({orgRevisionId: findRevision?.id})
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.where(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "prefix LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "firstName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "lastName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "citizenId LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "posTypeName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "posLevelName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.orderBy("citizenId", "ASC")
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
if (!findPosMaster) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
|
||||||
|
}
|
||||||
|
|
||||||
|
const formattedData = findPosMaster.map((item) => {
|
||||||
|
let orgShortName = "";
|
||||||
|
|
||||||
|
if (item.orgChild1Id === null) {
|
||||||
|
orgShortName = item?.orgRootShortName;
|
||||||
|
} else if (item.orgChild2Id === null) {
|
||||||
|
orgShortName = item?.orgChild1ShortName;
|
||||||
|
} else if (item.orgChild3Id === null) {
|
||||||
|
orgShortName = item?.orgChild2ShortName;
|
||||||
|
} else if (item.orgChild4Id === null) {
|
||||||
|
orgShortName = item?.orgChild3ShortName;
|
||||||
|
} else {
|
||||||
|
orgShortName = item?.orgChild4ShortName;
|
||||||
|
}
|
||||||
|
// const posExecutive =
|
||||||
|
// item.positions == null ||
|
||||||
|
// item.positions?.find((position) => position.positionIsSelected == true) == null ||
|
||||||
|
// item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
||||||
|
// null ||
|
||||||
|
// item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
|
// ?.posExecutiveName == null
|
||||||
|
// ? null
|
||||||
|
// : item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
|
// .posExecutiveName;
|
||||||
|
|
||||||
|
|
||||||
|
let datePeriodStart = new Date(
|
||||||
|
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||||
|
);
|
||||||
|
let datePeriodEnd = new Date(
|
||||||
|
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||||
|
);
|
||||||
|
if (body.period.toLocaleUpperCase() == "APR") {
|
||||||
|
datePeriodStart = new Date(`${body.year}-03-31T00:00:00.000Z`);
|
||||||
|
datePeriodEnd = new Date(`${body.year}-03-31T00:00:00.000Z`);
|
||||||
|
}
|
||||||
|
if (body.period.toLocaleUpperCase() == "OCT") {
|
||||||
|
datePeriodStart = new Date(`${body.year}-09-30T00:00:00.000Z`);
|
||||||
|
datePeriodEnd = new Date(`${body.year}-09-30T00:00:00.000Z`);
|
||||||
|
}
|
||||||
|
datePeriodStart = new Date(
|
||||||
|
new Date(datePeriodStart.setDate(datePeriodStart.getDate() + 1)).setMonth(
|
||||||
|
datePeriodStart.getMonth() - 6,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// const specialPosition = item.positions.find(
|
||||||
|
// (position) => position.positionIsSelected === true,
|
||||||
|
// );
|
||||||
|
// const isSpecial = specialPosition ? specialPosition.isSpecial : null;
|
||||||
|
|
||||||
|
|
||||||
|
const pointSum = item.pointSum
|
||||||
|
? `(${this.textPointSummaryKpi(item.pointSum)})${item.pointSum}` //่join ธรรมดาดึง row ล่าสุดอยู่แล้ว
|
||||||
|
: null;
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
profileId: item.profileId,
|
||||||
|
prefix: item.prefix,
|
||||||
|
firstName: item.firstName,
|
||||||
|
lastName: item.lastName,
|
||||||
|
citizenId: item.citizenId,
|
||||||
|
posMasterNoPrefix: item.posMasterNoPrefix,
|
||||||
|
posMasterNo: item.posMasterNo,
|
||||||
|
posMasterNoSuffix: item.posMasterNoSuffix,
|
||||||
|
orgShortName: orgShortName,
|
||||||
|
position: item.position,
|
||||||
|
posType: item.posTypeName,
|
||||||
|
posLevel: item.posLevelName,
|
||||||
|
posExecutive: item.posExecutiveName,
|
||||||
|
amount: item.amount,
|
||||||
|
rootId: item.orgRootId,
|
||||||
|
root: item.orgRootName,
|
||||||
|
rootOrder: item.orgRootOrder,
|
||||||
|
child1Id: item.orgChild1Id,
|
||||||
|
child1: item.orgChild1Name,
|
||||||
|
child1Order: item.orgChild1Order,
|
||||||
|
child2Id: item.orgChild2Id,
|
||||||
|
child2: item.orgChild2Name,
|
||||||
|
child2Order: item.orgChild2Order,
|
||||||
|
child3Id: item.orgChild3Id,
|
||||||
|
child3: item.orgChild3Name,
|
||||||
|
child3Order: item.orgChild3Order,
|
||||||
|
child4Id: item.orgChild4Id,
|
||||||
|
child4: item.orgChild4Name,
|
||||||
|
child4Order: item.orgChild4Order,
|
||||||
|
result: pointSum,
|
||||||
|
duration: null,
|
||||||
|
// isPunish:
|
||||||
|
// item.current_holder.profileDisciplines.filter(
|
||||||
|
// (x: any) =>
|
||||||
|
// new Date(
|
||||||
|
// `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||||
|
// ) >= datePeriodStart &&
|
||||||
|
// new Date(
|
||||||
|
// `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||||
|
// ) <= datePeriodEnd,
|
||||||
|
// ).length > 0
|
||||||
|
// ? true
|
||||||
|
// : false,
|
||||||
|
isSuspension: item.dateRetire == null ? false : true,
|
||||||
|
isAbsent: item.profileDisciplineId ? true : false,
|
||||||
|
isLeave: item.profileLeaveId ? true : false,
|
||||||
|
isRetired:
|
||||||
|
item.birthDate == null ||
|
||||||
|
calculateRetireDate(item.birthDate).getFullYear() != body.year
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
|
// isSpecial: isSpecial,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return new HttpSuccess({ data: formattedData, total: total });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
profile.amountSpecial = body.amountSpecial ?? _null;
|
profile.amountSpecial = body.amountSpecial ?? _null;
|
||||||
profile.positionSalaryAmount = body.positionSalaryAmount ?? _null;
|
profile.positionSalaryAmount = body.positionSalaryAmount ?? _null;
|
||||||
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null;
|
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null;
|
||||||
|
profile.salaryLevel = body.salaryLevel ?? _null;
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,7 @@ export class CreateProfileSalaryEmployee {
|
||||||
commandName?: string | null;
|
commandName?: string | null;
|
||||||
posNumCodeSit?: string | null;
|
posNumCodeSit?: string | null;
|
||||||
posNumCodeSitAbb?: string | null;
|
posNumCodeSitAbb?: string | null;
|
||||||
|
salaryLevel?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateProfileSalaryEmployee {
|
export class UpdateProfileSalaryEmployee {
|
||||||
|
|
@ -387,6 +388,7 @@ export class UpdateProfileSalaryEmployee {
|
||||||
commandName?: string | null;
|
commandName?: string | null;
|
||||||
posNumCodeSit?: string | null;
|
posNumCodeSit?: string | null;
|
||||||
posNumCodeSitAbb?: string | null;
|
posNumCodeSitAbb?: string | null;
|
||||||
|
salaryLevel?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateProfileSalary = {
|
export type UpdateProfileSalary = {
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,23 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
profile.birthDate,
|
profile.birthDate,
|
||||||
orgRoot.id as rootId,
|
orgRoot.id as rootId,
|
||||||
orgRoot.orgRootShortName,
|
orgRoot.orgRootShortName,
|
||||||
|
orgRoot.orgRootOrder,
|
||||||
orgRoot.orgRootName,
|
orgRoot.orgRootName,
|
||||||
orgChild1.id as child1Id,
|
orgChild1.id as child1Id,
|
||||||
orgChild1.orgChild1ShortName,
|
orgChild1.orgChild1ShortName,
|
||||||
|
orgChild1.orgChild1Order,
|
||||||
orgChild1.orgChild1Name,
|
orgChild1.orgChild1Name,
|
||||||
orgChild2.id as child2Id,
|
orgChild2.id as child2Id,
|
||||||
orgChild2.orgChild2ShortName,
|
orgChild2.orgChild2ShortName,
|
||||||
|
orgChild2.orgChild2Order,
|
||||||
orgChild2.orgChild2Name,
|
orgChild2.orgChild2Name,
|
||||||
orgChild3.id as child3Id,
|
orgChild3.id as child3Id,
|
||||||
orgChild3.orgChild3ShortName,
|
orgChild3.orgChild3ShortName,
|
||||||
|
orgChild3.orgChild3Order,
|
||||||
orgChild3.orgChild3Name,
|
orgChild3.orgChild3Name,
|
||||||
orgChild4.id as child4Id,
|
orgChild4.id as child4Id,
|
||||||
orgChild4.orgChild4ShortName,
|
orgChild4.orgChild4ShortName,
|
||||||
|
orgChild4.orgChild4Order,
|
||||||
orgChild4.orgChild4Name,
|
orgChild4.orgChild4Name,
|
||||||
position.id as positionId,
|
position.id as positionId,
|
||||||
position.positionIsSelected,
|
position.positionIsSelected,
|
||||||
|
|
@ -133,30 +138,40 @@ export class viewPosMaster {
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
orgRootShortName: string;
|
orgRootShortName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
orgRootOrder: string;
|
||||||
|
@ViewColumn()
|
||||||
orgRootName: string;
|
orgRootName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
child1Id: string;
|
child1Id: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
orgChild1ShortName: string;
|
orgChild1ShortName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
orgChild1Order: string;
|
||||||
|
@ViewColumn()
|
||||||
orgChild1Name: string;
|
orgChild1Name: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
child2Id: string;
|
child2Id: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
orgChild2ShortName: string;
|
orgChild2ShortName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
orgChild2Order: string;
|
||||||
|
@ViewColumn()
|
||||||
orgChild2Name: string;
|
orgChild2Name: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
child3Id: string;
|
child3Id: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
orgChild3ShortName: string;
|
orgChild3ShortName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
orgChild3Order: string;
|
||||||
|
@ViewColumn()
|
||||||
orgChild3Name: string;
|
orgChild3Name: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
child4Id: string;
|
child4Id: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
orgChild4ShortName: string;
|
orgChild4ShortName: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
orgChild4Order: string;
|
||||||
|
@ViewColumn()
|
||||||
orgChild4Name: string;
|
orgChild4Name: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
positionId: string;
|
positionId: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue