add หน่วยงานที่ออกคำสั่ง(ตัวย่อ) (issue #1459)

This commit is contained in:
Bright 2025-04-29 10:48:33 +07:00
parent bcca1f205a
commit f7cca93877
3 changed files with 458 additions and 62 deletions

View file

@ -85,7 +85,7 @@ import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/command")
@Tags("Command")
@Security("bearerAuth")
@ -134,6 +134,7 @@ export class CommandController extends Controller {
private profileFamilyMotherHistoryRepo = AppDataSource.getRepository(ProfileFamilyMotherHistory);
private profileFamilyFatherRepo = AppDataSource.getRepository(ProfileFamilyFather);
private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
/**
* API list
@ -2953,19 +2954,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -2992,6 +3020,7 @@ export class CommandController extends Controller {
lastUpdatedAt: new Date(),
};
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
Object.assign(data, { ...item, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -3101,19 +3130,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -3130,6 +3186,7 @@ export class CommandController extends Controller {
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3268,19 +3325,46 @@ export class CommandController extends Controller {
where: { name: Like("USER") },
});
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -3310,6 +3394,7 @@ export class CommandController extends Controller {
lastUpdatedAt: new Date(),
};
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
Object.assign(data, { ...item, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -3457,19 +3542,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -3489,6 +3601,7 @@ export class CommandController extends Controller {
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3590,19 +3703,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -3622,6 +3762,7 @@ export class CommandController extends Controller {
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3871,19 +4012,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -3960,6 +4128,7 @@ export class CommandController extends Controller {
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileId: profile.id,
commandId: item.commandId,
@ -4154,6 +4323,7 @@ export class CommandController extends Controller {
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileEmployeeId: profile.id,
commandId: item.commandId,
@ -4323,19 +4493,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -4410,6 +4607,7 @@ export class CommandController extends Controller {
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileEmployeeId: profile.id,
commandId: item.commandId,
@ -4567,19 +4765,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -4655,6 +4880,7 @@ export class CommandController extends Controller {
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileId: item.profileId,
commandId: item.commandId,
@ -4743,19 +4969,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.data.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -4883,7 +5136,8 @@ export class CommandController extends Controller {
commandCode: item.commandCode,
commandName: item.commandName,
remark: item.remark,
posNumCodeSit: _posNumCodeSit
posNumCodeSit: _posNumCodeSit,
posNumCodeSitAbb: _posNumCodeSitAbb
});
await removeProfileInOrganize(profile.id, "OFFICER");
const clearProfile = await checkCommandType(String(item.commandId));
@ -4966,21 +5220,46 @@ export class CommandController extends Controller {
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
const _null: any = null;
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: {
id: body.data.find(x => x.bodySalarys?.commandId)?.bodySalarys?.commandId ?? ""
}
where: { id: body.data.find(x => x.bodySalarys?.commandId)?.bodySalarys?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -5274,6 +5553,7 @@ export class CommandController extends Controller {
});
const profileSal: any = new ProfileSalary();
profileSal.posNumCodeSit = _posNumCodeSit;
profileSal.posNumCodeSitAbb = _posNumCodeSitAbb;
Object.assign(profileSal, { ...item.bodySalarys, ...meta });
const salaryHistory = new ProfileSalaryHistory();
Object.assign(salaryHistory, { ...profileSal, id: undefined });
@ -5445,19 +5725,46 @@ export class CommandController extends Controller {
where: { name: Like("USER") },
});
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.refIds.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -5510,6 +5817,7 @@ export class CommandController extends Controller {
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileEmployeeId: profile.id,
amount: item.amount,
@ -5967,19 +6275,46 @@ export class CommandController extends Controller {
},
) {
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.refIds.find(x => x.commandId)?.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
await Promise.all(
@ -6035,6 +6370,7 @@ export class CommandController extends Controller {
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
profileId: profile?.id,
date: new Date(),

View file

@ -28,6 +28,7 @@ import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
import { Command } from "../entities/Command";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/profile/salary")
@Tags("ProfileSalary")
@Security("bearerAuth")
@ -41,7 +42,8 @@ export class ProfileSalaryController extends Controller {
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
private commandRepository = AppDataSource.getRepository(Command);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
@Get("TenurePositionOfficer")
public async cronjobTenurePositionOfficer() {
let data: any = [];
@ -674,23 +676,51 @@ export class ProfileSalaryController extends Controller {
});
const before = null;
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileRepo.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,

View file

@ -28,6 +28,7 @@ import { In, LessThan, MoreThan } from "typeorm";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
import { Command } from "../entities/Command";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/profile-employee/salary")
@Tags("ProfileSalary")
@Security("bearerAuth")
@ -37,6 +38,7 @@ export class ProfileSalaryEmployeeController extends Controller {
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
private commandRepository = AppDataSource.getRepository(Command);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
@Get("user")
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
@ -358,23 +360,51 @@ export class ProfileSalaryEmployeeController extends Controller {
});
const before = null;
let _posNumCodeSit: string = ""
let _posNumCodeSitAbb: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
if (_command?.isBangkok.toLocaleUpperCase() == "OFFICE") {
const orgRootDeputy = await this.orgRootRepository.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 this.profileGovementRepo.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
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 ?? ""
}
}
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
data.posNumCodeSitAbb = _posNumCodeSitAbb;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,