fix เอกสาร กพ.7/กก.1 #1642

This commit is contained in:
Bright 2025-07-23 15:07:59 +07:00
parent ee2221b719
commit acfac64f9c
6 changed files with 1451 additions and 39 deletions

View file

@ -1110,12 +1110,14 @@ export class ProfileController extends Controller {
: null, : null,
disciplineDetail: item.detail ?? null, disciplineDetail: item.detail ?? null,
refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null, refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
level: item.level ?? ""
})) }))
: [ : [
{ {
disciplineYear: "-", disciplineYear: "-",
disciplineDetail: "-", disciplineDetail: "-",
refNo: "-", refNo: "-",
level: "-"
}, },
]; ];
@ -1142,20 +1144,6 @@ export class ProfileController extends Controller {
}, },
]; ];
const salary_raw = await this.salaryRepo.find({ const salary_raw = await this.salaryRepo.find({
select: [
"commandDateAffect",
"positionName",
"posNoAbb",
"posNo",
"positionType",
"positionLevel",
"positionSalaryAmount",
"commandNo",
"positionCee",
"amount",
"amountSpecial",
"remark",
],
where: { where: {
profileId: id, profileId: id,
commandCode: In(["5", "6"]), commandCode: In(["5", "6"]),
@ -1167,6 +1155,7 @@ export class ProfileController extends Controller {
const salarys = const salarys =
salary_raw.length > 0 salary_raw.length > 0
? salary_raw.map((item) => ({ ? salary_raw.map((item) => ({
commandName: item.commandName ?? "",
salaryDate: item.commandDateAffect salaryDate: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: null, : null,
@ -1203,6 +1192,7 @@ export class ProfileController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
salaryDate: "-", salaryDate: "-",
position: "-", position: "-",
posNo: "-", posNo: "-",
@ -1408,6 +1398,26 @@ export class ProfileController extends Controller {
}, },
]; ];
const profileHistory = await this.profileHistoryRepo.find({
where: { profileId: 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({ const position_raw = await this.salaryRepo.find({
where: { where: {
profileId: id, profileId: id,
@ -1419,6 +1429,7 @@ export class ProfileController extends Controller {
const positionList = const positionList =
position_raw.length > 0 position_raw.length > 0
? position_raw.map((item) => ({ ? position_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "", : "",
@ -1427,7 +1438,7 @@ export class ProfileController extends Controller {
: "", : "",
posNo: posNo:
item.posNoAbb && item.posNo item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`) ? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "", : "",
position: item.positionName, position: item.positionName,
posType: item.positionType, posType: item.positionType,
@ -1443,6 +1454,7 @@ export class ProfileController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
commandDateAffect: "-", commandDateAffect: "-",
commandDateSign: "-", commandDateSign: "-",
posNo: "-", posNo: "-",
@ -1553,6 +1565,15 @@ export class ProfileController extends Controller {
: "", : "",
pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "", pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "",
pointSumTh: item.pointSum ? Extension.textPoint(item.pointSum) : "", 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
? "ดีมาก (คะแนนร้อยละ ๘๐. - ๘๙.๙๙)"
: "ดีเด่น (คะแนนร้อยละ ๙๐. ขึ้นไป)"
})) }))
: [ : [
{ {
@ -1562,6 +1583,7 @@ export class ProfileController extends Controller {
point2: "-", point2: "-",
pointSum: "-", pointSum: "-",
pointSumTh: "-", pointSumTh: "-",
level: "-"
}, },
]; ];
const profileAbility_raw = await this.profileAbilityRepo.find({ const profileAbility_raw = await this.profileAbilityRepo.find({
@ -1592,6 +1614,7 @@ export class ProfileController extends Controller {
const otherIncome = const otherIncome =
otherIncome_raw.length > 0 otherIncome_raw.length > 0
? otherIncome_raw.map((item) => ({ ? otherIncome_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "", : "",
@ -1609,6 +1632,7 @@ export class ProfileController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
commandDateAffect: "-", commandDateAffect: "-",
commandDateSign: "-", commandDateSign: "-",
commandNo: "-", commandNo: "-",
@ -1764,6 +1788,7 @@ export class ProfileController extends Controller {
? Extension.ToThaiNumber(profiles.registrationZipCode) ? Extension.ToThaiNumber(profiles.registrationZipCode)
: "", : "",
fullRegistrationAddress: fullRegistrationAddress, fullRegistrationAddress: fullRegistrationAddress,
updateAt: Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.lastUpdatedAt)),
telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "",
url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null, url1: _ImgUrl[0] ? _ImgUrl[0] : null,
@ -1805,6 +1830,7 @@ export class ProfileController extends Controller {
educations, educations,
salarys, salarys,
changeName, changeName,
history,
positionList, positionList,
actposition, actposition,
duty, duty,
@ -5099,6 +5125,7 @@ export class ProfileController extends Controller {
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileHistory(), { Object.assign(new ProfileHistory(), {
...record, ...record,
birthDateOld: _record?.birthDate,
profileId: id, profileId: id,
id: undefined, id: undefined,
}), }),

View file

@ -1107,12 +1107,14 @@ export class ProfileEmployeeController extends Controller {
: null, : null,
disciplineDetail: item.detail ?? null, disciplineDetail: item.detail ?? null,
refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null, refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
level: item.level ?? ""
})) }))
: [ : [
{ {
disciplineYear: "-", disciplineYear: "-",
disciplineDetail: "-", disciplineDetail: "-",
refNo: "-", refNo: "-",
level: "-"
}, },
]; ];
@ -1139,20 +1141,6 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const salary_raw = await this.salaryRepo.find({ const salary_raw = await this.salaryRepo.find({
select: [
"commandDateAffect",
"positionName",
"posNoAbb",
"posNo",
"positionType",
"positionLevel",
"positionSalaryAmount",
"commandNo",
"positionCee",
"amount",
"amountSpecial",
"remark",
],
where: { where: {
profileEmployeeId: id, profileEmployeeId: id,
commandCode: In(["5", "6"]), commandCode: In(["5", "6"]),
@ -1164,6 +1152,7 @@ export class ProfileEmployeeController extends Controller {
const salarys = const salarys =
salary_raw.length > 0 salary_raw.length > 0
? salary_raw.map((item) => ({ ? salary_raw.map((item) => ({
commandName: item.commandName ?? "",
salaryDate: item.commandDateAffect salaryDate: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: null, : null,
@ -1198,6 +1187,7 @@ export class ProfileEmployeeController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
salaryDate: "-", salaryDate: "-",
position: "-", position: "-",
posNo: "-", posNo: "-",
@ -1403,6 +1393,26 @@ 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: "-",
}
]
const position_raw = await this.salaryRepo.find({ const position_raw = await this.salaryRepo.find({
where: { where: {
profileEmployeeId: id, profileEmployeeId: id,
@ -1414,6 +1424,7 @@ export class ProfileEmployeeController extends Controller {
const positionList = const positionList =
position_raw.length > 0 position_raw.length > 0
? position_raw.map((item) => ({ ? position_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "", : "",
@ -1422,7 +1433,7 @@ export class ProfileEmployeeController extends Controller {
: "", : "",
posNo: posNo:
item.posNoAbb && item.posNo item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`) ? Extension.ToThaiNumber(`${item.posNoAbb} ${item.posNo}`)
: "", : "",
position: item.positionName, position: item.positionName,
posType: item.positionType, posType: item.positionType,
@ -1438,6 +1449,7 @@ export class ProfileEmployeeController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
commandDateAffect: "-", commandDateAffect: "-",
commandDateSign: "-", commandDateSign: "-",
posNo: "-", posNo: "-",
@ -1548,6 +1560,15 @@ export class ProfileEmployeeController extends Controller {
: "", : "",
pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "", pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "",
pointSumTh: item.pointSum ? Extension.textPoint(item.pointSum) : "", 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
? "ดีมาก (คะแนนร้อยละ ๘๐. - ๘๙.๙๙)"
: "ดีเด่น (คะแนนร้อยละ ๙๐. ขึ้นไป)"
})) }))
: [ : [
{ {
@ -1587,6 +1608,7 @@ export class ProfileEmployeeController extends Controller {
const otherIncome = const otherIncome =
otherIncome_raw.length > 0 otherIncome_raw.length > 0
? otherIncome_raw.map((item) => ({ ? otherIncome_raw.map((item) => ({
commandName: item.commandName ?? "",
commandDateAffect: item.commandDateAffect commandDateAffect: item.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: "", : "",
@ -1604,6 +1626,7 @@ export class ProfileEmployeeController extends Controller {
})) }))
: [ : [
{ {
commandName: "-",
commandDateAffect: "-", commandDateAffect: "-",
commandDateSign: "-", commandDateSign: "-",
commandNo: "-", commandNo: "-",
@ -1759,6 +1782,7 @@ export class ProfileEmployeeController extends Controller {
? Extension.ToThaiNumber(profiles.registrationZipCode) ? Extension.ToThaiNumber(profiles.registrationZipCode)
: "", : "",
fullRegistrationAddress: fullRegistrationAddress, fullRegistrationAddress: fullRegistrationAddress,
updateAt: Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.lastUpdatedAt)),
telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "",
url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`, url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_MGT}`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null, url1: _ImgUrl[0] ? _ImgUrl[0] : null,
@ -1800,6 +1824,7 @@ export class ProfileEmployeeController extends Controller {
educations, educations,
salarys, salarys,
changeName, changeName,
history,
positionList, positionList,
actposition, actposition,
duty, duty,
@ -1981,6 +2006,7 @@ export class ProfileEmployeeController extends Controller {
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileEmployeeHistory(), { Object.assign(new ProfileEmployeeHistory(), {
...record, ...record,
birthDateOld: _record?.birthDate,
lastUpdateUserId: request.user.sub, lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name, lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(), lastUpdatedAt: new Date(),

View file

@ -1497,6 +1497,15 @@ export class ProfileEmployeeTempController extends Controller {
} else if (searchField == "position") { } else if (searchField == "position") {
queryLike = "profileEmployee.position LIKE :keyword"; queryLike = "profileEmployee.position LIKE :keyword";
} }
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`
const findRevision = await this.orgRevisionRepo.findOne({ const findRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true }, where: { orgRevisionIsCurrent: true },
}); });
@ -1598,11 +1607,7 @@ export class ProfileEmployeeTempController extends Controller {
new Brackets((qb) => { new Brackets((qb) => {
if (!searchKeyword) { if (!searchKeyword) {
qb.andWhere( qb.andWhere(
`current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND _conditionAll,
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
`,
{ {
keycloak: request.user.sub, keycloak: request.user.sub,
type: type ? type.trim().toLocaleUpperCase() : "TEMP" type: type ? type.trim().toLocaleUpperCase() : "TEMP"
@ -1610,14 +1615,26 @@ export class ProfileEmployeeTempController extends Controller {
) )
} }
else { else {
qb.andWhere( if (searchField != "citizenId") {
searchKeyword != undefined && searchKeyword != null && searchKeyword != "" qb.andWhere(
? queryLike `${_conditionAll} AND ${_conditionFullname}`,
: "1=1",
{ {
keyword: `%${searchKeyword}%`, 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"
},
)
}
} }
}), }),
) )

View file

@ -665,6 +665,14 @@ export class ProfileHistory extends Profile {
}) })
profileId: string; profileId: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเกิดเดิม โดยจะบันทึกเมื่อมีการแก้ไขข้อมูลส่วนตัว",
default: null,
})
birthDateOld: Date;
@ManyToOne(() => Profile, (v) => v.histories, { onDelete: "CASCADE" }) @ManyToOne(() => Profile, (v) => v.histories, { onDelete: "CASCADE" })
profile: Profile; profile: Profile;
} }

View file

@ -928,6 +928,14 @@ export class ProfileEmployeeHistory extends ProfileEmployee {
}) })
profileEmployeeId: string; profileEmployeeId: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเกิดเดิม โดยจะบันทึกเมื่อมีการแก้ไขข้อมูลส่วนตัว",
default: null,
})
birthDateOld: Date;
@ManyToOne(() => ProfileEmployee, (v) => v.histories, { onDelete: "CASCADE" }) @ManyToOne(() => ProfileEmployee, (v) => v.histories, { onDelete: "CASCADE" })
profileEmployee: ProfileEmployee; profileEmployee: ProfileEmployee;
} }

File diff suppressed because one or more lines are too long