Merge branch 'develop' into adiDev
This commit is contained in:
commit
732467965e
1 changed files with 171 additions and 166 deletions
|
|
@ -2961,179 +2961,184 @@ export class PositionController extends Controller {
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ค้นหาคนตามโครงสร้าง
|
* API ค้นหาคนตามโครงสร้าง
|
||||||
*
|
*
|
||||||
* @summary ค้นหาคนตามโครงสร้าง
|
* @summary ค้นหาคนตามโครงสร้าง
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("profile/search")
|
@Post("profile/search")
|
||||||
async searchProfile(
|
async searchProfile(
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
isAll: boolean;
|
isAll: boolean;
|
||||||
node: number;
|
node: number;
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let typeCondition: any = {};
|
let typeCondition: any = {};
|
||||||
|
|
||||||
if (body.isAll == false) {
|
if (body.isAll == false) {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
orgChild1Id: IsNull(),
|
orgChild1Id: IsNull(),
|
||||||
};
|
};
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
orgChild2Id: IsNull(),
|
orgChild2Id: IsNull(),
|
||||||
};
|
};
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
orgChild3Id: IsNull(),
|
orgChild3Id: IsNull(),
|
||||||
};
|
};
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
orgChild4Id: IsNull(),
|
orgChild4Id: IsNull(),
|
||||||
};
|
};
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
};
|
};
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
};
|
};
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
};
|
};
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
};
|
};
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
||||||
.leftJoinAndSelect("posMaster.positions", "positions")
|
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||||
.leftJoinAndSelect("positions.posType", "posType")
|
.leftJoinAndSelect("positions.posType", "posType")
|
||||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||||
.where("posMaster.current_holderId IS NOT NULL")
|
.where("posMaster.current_holderId IS NOT NULL")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.orWhere(typeCondition);
|
qb.orWhere(typeCondition);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("posMaster.posMasterOrder", "ASC")
|
.orderBy("posMaster.posMasterOrder", "ASC")
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
|
|
||||||
const formattedData = await Promise.all(
|
const formattedData = await Promise.all(
|
||||||
posMaster.map(async (posMaster) => {
|
posMaster.map(async (posMaster) => {
|
||||||
let shortName = "";
|
let shortName = "";
|
||||||
if (
|
if (
|
||||||
posMaster.orgRootId !== null &&
|
posMaster.orgRootId !== null &&
|
||||||
posMaster.orgChild1Id == null &&
|
posMaster.orgChild1Id == null &&
|
||||||
posMaster.orgChild2Id == null &&
|
posMaster.orgChild2Id == null &&
|
||||||
posMaster.orgChild3Id == null
|
posMaster.orgChild3Id == null
|
||||||
) {
|
) {
|
||||||
body.node = 0;
|
body.node = 0;
|
||||||
shortName = posMaster.orgRoot.orgRootShortName;
|
shortName = posMaster.orgRoot.orgRootShortName;
|
||||||
} else if (
|
} else if (
|
||||||
posMaster.orgRootId !== null &&
|
posMaster.orgRootId !== null &&
|
||||||
posMaster.orgChild1Id !== null &&
|
posMaster.orgChild1Id !== null &&
|
||||||
posMaster.orgChild2Id == null &&
|
posMaster.orgChild2Id == null &&
|
||||||
posMaster.orgChild3Id == null
|
posMaster.orgChild3Id == null
|
||||||
) {
|
) {
|
||||||
body.node = 1;
|
body.node = 1;
|
||||||
shortName = posMaster.orgChild1.orgChild1ShortName;
|
shortName = posMaster.orgChild1.orgChild1ShortName;
|
||||||
} else if (
|
} else if (
|
||||||
posMaster.orgRootId !== null &&
|
posMaster.orgRootId !== null &&
|
||||||
posMaster.orgChild1Id !== null &&
|
posMaster.orgChild1Id !== null &&
|
||||||
posMaster.orgChild2Id !== null &&
|
posMaster.orgChild2Id !== null &&
|
||||||
posMaster.orgChild3Id == null
|
posMaster.orgChild3Id == null
|
||||||
) {
|
) {
|
||||||
body.node = 2;
|
body.node = 2;
|
||||||
shortName = posMaster.orgChild2.orgChild2ShortName;
|
shortName = posMaster.orgChild2.orgChild2ShortName;
|
||||||
} else if (
|
} else if (
|
||||||
posMaster.orgRootId !== null &&
|
posMaster.orgRootId !== null &&
|
||||||
posMaster.orgChild1Id !== null &&
|
posMaster.orgChild1Id !== null &&
|
||||||
posMaster.orgChild2Id !== null &&
|
posMaster.orgChild2Id !== null &&
|
||||||
posMaster.orgChild3Id !== null
|
posMaster.orgChild3Id !== null
|
||||||
) {
|
) {
|
||||||
body.node = 3;
|
body.node = 3;
|
||||||
shortName = posMaster.orgChild3.orgChild3ShortName;
|
shortName = posMaster.orgChild3.orgChild3ShortName;
|
||||||
} else if (
|
} else if (
|
||||||
posMaster.orgRootId !== null &&
|
posMaster.orgRootId !== null &&
|
||||||
posMaster.orgChild1Id !== null &&
|
posMaster.orgChild1Id !== null &&
|
||||||
posMaster.orgChild2Id !== null &&
|
posMaster.orgChild2Id !== null &&
|
||||||
posMaster.orgChild3Id !== null
|
posMaster.orgChild3Id !== null
|
||||||
) {
|
) {
|
||||||
body.node = 4;
|
body.node = 4;
|
||||||
shortName = posMaster.orgChild4.orgChild4ShortName;
|
shortName = posMaster.orgChild4.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: any = null;
|
let node: any = null;
|
||||||
let nodeId: any = null;
|
let nodeId: any = null;
|
||||||
if (posMaster.orgChild4Id != null) {
|
if (posMaster.orgChild4Id != null) {
|
||||||
node = 4;
|
node = 4;
|
||||||
nodeId = posMaster.orgChild4Id;
|
nodeId = posMaster.orgChild4Id;
|
||||||
} else if (posMaster.orgChild3Id != null) {
|
} else if (posMaster.orgChild3Id != null) {
|
||||||
node = 3;
|
node = 3;
|
||||||
nodeId = posMaster.orgChild3Id;
|
nodeId = posMaster.orgChild3Id;
|
||||||
} else if (posMaster.orgChild2Id != null) {
|
} else if (posMaster.orgChild2Id != null) {
|
||||||
node = 2;
|
node = 2;
|
||||||
nodeId = posMaster.orgChild2Id;
|
nodeId = posMaster.orgChild2Id;
|
||||||
} else if (posMaster.orgChild1Id != null) {
|
} else if (posMaster.orgChild1Id != null) {
|
||||||
node = 1;
|
node = 1;
|
||||||
nodeId = posMaster.orgChild1Id;
|
nodeId = posMaster.orgChild1Id;
|
||||||
} else if (posMaster.orgRootId != null) {
|
} else if (posMaster.orgRootId != null) {
|
||||||
node = 0;
|
node = 0;
|
||||||
nodeId = posMaster.orgRootId;
|
nodeId = posMaster.orgRootId;
|
||||||
}
|
}
|
||||||
const fullname = posMaster.current_holder.prefix + " " + posMaster.current_holder.firstName + " " + posMaster.current_holder.lastName;
|
const fullname =
|
||||||
return {
|
posMaster.current_holder.prefix +
|
||||||
id: posMaster.id,
|
" " +
|
||||||
node: node,
|
posMaster.current_holder.firstName +
|
||||||
nodeId: nodeId,
|
" " +
|
||||||
orgRootId: posMaster.orgRootId,
|
posMaster.current_holder.lastName;
|
||||||
orgChild1Id: posMaster.orgChild1Id,
|
return {
|
||||||
orgChild2Id: posMaster.orgChild2Id,
|
id: posMaster.id,
|
||||||
orgChild3Id: posMaster.orgChild3Id,
|
node: node,
|
||||||
orgChild4Id: posMaster.orgChild4Id,
|
nodeId: nodeId,
|
||||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
orgRootId: posMaster.orgRootId,
|
||||||
posMasterNo: posMaster.posMasterNo,
|
orgChild1Id: posMaster.orgChild1Id,
|
||||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
orgChild2Id: posMaster.orgChild2Id,
|
||||||
orgShortname: shortName,
|
orgChild3Id: posMaster.orgChild3Id,
|
||||||
isSit: posMaster.isSit,
|
orgChild4Id: posMaster.orgChild4Id,
|
||||||
name: fullname,
|
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||||
citizenId: posMaster.current_holder.citizenId,
|
posMasterNo: posMaster.posMasterNo,
|
||||||
position: posMaster.current_holder.position,
|
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||||
};
|
orgShortname: shortName,
|
||||||
}),
|
isSit: posMaster.isSit,
|
||||||
);
|
name: fullname,
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
profileId: posMaster.current_holder.id,
|
||||||
}
|
citizenId: posMaster.current_holder.citizenId,
|
||||||
|
position: posMaster.current_holder.position,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue