แก้api clone org
This commit is contained in:
parent
b2d8fa6bf8
commit
0819836932
2 changed files with 523 additions and 520 deletions
|
|
@ -139,7 +139,7 @@ export class OrganizationController extends Controller {
|
|||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG"
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
if (requestBody.orgRevisionId == null)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
|
|
@ -148,12 +148,12 @@ export class OrganizationController extends Controller {
|
|||
});
|
||||
if (!_revision) throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
|
||||
let positions: Position[] = [];
|
||||
//clone data
|
||||
const orgRoot = await this.orgRootRepository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
const _orgRoot = orgRoot.map((x) => ({
|
||||
let _orgRoot: any = orgRoot.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
|
|
@ -162,23 +162,75 @@ export class OrganizationController extends Controller {
|
|||
}));
|
||||
await this.orgRootRepository.save(_orgRoot);
|
||||
|
||||
_orgRoot.forEach(async (x: any) => {
|
||||
var dataId = x.id;
|
||||
//clone data
|
||||
const orgChild1 = await this.child1Repository.find({
|
||||
where: { orgRootId: dataId, orgRevisionId: requestBody.orgRevisionId },
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
const orgChild1 = await this.child1Repository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
});
|
||||
let _orgChild1: any = orgChild1.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child1Repository.save(_orgChild1);
|
||||
|
||||
const _orgChild1 = orgChild1.map((x) => ({
|
||||
const orgChild2 = await this.child2Repository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
});
|
||||
let _orgChild2: any = orgChild2.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child2Repository.save(_orgChild2);
|
||||
|
||||
const orgChild3 = await this.child3Repository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
});
|
||||
let _orgChild3: any = orgChild3.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child3Repository.save(_orgChild3);
|
||||
|
||||
const orgChild4 = await this.child4Repository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
});
|
||||
let _orgChild4: any = orgChild4.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child4Repository.save(_orgChild4);
|
||||
|
||||
const orgPosMaster = await this.posMasterRepository.find({
|
||||
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||
relations: ["positions"],
|
||||
});
|
||||
let _orgPosMaster: PosMaster[];
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
_orgPosMaster = orgPosMaster.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child1Repository.save(_orgChild1);
|
||||
await this.posMasterRepository.save(_orgPosMaster);
|
||||
}
|
||||
|
||||
_orgRoot.forEach(async (x: any) => {
|
||||
var dataId = x.id;
|
||||
delete x.id;
|
||||
const data = Object.assign(new OrgRoot(), x);
|
||||
data.orgRevisionId = revision.id;
|
||||
|
|
@ -189,36 +241,28 @@ export class OrganizationController extends Controller {
|
|||
data.lastUpdateFullName = request.user.name;
|
||||
data.lastUpdatedAt = new Date();
|
||||
await this.orgRootRepository.save(data);
|
||||
if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
const _posMaster = x.posMasters.map((item: any) => ({
|
||||
...item,
|
||||
ancestorDNA:
|
||||
item.ancestorDNA == null ||
|
||||
item.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? item.id
|
||||
: item.ancestorDNA,
|
||||
}));
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
await Promise.all(
|
||||
x.posMasters.map(async (item: any) => {
|
||||
var masterId = x.id;
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
_orgPosMaster
|
||||
.filter((x: PosMaster) => x.orgRootId == dataId && x.orgChild1Id == null)
|
||||
.map(async (item: any) => {
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.positions = [];
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: masterId },
|
||||
});
|
||||
await Promise.all(
|
||||
positions.map(async (pos: any) => {
|
||||
item.positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
|
|
@ -228,158 +272,51 @@ export class OrganizationController extends Controller {
|
|||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
// positions.push(position);
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
_orgChild1.forEach(async (x: any) => {
|
||||
var data1Id = x.id;
|
||||
//clone data
|
||||
const orgChild2 = await this.child2Repository.find({
|
||||
where: {
|
||||
orgRootId: dataId,
|
||||
orgChild1Id: data1Id,
|
||||
orgRevisionId: requestBody.orgRevisionId,
|
||||
},
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
const _orgChild2 = orgChild2.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child2Repository.save(_orgChild2);
|
||||
|
||||
delete x.id;
|
||||
const data1 = Object.assign(new OrgChild1(), x);
|
||||
data1.orgRootId = data.id;
|
||||
data1.orgRevisionId = revision.id;
|
||||
data1.createdUserId = request.user.sub;
|
||||
data1.createdFullName = request.user.name;
|
||||
data1.createdAt = new Date();
|
||||
data1.lastUpdateUserId = request.user.sub;
|
||||
data1.lastUpdateFullName = request.user.name;
|
||||
data1.lastUpdatedAt = new Date();
|
||||
await this.child1Repository.save(data1);
|
||||
if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
const _posMaster = x.posMasters.map((item: any) => ({
|
||||
...item,
|
||||
ancestorDNA:
|
||||
item.ancestorDNA == null ||
|
||||
item.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? item.id
|
||||
: item.ancestorDNA,
|
||||
}));
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
await Promise.all(
|
||||
x.posMasters.map(async (item: any) => {
|
||||
var masterId = x.id;
|
||||
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: masterId },
|
||||
});
|
||||
await Promise.all(
|
||||
positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
_orgChild2.forEach(async (x: any) => {
|
||||
var data2Id = x.id;
|
||||
//clone data
|
||||
const orgChild3 = await this.child3Repository.find({
|
||||
where: {
|
||||
orgRootId: dataId,
|
||||
orgChild1Id: data1Id,
|
||||
orgChild2Id: data2Id,
|
||||
orgRevisionId: requestBody.orgRevisionId,
|
||||
},
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
const _orgChild3 = orgChild3.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child3Repository.save(_orgChild3);
|
||||
|
||||
_orgChild1
|
||||
.filter((x: OrgChild1) => x.orgRootId == dataId)
|
||||
.forEach(async (x: any) => {
|
||||
var data1Id = x.id;
|
||||
delete x.id;
|
||||
const data2 = Object.assign(new OrgChild2(), x);
|
||||
data2.orgChild1Id = data1.id;
|
||||
data2.orgRootId = data.id;
|
||||
data2.orgRevisionId = revision.id;
|
||||
data2.createdUserId = request.user.sub;
|
||||
data2.createdFullName = request.user.name;
|
||||
data2.createdAt = new Date();
|
||||
data2.lastUpdateUserId = request.user.sub;
|
||||
data2.lastUpdateFullName = request.user.name;
|
||||
data2.lastUpdatedAt = new Date();
|
||||
await this.child2Repository.save(data2);
|
||||
if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
const _posMaster = x.posMasters.map((item: any) => ({
|
||||
...item,
|
||||
ancestorDNA:
|
||||
item.ancestorDNA == null ||
|
||||
item.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? item.id
|
||||
: item.ancestorDNA,
|
||||
}));
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
const data1 = Object.assign(new OrgChild1(), x);
|
||||
data1.orgRootId = data.id;
|
||||
data1.orgRevisionId = revision.id;
|
||||
data1.createdUserId = request.user.sub;
|
||||
data1.createdFullName = request.user.name;
|
||||
data1.createdAt = new Date();
|
||||
data1.lastUpdateUserId = request.user.sub;
|
||||
data1.lastUpdateFullName = request.user.name;
|
||||
data1.lastUpdatedAt = new Date();
|
||||
await this.child1Repository.save(data1);
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
await Promise.all(
|
||||
x.posMasters.map(async (item: any) => {
|
||||
var masterId = x.id;
|
||||
_orgPosMaster
|
||||
.filter((x: PosMaster) => x.orgChild1Id == data1Id && x.orgChild2Id == null)
|
||||
.map(async (item: any) => {
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.positions = [];
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: masterId },
|
||||
});
|
||||
await Promise.all(
|
||||
positions.map(async (pos: any) => {
|
||||
item.positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
|
|
@ -389,148 +326,53 @@ export class OrganizationController extends Controller {
|
|||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
// positions.push(position);
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
_orgChild3.forEach(async (x: any) => {
|
||||
var data3Id = x.id;
|
||||
//clone data
|
||||
const orgChild4 = await this.child4Repository.find({
|
||||
where: {
|
||||
orgRootId: dataId,
|
||||
orgChild1Id: data1Id,
|
||||
orgChild2Id: data2Id,
|
||||
orgChild3Id: data3Id,
|
||||
orgRevisionId: requestBody.orgRevisionId,
|
||||
},
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
const _orgChild4 = orgChild4.map((x) => ({
|
||||
...x,
|
||||
ancestorDNA:
|
||||
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? x.id
|
||||
: x.ancestorDNA,
|
||||
}));
|
||||
await this.child4Repository.save(_orgChild4);
|
||||
|
||||
delete x.id;
|
||||
const data3 = Object.assign(new OrgChild3(), x);
|
||||
data3.orgChild2Id = data2.id;
|
||||
data3.orgChild1Id = data1.id;
|
||||
data3.orgRootId = data.id;
|
||||
data3.orgRevisionId = revision.id;
|
||||
data3.createdUserId = request.user.sub;
|
||||
data3.createdFullName = request.user.name;
|
||||
data3.createdAt = new Date();
|
||||
data3.lastUpdateUserId = request.user.sub;
|
||||
data3.lastUpdateFullName = request.user.name;
|
||||
data3.lastUpdatedAt = new Date();
|
||||
await this.child3Repository.save(data3);
|
||||
if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
const _posMaster = x.posMasters.map((item: any) => ({
|
||||
...item,
|
||||
ancestorDNA:
|
||||
item.ancestorDNA == null ||
|
||||
item.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? item.id
|
||||
: item.ancestorDNA,
|
||||
}));
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
await Promise.all(
|
||||
x.posMasters.map(async (item: any) => {
|
||||
var masterId = x.id;
|
||||
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.orgChild3Id = data3.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: masterId },
|
||||
});
|
||||
await Promise.all(
|
||||
positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
_orgChild4.forEach(async (x: any) => {
|
||||
_orgChild2
|
||||
.filter((x: OrgChild2) => x.orgChild1Id == data1Id)
|
||||
.forEach(async (x: any) => {
|
||||
var data2Id = x.id;
|
||||
delete x.id;
|
||||
const data4 = Object.assign(new OrgChild4(), x);
|
||||
data4.orgChild3Id = data3.id;
|
||||
data4.orgChild2Id = data2.id;
|
||||
data4.orgChild1Id = data1.id;
|
||||
data4.orgRootId = data.id;
|
||||
data4.orgRevisionId = revision.id;
|
||||
data4.createdUserId = request.user.sub;
|
||||
data4.createdFullName = request.user.name;
|
||||
data4.createdAt = new Date();
|
||||
data4.lastUpdateUserId = request.user.sub;
|
||||
data4.lastUpdateFullName = request.user.name;
|
||||
data4.lastUpdatedAt = new Date();
|
||||
await this.child4Repository.save(data4);
|
||||
if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
const _posMaster = x.posMasters.map((item: any) => ({
|
||||
...item,
|
||||
ancestorDNA:
|
||||
item.ancestorDNA == null ||
|
||||
item.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||
? item.id
|
||||
: item.ancestorDNA,
|
||||
}));
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
const data2 = Object.assign(new OrgChild2(), x);
|
||||
data2.orgChild1Id = data1.id;
|
||||
data2.orgRootId = data.id;
|
||||
data2.orgRevisionId = revision.id;
|
||||
data2.createdUserId = request.user.sub;
|
||||
data2.createdFullName = request.user.name;
|
||||
data2.createdAt = new Date();
|
||||
data2.lastUpdateUserId = request.user.sub;
|
||||
data2.lastUpdateFullName = request.user.name;
|
||||
data2.lastUpdatedAt = new Date();
|
||||
await this.child2Repository.save(data2);
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
await Promise.all(
|
||||
x.posMasters.map(async (item: any) => {
|
||||
var masterId = x.id;
|
||||
_orgPosMaster
|
||||
.filter((x: PosMaster) => x.orgChild2Id == data2Id && x.orgChild3Id == null)
|
||||
.map(async (item: any) => {
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.positions = [];
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.orgChild3Id = data3.id;
|
||||
posMaster.orgChild4Id = data4.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: { posMasterId: masterId },
|
||||
});
|
||||
await Promise.all(
|
||||
positions.map(async (pos: any) => {
|
||||
item.positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
|
|
@ -540,39 +382,157 @@ export class OrganizationController extends Controller {
|
|||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
// positions.push(position);
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// else if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION") {
|
||||
// } else if (requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON") {
|
||||
// }
|
||||
|
||||
const orgRevisions = await this.orgRevisionRepository.find({
|
||||
_orgChild3
|
||||
.filter((x: OrgChild3) => x.orgChild2Id == data2Id)
|
||||
.forEach(async (x: any) => {
|
||||
var data3Id = x.id;
|
||||
delete x.id;
|
||||
const data3 = Object.assign(new OrgChild3(), x);
|
||||
data3.orgChild2Id = data2.id;
|
||||
data3.orgChild1Id = data1.id;
|
||||
data3.orgRootId = data.id;
|
||||
data3.orgRevisionId = revision.id;
|
||||
data3.createdUserId = request.user.sub;
|
||||
data3.createdFullName = request.user.name;
|
||||
data3.createdAt = new Date();
|
||||
data3.lastUpdateUserId = request.user.sub;
|
||||
data3.lastUpdateFullName = request.user.name;
|
||||
data3.lastUpdatedAt = new Date();
|
||||
await this.child3Repository.save(data3);
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
await Promise.all(
|
||||
_orgPosMaster
|
||||
.filter(
|
||||
(x: PosMaster) => x.orgChild3Id == data3Id && x.orgChild4Id == null,
|
||||
)
|
||||
.map(async (item: any) => {
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.positions = [];
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.orgChild3Id = data3.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
item.positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
// positions.push(position);
|
||||
await this.positionRepository.save(position);
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
_orgChild4
|
||||
.filter((x: OrgChild4) => x.orgChild3Id == data3Id)
|
||||
.forEach(async (x: any) => {
|
||||
var data4Id = x.id;
|
||||
delete x.id;
|
||||
const data4 = Object.assign(new OrgChild4(), x);
|
||||
data4.orgChild3Id = data3.id;
|
||||
data4.orgChild2Id = data2.id;
|
||||
data4.orgChild1Id = data1.id;
|
||||
data4.orgRootId = data.id;
|
||||
data4.orgRevisionId = revision.id;
|
||||
data4.createdUserId = request.user.sub;
|
||||
data4.createdFullName = request.user.name;
|
||||
data4.createdAt = new Date();
|
||||
data4.lastUpdateUserId = request.user.sub;
|
||||
data4.lastUpdateFullName = request.user.name;
|
||||
data4.lastUpdatedAt = new Date();
|
||||
await this.child4Repository.save(data4);
|
||||
if (
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON"
|
||||
) {
|
||||
await Promise.all(
|
||||
_orgPosMaster
|
||||
.filter((x: PosMaster) => x.orgChild4Id == data4Id)
|
||||
.map(async (item: any) => {
|
||||
delete item.id;
|
||||
const posMaster = Object.assign(new PosMaster(), item);
|
||||
posMaster.positions = [];
|
||||
posMaster.orgRevisionId = revision.id;
|
||||
posMaster.orgRootId = data.id;
|
||||
posMaster.orgChild1Id = data1.id;
|
||||
posMaster.orgChild2Id = data2.id;
|
||||
posMaster.orgChild3Id = data3.id;
|
||||
posMaster.orgChild4Id = data4.id;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
item.positions.map(async (pos: any) => {
|
||||
delete pos.id;
|
||||
const position = Object.assign(new Position(), pos);
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
// positions.push(position);
|
||||
await this.positionRepository.save(position);
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// await this.positionRepository.save(positions);
|
||||
}
|
||||
|
||||
const _orgRevisions = await this.orgRevisionRepository.find({
|
||||
where: [{ orgRevisionIsDraft: true, id: Not(revision.id) }],
|
||||
});
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: [{ orgRevisionId: In(orgRevisions.map((x) => x.id)) }],
|
||||
const _posMasters = await this.posMasterRepository.find({
|
||||
where: [{ orgRevisionId: In(_orgRevisions.map((x) => x.id)) }],
|
||||
});
|
||||
const positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
|
||||
const _positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(_posMasters.map((x) => x.id)) }],
|
||||
});
|
||||
await this.positionRepository.remove(positions);
|
||||
await this.posMasterRepository.remove(posMasters);
|
||||
await this.child4Repository.delete({ orgRevisionId: In(orgRevisions.map((x) => x.id)) });
|
||||
await this.child3Repository.delete({ orgRevisionId: In(orgRevisions.map((x) => x.id)) });
|
||||
await this.child2Repository.delete({ orgRevisionId: In(orgRevisions.map((x) => x.id)) });
|
||||
await this.child1Repository.delete({ orgRevisionId: In(orgRevisions.map((x) => x.id)) });
|
||||
await this.orgRootRepository.delete({ orgRevisionId: In(orgRevisions.map((x) => x.id)) });
|
||||
await this.orgRevisionRepository.remove(orgRevisions);
|
||||
await this.positionRepository.remove(_positions);
|
||||
await this.posMasterRepository.remove(_posMasters);
|
||||
await this.child4Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await this.child3Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await this.child2Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await this.child1Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await this.orgRootRepository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await this.orgRevisionRepository.remove(_orgRevisions);
|
||||
|
||||
return new HttpSuccess(revision);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -246,12 +246,26 @@ export class ReportController extends Controller {
|
|||
.map(async (posMaster) => {
|
||||
if (posMaster.orgChild1 == null) {
|
||||
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
||||
const posType = [...new Set(posMaster.positions.map((x) => x.posType.posTypeName))];
|
||||
const posType = [
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
const posLevel = [
|
||||
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
const posExecutive = [
|
||||
...new Set(posMaster.positions.map((x) => x.posExecutive.posExecutiveName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
let positionMasterProfileOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
|
|
@ -275,16 +289,24 @@ export class ReportController extends Controller {
|
|||
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
||||
];
|
||||
profilePosType = [
|
||||
...new Set(positionMasterOld.positions.map((x: any) => x.posType.posTypeName)),
|
||||
...new Set(
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x: any) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
profilePosLevel = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posLevel.posLevelName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x: any) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
profilePosExecutive = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
@ -299,14 +321,15 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? positionName.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.positionName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.positionName
|
||||
: posMaster.next_holder.position,
|
||||
posType:
|
||||
posMaster.next_holder == null
|
||||
? posType.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
|
||||
?.posTypeName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posType?.posTypeName
|
||||
: posMaster.next_holder.posType == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posType.posTypeName,
|
||||
|
|
@ -314,8 +337,8 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posLevel.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
|
||||
?.posLevelName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posLevel?.posLevelName
|
||||
: posMaster.next_holder.posLevel == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posLevel.posLevelName,
|
||||
|
|
@ -323,12 +346,13 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posExecutive.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
|
||||
?.posExecutiveName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posExecutive?.posExecutiveName
|
||||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find((x: any) => (x.isSit = true))
|
||||
?.posExecutive?.posExecutiveName,
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
|
||||
profileOrgName:
|
||||
posMaster.next_holder == null
|
||||
|
|
@ -404,7 +428,7 @@ export class ReportController extends Controller {
|
|||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.positionIsSelected = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
};
|
||||
if (_node == null) {
|
||||
|
|
@ -469,28 +493,20 @@ export class ReportController extends Controller {
|
|||
}
|
||||
const head = {
|
||||
no: no,
|
||||
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
|
||||
posMasterNo: node.posMasterNo,
|
||||
profileFullname: node.profileFullname,
|
||||
posExecutive: node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
||||
positionName: node.positionName == _node.positionName ? "" : node.positionName,
|
||||
posType: node.posType == _node.posType ? "" : node.posType,
|
||||
posLevel: node.posLevel == _node.posLevel ? "" : node.posLevel,
|
||||
profilePosMasterNo:
|
||||
node.profilePosMasterNo == _node.profilePosMasterNo
|
||||
? ""
|
||||
: node.profilePosMasterNo,
|
||||
positionName: node.positionName,
|
||||
posType: node.posType,
|
||||
posLevel: node.posLevel,
|
||||
profilePosMasterNo: node.profilePosMasterNo,
|
||||
profilePosExecutive:
|
||||
node.profilePosExecutive == _node.profilePosExecutive
|
||||
? ""
|
||||
: node.profilePosExecutive,
|
||||
profilePositionName:
|
||||
node.profilePositionName == _node.profilePositionName
|
||||
? ""
|
||||
: node.profilePositionName,
|
||||
profilePosType:
|
||||
node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
|
||||
profilePosLevel:
|
||||
node.profilePosLevel == _node.profilePosLevel ? "" : node.profilePosLevel,
|
||||
profilePositionName: node.profilePositionName,
|
||||
profilePosType: node.profilePosType,
|
||||
profilePosLevel: node.profilePosLevel,
|
||||
};
|
||||
data.push(head);
|
||||
}
|
||||
|
|
@ -511,13 +527,25 @@ export class ReportController extends Controller {
|
|||
if (posMaster.orgChild2Id == null) {
|
||||
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
||||
const posType = [
|
||||
...new Set(posMaster.positions.map((x) => x.posType.posTypeName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
const posLevel = [
|
||||
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
const posExecutive = [
|
||||
...new Set(posMaster.positions.map((x) => x.posExecutive.posExecutiveName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
let positionMasterProfileOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
|
|
@ -542,19 +570,23 @@ export class ReportController extends Controller {
|
|||
];
|
||||
profilePosType = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posType.posTypeName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x: any) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
profilePosLevel = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posLevel.posLevelName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x: any) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
profilePosExecutive = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map(
|
||||
(x: any) => x.posExecutive.posExecutiveName,
|
||||
),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
@ -569,14 +601,15 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? positionName.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.positionName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.positionName
|
||||
: posMaster.next_holder.position,
|
||||
posType:
|
||||
posMaster.next_holder == null
|
||||
? posType.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
|
||||
?.posTypeName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posType?.posTypeName
|
||||
: posMaster.next_holder.posType == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posType.posTypeName,
|
||||
|
|
@ -584,8 +617,8 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posLevel.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
|
||||
?.posLevelName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posLevel?.posLevelName
|
||||
: posMaster.next_holder.posLevel == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posLevel.posLevelName,
|
||||
|
|
@ -593,12 +626,13 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posExecutive.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
|
||||
?.posExecutiveName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posExecutive?.posExecutiveName
|
||||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find((x: any) => (x.isSit = true))
|
||||
?.posExecutive?.posExecutiveName,
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
|
||||
profileOrgName:
|
||||
posMaster.next_holder == null
|
||||
|
|
@ -674,7 +708,7 @@ export class ReportController extends Controller {
|
|||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.positionIsSelected = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
};
|
||||
if (_node == null) {
|
||||
|
|
@ -739,30 +773,21 @@ export class ReportController extends Controller {
|
|||
}
|
||||
const head = {
|
||||
no: no,
|
||||
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
|
||||
posMasterNo: node.posMasterNo,
|
||||
profileFullname: node.profileFullname,
|
||||
posExecutive:
|
||||
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
||||
positionName:
|
||||
node.positionName == _node.positionName ? "" : node.positionName,
|
||||
posType: node.posType == _node.posType ? "" : node.posType,
|
||||
posLevel: node.posLevel == _node.posLevel ? "" : node.posLevel,
|
||||
profilePosMasterNo:
|
||||
node.profilePosMasterNo == _node.profilePosMasterNo
|
||||
? ""
|
||||
: node.profilePosMasterNo,
|
||||
positionName: node.positionName,
|
||||
posType: node.posType,
|
||||
posLevel: node.posLevel,
|
||||
profilePosMasterNo: node.profilePosMasterNo,
|
||||
profilePosExecutive:
|
||||
node.profilePosExecutive == _node.profilePosExecutive
|
||||
? ""
|
||||
: node.profilePosExecutive,
|
||||
profilePositionName:
|
||||
node.profilePositionName == _node.profilePositionName
|
||||
? ""
|
||||
: node.profilePositionName,
|
||||
profilePosType:
|
||||
node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
|
||||
profilePosLevel:
|
||||
node.profilePosLevel == _node.profilePosLevel ? "" : node.profilePosLevel,
|
||||
profilePositionName: node.profilePositionName,
|
||||
profilePosType: node.profilePosType,
|
||||
profilePosLevel: node.profilePosLevel,
|
||||
};
|
||||
data.push(head);
|
||||
}
|
||||
|
|
@ -785,13 +810,25 @@ export class ReportController extends Controller {
|
|||
...new Set(posMaster.positions.map((x) => x.positionName)),
|
||||
];
|
||||
const posType = [
|
||||
...new Set(posMaster.positions.map((x) => x.posType.posTypeName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
const posLevel = [
|
||||
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
const posExecutive = [
|
||||
...new Set(posMaster.positions.map((x) => x.posExecutive.posExecutiveName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
let positionMasterProfileOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
|
|
@ -816,19 +853,23 @@ export class ReportController extends Controller {
|
|||
];
|
||||
profilePosType = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posType.posTypeName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x: any) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
profilePosLevel = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posLevel.posLevelName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x: any) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
profilePosExecutive = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map(
|
||||
(x: any) => x.posExecutive.posExecutiveName,
|
||||
),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
@ -843,14 +884,15 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? positionName.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.positionName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.positionName
|
||||
: posMaster.next_holder.position,
|
||||
posType:
|
||||
posMaster.next_holder == null
|
||||
? posType.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
|
||||
?.posTypeName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posType?.posTypeName
|
||||
: posMaster.next_holder.posType == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posType.posTypeName,
|
||||
|
|
@ -858,8 +900,8 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posLevel.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
|
||||
?.posLevelName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posLevel?.posLevelName
|
||||
: posMaster.next_holder.posLevel == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posLevel.posLevelName,
|
||||
|
|
@ -867,12 +909,12 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posExecutive.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
|
||||
?.posExecutiveName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posExecutive?.posExecutiveName
|
||||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.isSit = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
|
||||
profileOrgName:
|
||||
|
|
@ -949,7 +991,7 @@ export class ReportController extends Controller {
|
|||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.positionIsSelected = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
};
|
||||
if (_node == null) {
|
||||
|
|
@ -1015,30 +1057,21 @@ export class ReportController extends Controller {
|
|||
}
|
||||
const head = {
|
||||
no: no,
|
||||
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
|
||||
posMasterNo: node.posMasterNo,
|
||||
profileFullname: node.profileFullname,
|
||||
posExecutive:
|
||||
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
||||
positionName:
|
||||
node.positionName == _node.positionName ? "" : node.positionName,
|
||||
posType: node.posType == _node.posType ? "" : node.posType,
|
||||
posLevel: node.posLevel == _node.posLevel ? "" : node.posLevel,
|
||||
profilePosMasterNo:
|
||||
node.profilePosMasterNo == _node.profilePosMasterNo
|
||||
? ""
|
||||
: node.profilePosMasterNo,
|
||||
positionName: node.positionName,
|
||||
posType: node.posType,
|
||||
posLevel: node.posLevel,
|
||||
profilePosMasterNo: node.profilePosMasterNo,
|
||||
profilePosExecutive:
|
||||
node.profilePosExecutive == _node.profilePosExecutive
|
||||
? ""
|
||||
: node.profilePosExecutive,
|
||||
profilePositionName:
|
||||
node.profilePositionName == _node.profilePositionName
|
||||
? ""
|
||||
: node.profilePositionName,
|
||||
profilePosType:
|
||||
node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
|
||||
profilePosLevel:
|
||||
node.profilePosLevel == _node.profilePosLevel ? "" : node.profilePosLevel,
|
||||
profilePositionName: node.profilePositionName,
|
||||
profilePosType: node.profilePosType,
|
||||
profilePosLevel: node.profilePosLevel,
|
||||
};
|
||||
data.push(head);
|
||||
}
|
||||
|
|
@ -1061,13 +1094,25 @@ export class ReportController extends Controller {
|
|||
...new Set(posMaster.positions.map((x) => x.positionName)),
|
||||
];
|
||||
const posType = [
|
||||
...new Set(posMaster.positions.map((x) => x.posType.posTypeName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
const posLevel = [
|
||||
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
const posExecutive = [
|
||||
...new Set(posMaster.positions.map((x) => x.posExecutive.posExecutiveName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
let positionMasterProfileOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
|
|
@ -1092,19 +1137,23 @@ export class ReportController extends Controller {
|
|||
];
|
||||
profilePosType = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posType.posTypeName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x: any) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
profilePosLevel = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posLevel.posLevelName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x: any) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
profilePosExecutive = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map(
|
||||
(x: any) => x.posExecutive.posExecutiveName,
|
||||
),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
@ -1119,14 +1168,15 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? positionName.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.positionName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.positionName
|
||||
: posMaster.next_holder.position,
|
||||
posType:
|
||||
posMaster.next_holder == null
|
||||
? posType.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
|
||||
?.posTypeName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posType?.posTypeName
|
||||
: posMaster.next_holder.posType == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posType.posTypeName,
|
||||
|
|
@ -1134,8 +1184,8 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posLevel.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
|
||||
?.posLevelName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posLevel?.posLevelName
|
||||
: posMaster.next_holder.posLevel == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posLevel.posLevelName,
|
||||
|
|
@ -1143,12 +1193,12 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posExecutive.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
|
||||
?.posExecutiveName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posExecutive?.posExecutiveName
|
||||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.isSit = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
|
||||
profileOrgName:
|
||||
|
|
@ -1225,7 +1275,7 @@ export class ReportController extends Controller {
|
|||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.positionIsSelected = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
};
|
||||
if (_node == null) {
|
||||
|
|
@ -1293,33 +1343,21 @@ export class ReportController extends Controller {
|
|||
}
|
||||
const head = {
|
||||
no: no,
|
||||
posMasterNo:
|
||||
node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
|
||||
posMasterNo: node.posMasterNo,
|
||||
profileFullname: node.profileFullname,
|
||||
posExecutive:
|
||||
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
||||
positionName:
|
||||
node.positionName == _node.positionName ? "" : node.positionName,
|
||||
posType: node.posType == _node.posType ? "" : node.posType,
|
||||
posLevel: node.posLevel == _node.posLevel ? "" : node.posLevel,
|
||||
profilePosMasterNo:
|
||||
node.profilePosMasterNo == _node.profilePosMasterNo
|
||||
? ""
|
||||
: node.profilePosMasterNo,
|
||||
positionName: node.positionName,
|
||||
posType: node.posType,
|
||||
posLevel: node.posLevel,
|
||||
profilePosMasterNo: node.profilePosMasterNo,
|
||||
profilePosExecutive:
|
||||
node.profilePosExecutive == _node.profilePosExecutive
|
||||
? ""
|
||||
: node.profilePosExecutive,
|
||||
profilePositionName:
|
||||
node.profilePositionName == _node.profilePositionName
|
||||
? ""
|
||||
: node.profilePositionName,
|
||||
profilePosType:
|
||||
node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
|
||||
profilePosLevel:
|
||||
node.profilePosLevel == _node.profilePosLevel
|
||||
? ""
|
||||
: node.profilePosLevel,
|
||||
profilePositionName: node.profilePositionName,
|
||||
profilePosType: node.profilePosType,
|
||||
profilePosLevel: node.profilePosLevel,
|
||||
};
|
||||
data.push(head);
|
||||
}
|
||||
|
|
@ -1341,13 +1379,25 @@ export class ReportController extends Controller {
|
|||
...new Set(posMaster.positions.map((x) => x.positionName)),
|
||||
];
|
||||
const posType = [
|
||||
...new Set(posMaster.positions.map((x) => x.posType.posTypeName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
const posLevel = [
|
||||
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
const posExecutive = [
|
||||
...new Set(posMaster.positions.map((x) => x.posExecutive.posExecutiveName)),
|
||||
...new Set(
|
||||
posMaster.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
let positionMasterProfileOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
|
|
@ -1372,19 +1422,23 @@ export class ReportController extends Controller {
|
|||
];
|
||||
profilePosType = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posType.posTypeName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posType != null)
|
||||
.map((x: any) => x.posType.posTypeName),
|
||||
),
|
||||
];
|
||||
profilePosLevel = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map((x: any) => x.posLevel.posLevelName),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posLevel != null)
|
||||
.map((x: any) => x.posLevel.posLevelName),
|
||||
),
|
||||
];
|
||||
profilePosExecutive = [
|
||||
...new Set(
|
||||
positionMasterOld.positions.map(
|
||||
(x: any) => x.posExecutive.posExecutiveName,
|
||||
),
|
||||
positionMasterOld.positions
|
||||
.filter((x: any) => x.posExecutive != null)
|
||||
.map((x: any) => x.posExecutive.posExecutiveName),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
@ -1399,14 +1453,15 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? positionName.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.positionName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.positionName
|
||||
: posMaster.next_holder.position,
|
||||
posType:
|
||||
posMaster.next_holder == null
|
||||
? posType.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
|
||||
?.posTypeName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posType?.posTypeName
|
||||
: posMaster.next_holder.posType == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posType.posTypeName,
|
||||
|
|
@ -1414,8 +1469,8 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posLevel.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
|
||||
?.posLevelName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posLevel?.posLevelName
|
||||
: posMaster.next_holder.posLevel == null
|
||||
? "-"
|
||||
: posMaster.next_holder.posLevel.posLevelName,
|
||||
|
|
@ -1423,12 +1478,12 @@ export class ReportController extends Controller {
|
|||
posMaster.next_holder == null
|
||||
? posExecutive.join(" หรือ ")
|
||||
: posMaster.isSit == false
|
||||
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
|
||||
?.posExecutiveName
|
||||
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
||||
?.posExecutive?.posExecutiveName
|
||||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.isSit = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
|
||||
profileOrgName:
|
||||
|
|
@ -1505,7 +1560,7 @@ export class ReportController extends Controller {
|
|||
: positionMasterProfileOld == null
|
||||
? "-"
|
||||
: positionMasterProfileOld.positions.find(
|
||||
(x: any) => (x.positionIsSelected = true),
|
||||
(x: any) => x.positionIsSelected == true,
|
||||
)?.posExecutive?.posExecutiveName,
|
||||
};
|
||||
if (_node == null) {
|
||||
|
|
@ -1573,33 +1628,21 @@ export class ReportController extends Controller {
|
|||
}
|
||||
const head = {
|
||||
no: no,
|
||||
posMasterNo:
|
||||
node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
|
||||
posMasterNo: node.posMasterNo,
|
||||
profileFullname: node.profileFullname,
|
||||
posExecutive:
|
||||
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
||||
positionName:
|
||||
node.positionName == _node.positionName ? "" : node.positionName,
|
||||
posType: node.posType == _node.posType ? "" : node.posType,
|
||||
posLevel: node.posLevel == _node.posLevel ? "" : node.posLevel,
|
||||
profilePosMasterNo:
|
||||
node.profilePosMasterNo == _node.profilePosMasterNo
|
||||
? ""
|
||||
: node.profilePosMasterNo,
|
||||
positionName: node.positionName,
|
||||
posType: node.posType,
|
||||
posLevel: node.posLevel,
|
||||
profilePosMasterNo: node.profilePosMasterNo,
|
||||
profilePosExecutive:
|
||||
node.profilePosExecutive == _node.profilePosExecutive
|
||||
? ""
|
||||
: node.profilePosExecutive,
|
||||
profilePositionName:
|
||||
node.profilePositionName == _node.profilePositionName
|
||||
? ""
|
||||
: node.profilePositionName,
|
||||
profilePosType:
|
||||
node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
|
||||
profilePosLevel:
|
||||
node.profilePosLevel == _node.profilePosLevel
|
||||
? ""
|
||||
: node.profilePosLevel,
|
||||
profilePositionName: node.profilePositionName,
|
||||
profilePosType: node.profilePosType,
|
||||
profilePosLevel: node.profilePosLevel,
|
||||
};
|
||||
data.push(head);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue