API ที่ต้องปรับแก้ไข คำสั่งโปรดเกล้าฯ แต่งตั้งให้ดำรงตำแหน่ง #1780
This commit is contained in:
parent
6936846a41
commit
8a7417edf9
2 changed files with 63 additions and 20 deletions
|
|
@ -2169,7 +2169,16 @@ export class CommandController extends Controller {
|
||||||
command.detailFooter = commandType.detailFooter;
|
command.detailFooter = commandType.detailFooter;
|
||||||
command.isAttachment = commandType.isAttachment;
|
command.isAttachment = commandType.isAttachment;
|
||||||
command.isUploadAttachment = commandType.isUploadAttachment;
|
command.isUploadAttachment = commandType.isUploadAttachment;
|
||||||
command.status = "NEW";
|
// ถ้าเป็นคำสั่งโปรดเกล้าฯ "C-PM-47" ให้เปิดถึงรออัปโหลดไฟล์ #1780
|
||||||
|
if (commandCode === "C-PM-47") {
|
||||||
|
command.isSignature = true;
|
||||||
|
command.isDraft = true;
|
||||||
|
command.isSign = true;
|
||||||
|
command.status = "PENDING";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command.status = "NEW";
|
||||||
|
}
|
||||||
command.issue = commandType.name;
|
command.issue = commandType.name;
|
||||||
(command.commandAffectDate = requestBody.commandAffectDate
|
(command.commandAffectDate = requestBody.commandAffectDate
|
||||||
? new Date(requestBody.commandAffectDate)
|
? new Date(requestBody.commandAffectDate)
|
||||||
|
|
|
||||||
|
|
@ -4075,21 +4075,53 @@ export class PositionController extends Controller {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let typeCondition: any = {};
|
let typeCondition: any = {};
|
||||||
let conditionA: any = null;
|
let conditionA: any = "1=1";
|
||||||
|
let params: any = {};
|
||||||
|
let posType: any = {};
|
||||||
|
let posLevel: any = {};
|
||||||
|
|
||||||
let posType = await this.posTypeRepository.findOne({
|
if (body.typeCommand === "ROYAL") {
|
||||||
where: { id: String(body.posType) },
|
posType = await this.posTypeRepository.find({
|
||||||
});
|
where: { posTypeName: In(["วิชาการ", "บริหาร"]) },
|
||||||
let posLevel = await this.posLevelRepository.findOne({
|
});
|
||||||
where: { id: String(body.posLevel) },
|
posLevel = await this.posLevelRepository.find({
|
||||||
});
|
where: {
|
||||||
|
posTypeId: In(posType.map((x: any) => x.id)),
|
||||||
|
posLevelName: In(["ทรงคุณวุฒิ", "สูง"])
|
||||||
|
},
|
||||||
|
});
|
||||||
|
conditionA = "positions.posTypeId IN (:...posTypeIds) AND positions.posLevelId IN (:...posLevelIds)";
|
||||||
|
params = {
|
||||||
|
posTypeIds: posType.map((x: any) => x.id),
|
||||||
|
posLevelIds: posLevel.map((x: any) => x.id),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
posType = await this.posTypeRepository.findOne({
|
||||||
|
where: { id: String(body.posType) },
|
||||||
|
});
|
||||||
|
posLevel = await this.posLevelRepository.findOne({
|
||||||
|
where: { id: String(body.posLevel) },
|
||||||
|
});
|
||||||
|
|
||||||
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
||||||
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||||
} else if (body.typeCommand == "APPOINT") {
|
params = {
|
||||||
conditionA = "posType.posTypeRank > :posTypeRank";
|
posType: posType?.id,
|
||||||
} else if (body.typeCommand == "SLIP") {
|
posLevel: posLevel?.id,
|
||||||
conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
};
|
||||||
|
} else if (body.typeCommand == "APPOINT") {
|
||||||
|
conditionA = "posType.posTypeRank > :posTypeRank";
|
||||||
|
params = {
|
||||||
|
posTypeRank: posType?.posTypeRank ?? 0,
|
||||||
|
};
|
||||||
|
} else if (body.typeCommand == "SLIP") {
|
||||||
|
conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
||||||
|
params = {
|
||||||
|
posType: posType?.id,
|
||||||
|
posLevelRank: posLevel?.posLevelRank ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.isAll == false) {
|
if (body.isAll == false) {
|
||||||
|
|
@ -4161,12 +4193,14 @@ export class PositionController extends Controller {
|
||||||
.andWhere("posMaster.next_holderId IS NULL")
|
.andWhere("posMaster.next_holderId IS NULL")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
qb.andWhere(typeCondition)
|
||||||
posType: posType == null ? `%%` : `${posType.id}`,
|
// .andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||||
posLevel: posLevel == null ? `%%` : `${posLevel.id}`,
|
// posType: posType == null ? `%%` : `${posType.id}`,
|
||||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
// posLevel: posLevel == null ? `%%` : `${posLevel.id}`,
|
||||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
// posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
||||||
});
|
// posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
||||||
|
// });
|
||||||
|
.andWhere(conditionA, params);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue