ค้นหารายชื่อลูกจ้างชั่วคราว
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
|
const [findProfile, total] = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
// .leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
.leftJoinAndSelect("profile.current_holderTemps", "current_holderTemps")
|
||||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
.leftJoinAndSelect("current_holderTemps.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
.leftJoinAndSelect("current_holderTemps.orgChild1", "orgChild1")
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holderTemps.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holderTemps.orgChild3", "orgChild3")
|
||||||
.where("current_holders.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
.leftJoinAndSelect("current_holderTemps.orgChild4", "orgChild4")
|
||||||
.andWhere("profile.employeeClass = :employeeClass", { employeeClass: "TEMP" })
|
.where("current_holderTemps.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||||
.andWhere(
|
.andWhere("profile.employeeClass = :employeeClass", { employeeClass: "TEMP" })
|
||||||
_data.root != undefined && _data.root != null
|
.andWhere(
|
||||||
? _data.root[0] != null
|
_data.root != undefined && _data.root != null
|
||||||
? `current_holders.orgRootId IN (:...root)`
|
? _data.root[0] != null
|
||||||
: `current_holders.orgRootId is null`
|
? `current_holderTemps.orgRootId IN (:...root)`
|
||||||
: "1=1",
|
: `current_holderTemps.orgRootId is null`
|
||||||
{ root: _data.root },
|
: "1=1",
|
||||||
)
|
{ root: _data.root },
|
||||||
.andWhere(
|
)
|
||||||
_data.child1 != undefined && _data.child1 != null
|
.andWhere(
|
||||||
? _data.child1[0] != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? `current_holders.orgChild1Id IN (:...child1)`
|
? _data.child1[0] != null
|
||||||
: `current_holders.orgChild1Id is null`
|
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||||
: "1=1",
|
: `current_holderTemps.orgChild1Id is null`
|
||||||
{ child1: _data.child1 },
|
: "1=1",
|
||||||
)
|
{ child1: _data.child1 },
|
||||||
.andWhere(
|
)
|
||||||
_data.child2 != undefined && _data.child2 != null
|
.andWhere(
|
||||||
? _data.child2[0] != null
|
_data.child2 != undefined && _data.child2 != null
|
||||||
? `current_holders.orgChild2Id IN (:...child2)`
|
? _data.child2[0] != null
|
||||||
: `current_holders.orgChild2Id is null`
|
? `current_holderTemps.orgChild2Id IN (:...child2)`
|
||||||
: "1=1",
|
: `current_holderTemps.orgChild2Id is null`
|
||||||
{ child2: _data.child2 },
|
: "1=1",
|
||||||
)
|
{ child2: _data.child2 },
|
||||||
.andWhere(
|
)
|
||||||
_data.child3 != undefined && _data.child3 != null
|
.andWhere(
|
||||||
? _data.child3[0] != null
|
_data.child3 != undefined && _data.child3 != null
|
||||||
? `current_holders.orgChild3Id IN (:...child3)`
|
? _data.child3[0] != null
|
||||||
: `current_holders.orgChild3Id is null`
|
? `current_holderTemps.orgChild3Id IN (:...child3)`
|
||||||
: "1=1",
|
: `current_holderTemps.orgChild3Id is null`
|
||||||
{ child3: _data.child3 },
|
: "1=1",
|
||||||
)
|
{ child3: _data.child3 },
|
||||||
.andWhere(
|
)
|
||||||
_data.child4 != undefined && _data.child4 != null
|
.andWhere(
|
||||||
? _data.child4[0] != null
|
_data.child4 != undefined && _data.child4 != null
|
||||||
? `current_holders.orgChild4Id IN (:...child4)`
|
? _data.child4[0] != null
|
||||||
: `current_holders.orgChild4Id is null`
|
? `current_holderTemps.orgChild4Id IN (:...child4)`
|
||||||
: "1=1",
|
: `current_holderTemps.orgChild4Id is null`
|
||||||
{ child4: _data.child4 },
|
: "1=1",
|
||||||
)
|
{ child4: _data.child4 },
|
||||||
.andWhere(
|
)
|
||||||
new Brackets((qb) => {
|
.andWhere(
|
||||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
new Brackets((qb) => {
|
||||||
}),
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
)
|
}),
|
||||||
.skip((page - 1) * pageSize)
|
)
|
||||||
.take(pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.getManyAndCount();
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holderTemps.length == 0
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.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)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.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)?.orgChild3 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: 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)
|
||||||
?.orgChild2 != null
|
?.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_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: 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)
|
||||||
?.orgChild1 != null
|
?.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_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holderTemps.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) !=
|
||||||
null &&
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgRoot != null
|
?.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;
|
: null;
|
||||||
|
|
||||||
const root =
|
const root =
|
||||||
item.current_holders.length == 0 ||
|
item.current_holderTemps.length == 0 ||
|
||||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
(item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
? 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,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgRoot;
|
)?.orgRoot;
|
||||||
const child1Holder = item.current_holders?.find(
|
const child1Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild1;
|
)?.orgChild1;
|
||||||
const child2Holder = item.current_holders?.find(
|
const child2Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild2;
|
)?.orgChild2;
|
||||||
const child3Holder = item.current_holders?.find(
|
const child3Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild3;
|
)?.orgChild3;
|
||||||
const child4Holder = item.current_holders?.find(
|
const child4Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild4;
|
)?.orgChild4;
|
||||||
const posMasterNo = item.current_holders?.find(
|
const posMasterNo = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.posMasterNo;
|
)?.posMasterNo;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue