fix api org_053 isAll ทำงานผิดพลาด

This commit is contained in:
AdisakKanthawilang 2024-02-12 10:57:35 +07:00
parent 0819836932
commit 1ed37b770c

View file

@ -36,7 +36,7 @@ import { Position } from "../entities/Position";
import { Brackets } from "typeorm/browser";
@Route("api/v1/org/pos")
@Tags("Position")
@Security("bearerAuth")
// @Security("bearerAuth")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
@ -426,7 +426,7 @@ export class PositionController extends Controller {
requestBody: CreatePosMaster,
@Request() request: { user: Record<string, any> },
) {
let posMaster = await this.posMasterRepository.findOne({ where: { id: id } });
const posMaster = await this.posMasterRepository.findOne({ where: { id: id } });
if (!posMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
}
@ -435,9 +435,6 @@ export class PositionController extends Controller {
posMaster.orgChild2Id = null;
posMaster.orgChild3Id = null;
posMaster.orgChild4Id = null;
posMaster.posMasterNo = requestBody.posMasterNo;
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
let orgRoot: any = null;
if (requestBody.orgRootId != null)
@ -517,7 +514,7 @@ export class PositionController extends Controller {
position.positionExecutiveField = x.posDictExecutiveField;
position.positionArea = x.posDictArea;
position.positionIsSelected = false;
position.posMasterId = posMaster?.id;
position.posMasterId = posMaster.id;
position.createdUserId = request.user.sub;
position.createdFullName = request.user.name;
position.lastUpdateUserId = request.user.sub;
@ -745,49 +742,52 @@ export class PositionController extends Controller {
relations: ["posLevel", "posType", "posExecutive"],
});
let shortName = "-";
if (body.isAll === true) {
if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 0;
shortName = posMaster.orgRoot.orgRootShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 1;
shortName = posMaster.orgChild1.orgChild1ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 2;
shortName = posMaster.orgChild2.orgChild2ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id == null
posMaster.orgChild3Id !== null
) {
body.type = 3;
shortName = posMaster.orgChild3.orgChild3ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id !== null
) {
body.type = 4;
shortName = posMaster.orgChild4.orgChild4ShortName;
}
}
return {
id: posMaster.id,
orgRootId: posMaster.orgRootId,
@ -806,18 +806,7 @@ export class PositionController extends Controller {
posMaster.next_holder == null
? null
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
orgShortname:
body.type === 0
? posMaster.orgRoot.orgRootShortName
: body.type === 1
? posMaster.orgChild1.orgChild1ShortName
: body.type === 2
? posMaster.orgChild2.orgChild2ShortName
: body.type === 3
? posMaster.orgChild3.orgChild3ShortName
: body.type === 4
? posMaster.orgChild4.orgChild4ShortName
: "-",
orgShortname: shortName,
positions: positions.map((position) => ({
id: position.id,
positionName: position.positionName,
@ -1140,7 +1129,7 @@ export class PositionController extends Controller {
*
*/
@Post("summary")
async PositionSummary(@Body() requestBody: { id: string; type: number; isNode: boolean }) {
async PositionSummary(@Body() requestBody: { id: string; type: number }) {
try {
let summary: any;
let totalPosition: any;
@ -1149,517 +1138,204 @@ export class PositionController extends Controller {
let totalPositionNextUse: any;
let totalPositionNextVacant: any;
if(requestBody.isNode === true){
switch (requestBody.type) {
case 0: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgRootId: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgRootId: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
switch (requestBody.type) {
case 0: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgRootId: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
case 1: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild1Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild1Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 2: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild2Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild2Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 3: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild3Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild3Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 4: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild4Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild4Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
default:
break;
totalPosition = await this.posMasterRepository.count({
where: { orgRootId: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
}
else {
switch (requestBody.type) {
case 0: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgRootId: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
orgChild1Id : IsNull() || "",
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
},
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
orgChild1Id : IsNull() || "",
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
orgChild1Id : IsNull() || "",
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: IsNull() || "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
orgChild1Id : IsNull() || "",
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: Not(IsNull()) || Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: requestBody.id,
orgChild1Id : IsNull() || "",
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: IsNull() || "",
},
});
break;
case 1: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild1Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
case 1: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild1Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : requestBody.id,
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
},
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : requestBody.id,
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : requestBody.id,
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : requestBody.id,
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : requestBody.id,
orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: IsNull() && "",
},
});
break;
}
case 2: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild2Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : requestBody.id,
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
},
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : requestBody.id,
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : requestBody.id,
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : requestBody.id,
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : requestBody.id,
orgChild3Id : IsNull() || "",
orgChild4Id : IsNull() || "",
next_holderId: IsNull() && "",
},
});
break;
}
case 3: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild3Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : requestBody.id,
orgChild4Id : IsNull() || "",
},
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : requestBody.id,
orgChild4Id : IsNull() || "",
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : requestBody.id,
orgChild4Id : IsNull() || "",
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : requestBody.id,
orgChild4Id : IsNull() || "",
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : requestBody.id,
orgChild4Id : IsNull() || "",
next_holderId: IsNull() && "",
},
});
break;
}
case 4: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild4Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : Not(IsNull()) || Not(""),
orgChild4Id : requestBody.id,
},
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : Not(IsNull()) || Not(""),
orgChild4Id : requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : Not(IsNull()) || Not(""),
orgChild4Id : requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : Not(IsNull()) || Not(""),
orgChild4Id : requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgRootId: Not(IsNull()) || Not(""),
orgChild1Id : Not(IsNull()) || Not(""),
orgChild2Id : Not(IsNull()) || Not(""),
orgChild3Id : Not(IsNull()) || Not(""),
orgChild4Id : requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
default:
break;
totalPosition = await this.posMasterRepository.count({
where: { orgChild1Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild1Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 2: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild2Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild2Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild2Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 3: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild3Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild3Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild3Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
case 4: {
const NodeId = await this.posMasterRepository.findOne({
where: { orgChild4Id: requestBody.id },
});
if (!NodeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
);
}
totalPosition = await this.posMasterRepository.count({
where: { orgChild4Id: requestBody.id },
});
totalPositionCurrentUse = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionCurrentVacant = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
current_holderId: IsNull() && "",
},
});
totalPositionNextUse = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""),
},
});
totalPositionNextVacant = await this.posMasterRepository.count({
where: {
orgChild4Id: requestBody.id,
next_holderId: IsNull() && "",
},
});
break;
}
default:
break;
}
summary = {