fix report & find commander

This commit is contained in:
Bright 2025-01-31 16:20:08 +07:00
parent 38bb51f491
commit 94eb53bcc9
2 changed files with 11 additions and 4 deletions

View file

@ -1152,9 +1152,11 @@ export class ProfileController extends Controller {
const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub },
});
const posMaster = await this.posMasterRepo.findOne({
where: { current_holderId: profile?.id },
where: {
current_holderId: profile?.id,
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
});
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
const orgRoot = posMaster.orgRootId;
@ -1870,7 +1872,10 @@ export class ProfileController extends Controller {
});
const posMaster = await this.posMasterRepo.findOne({
where: { current_holderId: profile?.id },
where: {
current_holderId: profile?.id,
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
});
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
const orgRoot = posMaster.orgRootId;

View file

@ -6603,6 +6603,7 @@ export class ReportController extends Controller {
typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""),
level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","),
levelRank: [...new Set(x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`))].join(""),
positions: [...new Set(x.positions.flatMap((y) => y.positionName))].join(""),
}))
const groupedData = _posMaster.reduce((acc:any, curr:any) => {
@ -6621,8 +6622,9 @@ export class ReportController extends Controller {
typeRank: parseInt(x.typeRank),
level: x.level,
levelRank: parseInt(x.levelRank),
total: x.total,
remark: "",
remark: x.positions,
}))
.sort((x, y) => {
if (x.typeRank !== y.typeRank) {