api ทะเบียนประวัติลูกจ้างชั่วคราว
This commit is contained in:
parent
1253acd1f4
commit
987e2900c5
3 changed files with 242 additions and 3 deletions
|
|
@ -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.rootTemp? _data.rootTemp :
|
||||
_data.child1Temp? _data.child1Temp :
|
||||
_data.child2Temp? _data.child2Temp :
|
||||
_data.child3Temp? _data.child3Temp :
|
||||
_data.child4Temp? _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