API ค้นหา กก. สกจ. และหัวหน้า
This commit is contained in:
parent
c2b566792d
commit
277b564711
1 changed files with 169 additions and 0 deletions
|
|
@ -2583,6 +2583,175 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess(command.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ค้นหา กก. สกจ. และหัวหน้า
|
||||
*
|
||||
* @summary API ค้นหา กก. สกจ. และหัวหน้า
|
||||
*
|
||||
*/
|
||||
@Post("find-higher")
|
||||
async findHigher(
|
||||
@Body()
|
||||
requestBody: {
|
||||
persons: {
|
||||
profileId?: string | null;
|
||||
}[];
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
let _null:any = null;
|
||||
let _data = new Array();
|
||||
const _posMasterCommission = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRoot: {
|
||||
isCommission: true,
|
||||
},
|
||||
isDirector: true,
|
||||
orgChild1: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
relations: ["current_holder", "orgRoot", "positions"],
|
||||
order: { posMasterOrder: "ASC" },
|
||||
});
|
||||
if(_posMasterCommission) {
|
||||
_data.push({
|
||||
citizenId: _posMasterCommission?.current_holder.citizenId ?? _null,
|
||||
fullName: `${_posMasterCommission?.current_holder.prefix ?? ""}${_posMasterCommission?.current_holder.firstName ?? ""} ${_posMasterCommission?.current_holder.lastName ?? ""}`,
|
||||
organizationName: _posMasterCommission.orgRoot
|
||||
? _posMasterCommission.orgRoot.orgRootName
|
||||
: _null,
|
||||
positionName: _posMasterCommission?.current_holder.position ?? _null,
|
||||
profileId: _posMasterCommission?.current_holder.id ?? _null
|
||||
});
|
||||
}
|
||||
|
||||
const _posMasterOfficer = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgChild1: {
|
||||
isOfficer: true,
|
||||
},
|
||||
isDirector: true,
|
||||
orgChild2: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
relations: ["current_holder", "orgRoot", "positions"],
|
||||
order: { posMasterOrder: "ASC" },
|
||||
});
|
||||
if(_posMasterOfficer) {
|
||||
_data.push({
|
||||
citizenId: _posMasterOfficer?.current_holder.citizenId ?? _null,
|
||||
fullName: `${_posMasterOfficer?.current_holder.prefix ?? ""}${_posMasterOfficer?.current_holder.firstName ?? ""} ${_posMasterOfficer?.current_holder.lastName ?? ""}`,
|
||||
organizationName: _posMasterOfficer.orgRoot
|
||||
? _posMasterOfficer.orgRoot.orgRootName
|
||||
: _null,
|
||||
positionName: _posMasterOfficer?.current_holder.position ?? _null,
|
||||
profileId: _posMasterOfficer?.current_holder.id ?? _null
|
||||
});
|
||||
}
|
||||
|
||||
let _orgRoot: any = [];
|
||||
let _orgChild1: any = [];
|
||||
let _orgChild2: any = [];
|
||||
let _orgChild3: any = [];
|
||||
let _orgChild4: any = [];
|
||||
|
||||
var posMasterOfficer = await this.posMasterRepository.find({
|
||||
where: {
|
||||
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"],
|
||||
});
|
||||
var posMasterEmployee = await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"],
|
||||
});
|
||||
|
||||
let posMaster = [...posMasterOfficer, ...posMasterEmployee];
|
||||
_orgRoot = posMaster
|
||||
.filter((x) => x.orgRootId != null && x.orgRootId != "")
|
||||
.map((x) => x.orgRootId);
|
||||
_orgChild1 = posMaster
|
||||
.filter((x) => x.orgChild1Id != null && x.orgChild1Id != "")
|
||||
.map((x) => x.orgChild1Id);
|
||||
_orgChild2 = posMaster
|
||||
.filter((x) => x.orgChild2Id != null && x.orgChild2Id != "")
|
||||
.map((x) => x.orgChild2Id);
|
||||
_orgChild3 = posMaster
|
||||
.filter((x) => x.orgChild3Id != null && x.orgChild3Id != "")
|
||||
.map((x) => x.orgChild3Id);
|
||||
_orgChild4 = posMaster
|
||||
.filter((x) => x.orgChild4Id != null && x.orgChild4Id != "")
|
||||
.map((x) => x.orgChild4Id);
|
||||
|
||||
let _posMaster: any;
|
||||
_posMaster = await this.posMasterRepository.find({
|
||||
where: [
|
||||
{
|
||||
orgRootId: In(_orgRoot),
|
||||
orgChild1: IsNull(),
|
||||
orgChild2: IsNull(),
|
||||
orgChild3: IsNull(),
|
||||
orgChild4: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
id: Not(In([_posMasterCommission?.id]))
|
||||
},
|
||||
{
|
||||
orgChild1: In(_orgChild1),
|
||||
orgChild2: IsNull(),
|
||||
orgChild3: IsNull(),
|
||||
orgChild4: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
id: Not(In([_posMasterOfficer?.id]))
|
||||
},
|
||||
{
|
||||
orgChild2: In(_orgChild2),
|
||||
orgChild3: IsNull(),
|
||||
orgChild4: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
{
|
||||
orgChild3: In(_orgChild3),
|
||||
orgChild4: IsNull(),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
{
|
||||
orgChild4: In(_orgChild4),
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
],
|
||||
relations: ["current_holder", "orgRoot"],
|
||||
});
|
||||
if (_posMaster.length > 0) {
|
||||
_posMaster.forEach((x:any) => {
|
||||
_data.push({
|
||||
citizenId: x?.current_holder.citizenId ?? _null,
|
||||
fullName: `${x?.current_holder.prefix ?? ""}${x?.current_holder.firstName ?? ""} ${x?.current_holder.lastName ?? ""}`,
|
||||
organizationName: x.orgRoot ? x.orgRoot.orgRootName : _null,
|
||||
positionName: x?.current_holder.position ?? _null,
|
||||
profileId: x?.current_holder.id ?? _null
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return new HttpSuccess(_data);
|
||||
}
|
||||
|
||||
@Post("excexute/salary-current")
|
||||
public async newSalaryAndUpdateCurrent(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue