ปรับโครงสร้าง root

This commit is contained in:
Kittapath 2024-06-20 11:58:51 +07:00
parent 9de005c7ae
commit 7f21756928
5 changed files with 143 additions and 60 deletions

View file

@ -3175,9 +3175,10 @@ export class OrganizationController extends Controller {
posMaster: await Promise.all(
orgRoot.posMasters
.filter(
(x) => x.orgChild1Id != null && x.current_holderId != null && x.posMasterOrder <= 3,
(x) => x.orgChild1Id == null && x.current_holderId != null && x.posMasterOrder <= 3,
)
.map(async (x) => ({
posmasterId: x.id,
orgTreeId: orgRoot.id,
orgLevel: 0,
fullNameCurrentHolder:
@ -3210,11 +3211,12 @@ export class OrganizationController extends Controller {
orgChild1.posMasters
.filter(
(x) =>
x.orgChild2Id != null &&
x.orgChild2Id == null &&
x.current_holderId != null &&
x.posMasterOrder <= 3,
)
.map(async (x) => ({
posmasterId: x.id,
orgTreeId: orgChild1.id,
orgLevel: 1,
fullNameCurrentHolder:
@ -3248,11 +3250,12 @@ export class OrganizationController extends Controller {
orgChild2.posMasters
.filter(
(x) =>
x.orgChild3Id != null &&
x.orgChild3Id == null &&
x.current_holderId != null &&
x.posMasterOrder <= 3,
)
.map(async (x) => ({
posmasterId: x.id,
orgTreeId: orgChild2.id,
orgLevel: 2,
fullNameCurrentHolder:
@ -3286,11 +3289,12 @@ export class OrganizationController extends Controller {
orgChild3.posMasters
.filter(
(x) =>
x.orgChild4Id != null &&
x.orgChild4Id == null &&
x.current_holderId != null &&
x.posMasterOrder <= 3,
)
.map(async (x) => ({
posmasterId: x.id,
orgTreeId: orgChild3.id,
orgLevel: 3,
fullNameCurrentHolder:
@ -3326,6 +3330,7 @@ export class OrganizationController extends Controller {
(x) => x.current_holderId != null && x.posMasterOrder <= 3,
)
.map(async (x) => ({
posmasterId: x.id,
orgTreeId: orgChild4.id,
orgLevel: 4,
fullNameCurrentHolder: