filter education
This commit is contained in:
parent
e7798402eb
commit
332a96efb3
4 changed files with 187 additions and 159 deletions
|
|
@ -86,6 +86,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
|||
import { ProfileAssistance } from "../entities/ProfileAssistance";
|
||||
import { CommandRecive } from "../entities/CommandRecive";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { getTopDegrees } from "../services/PositionService";
|
||||
@Route("api/v1/org/profile")
|
||||
@Tags("Profile")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -6292,7 +6293,9 @@ export class ProfileController extends Controller {
|
|||
// : undefined,
|
||||
// })
|
||||
.where("current_holders.orgRevisionId = :orgRevisionId", {
|
||||
orgRevisionId: (await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } }))?.id
|
||||
orgRevisionId: (
|
||||
await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } })
|
||||
)?.id,
|
||||
})
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
|
|
@ -8148,7 +8151,7 @@ export class ProfileController extends Controller {
|
|||
salary: profile ? profile.amount : null,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
? await getTopDegrees(profile.profileEducations)
|
||||
: "-",
|
||||
statusCheckEdit: profile.statusCheckEdit,
|
||||
isEdit: permissionProflile?.isEdit ?? false,
|
||||
|
|
@ -8345,7 +8348,7 @@ export class ProfileController extends Controller {
|
|||
mouthSalaryAmount: profile ? profile.mouthSalaryAmount : null,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
? await getTopDegrees(profile.profileEducations)
|
||||
: "",
|
||||
dateAppoint: profile.dateAppoint,
|
||||
avatarUrl:
|
||||
|
|
@ -8497,7 +8500,7 @@ export class ProfileController extends Controller {
|
|||
salary: profile.amount,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
? await getTopDegrees(profile.profileEducations)
|
||||
: "-",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ import { ProfileAssistance } from "../entities/ProfileAssistance";
|
|||
import { ProfileChangeName } from "../entities/ProfileChangeName";
|
||||
import { ProfileChildren } from "../entities/ProfileChildren";
|
||||
import { ProfileDuty } from "../entities/ProfileDuty";
|
||||
import { getTopDegrees } from "../services/PositionService";
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -1107,14 +1108,14 @@ export class ProfileEmployeeController extends Controller {
|
|||
: null,
|
||||
disciplineDetail: item.detail ?? null,
|
||||
refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
|
||||
level: item.level ?? ""
|
||||
level: item.level ?? "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
disciplineYear: "-",
|
||||
disciplineDetail: "-",
|
||||
refNo: "-",
|
||||
level: "-"
|
||||
level: "-",
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -1164,7 +1165,9 @@ export class ProfileEmployeeController extends Controller {
|
|||
salary:
|
||||
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||
special:
|
||||
item.amountSpecial != null ? Extension.ToThaiNumber(item.amountSpecial.toLocaleString()) : null,
|
||||
item.amountSpecial != null
|
||||
? Extension.ToThaiNumber(item.amountSpecial.toLocaleString())
|
||||
: null,
|
||||
rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
refAll: item.remark ? Extension.ToThaiNumber(item.remark) : null,
|
||||
positionLevel: item.positionLevel
|
||||
|
|
@ -1314,7 +1317,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
"profileLeave.dateLeaveEnd AS dateLeaveEnd",
|
||||
"profileLeave.leaveDays AS leaveDays",
|
||||
"profileLeave.reason AS reason",
|
||||
"leaveType.name as name"
|
||||
"leaveType.name as name",
|
||||
])
|
||||
.where("profileLeave.profileEmployeeId = :profileId", { profileId: id })
|
||||
.andWhere("leaveType.code IN (:...codes)", { codes: ["LV-008", "LV-009", "LV-010"] })
|
||||
|
|
@ -1324,10 +1327,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
const leaves2 =
|
||||
leave2_raw.length > 0
|
||||
? leave2_raw.map((item) => ({
|
||||
date: item.dateLeaveStart && item.dateLeaveEnd
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart)) + " - "
|
||||
+ Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveEnd))
|
||||
: "-",
|
||||
date:
|
||||
item.dateLeaveStart && item.dateLeaveEnd
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart)) +
|
||||
" - " +
|
||||
Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveEnd))
|
||||
: "-",
|
||||
type: item.name || "-",
|
||||
leaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "-",
|
||||
reason: item.reason || "-",
|
||||
|
|
@ -1389,24 +1394,25 @@ export class ProfileEmployeeController extends Controller {
|
|||
];
|
||||
|
||||
const profileHistory = await this.profileHistoryRepo.find({
|
||||
where: { profileEmployeeId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const history = profileHistory.length > 0
|
||||
? profileHistory.map(item => ({
|
||||
birthDateOld: item.birthDateOld
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.birthDateOld))
|
||||
: "",
|
||||
birthDate: item.birthDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.birthDate))
|
||||
: "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
birthDateOld: "-",
|
||||
birthDate: "-",
|
||||
}
|
||||
]
|
||||
where: { profileEmployeeId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const history =
|
||||
profileHistory.length > 0
|
||||
? profileHistory.map((item) => ({
|
||||
birthDateOld: item.birthDateOld
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.birthDateOld))
|
||||
: "",
|
||||
birthDate: item.birthDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.birthDate))
|
||||
: "",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
birthDateOld: "-",
|
||||
birthDate: "-",
|
||||
},
|
||||
];
|
||||
|
||||
const position_raw = await this.salaryRepo.find({
|
||||
where: {
|
||||
|
|
@ -1555,15 +1561,16 @@ export class ProfileEmployeeController extends Controller {
|
|||
: "",
|
||||
pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "",
|
||||
pointSumTh: item.pointSum ? Extension.textPoint(item.pointSum) : "",
|
||||
level: item.pointSum < 60.00
|
||||
? "ต้องปรับปรุง (คะแนนต่ำกว่าร้อยละ ๖๐.๐๐)"
|
||||
: item.pointSum <= 69.99 && item.pointSum >= 60.00
|
||||
? "พอใช้ (คะแนนร้อยละ ๖๐.๐๐ - ๖๙.๙๙)"
|
||||
: item.pointSum <= 79.99 && item.pointSum >= 70.00
|
||||
? "ดี (คะแนนร้อยละ ๗๐.๐๐ - ๗๙.๙๙)"
|
||||
: item.pointSum <= 89.99 && item.pointSum >= 80.00
|
||||
? "ดีมาก (คะแนนร้อยละ ๘๐.๐๐ - ๘๙.๙๙)"
|
||||
: "ดีเด่น (คะแนนร้อยละ ๙๐.๐๐ ขึ้นไป)"
|
||||
level:
|
||||
item.pointSum < 60.0
|
||||
? "ต้องปรับปรุง (คะแนนต่ำกว่าร้อยละ ๖๐.๐๐)"
|
||||
: item.pointSum <= 69.99 && item.pointSum >= 60.0
|
||||
? "พอใช้ (คะแนนร้อยละ ๖๐.๐๐ - ๖๙.๙๙)"
|
||||
: item.pointSum <= 79.99 && item.pointSum >= 70.0
|
||||
? "ดี (คะแนนร้อยละ ๗๐.๐๐ - ๗๙.๙๙)"
|
||||
: item.pointSum <= 89.99 && item.pointSum >= 80.0
|
||||
? "ดีมาก (คะแนนร้อยละ ๘๐.๐๐ - ๘๙.๙๙)"
|
||||
: "ดีเด่น (คะแนนร้อยละ ๙๐.๐๐ ขึ้นไป)",
|
||||
}))
|
||||
: [
|
||||
{
|
||||
|
|
@ -4012,26 +4019,28 @@ export class ProfileEmployeeController extends Controller {
|
|||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||
let _system:string ="SYS_REGISTRY_EMP";
|
||||
if(body.system)
|
||||
_system = body.system;
|
||||
let _system: string = "SYS_REGISTRY_EMP";
|
||||
if (body.system) _system = body.system;
|
||||
let _data = await new permission().PermissionOrgList(request, _system);
|
||||
const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
let queryLike = "1=1"
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "fullName":
|
||||
queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "position":
|
||||
|
|
@ -4039,7 +4048,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
break;
|
||||
|
||||
case "posNo":
|
||||
queryLike = `
|
||||
queryLike = `
|
||||
CASE
|
||||
WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, " ", current_holders.posMasterNo)
|
||||
WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, " ", current_holders.posMasterNo)
|
||||
|
|
@ -4063,10 +4072,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1"
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
const [findProfile, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
|
|
@ -5608,9 +5617,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
posNo: orgRevisionRef?.posMasterNo,
|
||||
positionExecutive: "",
|
||||
positionType: profile.posType?.posTypeName,
|
||||
positionLevel: profile.posType && profile.posLevel
|
||||
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
|
||||
: "",
|
||||
positionLevel:
|
||||
profile.posType && profile.posLevel
|
||||
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
|
||||
: "",
|
||||
amountSpecial: profile.amountSpecial,
|
||||
orgRoot: orgRootRef?.orgRootName,
|
||||
orgChild1: orgChild1Ref?.orgChild1Name,
|
||||
|
|
@ -6366,7 +6376,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
salary: profile.amount,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
? await getTopDegrees(profile.profileEducations)
|
||||
: "-",
|
||||
statusCheckEdit: profile.statusCheckEdit,
|
||||
isEdit: permissionProflile?.isEdit ?? false,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import permission from "../interfaces/permission";
|
|||
import axios from "axios";
|
||||
import { deleteUser } from "../keycloak";
|
||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||
import { getTopDegrees } from "../services/PositionService";
|
||||
@Route("api/v1/org/profile-temp")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -688,7 +689,9 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
Salary:
|
||||
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||
Special:
|
||||
item.amountSpecial != null ? Extension.ToThaiNumber(item.amountSpecial.toLocaleString()) : null,
|
||||
item.amountSpecial != null
|
||||
? Extension.ToThaiNumber(item.amountSpecial.toLocaleString())
|
||||
: null,
|
||||
Rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
RefAll: item.remark ? Extension.ToThaiNumber(item.remark) : null,
|
||||
PositionLevel:
|
||||
|
|
@ -1142,8 +1145,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
{
|
||||
statusTemp: "PENDING",
|
||||
type: "TEMP",
|
||||
keycloak: request.user.sub
|
||||
}
|
||||
keycloak: request.user.sub,
|
||||
},
|
||||
)
|
||||
.getManyAndCount();
|
||||
const data = await Promise.all(
|
||||
|
|
@ -1510,15 +1513,12 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
} else if (searchField == "position") {
|
||||
queryLike = "profileEmployee.position LIKE :keyword";
|
||||
}
|
||||
let _conditionAll =
|
||||
`current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND
|
||||
let _conditionAll = `current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND
|
||||
current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND
|
||||
current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND
|
||||
profileEmployee.employeeClass = :type`
|
||||
let _conditionFullname=
|
||||
`CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword`
|
||||
let _conditionCitizenId =
|
||||
`profileEmployee.citizenId LIKE :keyword`
|
||||
profileEmployee.employeeClass = :type`;
|
||||
let _conditionFullname = `CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword`;
|
||||
let _conditionCitizenId = `profileEmployee.citizenId LIKE :keyword`;
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
|
@ -1611,42 +1611,29 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
keyword2: `${posLevel}`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
"profileEmployee.employeeClass = :type", {
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
|
||||
}
|
||||
)
|
||||
.andWhere("profileEmployee.employeeClass = :type", {
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP",
|
||||
})
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
if (!searchKeyword) {
|
||||
qb.andWhere(
|
||||
_conditionAll,
|
||||
{
|
||||
keycloak: request.user.sub,
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
|
||||
}
|
||||
)
|
||||
}
|
||||
else {
|
||||
qb.andWhere(_conditionAll, {
|
||||
keycloak: request.user.sub,
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP",
|
||||
});
|
||||
} else {
|
||||
if (searchField != "citizenId") {
|
||||
qb.andWhere(
|
||||
`${_conditionAll} AND ${_conditionFullname}`,
|
||||
{
|
||||
qb.andWhere(`${_conditionAll} AND ${_conditionFullname}`, {
|
||||
keyword: `%${searchKeyword}%`,
|
||||
keycloak: request.user.sub,
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
|
||||
},
|
||||
)
|
||||
}
|
||||
else {
|
||||
qb.andWhere(
|
||||
`${_conditionAll} AND ${_conditionCitizenId}`,
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
keycloak: request.user.sub,
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
|
||||
},
|
||||
)
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP",
|
||||
});
|
||||
} else {
|
||||
qb.andWhere(`${_conditionAll} AND ${_conditionCitizenId}`, {
|
||||
keyword: `%${searchKeyword}%`,
|
||||
keycloak: request.user.sub,
|
||||
type: type ? type.trim().toLocaleUpperCase() : "TEMP",
|
||||
});
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
|
@ -1660,18 +1647,20 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
_data.current_holderTemps.length == 0
|
||||
? null
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild4 != null
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild3 != null
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
|
|
@ -1844,46 +1833,46 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "CONCAT(profileEmployee.prefix,profileEmployee.firstName,' ',profileEmployee.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "CONCAT(profileEmployee.firstName,' ',profileEmployee.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
);
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "CONCAT(profileEmployee.prefix,profileEmployee.firstName,' ',profileEmployee.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "CONCAT(profileEmployee.firstName,' ',profileEmployee.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profileEmployee.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
);
|
||||
// .orWhere(
|
||||
// requestBody.keyword != null && requestBody.keyword != ""
|
||||
// ? "profileEmployee.position LIKE :keyword"
|
||||
|
|
@ -2194,19 +2183,20 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||
let _system:string ="SYS_REGISTRY_TEMP";
|
||||
if(body.system)
|
||||
_system = body.system;
|
||||
let _system: string = "SYS_REGISTRY_TEMP";
|
||||
if (body.system) _system = body.system;
|
||||
let _data = await new permission().PermissionOrgList(request, _system);
|
||||
const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
let queryLike = "1=1"
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
|
|
@ -2221,11 +2211,12 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
break;
|
||||
|
||||
case "fullName":
|
||||
queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1"
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2298,18 +2289,20 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
item.current_holderTemps.length == 0
|
||||
? null
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild4 != null
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
|
|
@ -2323,7 +2316,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
const root =
|
||||
item.current_holderTemps.length == 0 ||
|
||||
(item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot ==
|
||||
null)
|
||||
? null
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
|
|
@ -3458,9 +3452,10 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
posNo: orgRevisionRef?.posMasterNo,
|
||||
positionExecutive: "",
|
||||
positionType: profile.posType?.posTypeName,
|
||||
positionLevel: profile.posType && profile.posLevel
|
||||
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
|
||||
: "",
|
||||
positionLevel:
|
||||
profile.posType && profile.posLevel
|
||||
? `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`
|
||||
: "",
|
||||
amountSpecial: profile.amountSpecial,
|
||||
orgRoot: orgRootRef?.orgRootName,
|
||||
orgChild1: orgChild1Ref?.orgChild1Name,
|
||||
|
|
@ -4169,7 +4164,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
salary: profile.amount,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
? await getTopDegrees(profile.profileEducations)
|
||||
: "-",
|
||||
};
|
||||
|
||||
|
|
@ -4225,7 +4220,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
});
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API แก้ไขเบอร์โทรศัพท์ ลูกจ้างชั่วคราว
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { PosMaster } from "../entities/PosMaster";
|
|||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||
import { ProfileEducation } from "../entities/ProfileEducation";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
|
||||
export async function CreatePosMasterHistoryOfficer(
|
||||
|
|
@ -38,9 +39,9 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
const h = new PosMasterHistory();
|
||||
const selectedPosition =
|
||||
pm.positions.length > 0
|
||||
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
|
||||
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
|
||||
: null;
|
||||
h.ancestorDNA = pm.ancestorDNA? pm.ancestorDNA : _null;
|
||||
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
||||
h.prefix = pm.current_holder?.prefix || _null;
|
||||
h.firstName = pm.current_holder?.firstName || _null;
|
||||
h.lastName = pm.current_holder?.lastName || _null;
|
||||
|
|
@ -214,3 +215,22 @@ export async function CreatePosMasterHistoryEmployeeTemp(
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTopDegrees(educations: ProfileEducation[]): Promise<string> {
|
||||
// filter เฉพาะ isUse==true หรือ isEducation==true
|
||||
const filtered = educations.filter((e) => e.isUse === true || e.isEducation === true);
|
||||
// sort: isEducation==true ก่อน, ถ้าเท่ากัน sort ด้วย level น้อยสุด
|
||||
const sorted = filtered.sort((a, b) => {
|
||||
const aEdu = !!a.isEducation ? 0 : 1;
|
||||
const bEdu = !!b.isEducation ? 0 : 1;
|
||||
if (aEdu !== bEdu) return aEdu - bEdu;
|
||||
const aLevel = typeof a.level === "number" ? a.level : Number.MAX_SAFE_INTEGER;
|
||||
const bLevel = typeof b.level === "number" ? b.level : Number.MAX_SAFE_INTEGER;
|
||||
return aLevel - bLevel;
|
||||
});
|
||||
|
||||
return sorted
|
||||
.map((e) => [e.degree, e.field].filter(Boolean).join(" "))
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue