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

View file

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

View file

@ -1497,6 +1497,15 @@ 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
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({
where: { orgRevisionIsCurrent: true },
});
@ -1598,11 +1607,7 @@ export class ProfileEmployeeTempController extends Controller {
new Brackets((qb) => {
if (!searchKeyword) {
qb.andWhere(
`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
`,
_conditionAll,
{
keycloak: request.user.sub,
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
@ -1610,14 +1615,26 @@ export class ProfileEmployeeTempController extends Controller {
)
}
else {
qb.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike
: "1=1",
if (searchField != "citizenId") {
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"
},
)
}
}
}),
)

View file

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

View file

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

File diff suppressed because one or more lines are too long