fix ข้อมูลตำแหน่ง-เงินเดือน (หน่วยงานที่ออกคำสั่งไม่แสดง) #1394

This commit is contained in:
Bright 2025-04-25 15:06:54 +07:00
parent d4f745c61f
commit 921e23f81a
3 changed files with 245 additions and 9 deletions

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,