ค้นหารายชื่อลูกจ้างชั่วคราว
This commit is contained in:
parent
900fb8deb5
commit
c31c16a011
1 changed files with 86 additions and 85 deletions
|
|
@ -2217,118 +2217,119 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
const [findProfile, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.where("current_holders.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||
.andWhere("profile.employeeClass = :employeeClass", { employeeClass: "TEMP" })
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `current_holders.orgRootId IN (:...root)`
|
||||
: `current_holders.orgRootId is null`
|
||||
: "1=1",
|
||||
{ root: _data.root },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `current_holders.orgChild1Id IN (:...child1)`
|
||||
: `current_holders.orgChild1Id is null`
|
||||
: "1=1",
|
||||
{ child1: _data.child1 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
? `current_holders.orgChild2Id IN (:...child2)`
|
||||
: `current_holders.orgChild2Id is null`
|
||||
: "1=1",
|
||||
{ child2: _data.child2 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
? `current_holders.orgChild3Id IN (:...child3)`
|
||||
: `current_holders.orgChild3Id is null`
|
||||
: "1=1",
|
||||
{ child3: _data.child3 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
? `current_holders.orgChild4Id IN (:...child4)`
|
||||
: `current_holders.orgChild4Id is null`
|
||||
: "1=1",
|
||||
{ child4: _data.child4 },
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
// .leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("profile.current_holderTemps", "current_holderTemps")
|
||||
.leftJoinAndSelect("current_holderTemps.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild4", "orgChild4")
|
||||
.where("current_holderTemps.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||
.andWhere("profile.employeeClass = :employeeClass", { employeeClass: "TEMP" })
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `current_holderTemps.orgRootId IN (:...root)`
|
||||
: `current_holderTemps.orgRootId is null`
|
||||
: "1=1",
|
||||
{ root: _data.root },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||
: `current_holderTemps.orgChild1Id is null`
|
||||
: "1=1",
|
||||
{ child1: _data.child1 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
? `current_holderTemps.orgChild2Id IN (:...child2)`
|
||||
: `current_holderTemps.orgChild2Id is null`
|
||||
: "1=1",
|
||||
{ child2: _data.child2 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
? `current_holderTemps.orgChild3Id IN (:...child3)`
|
||||
: `current_holderTemps.orgChild3Id is null`
|
||||
: "1=1",
|
||||
{ child3: _data.child3 },
|
||||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
? `current_holderTemps.orgChild4Id IN (:...child4)`
|
||||
: `current_holderTemps.orgChild4Id is null`
|
||||
: "1=1",
|
||||
{ child4: _data.child4 },
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: ProfileEmployee) => {
|
||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
item.current_holderTemps.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
item.current_holderTemps.length == 0 ||
|
||||
(item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const rootHolder = item.current_holders?.find(
|
||||
const rootHolder = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.orgRoot;
|
||||
const child1Holder = item.current_holders?.find(
|
||||
const child1Holder = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.orgChild1;
|
||||
const child2Holder = item.current_holders?.find(
|
||||
const child2Holder = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.orgChild2;
|
||||
const child3Holder = item.current_holders?.find(
|
||||
const child3Holder = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.orgChild3;
|
||||
const child4Holder = item.current_holders?.find(
|
||||
const child4Holder = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.orgChild4;
|
||||
const posMasterNo = item.current_holders?.find(
|
||||
const posMasterNo = item.current_holderTemps?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue