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.isAttachment = commandType.isAttachment;
|
||||
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.commandAffectDate = requestBody.commandAffectDate
|
||||
? new Date(requestBody.commandAffectDate)
|
||||
|
|
|
|||
|
|
@ -4075,21 +4075,53 @@ export class PositionController extends Controller {
|
|||
},
|
||||
) {
|
||||
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({
|
||||
where: { id: String(body.posType) },
|
||||
});
|
||||
let posLevel = await this.posLevelRepository.findOne({
|
||||
where: { id: String(body.posLevel) },
|
||||
});
|
||||
if (body.typeCommand === "ROYAL") {
|
||||
posType = await this.posTypeRepository.find({
|
||||
where: { posTypeName: In(["วิชาการ", "บริหาร"]) },
|
||||
});
|
||||
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") {
|
||||
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||
} else if (body.typeCommand == "APPOINT") {
|
||||
conditionA = "posType.posTypeRank > :posTypeRank";
|
||||
} else if (body.typeCommand == "SLIP") {
|
||||
conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
||||
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
||||
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||
params = {
|
||||
posType: posType?.id,
|
||||
posLevel: posLevel?.id,
|
||||
};
|
||||
} 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) {
|
||||
|
|
@ -4161,12 +4193,14 @@ export class PositionController extends Controller {
|
|||
.andWhere("posMaster.next_holderId IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
posType: posType == null ? `%%` : `${posType.id}`,
|
||||
posLevel: posLevel == null ? `%%` : `${posLevel.id}`,
|
||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
||||
});
|
||||
qb.andWhere(typeCondition)
|
||||
// .andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
// posType: posType == null ? `%%` : `${posType.id}`,
|
||||
// posLevel: posLevel == null ? `%%` : `${posLevel.id}`,
|
||||
// posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
||||
// posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
||||
// });
|
||||
.andWhere(conditionA, params);
|
||||
}),
|
||||
)
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue