api list รายชื่อตามสิทธิ์ admin ปรับ order & แก้ของลูกจ้าง
This commit is contained in:
parent
4fdd5e7d7d
commit
9cda6e176e
1 changed files with 125 additions and 29 deletions
|
|
@ -26,6 +26,7 @@ import { Position } from "../entities/Position";
|
||||||
import { Insignia } from "../entities/Insignia";
|
import { Insignia } from "../entities/Insignia";
|
||||||
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
|
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
import { calculateRetireLaw } from "../interfaces/utils";
|
import { calculateRetireLaw } from "../interfaces/utils";
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
|
|
@ -44,6 +45,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||||
private positionRepository = AppDataSource.getRepository(Position);
|
private positionRepository = AppDataSource.getRepository(Position);
|
||||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||||
|
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||||
|
|
||||||
|
|
@ -4164,7 +4166,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}
|
}
|
||||||
} else if (body.role === "ROOT") {
|
} else if (body.role === "ROOT") {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId
|
orgRoot: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
};
|
};
|
||||||
} else if (body.role === "NORMAL") {
|
} else if (body.role === "NORMAL") {
|
||||||
switch (node) {
|
switch (node) {
|
||||||
|
|
@ -4225,6 +4229,26 @@ export class OrganizationDotnetController extends Controller {
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
],
|
],
|
||||||
|
order: {
|
||||||
|
current_holders: {
|
||||||
|
orgRoot: {
|
||||||
|
orgRootOrder: "ASC",
|
||||||
|
},
|
||||||
|
orgChild1: {
|
||||||
|
orgChild1Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild2: {
|
||||||
|
orgChild2Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild3: {
|
||||||
|
orgChild3Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild4: {
|
||||||
|
orgChild4Order: "ASC",
|
||||||
|
},
|
||||||
|
posMasterNo: "ASC",
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (body.isRetirement) {
|
if (body.isRetirement) {
|
||||||
profile = await this.profileRepo.find({
|
profile = await this.profileRepo.find({
|
||||||
|
|
@ -4246,7 +4270,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let findRevision = await this.orgRevisionRepo.findOne({
|
let findRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (body.revisionId) {
|
if (body.revisionId) {
|
||||||
|
|
@ -4285,15 +4309,15 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const Oc =
|
const Oc =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: (node == 4 || node == null) && item.current_holders[0].orgChild4 != null
|
: item.current_holders[0].orgChild4 != null
|
||||||
? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: (node == 3 || node == null) && item.current_holders[0].orgChild3 != null
|
: item.current_holders[0].orgChild3 != null
|
||||||
? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: (node == 2 || node == null) && item.current_holders[0].orgChild2 != null
|
: item.current_holders[0].orgChild2 != null
|
||||||
? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: (node == 1 || node == null) && item.current_holders[0].orgChild1 != null
|
: item.current_holders[0].orgChild1 != null
|
||||||
? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: (node == 0 || node == null) && item.current_holders[0].orgRoot != null
|
: item.current_holders[0].orgRoot != null
|
||||||
? `${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
@ -4659,19 +4683,39 @@ export class OrganizationDotnetController extends Controller {
|
||||||
if (body.role === "OWNER" || body.role === "CHILD") {
|
if (body.role === "OWNER" || body.role === "CHILD") {
|
||||||
switch (node) {
|
switch (node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = { orgRootId: body.nodeId };
|
typeCondition = {
|
||||||
|
orgRoot: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
}
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
typeCondition = { orgChild1Id: body.nodeId };
|
typeCondition = {
|
||||||
|
orgChild1: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
}
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
typeCondition = { orgChild2Id: body.nodeId };
|
typeCondition = {
|
||||||
|
orgChild2: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
}
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
typeCondition = { orgChild3Id: body.nodeId };
|
typeCondition = {
|
||||||
|
orgChild3: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
}
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
typeCondition = { orgChild4Id: body.nodeId };
|
typeCondition = {
|
||||||
|
orgChild4: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
}
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case null:
|
case null:
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
|
|
@ -4682,32 +4726,49 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}
|
}
|
||||||
} else if (body.role === "ROOT") {
|
} else if (body.role === "ROOT") {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId
|
orgRoot: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
};
|
};
|
||||||
} else if (body.role === "NORMAL") {
|
} else if (body.role === "NORMAL") {
|
||||||
switch (node) {
|
switch (node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRoot: {
|
||||||
orgChild1Id: IsNull(),
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
|
orgChild1: IsNull()
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1: {
|
||||||
orgChild2Id: IsNull(),
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
|
orgChild2: IsNull()
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2: {
|
||||||
orgChild3Id: IsNull(),
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
|
orgChild3: IsNull()
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3: {
|
||||||
orgChild4Id: IsNull(),
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
|
orgChild4: IsNull()
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
typeCondition = {
|
||||||
|
orgChild4: {
|
||||||
|
ancestorDNA: body.nodeId
|
||||||
|
},
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -4728,6 +4789,26 @@ export class OrganizationDotnetController extends Controller {
|
||||||
"current_holders.orgChild3",
|
"current_holders.orgChild3",
|
||||||
"current_holders.orgChild4",
|
"current_holders.orgChild4",
|
||||||
],
|
],
|
||||||
|
order: {
|
||||||
|
current_holders: {
|
||||||
|
orgRoot: {
|
||||||
|
orgRootOrder: "ASC",
|
||||||
|
},
|
||||||
|
orgChild1: {
|
||||||
|
orgChild1Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild2: {
|
||||||
|
orgChild2Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild3: {
|
||||||
|
orgChild3Order: "ASC",
|
||||||
|
},
|
||||||
|
orgChild4: {
|
||||||
|
orgChild4Order: "ASC",
|
||||||
|
},
|
||||||
|
posMasterNo: "ASC",
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (body.isRetirement) {
|
if (body.isRetirement) {
|
||||||
profile = await this.profileEmpRepo.find({
|
profile = await this.profileEmpRepo.find({
|
||||||
|
|
@ -4749,7 +4830,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let findRevision = await this.orgRevisionRepo.findOne({
|
let findRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true },
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (body.revisionId) {
|
if (body.revisionId) {
|
||||||
|
|
@ -4759,7 +4840,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile_ = await Promise.all(
|
const profile_ = await Promise.all(
|
||||||
profile.map((item: ProfileEmployee) => {
|
profile.map(async(item: ProfileEmployee) => {
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
|
|
@ -4788,17 +4869,25 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const Oc =
|
const Oc =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
: body.node == 4 && item.current_holders[0].orgChild4 != null
|
: item.current_holders[0].orgChild4 != null
|
||||||
? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: body.node == 3 && item.current_holders[0].orgChild3 != null
|
: item.current_holders[0].orgChild3 != null
|
||||||
? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: body.node == 2 && item.current_holders[0].orgChild2 != null
|
: item.current_holders[0].orgChild2 != null
|
||||||
? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: body.node == 1 && item.current_holders[0].orgChild1 != null
|
: item.current_holders[0].orgChild1 != null
|
||||||
? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: body.node == 0 && item.current_holders[0].orgRoot != null
|
: item.current_holders[0].orgRoot != null
|
||||||
? `${item.current_holders[0].orgRoot.orgRootName}`
|
? `${item.current_holders[0].orgRoot.orgRootName}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
let _posMaster = await this.empPosMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionId: findRevision?.id,
|
||||||
|
current_holderId: item.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
prefix: item.prefix,
|
prefix: item.prefix,
|
||||||
|
|
@ -4808,9 +4897,16 @@ export class OrganizationDotnetController extends Controller {
|
||||||
keycloak: item.keycloak,
|
keycloak: item.keycloak,
|
||||||
posNo: shortName,
|
posNo: shortName,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
positionLevel: item.posLevel?.posLevelName ?? null,
|
positionLevel: item.posType?.posTypeShortName && item.posLevel?.posLevelName
|
||||||
|
? `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`
|
||||||
|
: null,
|
||||||
positionType: item.posType?.posTypeName ?? null,
|
positionType: item.posType?.posTypeName ?? null,
|
||||||
oc: Oc,
|
oc: Oc,
|
||||||
|
orgRootId: _posMaster?.orgRootId,
|
||||||
|
orgChild1Id: _posMaster?.orgChild1Id,
|
||||||
|
orgChild2Id: _posMaster?.orgChild2Id,
|
||||||
|
orgChild3Id: _posMaster?.orgChild3Id,
|
||||||
|
orgChild4Id: _posMaster?.orgChild4Id,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue