add command code 20
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
This commit is contained in:
parent
b1210d51e8
commit
757da877f6
8 changed files with 268 additions and 218 deletions
|
|
@ -30,7 +30,7 @@ import {
|
||||||
UpdateProfileFather,
|
UpdateProfileFather,
|
||||||
UpdateProfileMother,
|
UpdateProfileMother,
|
||||||
UpdateProfileCouple,
|
UpdateProfileCouple,
|
||||||
UpdatePrivacyDto
|
UpdatePrivacyDto,
|
||||||
} from "../entities/Profile";
|
} from "../entities/Profile";
|
||||||
import { Brackets, In, IsNull, Like, Not } from "typeorm";
|
import { Brackets, In, IsNull, Like, Not } from "typeorm";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
|
@ -280,7 +280,7 @@ export class ProfileController extends Controller {
|
||||||
// ],
|
// ],
|
||||||
where: {
|
where: {
|
||||||
profileId: id,
|
profileId: id,
|
||||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]),
|
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||||
},
|
},
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
@ -1428,7 +1428,7 @@ export class ProfileController extends Controller {
|
||||||
const position_raw = await this.salaryRepo.find({
|
const position_raw = await this.salaryRepo.find({
|
||||||
where: {
|
where: {
|
||||||
profileId: id,
|
profileId: id,
|
||||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]),
|
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||||
isEntry: false,
|
isEntry: false,
|
||||||
},
|
},
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
|
|
@ -5186,7 +5186,7 @@ export class ProfileController extends Controller {
|
||||||
@Put("privacy")
|
@Put("privacy")
|
||||||
async updatePrivacy(
|
async updatePrivacy(
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
@Body() body: UpdatePrivacyDto
|
@Body() body: UpdatePrivacyDto,
|
||||||
) {
|
) {
|
||||||
let isEmployee = false;
|
let isEmployee = false;
|
||||||
let profile: any = null;
|
let profile: any = null;
|
||||||
|
|
@ -5220,15 +5220,12 @@ export class ProfileController extends Controller {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatus.BAD_REQUEST, "system ไม่ถูกต้อง");
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
"system ไม่ถูกต้อง"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
profile.lastUpdatedAt = new Date();
|
profile.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
if (isEmployee) {
|
if (isEmployee) {
|
||||||
await this.profileEmpRepo.save(profile, { data: request });
|
await this.profileEmpRepo.save(profile, { data: request });
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -7418,7 +7415,7 @@ export class ProfileController extends Controller {
|
||||||
posNo: null,
|
posNo: null,
|
||||||
privacyCheckin: profile.privacyCheckin,
|
privacyCheckin: profile.privacyCheckin,
|
||||||
privacyUser: profile.privacyUser,
|
privacyUser: profile.privacyUser,
|
||||||
privacyMgt : profile.privacyMgt,
|
privacyMgt: profile.privacyMgt,
|
||||||
isDeputy: root?.isDeputy ?? false,
|
isDeputy: root?.isDeputy ?? false,
|
||||||
// root?.orgRootShortName && posMaster?.posMasterNo
|
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||||
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||||
|
|
@ -7591,7 +7588,7 @@ export class ProfileController extends Controller {
|
||||||
posNo: null,
|
posNo: null,
|
||||||
privacyCheckin: profile.privacyCheckin,
|
privacyCheckin: profile.privacyCheckin,
|
||||||
privacyUser: profile.privacyUser,
|
privacyUser: profile.privacyUser,
|
||||||
privacyMgt : profile.privacyMgt,
|
privacyMgt: profile.privacyMgt,
|
||||||
isDeputy: root?.isDeputy ?? false,
|
isDeputy: root?.isDeputy ?? false,
|
||||||
// root?.orgRootShortName && posMaster?.posMasterNo
|
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||||
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||||
|
|
@ -10940,12 +10937,12 @@ export class ProfileController extends Controller {
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: Profile) => {
|
findProfile.map(async (item: Profile) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
let shortName = null;
|
let shortName = null;
|
||||||
let root = null;
|
let root = null;
|
||||||
let posMasterNo = null;
|
let posMasterNo = null;
|
||||||
if (item.isLeave == false) {
|
if (item.isLeave == false) {
|
||||||
shortName =
|
shortName =
|
||||||
|
|
@ -10956,14 +10953,15 @@ export class ProfileController extends Controller {
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
null
|
?.orgChild3 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||||
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
|
|
@ -10983,21 +10981,36 @@ export class ProfileController extends Controller {
|
||||||
posMasterNo = item.current_holders?.find(
|
posMasterNo = item.current_holders?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.posMasterNo;
|
)?.posMasterNo;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const profileSalary = await this.salaryRepo
|
const profileSalary = await this.salaryRepo
|
||||||
.createQueryBuilder("s")
|
.createQueryBuilder("s")
|
||||||
.where("s.profileId = :profileId", { profileId: item.id })
|
.where("s.profileId = :profileId", { profileId: item.id })
|
||||||
.andWhere("s.commandCode IN (:...codes)", {
|
.andWhere("s.commandCode IN (:...codes)", {
|
||||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
codes: [
|
||||||
|
"0",
|
||||||
|
"9",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"8",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12",
|
||||||
|
"13",
|
||||||
|
"14",
|
||||||
|
"15",
|
||||||
|
"16",
|
||||||
|
"20",
|
||||||
|
],
|
||||||
})
|
})
|
||||||
.orderBy("s.order", "DESC")
|
.orderBy("s.order", "DESC")
|
||||||
.addOrderBy("s.createdAt", "DESC")
|
.addOrderBy("s.createdAt", "DESC")
|
||||||
.take(2)
|
.take(2)
|
||||||
.getMany();
|
.getMany();
|
||||||
if (profileSalary.length > 0) {
|
if (profileSalary.length > 0) {
|
||||||
shortName = item.isRetirement
|
shortName = item.isRetirement
|
||||||
? profileSalary.length > 1
|
? profileSalary.length > 1
|
||||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||||
|
|
@ -11006,7 +11019,7 @@ export class ProfileController extends Controller {
|
||||||
? profileSalary[1]?.posNo
|
? profileSalary[1]?.posNo
|
||||||
: profileSalary[0]?.posNo
|
: profileSalary[0]?.posNo
|
||||||
: profileSalary[0]?.posNo;
|
: profileSalary[0]?.posNo;
|
||||||
root = item.isRetirement
|
root = item.isRetirement
|
||||||
? profileSalary.length > 1
|
? profileSalary.length > 1
|
||||||
? profileSalary[1]?.orgRoot
|
? profileSalary[1]?.orgRoot
|
||||||
: profileSalary[0]?.orgRoot
|
: profileSalary[0]?.orgRoot
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
// ],
|
// ],
|
||||||
where: {
|
where: {
|
||||||
profileEmployeeId: id,
|
profileEmployeeId: id,
|
||||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]),
|
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||||
},
|
},
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
@ -1423,7 +1423,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
const position_raw = await this.salaryRepo.find({
|
const position_raw = await this.salaryRepo.find({
|
||||||
where: {
|
where: {
|
||||||
profileEmployeeId: id,
|
profileEmployeeId: id,
|
||||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]),
|
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||||
isEntry: false,
|
isEntry: false,
|
||||||
},
|
},
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
|
|
@ -5735,61 +5735,61 @@ export class ProfileEmployeeController 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 queryLike = "1=1";
|
let queryLike = "1=1";
|
||||||
switch (body.fieldName) {
|
switch (body.fieldName) {
|
||||||
case "citizenId":
|
case "citizenId":
|
||||||
queryLike = "profile.citizenId LIKE :keyword";
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "fullname":
|
case "fullname":
|
||||||
case "fullName":
|
case "fullName":
|
||||||
queryLike =
|
queryLike =
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "firstname":
|
case "firstname":
|
||||||
case "firstName":
|
case "firstName":
|
||||||
queryLike = "profile.firstName LIKE :keyword";
|
queryLike = "profile.firstName LIKE :keyword";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lastname":
|
case "lastname":
|
||||||
case "lastName":
|
case "lastName":
|
||||||
queryLike = "profile.lastName LIKE :keyword";
|
queryLike = "profile.lastName LIKE :keyword";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
queryLike = "1=1";
|
queryLike = "1=1";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = await this.profileRepo
|
let query = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.where("profile.keycloak IS NULL")
|
.where("profile.keycloak IS NULL")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [findProfile, total] = await query
|
const [findProfile, total] = await query
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
let shortName = null;
|
let shortName = null;
|
||||||
let root = null;
|
let root = null;
|
||||||
let posMasterNo = null;
|
let posMasterNo = null;
|
||||||
if (item.isLeave == false) {
|
if (item.isLeave == false) {
|
||||||
shortName =
|
shortName =
|
||||||
|
|
@ -5800,14 +5800,15 @@ export class ProfileEmployeeController extends Controller {
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
null
|
?.orgChild3 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||||
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
|
|
@ -5828,21 +5829,36 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posMasterNo = item.current_holders?.find(
|
posMasterNo = item.current_holders?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.posMasterNo;
|
)?.posMasterNo;
|
||||||
}
|
} else {
|
||||||
else {
|
const profileSalary = await this.salaryRepo
|
||||||
const profileSalary = await this.salaryRepo
|
|
||||||
.createQueryBuilder("s")
|
.createQueryBuilder("s")
|
||||||
.where("s.profileEmployeeId = :profileId", { profileId: item.id })
|
.where("s.profileEmployeeId = :profileId", { profileId: item.id })
|
||||||
.andWhere("s.commandCode IN (:...codes)", {
|
.andWhere("s.commandCode IN (:...codes)", {
|
||||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
codes: [
|
||||||
|
"0",
|
||||||
|
"9",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"8",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12",
|
||||||
|
"13",
|
||||||
|
"14",
|
||||||
|
"15",
|
||||||
|
"16",
|
||||||
|
"20",
|
||||||
|
],
|
||||||
})
|
})
|
||||||
.orderBy("s.order", "DESC")
|
.orderBy("s.order", "DESC")
|
||||||
.addOrderBy("s.createdAt", "DESC")
|
.addOrderBy("s.createdAt", "DESC")
|
||||||
.take(2)
|
.take(2)
|
||||||
.getMany();
|
.getMany();
|
||||||
if (profileSalary.length > 0) {
|
if (profileSalary.length > 0) {
|
||||||
shortName = item.isRetirement
|
shortName = item.isRetirement
|
||||||
? profileSalary.length > 1
|
? profileSalary.length > 1
|
||||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||||
|
|
@ -5851,14 +5867,13 @@ export class ProfileEmployeeController extends Controller {
|
||||||
? profileSalary[1]?.posNo
|
? profileSalary[1]?.posNo
|
||||||
: profileSalary[0]?.posNo
|
: profileSalary[0]?.posNo
|
||||||
: profileSalary[0]?.posNo;
|
: profileSalary[0]?.posNo;
|
||||||
root = item.isRetirement
|
root = item.isRetirement
|
||||||
? profileSalary.length > 1
|
? profileSalary.length > 1
|
||||||
? profileSalary[1]?.orgRoot
|
? profileSalary[1]?.orgRoot
|
||||||
: profileSalary[0]?.orgRoot
|
: profileSalary[0]?.orgRoot
|
||||||
: profileSalary[0]?.orgRoot;
|
: profileSalary[0]?.orgRoot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||||
where: { profileEmployeeId: item.id },
|
where: { profileEmployeeId: item.id },
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
// ],
|
// ],
|
||||||
where: {
|
where: {
|
||||||
profileEmployeeId: id,
|
profileEmployeeId: id,
|
||||||
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]),
|
commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16", "20"]),
|
||||||
},
|
},
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -359,6 +360,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
|
|
@ -387,6 +388,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
|
|
|
||||||
|
|
@ -276,34 +276,35 @@ export class ProfileInsigniaController extends Controller {
|
||||||
}
|
}
|
||||||
const profileSalarys = await this.profileSalaryRepo.find({
|
const profileSalarys = await this.profileSalaryRepo.find({
|
||||||
where: [
|
where: [
|
||||||
{
|
{
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
commandCode: In([
|
commandCode: In([
|
||||||
"0",
|
"0",
|
||||||
"9",
|
"9",
|
||||||
"1",
|
"1",
|
||||||
"2",
|
"2",
|
||||||
"3",
|
"3",
|
||||||
"4",
|
"4",
|
||||||
"8",
|
"8",
|
||||||
"10",
|
"10",
|
||||||
"11",
|
"11",
|
||||||
"12",
|
"12",
|
||||||
"13",
|
"13",
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
]),
|
"20",
|
||||||
},
|
]),
|
||||||
{ profileId: body.profileId, commandCode: IsNull() },
|
},
|
||||||
],
|
{ profileId: body.profileId, commandCode: IsNull() },
|
||||||
|
],
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
if (!profileSalarys) {
|
if (!profileSalarys) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบข้อมูลตำแหน่งและเงินเดือน");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบข้อมูลตำแหน่งและเงินเดือน");
|
||||||
}
|
}
|
||||||
const birth = new Date(profile.birthDate);
|
const birth = new Date(profile.birthDate);
|
||||||
const mapData = profileSalarys.map(x => {
|
const mapData = profileSalarys.map((x) => {
|
||||||
// คำนวณอายุ
|
// คำนวณอายุ
|
||||||
let age = null;
|
let age = null;
|
||||||
if (x.commandDateAffect && profile.birthDate) {
|
if (x.commandDateAffect && profile.birthDate) {
|
||||||
|
|
@ -317,16 +318,16 @@ export class ProfileInsigniaController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
dateAffect: x.commandDateAffect,
|
dateAffect: x.commandDateAffect,
|
||||||
position: x.positionName,
|
position: x.positionName,
|
||||||
root: x.orgRoot,
|
root: x.orgRoot,
|
||||||
child1: x.orgChild1,
|
child1: x.orgChild1,
|
||||||
child2: x.orgChild2,
|
child2: x.orgChild2,
|
||||||
child3: x.orgChild3,
|
child3: x.orgChild3,
|
||||||
child4: x.orgChild4,
|
child4: x.orgChild4,
|
||||||
age: age,
|
age: age,
|
||||||
amount: x.amount,
|
amount: x.amount,
|
||||||
remark: x.remark
|
remark: x.remark,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return new HttpSuccess(mapData);
|
return new HttpSuccess(mapData);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ export class ProfileSalaryController extends Controller {
|
||||||
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
|
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
|
||||||
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
||||||
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
|
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
|
||||||
private positionExecutiveOfficerRepo = AppDataSource.getRepository(TenurePositionExecutiveOfficer);
|
private positionExecutiveOfficerRepo = AppDataSource.getRepository(
|
||||||
|
TenurePositionExecutiveOfficer,
|
||||||
|
);
|
||||||
private commandRepository = AppDataSource.getRepository(Command);
|
private commandRepository = AppDataSource.getRepository(Command);
|
||||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
|
|
@ -66,11 +68,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x.isLeave) {
|
if (x.isLeave) {
|
||||||
_currentDate = x.leaveDate
|
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||||
? Extension.toDateOnlyString(x.leaveDate)
|
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [x.id, _currentDate]);
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||||
|
x.id,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
_position.length > 1
|
_position.length > 1
|
||||||
|
|
@ -96,7 +99,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
// Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
// Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
||||||
// Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
// Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
||||||
// Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
// Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
||||||
Years: Math.floor(calDayDiff.days_diff / 365.2524),
|
Years: Math.floor(calDayDiff.days_diff / 365.2524),
|
||||||
Months: Math.floor((calDayDiff.days_diff / 30.4375) % 12),
|
Months: Math.floor((calDayDiff.days_diff / 30.4375) % 12),
|
||||||
Days: Math.floor(calDayDiff.days_diff % 30.4375),
|
Days: Math.floor(calDayDiff.days_diff % 30.4375),
|
||||||
};
|
};
|
||||||
|
|
@ -116,13 +119,11 @@ export class ProfileSalaryController extends Controller {
|
||||||
const profile = await this.profileEmployeeRepo.find();
|
const profile = await this.profileEmployeeRepo.find();
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
if (x?.isLeave) {
|
||||||
_currentDate = x.leaveDate
|
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||||
? Extension.toDateOnlyString(x.leaveDate)
|
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
|
|
@ -149,7 +150,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
// Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
// Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
||||||
// Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
// Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
||||||
// Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
// Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
||||||
Years: Math.floor(calDayDiff.days_diff / 365.2524),
|
Years: Math.floor(calDayDiff.days_diff / 365.2524),
|
||||||
Months: Math.floor((calDayDiff.days_diff / 30.4375) % 12),
|
Months: Math.floor((calDayDiff.days_diff / 30.4375) % 12),
|
||||||
Days: Math.floor(calDayDiff.days_diff % 30.4375),
|
Days: Math.floor(calDayDiff.days_diff % 30.4375),
|
||||||
};
|
};
|
||||||
|
|
@ -169,11 +170,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
if (x?.isLeave) {
|
||||||
_currentDate = x.leaveDate
|
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||||
? Extension.toDateOnlyString(x.leaveDate)
|
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [x.id, _currentDate]);
|
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
||||||
|
x.id,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
||||||
const mapPositionLevel =
|
const mapPositionLevel =
|
||||||
_positionLevel.length > 1
|
_positionLevel.length > 1
|
||||||
|
|
@ -226,13 +228,11 @@ export class ProfileSalaryController extends Controller {
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
if (x?.isLeave) {
|
||||||
_currentDate = x.leaveDate
|
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||||
? Extension.toDateOnlyString(x.leaveDate)
|
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
||||||
const mapPositionLevel =
|
const mapPositionLevel =
|
||||||
|
|
@ -293,9 +293,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
if (x?.isLeave) {
|
||||||
_currentDate = x.leaveDate
|
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||||
? Extension.toDateOnlyString(x.leaveDate)
|
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const position = await this.positionRepo.findOne({
|
const position = await this.positionRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -310,7 +308,10 @@ export class ProfileSalaryController extends Controller {
|
||||||
posExecutive: true,
|
posExecutive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const positionExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [x.id, _currentDate]);
|
const positionExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [
|
||||||
|
x.id,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _position = positionExecutive.length > 0 ? positionExecutive[0] : [];
|
const _position = positionExecutive.length > 0 ? positionExecutive[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
_position.length > 1
|
_position.length > 1
|
||||||
|
|
@ -349,14 +350,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
const allRegis = await AppDataSource.getRepository(viewRegistryOfficer)
|
const allRegis = await AppDataSource.getRepository(viewRegistryOfficer)
|
||||||
.createQueryBuilder("registryOfficer")
|
.createQueryBuilder("registryOfficer")
|
||||||
.getMany();
|
.getMany();
|
||||||
const profileIds = new Set((await this.profileRepo.find()).map(p => p.id));
|
const profileIds = new Set((await this.profileRepo.find()).map((p) => p.id));
|
||||||
const mapData = allRegis
|
const mapData = allRegis
|
||||||
.filter(x => profileIds.has(x.profileId))
|
.filter((x) => profileIds.has(x.profileId))
|
||||||
.map(x => ({
|
.map((x) => ({
|
||||||
...x,
|
...x,
|
||||||
isProbation: Boolean(x.isProbation),
|
isProbation: Boolean(x.isProbation),
|
||||||
isLeave: Boolean(x.isLeave),
|
isLeave: Boolean(x.isLeave),
|
||||||
isRetirement: Boolean(x.isRetirement),
|
isRetirement: Boolean(x.isRetirement),
|
||||||
Educations: x.Educations ? JSON.stringify(x.Educations) : "",
|
Educations: x.Educations ? JSON.stringify(x.Educations) : "",
|
||||||
}));
|
}));
|
||||||
if (mapData.length > 0) {
|
if (mapData.length > 0) {
|
||||||
|
|
@ -371,14 +372,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
const allRegis = await AppDataSource.getRepository(viewRegistryEmployee)
|
const allRegis = await AppDataSource.getRepository(viewRegistryEmployee)
|
||||||
.createQueryBuilder("registryEmployee")
|
.createQueryBuilder("registryEmployee")
|
||||||
.getMany();
|
.getMany();
|
||||||
const profileEmpIds = new Set((await this.profileEmployeeRepo.find()).map(p => p.id));
|
const profileEmpIds = new Set((await this.profileEmployeeRepo.find()).map((p) => p.id));
|
||||||
const mapData = allRegis
|
const mapData = allRegis
|
||||||
.filter(x => profileEmpIds.has(x.profileEmployeeId))
|
.filter((x) => profileEmpIds.has(x.profileEmployeeId))
|
||||||
.map(x => ({
|
.map((x) => ({
|
||||||
...x,
|
...x,
|
||||||
isProbation: Boolean(x.isProbation),
|
isProbation: Boolean(x.isProbation),
|
||||||
isLeave: Boolean(x.isLeave),
|
isLeave: Boolean(x.isLeave),
|
||||||
isRetirement: Boolean(x.isRetirement),
|
isRetirement: Boolean(x.isRetirement),
|
||||||
Educations: x.Educations ? JSON.stringify(x.Educations) : "",
|
Educations: x.Educations ? JSON.stringify(x.Educations) : "",
|
||||||
}));
|
}));
|
||||||
if (mapData.length > 0) {
|
if (mapData.length > 0) {
|
||||||
|
|
@ -407,14 +408,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
if (r.commandId) {
|
if (r.commandId) {
|
||||||
_command = await this.commandRepository.findOne({
|
_command = await this.commandRepository.findOne({
|
||||||
where: { id: r.commandId },
|
where: { id: r.commandId },
|
||||||
relations: ["commandType"]
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...r,
|
...r,
|
||||||
commandType: _command && _command?.commandType ? _command?.commandType.code : null
|
commandType: _command && _command?.commandType ? _command?.commandType.code : null,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -444,6 +445,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
{ profileId: profile.id, commandCode: IsNull() },
|
{ profileId: profile.id, commandCode: IsNull() },
|
||||||
|
|
@ -457,14 +459,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
if (r.commandId) {
|
if (r.commandId) {
|
||||||
_command = await this.commandRepository.findOne({
|
_command = await this.commandRepository.findOne({
|
||||||
where: { id: r.commandId },
|
where: { id: r.commandId },
|
||||||
relations: ["commandType"]
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...r,
|
...r,
|
||||||
commandType: _command && _command?.commandType ? _command?.commandType.code : null
|
commandType: _command && _command?.commandType ? _command?.commandType.code : null,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -491,14 +493,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
if (r.commandId) {
|
if (r.commandId) {
|
||||||
_command = await this.commandRepository.findOne({
|
_command = await this.commandRepository.findOne({
|
||||||
where: { id: r.commandId },
|
where: { id: r.commandId },
|
||||||
relations: ["commandType"]
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...r,
|
...r,
|
||||||
commandType: _command && _command?.commandType ? _command?.commandType.code : null
|
commandType: _command && _command?.commandType ? _command?.commandType.code : null,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -527,6 +529,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
{ profileId: profileId, commandCode: IsNull() },
|
{ profileId: profileId, commandCode: IsNull() },
|
||||||
|
|
@ -548,14 +551,14 @@ export class ProfileSalaryController extends Controller {
|
||||||
if (r.commandId) {
|
if (r.commandId) {
|
||||||
_command = await this.commandRepository.findOne({
|
_command = await this.commandRepository.findOne({
|
||||||
where: { id: r.commandId },
|
where: { id: r.commandId },
|
||||||
relations: ["commandType"]
|
relations: ["commandType"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...r,
|
...r,
|
||||||
commandType: _command && _command?.commandType ? _command?.commandType.code : null
|
commandType: _command && _command?.commandType ? _command?.commandType.code : null,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -572,11 +575,13 @@ export class ProfileSalaryController extends Controller {
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (profile && profile?.isLeave) {
|
if (profile && profile?.isLeave) {
|
||||||
_currentDate = profile && profile.leaveDate
|
_currentDate =
|
||||||
? Extension.toDateOnlyString(profile.leaveDate)
|
profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate;
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [profile.id, _currentDate]);
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||||
|
profile.id,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
|
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
|
|
@ -607,7 +612,10 @@ export class ProfileSalaryController extends Controller {
|
||||||
},
|
},
|
||||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||||
);
|
);
|
||||||
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [profile.id, _currentDate]);
|
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
||||||
|
profile.id,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||||
const mapPosLevel =
|
const mapPosLevel =
|
||||||
_posLevel.length > 1
|
_posLevel.length > 1
|
||||||
|
|
@ -646,7 +654,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
|
|
||||||
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [
|
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [
|
||||||
profile.id,
|
profile.id,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
|
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
|
||||||
const mapPosExecutive =
|
const mapPosExecutive =
|
||||||
|
|
@ -691,19 +699,23 @@ export class ProfileSalaryController extends Controller {
|
||||||
// "SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));",
|
// "SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));",
|
||||||
// );
|
// );
|
||||||
const _profile = await this.profileRepo.findOne({
|
const _profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileId }
|
where: { id: profileId },
|
||||||
})
|
});
|
||||||
if (!_profile) {
|
if (!_profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (_profile && _profile?.isLeave) {
|
if (_profile && _profile?.isLeave) {
|
||||||
_currentDate = _profile && _profile.leaveDate
|
_currentDate =
|
||||||
? Extension.toDateOnlyString(_profile.leaveDate)
|
_profile && _profile.leaveDate
|
||||||
: _currentDate
|
? Extension.toDateOnlyString(_profile.leaveDate)
|
||||||
|
: _currentDate;
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [profileId, _currentDate]);
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||||
|
profileId,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
|
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
|
|
@ -738,7 +750,10 @@ export class ProfileSalaryController extends Controller {
|
||||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [profileId, _currentDate]);
|
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
||||||
|
profileId,
|
||||||
|
_currentDate,
|
||||||
|
]);
|
||||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||||
const mapPosLevel =
|
const mapPosLevel =
|
||||||
_posLevel.length > 1
|
_posLevel.length > 1
|
||||||
|
|
@ -780,7 +795,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
|
|
||||||
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [
|
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?, ?)", [
|
||||||
profileId,
|
profileId,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
|
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
|
||||||
const mapPosExecutive =
|
const mapPosExecutive =
|
||||||
|
|
@ -891,9 +906,9 @@ export class ProfileSalaryController extends Controller {
|
||||||
};
|
};
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
if (body.commandCode && !body.commandName) {
|
if (body.commandCode && !body.commandName) {
|
||||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
|
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ";
|
||||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
|
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
|
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
}
|
}
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
|
|
@ -929,10 +944,10 @@ export class ProfileSalaryController extends Controller {
|
||||||
order: { order: "DESC" },
|
order: { order: "DESC" },
|
||||||
});
|
});
|
||||||
const before = null;
|
const before = null;
|
||||||
let _posNumCodeSit: string = ""
|
let _posNumCodeSit: string = "";
|
||||||
let _posNumCodeSitAbb: string = ""
|
let _posNumCodeSitAbb: string = "";
|
||||||
const _command = await this.commandRepository.findOne({
|
const _command = await this.commandRepository.findOne({
|
||||||
where: { id: body.commandId ?? "" }
|
where: { id: body.commandId ?? "" },
|
||||||
});
|
});
|
||||||
if (_command) {
|
if (_command) {
|
||||||
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
||||||
|
|
@ -941,35 +956,35 @@ export class ProfileSalaryController extends Controller {
|
||||||
isDeputy: true,
|
isDeputy: true,
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
orgRevisionIsDraft: false
|
orgRevisionIsDraft: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
relations: ["orgRevision"]
|
relations: ["orgRevision"],
|
||||||
})
|
});
|
||||||
_posNumCodeSit = orgRootDeputy ? orgRootDeputy?.orgRootName : "สำนักปลัดกรุงเทพมหานคร";
|
_posNumCodeSit = orgRootDeputy ? orgRootDeputy?.orgRootName : "สำนักปลัดกรุงเทพมหานคร";
|
||||||
_posNumCodeSitAbb = orgRootDeputy ? orgRootDeputy?.orgRootShortName : "สนป.";
|
_posNumCodeSitAbb = orgRootDeputy ? orgRootDeputy?.orgRootShortName : "สนป.";
|
||||||
}
|
} else if (_command?.isBangkok?.toLocaleUpperCase() == "BANGKOK") {
|
||||||
else if (_command?.isBangkok?.toLocaleUpperCase() == "BANGKOK") {
|
_posNumCodeSit = "กรุงเทพมหานคร";
|
||||||
_posNumCodeSit = "กรุงเทพมหานคร"
|
_posNumCodeSitAbb = "กทม.";
|
||||||
_posNumCodeSitAbb = "กทม."
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
let _profileAdmin = await this.profileRepo.findOne({
|
let _profileAdmin = await this.profileRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
keycloak: _command?.createdUserId.toString(),
|
keycloak: _command?.createdUserId.toString(),
|
||||||
current_holders: {
|
current_holders: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
orgRevisionIsCurrent: true,
|
orgRevisionIsCurrent: true,
|
||||||
orgRevisionIsDraft: false
|
orgRevisionIsDraft: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
relations: ["current_holders", "current_holders.orgRevision", "current_holders.orgRoot"]
|
relations: ["current_holders", "current_holders.orgRevision", "current_holders.orgRoot"],
|
||||||
});
|
});
|
||||||
_posNumCodeSit = _profileAdmin?.current_holders
|
_posNumCodeSit =
|
||||||
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
|
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootName)?.orgRoot.orgRootName ??
|
||||||
_posNumCodeSitAbb = _profileAdmin?.current_holders
|
"";
|
||||||
.find(x => x.orgRoot.orgRootShortName)?.orgRoot.orgRootShortName ?? ""
|
_posNumCodeSitAbb =
|
||||||
|
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootShortName)?.orgRoot
|
||||||
|
.orgRootShortName ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalary();
|
||||||
|
|
@ -1014,9 +1029,9 @@ export class ProfileSalaryController extends Controller {
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
if (body.commandCode && !body.commandName) {
|
if (body.commandCode && !body.commandName) {
|
||||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
|
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ";
|
||||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
|
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
|
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
}
|
}
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, { ...record, id: undefined });
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
{ profileEmployeeId: profile.id, commandCode: IsNull() },
|
{ profileEmployeeId: profile.id, commandCode: IsNull() },
|
||||||
|
|
@ -128,6 +129,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
"14",
|
"14",
|
||||||
"15",
|
"15",
|
||||||
"16",
|
"16",
|
||||||
|
"20",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
{ profileEmployeeId: profileId, commandCode: IsNull() },
|
{ profileEmployeeId: profileId, commandCode: IsNull() },
|
||||||
|
|
@ -146,13 +148,12 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (profile && profile?.isLeave) {
|
if (profile && profile?.isLeave) {
|
||||||
_currentDate = profile && profile.leaveDate
|
_currentDate =
|
||||||
? Extension.toDateOnlyString(profile.leaveDate)
|
profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate;
|
||||||
: _currentDate
|
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||||
profile.id,
|
profile.id,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
|
|
@ -185,7 +186,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
|
|
||||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||||
profile.id,
|
profile.id,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||||
const mapPosLevel =
|
const mapPosLevel =
|
||||||
|
|
@ -228,21 +229,22 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
@Get("tenure/{profileId}")
|
@Get("tenure/{profileId}")
|
||||||
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
const _profile = await this.profileRepo.findOne({
|
const _profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileId }
|
where: { id: profileId },
|
||||||
})
|
});
|
||||||
if (!_profile) {
|
if (!_profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (_profile && _profile?.isLeave) {
|
if (_profile && _profile?.isLeave) {
|
||||||
_currentDate = _profile && _profile.leaveDate
|
_currentDate =
|
||||||
? Extension.toDateOnlyString(_profile.leaveDate)
|
_profile && _profile.leaveDate
|
||||||
: _currentDate
|
? Extension.toDateOnlyString(_profile.leaveDate)
|
||||||
|
: _currentDate;
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||||
profileId,
|
profileId,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _position = position.length > 0 ? position[0] : [];
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
|
|
@ -275,7 +277,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
|
|
||||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||||
profileId,
|
profileId,
|
||||||
_currentDate
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||||
const mapPosLevel =
|
const mapPosLevel =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue