หาคนเกษียณตามปี
This commit is contained in:
parent
58274b479c
commit
f2efb44336
3 changed files with 29 additions and 29 deletions
|
|
@ -4975,7 +4975,7 @@ export class ProfileController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("cal/retire")
|
@Post("cal/retire")
|
||||||
async calDateRetire(@Body() body:{birthDate: Date}) {
|
async calDateRetire(@Body() body: { birthDate: Date }) {
|
||||||
const retireDate = await calculateRetireDate(body.birthDate);
|
const retireDate = await calculateRetireDate(body.birthDate);
|
||||||
const age = calculateAge(body.birthDate);
|
const age = calculateAge(body.birthDate);
|
||||||
|
|
||||||
|
|
@ -10436,7 +10436,11 @@ export class ProfileController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
.where("YEAR(profile.dateRetire) = :year", { year })
|
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||||
|
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||||
|
start: `${year - 1}-10-02`,
|
||||||
|
end: `${year}-10-01`,
|
||||||
|
})
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
if (!profiles || profiles.length === 0) {
|
if (!profiles || profiles.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -5032,7 +5032,11 @@ export class ProfileEmployeeController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||||
|
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||||
|
start: `${year - 1}-10-02`,
|
||||||
|
end: `${year}-10-01`,
|
||||||
|
})
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
if (!profiles || profiles.length === 0) {
|
if (!profiles || profiles.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -1527,7 +1527,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = await this.profileRepo
|
let query = await this.profileRepo
|
||||||
.createQueryBuilder("profileEmployee")
|
.createQueryBuilder("profileEmployee")
|
||||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||||
|
|
@ -1640,36 +1640,24 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
|
|
||||||
if (sortBy) {
|
if (sortBy) {
|
||||||
if(sortBy == "posLevel"){
|
if (sortBy == "posLevel") {
|
||||||
query = query.orderBy(
|
query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
|
||||||
`posLevel.posLevelName`,
|
} else if (sortBy == "posType") {
|
||||||
descending ? "DESC" : "ASC"
|
query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
|
||||||
);
|
} else if (sortBy == "govAge") {
|
||||||
}else if(sortBy == "posType"){
|
query = query.orderBy(`profileEmployee.dateAppoint`, descending ? "DESC" : "ASC");
|
||||||
query = query.orderBy(
|
} else {
|
||||||
`posType.posTypeName`,
|
query = query.orderBy(`profileEmployee.${sortBy}`, descending ? "DESC" : "ASC");
|
||||||
descending ? "DESC" : "ASC"
|
|
||||||
);
|
|
||||||
}else if(sortBy == "govAge"){
|
|
||||||
query = query.orderBy(
|
|
||||||
`profileEmployee.dateAppoint`,
|
|
||||||
descending ? "DESC" : "ASC"
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
query = query.orderBy(
|
|
||||||
`profileEmployee.${sortBy}`,
|
|
||||||
descending ? "DESC" : "ASC"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [record, total] = await query
|
const [record, total] = await query
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const data = await Promise.all(
|
const data = await Promise.all(
|
||||||
record.map((_data) => {
|
record.map((_data) => {
|
||||||
|
|
@ -3241,7 +3229,11 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||||
|
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||||
|
start: `${year - 1}-10-02`,
|
||||||
|
end: `${year}-10-01`,
|
||||||
|
})
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
if (!profiles || profiles.length === 0) {
|
if (!profiles || profiles.length === 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue