แก้ข้อความ/ตัดข้อมูลรายงาน ทปอ.สามัญ #2274
This commit is contained in:
parent
66d8ba089d
commit
bc83a2bc40
3 changed files with 517 additions and 141 deletions
|
|
@ -1,6 +1,17 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import { CommandRecive } from "../entities/CommandRecive";
|
||||
import { Command } from "../entities/Command";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { Profile } from "../entities/Profile";
|
||||
|
||||
export interface PosNumCodeSitResult {
|
||||
posNumCodeSit: string;
|
||||
posNumCodeSitAbb: string;
|
||||
commandTypeName: string;
|
||||
commandNo: string;
|
||||
commandYear: number;
|
||||
commandExcecuteDate: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* เรียงลำดับผู้ได้รับคำสั่งใหม่หลังจากลบรายการ และอัพเดทสถานะคำสั่งถ้าไม่มีผู้ได้รับคำสั่งเหลือ
|
||||
|
|
@ -44,3 +55,92 @@ export async function reOrderCommandRecivesAndDelete(
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ดึงข้อมูล posNumCodeSit และ posNumCodeSitAbb จาก commandId
|
||||
* @param commandId ID ของคำสั่ง
|
||||
* @param status สถานะของคำสั่ง (ไม่บังคับส่ง)
|
||||
* @returns Promise<PosNumCodeSitResult> ข้อมูลชื่อหน่วยงานและชื่อย่อ
|
||||
*/
|
||||
export async function getPosNumCodeSit(
|
||||
commandId: string,
|
||||
status?: string
|
||||
): Promise<PosNumCodeSitResult> {
|
||||
const commandRepo = AppDataSource.getRepository(Command);
|
||||
const orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||
const profileRepo = AppDataSource.getRepository(Profile);
|
||||
|
||||
let posNumCodeSit:string = "";
|
||||
let posNumCodeSitAbb:string = "";
|
||||
let commandTypeName:string = "";
|
||||
let commandNo:string = "";
|
||||
let commandYear:number = 0;
|
||||
let commandExcecuteDate:Date = new Date;
|
||||
|
||||
|
||||
let _command: Command | null;
|
||||
if (!status) {
|
||||
_command = await commandRepo.findOne({
|
||||
where: { id: commandId },
|
||||
relations: { commandType: true }
|
||||
});
|
||||
}
|
||||
else {
|
||||
_command = await commandRepo.findOne({
|
||||
where: { id: commandId, status: status },
|
||||
relations: { commandType: true }
|
||||
});
|
||||
}
|
||||
|
||||
if (_command) {
|
||||
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
||||
const orgRootDeputy = await orgRootRepo.findOne({
|
||||
where: {
|
||||
isDeputy: true,
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
relations: ["orgRevision"],
|
||||
});
|
||||
posNumCodeSit = orgRootDeputy ? orgRootDeputy?.orgRootName : "สำนักปลัดกรุงเทพมหานคร";
|
||||
posNumCodeSitAbb = orgRootDeputy ? orgRootDeputy?.orgRootShortName : "สนป.";
|
||||
} else if (_command?.isBangkok?.toLocaleUpperCase() == "BANGKOK") {
|
||||
posNumCodeSit = "กรุงเทพมหานคร";
|
||||
posNumCodeSitAbb = "กทม.";
|
||||
} else {
|
||||
let _profileAdmin = await profileRepo.findOne({
|
||||
where: {
|
||||
keycloak: _command?.createdUserId.toString(),
|
||||
current_holders: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
relations: ["current_holders", "current_holders.orgRevision", "current_holders.orgRoot"],
|
||||
});
|
||||
posNumCodeSit =
|
||||
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootName)?.orgRoot.orgRootName ??
|
||||
"";
|
||||
posNumCodeSitAbb =
|
||||
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootShortName)?.orgRoot
|
||||
.orgRootShortName ?? "";
|
||||
}
|
||||
commandTypeName = _command?.commandType?.name ?? "";
|
||||
commandNo = _command?.commandNo ?? "";
|
||||
commandYear = _command?.commandYear;
|
||||
commandExcecuteDate = _command?.commandExcecuteDate;
|
||||
}
|
||||
|
||||
return {
|
||||
posNumCodeSit,
|
||||
posNumCodeSitAbb,
|
||||
commandTypeName,
|
||||
commandNo,
|
||||
commandYear,
|
||||
commandExcecuteDate,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue