no message

This commit is contained in:
kittapath 2024-10-24 19:28:53 +07:00
parent d083689f68
commit a659ce82e7
2 changed files with 242 additions and 1 deletions

View file

@ -3178,6 +3178,247 @@ export class PositionController extends Controller {
return new HttpSuccess();
}
/**
* API .
*
* @summary .
*
*/
@Post("placement/search-all")
async searchPlacementAll(
@Body()
body: {
node: number;
nodeId: string;
position?: string | null;
posType?: string | null;
posLevel?: string | null;
isAll: boolean;
isBlank: boolean;
},
) {
let typeCondition: any = {};
let conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
let posType = await this.posTypeRepository.findOne({
where: { id: String(body.posType) },
});
let posLevel = await this.posLevelRepository.findOne({
where: { id: String(body.posLevel) },
});
if (body.isAll == false) {
if (body.node === 0) {
typeCondition = {
orgRootId: body.nodeId,
orgChild1Id: IsNull(),
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 1) {
typeCondition = {
orgChild1Id: body.nodeId,
orgChild2Id: IsNull(),
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 2) {
typeCondition = {
orgChild2Id: body.nodeId,
orgChild3Id: IsNull(),
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 3) {
typeCondition = {
orgChild3Id: body.nodeId,
orgChild4Id: IsNull(),
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 4) {
typeCondition = {
orgChild4Id: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
}
} else {
if (body.node === 0) {
typeCondition = {
orgRootId: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 1) {
typeCondition = {
orgChild1Id: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 2) {
typeCondition = {
orgChild2Id: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 3) {
typeCondition = {
orgChild3Id: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
} else if (body.node === 4) {
typeCondition = {
orgChild4Id: body.nodeId,
};
if (body.isBlank == true) {
typeCondition.current_holderId = IsNull();
}
}
}
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
.createQueryBuilder("posMaster")
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
.leftJoinAndSelect("posMaster.positions", "positions")
.leftJoinAndSelect("positions.posType", "posType")
.leftJoinAndSelect("positions.posLevel", "posLevel")
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
.andWhere(
new Brackets((qb) => {
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
posType: posType == null ? `%%` : `${posType.id}`,
posLevel: posLevel == null ? `%%` : `${posLevel.id}`,
});
}),
)
.orderBy("posMaster.posMasterOrder", "ASC")
.getManyAndCount();
const formattedData = await Promise.all(
posMaster.map(async (posMaster) => {
let shortName = "";
if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.node = 0;
shortName = posMaster.orgRoot.orgRootShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.node = 1;
shortName = posMaster.orgChild1.orgChild1ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id == null
) {
body.node = 2;
shortName = posMaster.orgChild2.orgChild2ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id !== null
) {
body.node = 3;
shortName = posMaster.orgChild3.orgChild3ShortName;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id !== null
) {
body.node = 4;
shortName = posMaster.orgChild4.orgChild4ShortName;
}
let node: any = null;
let nodeId: any = null;
if (posMaster.orgChild4Id != null) {
node = 4;
nodeId = posMaster.orgChild4Id;
} else if (posMaster.orgChild3Id != null) {
node = 3;
nodeId = posMaster.orgChild3Id;
} else if (posMaster.orgChild2Id != null) {
node = 2;
nodeId = posMaster.orgChild2Id;
} else if (posMaster.orgChild1Id != null) {
node = 1;
nodeId = posMaster.orgChild1Id;
} else if (posMaster.orgRootId != null) {
node = 0;
nodeId = posMaster.orgRootId;
}
return {
id: posMaster.id,
node: node,
nodeId: nodeId,
orgRootId: posMaster.orgRootId,
orgChild1Id: posMaster.orgChild1Id,
orgChild2Id: posMaster.orgChild2Id,
orgChild3Id: posMaster.orgChild3Id,
orgChild4Id: posMaster.orgChild4Id,
posMasterNoPrefix: posMaster.posMasterNoPrefix,
posMasterNo: posMaster.posMasterNo,
posMasterNoSuffix: posMaster.posMasterNoSuffix,
orgShortname: shortName,
isSit: posMaster.isSit,
fullNameCurrentHolder:
posMaster.current_holder == null
? null
: `${posMaster.current_holder.prefix}${posMaster.current_holder.firstName} ${posMaster.current_holder.lastName}`,
fullNameNextHolder:
posMaster.next_holder == null
? null
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
isPosition: posMaster.positions.filter((x) => x.positionName == body.position).length > 0,
positions: posMaster.positions.map((position) => ({
id: position.id,
positionName: position.positionName,
positionField: position.positionField,
posTypeId: position.posTypeId,
posTypeName: position.posType == null ? null : position.posType.posTypeName,
posLevelId: position.posLevelId,
posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
posExecutiveId: position.posExecutiveId,
posExecutiveName:
position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
positionExecutiveField: position.positionExecutiveField,
positionArea: position.positionArea,
positionIsSelected: position.positionIsSelected,
isSpecial: position.isSpecial,
})),
};
}),
);
return new HttpSuccess({ data: formattedData, total });
}
/**
* API .
*

View file

@ -1231,7 +1231,7 @@ export class ProfileController extends Controller {
*
*/
@Post("commander-director")
public async getProfileCommanderDirector(
async getProfileCommanderDirector(
@Request() request: RequestWithUser,
@Body() body: { isDirector: boolean; keyword: string; page: number; pageSize: number },
) {