Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
aee012fa3f
4 changed files with 290 additions and 21 deletions
|
|
@ -177,11 +177,11 @@ export class ProfileController extends Controller {
|
|||
LastName: profile.lastName != null ? profile.lastName : "",
|
||||
DateOfBirth:
|
||||
profile.birthDate != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.birthDate))
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_perfixMonthYear(profile.birthDate))
|
||||
: "",
|
||||
DateRetire:
|
||||
profile.dateRetire != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire))
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_perfixMonthYear(profile.dateRetire))
|
||||
: "",
|
||||
RegistrationAddress: Extension.ToThaiNumber(
|
||||
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
|
||||
|
|
@ -197,11 +197,13 @@ export class ProfileController extends Controller {
|
|||
: "",
|
||||
AppointText:
|
||||
profile.dateAppoint != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateAppoint))
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_perfixMonthYear(profile.dateAppoint))
|
||||
: "",
|
||||
SalaryDate:
|
||||
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date))
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiShortDate_perfixMonthYear(profile.profileSalary[0].date),
|
||||
)
|
||||
: "",
|
||||
PositionName: profile.position != null ? profile.position : "",
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
|
|
@ -307,13 +309,15 @@ export class ProfileController extends Controller {
|
|||
Prefix: profiles?.prefix != null ? profiles.prefix : "",
|
||||
FirstName: profiles?.firstName != null ? profiles.firstName : "",
|
||||
LastName: profiles?.lastName != null ? profiles.lastName : "",
|
||||
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
|
||||
FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
BirthDay: profiles?.birthDate
|
||||
? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
|
||||
: null,
|
||||
BirthDayText:
|
||||
profiles.birthDate != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiShortDate_noPrefix(profiles.birthDate).toString(),
|
||||
)
|
||||
: "",
|
||||
BirthMonth: profiles?.birthDate
|
||||
? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString())
|
||||
|
|
@ -323,7 +327,9 @@ export class ProfileController extends Controller {
|
|||
: null,
|
||||
BirthYearText:
|
||||
profiles.birthDate != null
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiShortDate_noPrefix(profiles.birthDate).toString(),
|
||||
)
|
||||
: "",
|
||||
Address: "",
|
||||
District: "",
|
||||
|
|
@ -336,21 +342,21 @@ export class ProfileController extends Controller {
|
|||
profileFamilyCouple?.couplePrefix ||
|
||||
profileFamilyCouple?.coupleFirstName ||
|
||||
profileFamilyCouple?.coupleLastNameOld
|
||||
? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
|
||||
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
|
||||
: null,
|
||||
FatherPrefix: profileFamilyFather?.fatherPrefix ?? "",
|
||||
FatherFullName:
|
||||
profileFamilyFather?.fatherPrefix ||
|
||||
profileFamilyFather?.fatherFirstName ||
|
||||
profileFamilyFather?.fatherLastName
|
||||
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
||||
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
||||
: null,
|
||||
MotherPrefix: profileFamilyMother?.motherPrefix ?? "",
|
||||
MotherFullName:
|
||||
profileFamilyMother?.motherPrefix ||
|
||||
profileFamilyMother?.motherFirstName ||
|
||||
profileFamilyMother?.motherLastName
|
||||
? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
||||
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
||||
: null,
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
Division: "",
|
||||
|
|
@ -358,7 +364,7 @@ export class ProfileController extends Controller {
|
|||
StartDate: profiles?.dateStart,
|
||||
AppointDate: profiles?.dateAppoint ?? "",
|
||||
BirthDate: profiles?.birthDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate))
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(profiles.birthDate))
|
||||
: null,
|
||||
RetireDate:
|
||||
profiles.dateRetireLaw != null
|
||||
|
|
@ -375,7 +381,7 @@ export class ProfileController extends Controller {
|
|||
CertificateType: item.certificateType ?? null,
|
||||
Issuer: item.issuer ?? null,
|
||||
CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
|
||||
IssueDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.issueDate)) ?? null,
|
||||
IssueDate: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.issueDate)) ?? null,
|
||||
}));
|
||||
const trainings = await this.trainingRepository.find({
|
||||
select: ["startDate", "endDate", "place", "department", "name"],
|
||||
|
|
@ -386,12 +392,14 @@ export class ProfileController extends Controller {
|
|||
Start:
|
||||
item.startDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate)),
|
||||
: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.startDate)),
|
||||
End:
|
||||
item.endDate == null ? "" : Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate)),
|
||||
item.endDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.endDate)),
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.endDate))}`
|
||||
: "",
|
||||
Level: "",
|
||||
Degree: item.name,
|
||||
|
|
@ -425,7 +433,7 @@ export class ProfileController extends Controller {
|
|||
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
|
||||
Date:
|
||||
item.startDate && item.endDate
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate))}`
|
||||
? `${Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.endDate))}`
|
||||
: "",
|
||||
Level: item.educationLevel ?? "",
|
||||
Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "",
|
||||
|
|
@ -445,7 +453,7 @@ export class ProfileController extends Controller {
|
|||
});
|
||||
|
||||
const Salary = salarys.map((item) => ({
|
||||
SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date)) ?? null,
|
||||
SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) ?? null,
|
||||
Position: item.position ?? null,
|
||||
PosNo: item.posNo ?? null,
|
||||
Salary: "",
|
||||
|
|
@ -457,7 +465,7 @@ export class ProfileController extends Controller {
|
|||
item.positionSalaryAmount == null
|
||||
? null
|
||||
: Extension.ToThaiNumber(item.positionSalaryAmount.toString()),
|
||||
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
|
||||
FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
}));
|
||||
return new HttpSuccess({
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import {
|
|||
CreateProfileEmployee,
|
||||
UpdateProfileEmployee,
|
||||
ProfileEmployeeHistory,
|
||||
UpdatePositionTempProfileEmployee
|
||||
} from "../entities/ProfileEmployee";
|
||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||
|
|
@ -44,6 +45,11 @@ import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
|||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
import { OrgChild2 } from "../entities/OrgChild2";
|
||||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("ProfileEmployee")
|
||||
|
|
@ -71,6 +77,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
|
||||
private educationRepository = AppDataSource.getRepository(ProfileEducation);
|
||||
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
|
||||
/**
|
||||
* report ประวัติแบบย่อ ลูกจ้าง
|
||||
|
|
@ -785,11 +796,20 @@ export class ProfileEmployeeController extends Controller {
|
|||
position: _data.position,
|
||||
posNo: shortName,
|
||||
employeeClass: _data.employeeClass == null ? null : _data.employeeClass,
|
||||
dateAppoint: _data.dateAppoint,
|
||||
govAge: Extension.CalculateGovAge(_data.dateAppoint,0,0),
|
||||
age: Extension.CalculateAgeStrV2(_data.birthDate,0,0),
|
||||
dateAppoint: _data.dateAppoint,
|
||||
dateStart: _data.dateStart,
|
||||
createdAt: _data.createdAt,
|
||||
createdAt: _data.createdAt,
|
||||
dateRetireLaw: _data.dateRetireLaw,
|
||||
draftOrgEmployeeStatus: null
|
||||
draftOrganizationOrganization:
|
||||
_data.nodeTemp == "0" ? _data.rootTemp :
|
||||
_data.nodeTemp == "1" ? _data.child1Temp :
|
||||
_data.nodeTemp == "2" ? _data.child2Temp :
|
||||
_data.nodeTemp == "3" ? _data.child3Temp :
|
||||
_data.nodeTemp == "4" ? _data.child4Temp : null,
|
||||
draftPositionEmployee: _data.positionTemp,
|
||||
draftOrgEmployeeStatus: _data.statusTemp
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
@ -1504,6 +1524,138 @@ export class ProfileEmployeeController extends Controller {
|
|||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกตำแหน่งลูกจ้างชั่วคราว
|
||||
*
|
||||
* @summary บันทึกตำแหน่งลูกจ้างชั่วคราว (ADMIN)
|
||||
*
|
||||
* @param {string} id Id ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||
*/
|
||||
@Put("position/{id}")
|
||||
async positionProfileEmployee(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string,
|
||||
@Body() body: UpdatePositionTempProfileEmployee,
|
||||
) {
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
if (body.posLevelId && !(await this.posLevelRepo.findOneBy({ id: body.posLevelId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
}
|
||||
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
const profileEmp = await this.profileRepo.findOneBy({ id });
|
||||
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
switch (body.node) {
|
||||
case 0: {
|
||||
const data = await this.orgRootRepository.findOne({
|
||||
where: { id: body.nodeId },
|
||||
});
|
||||
if (data != null) {
|
||||
profileEmp.rootIdTemp = data.id;
|
||||
profileEmp.rootTemp = data.orgRootName;
|
||||
profileEmp.rootShortNameTemp = data.orgRootShortName;
|
||||
}
|
||||
}
|
||||
case 1: {
|
||||
const data = await this.child1Repository.findOne({
|
||||
where: { id: body.nodeId },
|
||||
relations: ["orgRoot"]
|
||||
});
|
||||
if (data != null) {
|
||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||
profileEmp.rootTemp = data.orgRoot.orgRootName;
|
||||
profileEmp.rootShortNameTemp = data.orgRoot.orgRootShortName;
|
||||
profileEmp.child1IdTemp = data.id;
|
||||
profileEmp.child1Temp = data.orgChild1Name;
|
||||
profileEmp.child1ShortNameTemp = data.orgChild1ShortName;
|
||||
}
|
||||
}
|
||||
case 2: {
|
||||
const data = await this.child2Repository.findOne({
|
||||
where: { id: body.nodeId },
|
||||
relations: ["orgRoot", "orgChild1"]
|
||||
});
|
||||
if (data != null) {
|
||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||
profileEmp.rootTemp = data.orgRoot.orgRootName;
|
||||
profileEmp.rootShortNameTemp = data.orgRoot.orgRootShortName;
|
||||
profileEmp.child1IdTemp = data.orgChild1.id;
|
||||
profileEmp.child1Temp = data.orgChild1.orgChild1Name;
|
||||
profileEmp.child1ShortNameTemp = data.orgChild1.orgChild1ShortName;
|
||||
profileEmp.child2IdTemp = data.id;
|
||||
profileEmp.child2Temp = data.orgChild2Name;
|
||||
profileEmp.child2ShortNameTemp = data.orgChild2ShortName;
|
||||
}
|
||||
}
|
||||
case 3: {
|
||||
const data = await this.child3Repository.findOne({
|
||||
where: { id: body.nodeId },
|
||||
relations: ["orgRoot", "orgChild1", "orgChild2"]
|
||||
});
|
||||
if (data != null) {
|
||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||
profileEmp.rootTemp = data.orgRoot.orgRootName;
|
||||
profileEmp.rootShortNameTemp = data.orgRoot.orgRootShortName;
|
||||
profileEmp.child1IdTemp = data.orgChild1.id;
|
||||
profileEmp.child1Temp = data.orgChild1.orgChild1Name;
|
||||
profileEmp.child1ShortNameTemp = data.orgChild1.orgChild1ShortName;
|
||||
profileEmp.child2IdTemp = data.orgChild2.id;
|
||||
profileEmp.child2Temp = data.orgChild2.orgChild2Name;
|
||||
profileEmp.child2ShortNameTemp = data.orgChild2.orgChild2ShortName;
|
||||
profileEmp.child3IdTemp = data.id;
|
||||
profileEmp.child3Temp = data.orgChild3Name;
|
||||
profileEmp.child3ShortNameTemp = data.orgChild3ShortName;
|
||||
}
|
||||
}
|
||||
case 4: {
|
||||
const data = await this.child4Repository.findOne({
|
||||
where: { id: body.nodeId },
|
||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"]
|
||||
});
|
||||
if (data != null) {
|
||||
profileEmp.rootIdTemp = data.orgRoot.id;
|
||||
profileEmp.rootTemp = data.orgRoot.orgRootName;
|
||||
profileEmp.rootShortNameTemp = data.orgRoot.orgRootShortName;
|
||||
profileEmp.child1IdTemp = data.orgChild1.id;
|
||||
profileEmp.child1Temp = data.orgChild1.orgChild1Name;
|
||||
profileEmp.child1ShortNameTemp = data.orgChild1.orgChild1ShortName;
|
||||
profileEmp.child2IdTemp = data.orgChild2.id;
|
||||
profileEmp.child2Temp = data.orgChild2.orgChild2Name;
|
||||
profileEmp.child2ShortNameTemp = data.orgChild2.orgChild2ShortName;
|
||||
profileEmp.child3IdTemp = data.orgChild3.id;
|
||||
profileEmp.child3Temp = data.orgChild3.orgChild3Name;
|
||||
profileEmp.child3ShortNameTemp = data.orgChild3.orgChild3ShortName;
|
||||
profileEmp.child4IdTemp = data.id;
|
||||
profileEmp.child4Temp = data.orgChild4Name;
|
||||
profileEmp.child4ShortNameTemp = data.orgChild4ShortName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profileEmp.lastUpdateUserId = request.user.sub;
|
||||
profileEmp.lastUpdateFullName = request.user.name;
|
||||
profileEmp.nodeTemp = String(body.node);
|
||||
profileEmp.nodeIdTemp = body.nodeId;
|
||||
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
||||
profileEmp.posmasterIdTemp = body.posmasterId;
|
||||
profileEmp.posMasterNoTemp = body.posMasterNo;
|
||||
profileEmp.positionIdTemp = body.positionId;
|
||||
profileEmp.positionTemp = body.position;
|
||||
profileEmp.positionFieldTemp = body.positionField;
|
||||
profileEmp.posTypeIdTemp = String(body.posTypeId);
|
||||
profileEmp.posTypeNameTemp = body.posTypeName;
|
||||
profileEmp.posLevelIdTemp = String(body.posLevelId);
|
||||
profileEmp.posLevelNameTemp = body.posLevelName;
|
||||
profileEmp.statusTemp = "REPORT";
|
||||
this.profileRepo.merge(profileEmp, body);
|
||||
await this.profileRepo.save(profileEmp);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API เช็คเลขบัตร
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue