fix update prefix and profileId
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m45s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m45s
This commit is contained in:
parent
e4f46a1762
commit
2951630b7b
10 changed files with 201 additions and 69 deletions
|
|
@ -50,8 +50,13 @@ import {
|
|||
getUserByUsername,
|
||||
getRoles,
|
||||
addUserRoles,
|
||||
updateUserAttributes,
|
||||
} from "../keycloak";
|
||||
import { getPositionCountsAggregated, getPositionCount, PositionCountsByNode } from "../services/OrganizationService";
|
||||
import {
|
||||
getPositionCountsAggregated,
|
||||
getPositionCount,
|
||||
PositionCountsByNode,
|
||||
} from "../services/OrganizationService";
|
||||
import {
|
||||
BatchSavePosMasterHistoryOfficer,
|
||||
CreatePosMasterHistoryEmployee,
|
||||
|
|
@ -4688,7 +4693,12 @@ export class OrganizationController extends Controller {
|
|||
case 2: {
|
||||
const data = await this.child1Repository.findOne({
|
||||
where: { id: idNode },
|
||||
relations: ["orgRevision", "orgChild2s", "orgChild2s.orgChild3s", "orgChild2s.orgChild3s.orgChild4s"],
|
||||
relations: [
|
||||
"orgRevision",
|
||||
"orgChild2s",
|
||||
"orgChild2s.orgChild3s",
|
||||
"orgChild2s.orgChild3s.orgChild4s",
|
||||
],
|
||||
});
|
||||
if (!data) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child1Id");
|
||||
|
|
@ -4700,7 +4710,9 @@ export class OrganizationController extends Controller {
|
|||
deptID: data.id,
|
||||
type: 2,
|
||||
totalPositionCount: child1Counts.totalCount,
|
||||
totalPositionVacant: isDraft ? child1Counts.nextVacantCount : child1Counts.currentVacantCount,
|
||||
totalPositionVacant: isDraft
|
||||
? child1Counts.nextVacantCount
|
||||
: child1Counts.currentVacantCount,
|
||||
children: this.buildOrgChild2s(data.orgChild2s, positionCounts, isDraft),
|
||||
};
|
||||
return new HttpSuccess([formattedData]);
|
||||
|
|
@ -4720,7 +4732,9 @@ export class OrganizationController extends Controller {
|
|||
deptID: data.id,
|
||||
type: 3,
|
||||
totalPositionCount: child2Counts.totalCount,
|
||||
totalPositionVacant: isDraft ? child2Counts.nextVacantCount : child2Counts.currentVacantCount,
|
||||
totalPositionVacant: isDraft
|
||||
? child2Counts.nextVacantCount
|
||||
: child2Counts.currentVacantCount,
|
||||
children: this.buildOrgChild3s(data.orgChild3s, positionCounts, isDraft),
|
||||
};
|
||||
return new HttpSuccess([formattedData]);
|
||||
|
|
@ -4740,7 +4754,9 @@ export class OrganizationController extends Controller {
|
|||
deptID: data.id,
|
||||
type: 4,
|
||||
totalPositionCount: child3Counts.totalCount,
|
||||
totalPositionVacant: isDraft ? child3Counts.nextVacantCount : child3Counts.currentVacantCount,
|
||||
totalPositionVacant: isDraft
|
||||
? child3Counts.nextVacantCount
|
||||
: child3Counts.currentVacantCount,
|
||||
children: this.buildOrgChild4s(data.orgChild4s, positionCounts, isDraft),
|
||||
};
|
||||
return new HttpSuccess([formattedData]);
|
||||
|
|
@ -4760,7 +4776,9 @@ export class OrganizationController extends Controller {
|
|||
deptID: data.id,
|
||||
type: 5,
|
||||
totalPositionCount: child4Counts.totalCount,
|
||||
totalPositionVacant: isDraft ? child4Counts.nextVacantCount : child4Counts.currentVacantCount,
|
||||
totalPositionVacant: isDraft
|
||||
? child4Counts.nextVacantCount
|
||||
: child4Counts.currentVacantCount,
|
||||
};
|
||||
return new HttpSuccess([formattedData]);
|
||||
}
|
||||
|
|
@ -8089,7 +8107,12 @@ export class OrganizationController extends Controller {
|
|||
if (_item) {
|
||||
_item.roleKeycloaks = Array.from(new Set([..._item.roleKeycloaks, ...roleKeycloak]));
|
||||
check += 1;
|
||||
await this.profileEmployeeRepo.save(_item);
|
||||
_item = await this.profileEmployeeRepo.save(_item);
|
||||
// update user attribute in keycloak
|
||||
await updateUserAttributes(_item.keycloak, {
|
||||
profileId: [_item.id],
|
||||
prefix: [_item.prefix || ""],
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error processing ${_item.citizenId}:`, error);
|
||||
|
|
@ -9096,7 +9119,7 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
private sumAllVacantCounts(
|
||||
map: Map<string, { currentVacantCount: number; nextVacantCount: number }>,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
): number {
|
||||
let sum = 0;
|
||||
for (const value of map.values()) {
|
||||
|
|
@ -9111,7 +9134,7 @@ export class OrganizationController extends Controller {
|
|||
private buildOrgRoots(
|
||||
orgRoots: OrgRoot[],
|
||||
positionCounts: PositionCountsByNode,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
) {
|
||||
if (!orgRoots) return [];
|
||||
return orgRoots
|
||||
|
|
@ -9135,7 +9158,7 @@ export class OrganizationController extends Controller {
|
|||
private buildOrgChild1s(
|
||||
orgChild1s: OrgChild1[],
|
||||
positionCounts: PositionCountsByNode,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
) {
|
||||
if (!orgChild1s) return [];
|
||||
return orgChild1s
|
||||
|
|
@ -9159,7 +9182,7 @@ export class OrganizationController extends Controller {
|
|||
private buildOrgChild2s(
|
||||
orgChild2s: OrgChild2[],
|
||||
positionCounts: PositionCountsByNode,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
) {
|
||||
if (!orgChild2s) return [];
|
||||
return orgChild2s
|
||||
|
|
@ -9183,7 +9206,7 @@ export class OrganizationController extends Controller {
|
|||
private buildOrgChild3s(
|
||||
orgChild3s: OrgChild3[],
|
||||
positionCounts: PositionCountsByNode,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
) {
|
||||
if (!orgChild3s) return [];
|
||||
return orgChild3s
|
||||
|
|
@ -9207,7 +9230,7 @@ export class OrganizationController extends Controller {
|
|||
private buildOrgChild4s(
|
||||
orgChild4s: OrgChild4[],
|
||||
positionCounts: PositionCountsByNode,
|
||||
isDraft: boolean
|
||||
isDraft: boolean,
|
||||
) {
|
||||
if (!orgChild4s) return [];
|
||||
return orgChild4s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue