Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-11-01 16:48:37 +07:00
commit 1280086ad1
2 changed files with 74 additions and 17 deletions

View file

@ -100,7 +100,7 @@ export class CommandTypeController extends Controller {
*/
@Get("{id}")
async GetById(@Path() id: string) {
const _commandType = await this.commandTypeRepository.findOne({
let _commandType = await this.commandTypeRepository.findOne({
where: { id },
select: [
"id",
@ -120,6 +120,28 @@ export class CommandTypeController extends Controller {
if (!_commandType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
if(_commandType.code == "C-PM-10") {
let _commandType10: any
_commandType10 = {
id: _commandType.id,
name: _commandType.name,
commandSysId: _commandType.commandSysId,
code: _commandType.code,
fileCover: _commandType.fileCover,
fileAttachment: _commandType.fileAttachment,
isActive: _commandType.isActive,
detailHeader: _commandType.detailHeader,
detailBody: _commandType.detailBody,
detailFooter: _commandType.detailFooter,
subtitle: _commandType.subtitle,
isAttachment: _commandType.isAttachment,
name1: "..........................ประธาน",
name2: "..........................ผู้บังคับบัญชา",
name3: "..........................ผู้ดูแล",
name4: "..........................ผู้ดูแล",
}
_commandType = _commandType10;
}
return new HttpSuccess(_commandType);
}

View file

@ -3311,6 +3311,13 @@ export class PositionController extends Controller {
.orderBy("posMaster.posMasterOrder", "ASC")
.getManyAndCount();
const _posType = await this.posTypeRepository.find({
where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) }
});
const _posLevel = await this.posLevelRepository.find({
where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) }
});
const formattedData = await Promise.all(
posMaster.map(async (posMaster) => {
let shortName = "";
@ -3375,6 +3382,49 @@ export class PositionController extends Controller {
nodeId = posMaster.orgRootId;
}
let _position: any
if( posLevel == null && posType == null && body.position != null) {
_position = posMaster.positions
.filter((x:any) =>
_posType.some((y:any) => y.id == x.posTypeId) &&
_posLevel.some((z:any) => z.id == x.posLevelId)
)
.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,
}));
}
else {
_position = 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 {
id: posMaster.id,
node: node,
@ -3398,22 +3448,7 @@ export class PositionController extends Controller {
? 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,
})),
positions: _position,
};
}),
);