no message

This commit is contained in:
Kittapath 2024-02-13 18:37:58 +07:00
parent 60b25c6620
commit d633e78058

View file

@ -1193,196 +1193,196 @@ export class PositionController extends Controller {
if (requestBody.isNode === true) { if (requestBody.isNode === true) {
switch (requestBody.type) { switch (requestBody.type) {
case 0: { case 0: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgRootId: requestBody.id }, // where: { orgRootId: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { orgRootId: requestBody.id }, where: { orgRootId: requestBody.id },
}); });
totalPositionCurrentUse = await this.posMasterRepository.count({ totalPositionCurrentUse = await this.posMasterRepository.count({
where: { where: {
orgRootId: requestBody.id, orgRootId: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
where: { where: {
orgRootId: requestBody.id, orgRootId: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
where: { where: {
orgRootId: requestBody.id, orgRootId: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
where: { where: {
orgRootId: requestBody.id, orgRootId: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 1: { case 1: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild1Id: requestBody.id }, // where: { orgChild1Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { orgChild1Id: requestBody.id }, where: { orgChild1Id: requestBody.id },
}); });
totalPositionCurrentUse = await this.posMasterRepository.count({ totalPositionCurrentUse = await this.posMasterRepository.count({
where: { where: {
orgChild1Id: requestBody.id, orgChild1Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
where: { where: {
orgChild1Id: requestBody.id, orgChild1Id: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
where: { where: {
orgChild1Id: requestBody.id, orgChild1Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
where: { where: {
orgChild1Id: requestBody.id, orgChild1Id: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 2: { case 2: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild2Id: requestBody.id }, // where: { orgChild2Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { orgChild2Id: requestBody.id }, where: { orgChild2Id: requestBody.id },
}); });
totalPositionCurrentUse = await this.posMasterRepository.count({ totalPositionCurrentUse = await this.posMasterRepository.count({
where: { where: {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
where: { where: {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
where: { where: {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
where: { where: {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 3: { case 3: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild3Id: requestBody.id }, // where: { orgChild3Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { orgChild3Id: requestBody.id }, where: { orgChild3Id: requestBody.id },
}); });
totalPositionCurrentUse = await this.posMasterRepository.count({ totalPositionCurrentUse = await this.posMasterRepository.count({
where: { where: {
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
where: { where: {
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
where: { where: {
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
where: { where: {
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 4: { case 4: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild4Id: requestBody.id }, // where: { orgChild4Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { orgChild4Id: requestBody.id }, where: { orgChild4Id: requestBody.id },
}); });
totalPositionCurrentUse = await this.posMasterRepository.count({ totalPositionCurrentUse = await this.posMasterRepository.count({
where: { where: {
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
where: { where: {
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
where: { where: {
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
where: { where: {
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
@ -1393,15 +1393,15 @@ export class PositionController extends Controller {
} else { } else {
switch (requestBody.type) { switch (requestBody.type) {
case 0: { case 0: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgRootId: requestBody.id }, // where: { orgRootId: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { where: {
orgRootId: requestBody.id, orgRootId: requestBody.id,
@ -1454,15 +1454,15 @@ export class PositionController extends Controller {
break; break;
} }
case 1: { case 1: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild1Id: requestBody.id }, // where: { orgChild1Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { where: {
orgRootId: Not(IsNull()) || Not(""), orgRootId: Not(IsNull()) || Not(""),
@ -1479,7 +1479,7 @@ export class PositionController extends Controller {
orgChild2Id: IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
@ -1489,7 +1489,7 @@ export class PositionController extends Controller {
orgChild2Id: IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
@ -1499,7 +1499,7 @@ export class PositionController extends Controller {
orgChild2Id: IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
@ -1509,21 +1509,21 @@ export class PositionController extends Controller {
orgChild2Id: IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 2: { case 2: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild2Id: requestBody.id }, // where: { orgChild2Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { where: {
orgRootId: Not(IsNull()) || Not(""), orgRootId: Not(IsNull()) || Not(""),
@ -1540,7 +1540,7 @@ export class PositionController extends Controller {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
@ -1550,7 +1550,7 @@ export class PositionController extends Controller {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
@ -1560,7 +1560,7 @@ export class PositionController extends Controller {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
@ -1570,21 +1570,21 @@ export class PositionController extends Controller {
orgChild2Id: requestBody.id, orgChild2Id: requestBody.id,
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 3: { case 3: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild3Id: requestBody.id }, // where: { orgChild3Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { where: {
orgRootId: Not(IsNull()) || Not(""), orgRootId: Not(IsNull()) || Not(""),
@ -1601,7 +1601,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
@ -1611,7 +1611,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
@ -1621,7 +1621,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
@ -1631,21 +1631,21 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: requestBody.id, orgChild3Id: requestBody.id,
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;
} }
case 4: { case 4: {
const NodeId = await this.posMasterRepository.findOne({ // const NodeId = await this.posMasterRepository.findOne({
where: { orgChild4Id: requestBody.id }, // where: { orgChild4Id: requestBody.id },
}); // });
if (!NodeId) { // if (!NodeId) {
throw new HttpError( // throw new HttpError(
HttpStatusCode.NOT_FOUND, // HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id, // "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
); // );
} // }
totalPosition = await this.posMasterRepository.count({ totalPosition = await this.posMasterRepository.count({
where: { where: {
orgRootId: Not(IsNull()) || Not(""), orgRootId: Not(IsNull()) || Not(""),
@ -1662,7 +1662,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: Not(IsNull()) || Not(""), orgChild3Id: Not(IsNull()) || Not(""),
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
current_holderId: Not(IsNull()) && Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionCurrentVacant = await this.posMasterRepository.count({ totalPositionCurrentVacant = await this.posMasterRepository.count({
@ -1672,7 +1672,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: Not(IsNull()) || Not(""), orgChild3Id: Not(IsNull()) || Not(""),
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
current_holderId: IsNull() && "", current_holderId: IsNull() || "",
}, },
}); });
totalPositionNextUse = await this.posMasterRepository.count({ totalPositionNextUse = await this.posMasterRepository.count({
@ -1682,7 +1682,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: Not(IsNull()) || Not(""), orgChild3Id: Not(IsNull()) || Not(""),
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
next_holderId: Not(IsNull()) && Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}); });
totalPositionNextVacant = await this.posMasterRepository.count({ totalPositionNextVacant = await this.posMasterRepository.count({
@ -1692,7 +1692,7 @@ export class PositionController extends Controller {
orgChild2Id: Not(IsNull()) || Not(""), orgChild2Id: Not(IsNull()) || Not(""),
orgChild3Id: Not(IsNull()) || Not(""), orgChild3Id: Not(IsNull()) || Not(""),
orgChild4Id: requestBody.id, orgChild4Id: requestBody.id,
next_holderId: IsNull() && "", next_holderId: IsNull() || "",
}, },
}); });
break; break;