Merge branch 'develop' into adiDev
This commit is contained in:
commit
441295aae4
7 changed files with 87 additions and 139 deletions
|
|
@ -309,19 +309,27 @@ export class PositionController extends Controller {
|
|||
posDictField: requestBody.posDictField,
|
||||
posTypeId: requestBody.posTypeId,
|
||||
posLevelId: requestBody.posLevelId,
|
||||
posExecutiveId: String(requestBody.posExecutiveId),
|
||||
posDictExecutiveField: requestBody.posDictExecutiveField,
|
||||
posDictArea: requestBody.posDictArea,
|
||||
posExecutiveId: requestBody.posExecutiveId?requestBody.posExecutiveId:"",
|
||||
posDictExecutiveField: requestBody.posDictExecutiveField?requestBody.posDictExecutiveField:"",
|
||||
posDictArea: requestBody.posDictArea?requestBody.posDictArea:"",
|
||||
isSpecial: requestBody.isSpecial,
|
||||
},
|
||||
});
|
||||
if (rowRepeated) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
Object.assign(posDict, requestBody);
|
||||
posDict.lastUpdateUserId = request.user.sub;
|
||||
posDict.lastUpdateFullName = request.user.name;
|
||||
this.posDictRepository.merge(posDict, requestBody);
|
||||
posDict.posDictName = requestBody.posDictName,
|
||||
posDict.posDictField = requestBody.posDictField,
|
||||
posDict.posTypeId = requestBody.posTypeId,
|
||||
posDict.posLevelId = requestBody.posLevelId,
|
||||
posDict.posExecutiveId = requestBody.posExecutiveId?requestBody.posExecutiveId:null,
|
||||
posDict.posDictExecutiveField = requestBody.posDictExecutiveField?requestBody.posDictExecutiveField:"",
|
||||
posDict.posDictArea = requestBody.posDictArea?requestBody.posDictArea:"",
|
||||
posDict.isSpecial = requestBody.isSpecial,
|
||||
// this.posDictRepository.merge(posDict, requestBody);
|
||||
await this.posDictRepository.save(posDict);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,14 +386,12 @@ export class ProfileController extends Controller {
|
|||
Start:
|
||||
item.startDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
|
||||
: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate)),
|
||||
End:
|
||||
item.endDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
||||
item.endDate == null ? "" : Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate)),
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
: "",
|
||||
Level: "",
|
||||
Degree: item.name,
|
||||
|
|
@ -427,7 +425,7 @@ export class ProfileController extends Controller {
|
|||
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
: "",
|
||||
Level: item.educationLevel ?? "",
|
||||
Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "",
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
: "",
|
||||
Level: "",
|
||||
Degree: item.name,
|
||||
|
|
@ -433,7 +433,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
End: new Date(item.endDate).getFullYear().toString() ?? null,
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
: "",
|
||||
Level: item.educationLevel ?? null,
|
||||
Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "",
|
||||
|
|
@ -494,42 +494,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
if (body.citizenId.length !== 13) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก",
|
||||
);
|
||||
if(body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == ""){
|
||||
body.employeeClass = "PERM";
|
||||
}
|
||||
|
||||
if (body.citizenId) {
|
||||
const citizenIdDigits = body.citizenId.toString().split("").map(Number);
|
||||
const cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
const calStp2 = cal % 11;
|
||||
let chkDigit = 11 - calStp2;
|
||||
if (chkDigit === 10) {
|
||||
chkDigit = 1;
|
||||
} else if (chkDigit === 11) {
|
||||
chkDigit = chkDigit % 10;
|
||||
}
|
||||
// else if(chkDigit === 11){
|
||||
// chkDigit = cal % 10;
|
||||
// }
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
if (!["PERM", "TEMP"].includes(body.employeeClass.toLocaleUpperCase())) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ประเภทลูกจ้างไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
const profile = Object.assign(new ProfileEmployee(), body);
|
||||
|
|
@ -539,8 +508,9 @@ export class ProfileEmployeeController extends Controller {
|
|||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||
profile.employeeClass = profile.employeeClass.toLocaleUpperCase()
|
||||
await this.profileRepo.save(profile);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -577,46 +547,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
if (body.citizenId && body.citizenId.length !== 13) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก",
|
||||
);
|
||||
}
|
||||
|
||||
if (body.citizenId) {
|
||||
const citizenIdDigits = body.citizenId.toString().split("").map(Number);
|
||||
const cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
const calStp2 = cal % 11;
|
||||
let chkDigit = 11 - calStp2;
|
||||
if (chkDigit === 10) {
|
||||
chkDigit = 1;
|
||||
} else if (chkDigit === 11) {
|
||||
chkDigit = chkDigit % 10;
|
||||
}
|
||||
// else if(chkDigit === 11){
|
||||
// chkDigit = cal % 10;
|
||||
// }
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
}
|
||||
|
||||
const record = await this.profileRepo.findOneBy({ id });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
await this.profileHistoryRepo.save(
|
||||
|
|
@ -627,14 +559,21 @@ export class ProfileEmployeeController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
if(body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == ""){
|
||||
body.employeeClass = "PERM";
|
||||
}
|
||||
if (!["PERM", "TEMP"].includes(body.employeeClass.toLocaleUpperCase())) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ประเภทลูกจ้างไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
|
||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
||||
await this.profileRepo.save(record);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -846,6 +785,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
position: _data.position,
|
||||
posNo: shortName,
|
||||
employeeClass: _data.employeeClass == null ? null : _data.employeeClass,
|
||||
dateAppoint: _data.dateAppoint,
|
||||
dateStart: _data.dateStart,
|
||||
createdAt: _data.createdAt,
|
||||
dateRetireLaw: _data.dateRetireLaw,
|
||||
draftOrgEmployeeStatus: null
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ export class KeycloakController extends Controller {
|
|||
|
||||
@Get("user")
|
||||
async getUserList(@Query() first = "", @Query() max = "", @Query() search = "") {
|
||||
const total = await getUserCount();
|
||||
const total = await getUserCount(first, max, search);
|
||||
const result = await getUserList(first, max, search);
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue