find list root id
This commit is contained in:
parent
de0e2a9643
commit
d781920ad4
2 changed files with 179 additions and 5 deletions
|
|
@ -620,7 +620,7 @@ export class OrganizationController extends Controller {
|
|||
// let attrOwnership = null;
|
||||
if (
|
||||
orgRevision.orgRevisionIsDraft == true &&
|
||||
orgRevision.orgRevisionIsCurrent == false
|
||||
orgRevision.orgRevisionIsCurrent == false
|
||||
// attrOwnership == false
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -4778,8 +4778,16 @@ export class OrganizationController extends Controller {
|
|||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
let _data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||
let _data = {
|
||||
root: null,
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
if (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) {
|
||||
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||
}
|
||||
const orgRootData = await AppDataSource.getRepository(OrgRoot)
|
||||
.createQueryBuilder("orgRoot")
|
||||
.where("orgRoot.orgRevisionId = :id", { id })
|
||||
|
|
@ -5543,6 +5551,174 @@ export class OrganizationController extends Controller {
|
|||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
/**
|
||||
* API รายละเอียดโครงสร้าง
|
||||
*
|
||||
* @summary ORG_023 - รายละเอียดโครงสร้าง (ADMIN) #25
|
||||
*
|
||||
*/
|
||||
@Get("system-root/{id}/{system}")
|
||||
async detailBySystemRoot(
|
||||
@Path() id: string,
|
||||
@Path() system: string,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } });
|
||||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
let _data = {
|
||||
root: null,
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
if (orgRevision.orgRevisionIsDraft == true && orgRevision.orgRevisionIsCurrent == false) {
|
||||
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||
}
|
||||
const orgRootData = await AppDataSource.getRepository(OrgRoot)
|
||||
.createQueryBuilder("orgRoot")
|
||||
.where("orgRoot.orgRevisionId = :id", { id })
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `orgRoot.id IN (:...node)`
|
||||
: `orgRoot.id is null`
|
||||
: "1=1",
|
||||
{
|
||||
node: _data.root,
|
||||
},
|
||||
)
|
||||
.select([
|
||||
"orgRoot.id",
|
||||
"orgRoot.orgRootName",
|
||||
"orgRoot.orgRootShortName",
|
||||
"orgRoot.orgRootCode",
|
||||
"orgRoot.orgRootOrder",
|
||||
"orgRoot.orgRootPhoneEx",
|
||||
"orgRoot.orgRootPhoneIn",
|
||||
"orgRoot.orgRootFax",
|
||||
"orgRoot.orgRevisionId",
|
||||
"orgRoot.orgRootRank",
|
||||
"orgRoot.orgRootRankSub",
|
||||
"orgRoot.responsibility",
|
||||
])
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.getMany();
|
||||
|
||||
const formattedData = await Promise.all(
|
||||
orgRootData.map(async (orgRoot) => {
|
||||
return {
|
||||
orgTreeId: orgRoot.id,
|
||||
orgLevel: 0,
|
||||
orgName: orgRoot.orgRootName,
|
||||
orgTreeName: orgRoot.orgRootName,
|
||||
orgTreeShortName: orgRoot.orgRootShortName,
|
||||
orgTreeCode: orgRoot.orgRootCode,
|
||||
orgCode: orgRoot.orgRootCode + "00",
|
||||
orgTreeRank: orgRoot.orgRootRank,
|
||||
orgTreeRankSub: orgRoot.orgRootRankSub,
|
||||
orgTreeOrder: orgRoot.orgRootOrder,
|
||||
orgTreePhoneEx: orgRoot.orgRootPhoneEx,
|
||||
orgTreePhoneIn: orgRoot.orgRootPhoneIn,
|
||||
orgTreeFax: orgRoot.orgRootFax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||
totalPosition: await this.posMasterRepository.count({
|
||||
where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id },
|
||||
}),
|
||||
totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
current_holderId: Not(IsNull()) || Not(""),
|
||||
},
|
||||
}),
|
||||
totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
current_holderId: IsNull() || "",
|
||||
},
|
||||
}),
|
||||
totalPositionNextUse: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
next_holderId: Not(IsNull()) || Not(""),
|
||||
},
|
||||
}),
|
||||
totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
next_holderId: IsNull() || "",
|
||||
},
|
||||
}),
|
||||
totalRootPosition: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
},
|
||||
}),
|
||||
totalRootPositionCurrentUse: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
current_holderId: Not(IsNull()) || Not(""),
|
||||
},
|
||||
}),
|
||||
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
current_holderId: IsNull() || "",
|
||||
},
|
||||
}),
|
||||
totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
next_holderId: Not(IsNull()) || Not(""),
|
||||
},
|
||||
}),
|
||||
totalRootPositionNextVacant: await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
next_holderId: IsNull() || "",
|
||||
},
|
||||
}),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
/**
|
||||
* API เช็คสกจในระบบ
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3214,8 +3214,6 @@ export class ProfileController extends Controller {
|
|||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.id = :revisionId", { revisionId })
|
||||
// .andWhere("orgRevision.orgRevisionIsDraft = false")
|
||||
// .andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
if (!orgRevisionPublish) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue