Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2025-04-28 14:46:16 +07:00
commit 519de90743
6 changed files with 1748 additions and 81 deletions

View file

@ -2952,6 +2952,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile: any = await this.profileRepository.findOneBy({ id: item.profileId });
@ -2975,7 +2991,7 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
data.posNumCodeSit = _posNumCodeSit;
Object.assign(data, { ...item, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -3084,6 +3100,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile: any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId });
@ -3097,7 +3129,7 @@ export class CommandController extends Controller {
});
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3235,6 +3267,22 @@ export class CommandController extends Controller {
const roleKeycloak = await this.roleKeycloakRepo.findOne({
where: { name: Like("USER") },
});
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOne({
@ -3261,7 +3309,7 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
data.posNumCodeSit = _posNumCodeSit;
Object.assign(data, { ...item, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -3408,6 +3456,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileEmployeeRepository.findOne({
@ -3424,7 +3488,7 @@ export class CommandController extends Controller {
});
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3525,6 +3589,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile: any = await this.profileRepository.findOne({
@ -3541,7 +3621,7 @@ export class CommandController extends Controller {
});
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,
@ -3790,6 +3870,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
if (item.profileType && item.profileType.trim().toUpperCase() == "OFFICER") {
@ -3863,6 +3959,7 @@ export class CommandController extends Controller {
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileId: profile.id,
commandId: item.commandId,
@ -4056,6 +4153,7 @@ export class CommandController extends Controller {
// ?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileEmployeeId: profile.id,
commandId: item.commandId,
@ -4224,6 +4322,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileEmployeeRepository.findOne({
@ -4295,6 +4409,7 @@ export class CommandController extends Controller {
// ?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileEmployeeId: profile.id,
commandId: item.commandId,
@ -4451,6 +4566,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOne({
@ -4523,6 +4654,7 @@ export class CommandController extends Controller {
?.positions?.filter((pos) => pos.positionIsSelected === true)[0] ?? null;
// ประวัติตำแหน่ง
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileId: item.profileId,
commandId: item.commandId,
@ -4610,6 +4742,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOne({
@ -4735,6 +4883,7 @@ export class CommandController extends Controller {
commandCode: item.commandCode,
commandName: item.commandName,
remark: item.remark,
posNumCodeSit: _posNumCodeSit
});
await removeProfileInOrganize(profile.id, "OFFICER");
const clearProfile = await checkCommandType(String(item.commandId));
@ -4816,6 +4965,24 @@ export class CommandController extends Controller {
const list = await getRoles();
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
const _null: any = null;
let _posNumCodeSit: string = ""
const _command = await this.commandRepository.findOne({
where: {
id: body.data.find(x => x.bodySalarys?.commandId)?.bodySalarys?.commandId ?? ""
}
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.data.map(async (item) => {
const before = null;
@ -5106,6 +5273,7 @@ export class CommandController extends Controller {
order: { order: "DESC" },
});
const profileSal: any = new ProfileSalary();
profileSal.posNumCodeSit = _posNumCodeSit;
Object.assign(profileSal, { ...item.bodySalarys, ...meta });
const salaryHistory = new ProfileSalaryHistory();
Object.assign(salaryHistory, { ...profileSal, id: undefined });
@ -5276,6 +5444,22 @@ export class CommandController extends Controller {
const roleKeycloak = await this.roleKeycloakRepo.findOne({
where: { name: Like("USER") },
});
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.refIds.map(async (item) => {
const profile = await this.profileEmployeeRepository.findOne({
@ -5325,7 +5509,7 @@ export class CommandController extends Controller {
});
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileEmployeeId: profile.id,
amount: item.amount,
@ -5782,6 +5966,22 @@ export class CommandController extends Controller {
}[];
},
) {
let _posNumCodeSit: 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 = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepository.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
await Promise.all(
body.refIds.map(async (item) => {
const posMaster = await this.posMasterRepository.findOne({
@ -5834,7 +6034,7 @@ export class CommandController extends Controller {
});
const before = null;
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
profileId: profile?.id,
date: new Date(),

View file

@ -924,6 +924,12 @@ export class ProfileController extends Controller {
"registrationDistrict",
"registrationProvince",
"profileAvatars",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
order: {
profileAvatars: { createdAt: "ASC" },
@ -934,13 +940,6 @@ export class ProfileController extends Controller {
let ImgUrl: any = null;
let _ImgUrl: any = [];
if (profiles?.avatar != null && profiles?.avatarName != null) {
// await new CallAPI()
// .GetData(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
// .then(async (x) => {
// ImgUrl = x.downloadUrl;
// })
// .catch();
let req_: any = req;
const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", "");
@ -975,18 +974,7 @@ export class ProfileController extends Controller {
ImgUrl = response_.data.downloadUrl;
} catch {}
}
const profileOc = await this.profileRepo.findOne({
relations: [
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: { id: id },
});
if (!profileOc) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const orgRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
});
@ -1010,39 +998,39 @@ export class ProfileController extends Controller {
});
const root =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
const child1 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
const child2 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
const child3 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
const child4 =
profileOc.current_holders == null ||
profileOc.current_holders.length == 0 ||
profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
profiles.current_holders == null ||
profiles.current_holders.length == 0 ||
profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
? null
: profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
: profiles.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
// Construct org path
let _root = root?.orgRootName;
@ -1058,7 +1046,7 @@ export class ProfileController extends Controller {
});
const certs =
cert_raw.length > 0
? cert_raw.slice(-2).map((item) => ({
? cert_raw.map((item) => ({
certificateType: item.certificateType ?? null,
issuer: item.issuer ?? null,
certificateNo: item.certificateNo ? Extension.ToThaiNumber(item.certificateNo) : null,
@ -1091,7 +1079,7 @@ export class ProfileController extends Controller {
});
const trainings =
training_raw.length > 0
? training_raw.slice(-2).map((item) => ({
? training_raw.map((item) => ({
institute: item.department ?? "",
start:
item.startDate == null
@ -1128,7 +1116,7 @@ export class ProfileController extends Controller {
});
const disciplines =
discipline_raw.length > 0
? discipline_raw.slice(-2).map((item) => ({
? discipline_raw.map((item) => ({
disciplineYear: item.refCommandDate
? Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString())
: null,
@ -1143,47 +1131,38 @@ export class ProfileController extends Controller {
},
];
const education_raw = await this.profileEducationRepo.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
// order: { lastUpdatedAt: "DESC" },
order: { level: "ASC" },
});
const education_raw = await this.profileEducationRepo
.createQueryBuilder("education")
.where("education.profileId = :profileId", { profileId: id })
.orderBy("CASE WHEN education.isEducation = true THEN 1 ELSE 2 END", "ASC")
.addOrderBy("education.level", "ASC")
.getMany();
const educations =
education_raw.length > 0
? education_raw.slice(-2).map((item) => ({
? education_raw.map((item) => ({
institute: item.institute,
start:
item.startDate == null
? ""
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
end:
item.endDate == null
? ""
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: "",
level: item.educationLevel ?? "",
date:
item.isDate
? item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: ""
: item.startDate && item.endDate
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
: "",
degree: item.degree ? `${item.degree} ${item.field ? item.field : ""}` : "",
field: item.field ?? "-",
}))
: [
{
institute: "-",
start: "-",
end: "-",
date: "-",
level: "-",
degree: "-",
field: "-",
},
];
const salary_raw = await this.salaryRepo.find({
select: [
"commandDateAffect",
"positionName",
"posNoAbb",
"posNo",
"positionType",
"positionLevel",
@ -1207,7 +1186,9 @@ export class ProfileController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect))
: null,
position: item.positionName != null ? Extension.ToThaiNumber(item.positionName) : null,
posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null,
posNo: item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`)
: null,
salary:
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
@ -1447,10 +1428,8 @@ export class ProfileController extends Controller {
commandDateSign: item.commandDateSign
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign))
: "",
posNo: item.posNoAbb
? Extension.ToThaiNumber(item.posNoAbb)
: "" + item.posNo
? Extension.ToThaiNumber(item.posNo)
posNo: item.posNoAbb && item.posNo
? Extension.ToThaiNumber(`${item.posNoAbb}${item.posNo}`)
: "",
position: item.positionName,
posType: item.positionType,
@ -1676,6 +1655,9 @@ export class ProfileController extends Controller {
appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
positionDate: positionList.length > 0
? positionList[positionList.length-1].commandDateAffect
: "",
citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName:

View file

@ -27,6 +27,7 @@ import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
import { Command } from "../entities/Command";
@Route("api/v1/org/profile/salary")
@Tags("ProfileSalary")
@Security("bearerAuth")
@ -39,6 +40,7 @@ export class ProfileSalaryController extends Controller {
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
private commandRepository = AppDataSource.getRepository(Command);
@Get("TenurePositionOfficer")
public async cronjobTenurePositionOfficer() {
@ -671,8 +673,24 @@ export class ProfileSalaryController extends Controller {
order: { order: "DESC" },
});
const before = null;
let _posNumCodeSit: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepo.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,

View file

@ -26,6 +26,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
import { In, LessThan, MoreThan } from "typeorm";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
import { Command } from "../entities/Command";
@Route("api/v1/org/profile-employee/salary")
@Tags("ProfileSalary")
@Security("bearerAuth")
@ -33,6 +34,7 @@ export class ProfileSalaryEmployeeController extends Controller {
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
private commandRepository = AppDataSource.getRepository(Command);
@Get("user")
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
@ -353,8 +355,24 @@ export class ProfileSalaryEmployeeController extends Controller {
order: { order: "DESC" },
});
const before = null;
let _posNumCodeSit: string = ""
const _command = await this.commandRepository.findOne({
where: { id: body.commandId ?? "" }
});
if (_command) {
if (_command?.isBangkok == "OFFICE") _posNumCodeSit = "สำนักปลัดกรุงเทพมหานคร"
else if (_command?.isBangkok == "BANGKOK") _posNumCodeSit = "กรุงเทพมหานคร"
else {
let _profileAdmin = await this.profileRepo.findOne({
where: { keycloak: _command?.createdUserId.toString()},
relations: ["current_holders", "current_holders.orgRoot",]
});
_posNumCodeSit = _profileAdmin?.current_holders
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
}
}
const data = new ProfileSalary();
data.posNumCodeSit = _posNumCodeSit;
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,
createdUserId: req.user.sub,

View file

@ -212,6 +212,22 @@ export class ProfileSalaryHistory extends EntityBase {
})
commandId: string;
@Column({
nullable: true,
length: 255,
comment: "หน่วยงานที่ออกคำสั่ง",
default: null,
})
posNumCodeSit: string;
@Column({
nullable: true,
length: 255,
comment: "หน่วยงานที่ออกคำสั่ง(ตัวย่อ)",
default: null,
})
posNumCodeSitAbb: string;
@ManyToOne(() => Command, (command) => command.profileSalaryHistorys)
@JoinColumn({ name: "commandId" })
command: Command;

File diff suppressed because one or more lines are too long