แก้ค้นหาลูกจ้าง
This commit is contained in:
parent
689d48aadc
commit
852525c8f5
2 changed files with 49 additions and 42 deletions
|
|
@ -35,6 +35,8 @@ import { OrgChild4 } from "../entities/OrgChild4";
|
|||
import { Position } from "../entities/Position";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("Position")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -47,6 +49,8 @@ export class PositionController extends Controller {
|
|||
private posExecutiveRepository = AppDataSource.getRepository(PosExecutive);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeEmployeeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
private posDictRepository = AppDataSource.getRepository(PosDict);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
|
|
@ -2759,10 +2763,10 @@ export class PositionController extends Controller {
|
|||
let typeCondition: any = {};
|
||||
let conditionA: any = null;
|
||||
|
||||
let posType = await this.posTypeRepository.findOne({
|
||||
let posType = await this.posTypeEmployeeRepository.findOne({
|
||||
where: { id: String(body.posType) },
|
||||
});
|
||||
let posLevel = await this.posLevelRepository.findOne({
|
||||
let posLevel = await this.posLevelEmployeeRepository.findOne({
|
||||
where: { id: String(body.posLevel) },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export class ProfileController extends Controller {
|
|||
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: [
|
||||
"profileSalary",
|
||||
|
|
@ -87,16 +87,20 @@ export class ProfileController extends Controller {
|
|||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4"
|
||||
"current_holders.orgChild4",
|
||||
],
|
||||
where: { id: id, },
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId })
|
||||
const district = await this.districtRepository.findOneBy({ id: profile.registrationDistrictId })
|
||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId })
|
||||
|
||||
const province = await this.provinceRepository.findOneBy({
|
||||
id: profile.registrationProvinceId,
|
||||
});
|
||||
const district = await this.districtRepository.findOneBy({
|
||||
id: profile.registrationDistrictId,
|
||||
});
|
||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId });
|
||||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
|
|
@ -147,22 +151,19 @@ export class ProfileController extends Controller {
|
|||
DateOfBirth: profile.birthDate,
|
||||
DateRetire: profile.dateRetire,
|
||||
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
||||
SalaryAmount: profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0].amount.toString()
|
||||
: null,
|
||||
Education: profile.profileEducations.length > 0
|
||||
? profile.profileEducations[profile.profileEducations.length-1].institute
|
||||
: null,
|
||||
SalaryAmount:
|
||||
profile.profileSalary.length > 0 ? profile.profileSalary[0].amount.toString() : null,
|
||||
Education:
|
||||
profile.profileEducations.length > 0
|
||||
? profile.profileEducations[profile.profileEducations.length - 1].institute
|
||||
: null,
|
||||
AppointText: profile.dateAppoint,
|
||||
SalaryDate: profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0].date
|
||||
: null,
|
||||
SalaryDate: profile.profileSalary.length > 0 ? profile.profileSalary[0].date : null,
|
||||
PositionName: profile.position,
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
}
|
||||
};
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -945,7 +946,7 @@ export class ProfileController extends Controller {
|
|||
"profile.citizenId",
|
||||
"profileSalary.position",
|
||||
"profileSalary.posNo",
|
||||
"profileSalary.date"
|
||||
"profileSalary.date",
|
||||
])
|
||||
.andWhere(
|
||||
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
|
||||
|
|
@ -965,27 +966,27 @@ export class ProfileController extends Controller {
|
|||
)
|
||||
.getMany();
|
||||
|
||||
const mapData = profiles.map(profile => {
|
||||
let profileSalary;
|
||||
if (profile.profileSalary && profile.profileSalary.length > 0) {
|
||||
profileSalary = profile.profileSalary.reduce((latest, current) => {
|
||||
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
||||
});
|
||||
}
|
||||
return {
|
||||
id: profile.id,
|
||||
// prefix: profile.prefix,
|
||||
// firstName: profile.firstName,
|
||||
// lastName: profile.lastName,
|
||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||
citizenId: profile.citizenId,
|
||||
position: profileSalary ? profileSalary.position : null,
|
||||
posNo: profileSalary ? profileSalary.posNo : null,
|
||||
date: profileSalary ? profileSalary.date : null
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
const mapData = profiles.map((profile) => {
|
||||
let profileSalary;
|
||||
if (profile.profileSalary && profile.profileSalary.length > 0) {
|
||||
profileSalary = profile.profileSalary.reduce((latest, current) => {
|
||||
return new Date(current.date) > new Date(latest.date) ? current : latest;
|
||||
});
|
||||
}
|
||||
return {
|
||||
id: profile.id,
|
||||
// prefix: profile.prefix,
|
||||
// firstName: profile.firstName,
|
||||
// lastName: profile.lastName,
|
||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||
citizenId: profile.citizenId,
|
||||
position: profileSalary ? profileSalary.position : null,
|
||||
posNo: profileSalary ? profileSalary.posNo : null,
|
||||
date: profileSalary ? profileSalary.date : null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1061,6 +1062,8 @@ export class ProfileController extends Controller {
|
|||
profileId: profile.id,
|
||||
prefix: profile.prefix,
|
||||
rank: profile.rank,
|
||||
avatar: profile.avatar,
|
||||
avatarName: profile.avatarName,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue