Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
b2d8fa6bf8
1 changed files with 506 additions and 193 deletions
|
|
@ -1140,7 +1140,7 @@ export class PositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("summary")
|
@Post("summary")
|
||||||
async PositionSummary(@Body() requestBody: { id: string; type: number }) {
|
async PositionSummary(@Body() requestBody: { id: string; type: number; isNode: boolean }) {
|
||||||
try {
|
try {
|
||||||
let summary: any;
|
let summary: any;
|
||||||
let totalPosition: any;
|
let totalPosition: any;
|
||||||
|
|
@ -1149,6 +1149,7 @@ export class PositionController extends Controller {
|
||||||
let totalPositionNextUse: any;
|
let totalPositionNextUse: any;
|
||||||
let totalPositionNextVacant: any;
|
let totalPositionNextVacant: any;
|
||||||
|
|
||||||
|
if(requestBody.isNode === true){
|
||||||
switch (requestBody.type) {
|
switch (requestBody.type) {
|
||||||
case 0: {
|
case 0: {
|
||||||
const NodeId = await this.posMasterRepository.findOne({
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -1348,6 +1349,318 @@ export class PositionController extends Controller {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (requestBody.type) {
|
||||||
|
case 0: {
|
||||||
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
where: { orgRootId: requestBody.id },
|
||||||
|
});
|
||||||
|
if (!NodeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalPosition = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: requestBody.id,
|
||||||
|
orgChild1Id : IsNull() || "",
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: requestBody.id,
|
||||||
|
orgChild1Id : IsNull() || "",
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: Not(IsNull()) || Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: requestBody.id,
|
||||||
|
orgChild1Id : IsNull() || "",
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: requestBody.id,
|
||||||
|
orgChild1Id : IsNull() || "",
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: Not(IsNull()) || Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: requestBody.id,
|
||||||
|
orgChild1Id : IsNull() || "",
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
where: { orgChild1Id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (!NodeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalPosition = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : requestBody.id,
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : requestBody.id,
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : requestBody.id,
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : requestBody.id,
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : requestBody.id,
|
||||||
|
orgChild2Id : IsNull() || "",
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
where: { orgChild2Id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (!NodeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalPosition = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : requestBody.id,
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : requestBody.id,
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : requestBody.id,
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : requestBody.id,
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : requestBody.id,
|
||||||
|
orgChild3Id : IsNull() || "",
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
where: { orgChild3Id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (!NodeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalPosition = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : requestBody.id,
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : requestBody.id,
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : requestBody.id,
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
current_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : requestBody.id,
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : requestBody.id,
|
||||||
|
orgChild4Id : IsNull() || "",
|
||||||
|
next_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
const NodeId = await this.posMasterRepository.findOne({
|
||||||
|
where: { orgChild4Id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (!NodeId) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalPosition = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild4Id : requestBody.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild4Id : requestBody.id,
|
||||||
|
current_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild4Id : requestBody.id,
|
||||||
|
current_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextUse = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild4Id : requestBody.id,
|
||||||
|
next_holderId: Not(IsNull()) && Not(""),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||||
|
where: {
|
||||||
|
orgRootId: Not(IsNull()) || Not(""),
|
||||||
|
orgChild1Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild2Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild3Id : Not(IsNull()) || Not(""),
|
||||||
|
orgChild4Id : requestBody.id,
|
||||||
|
next_holderId: IsNull() && "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
summary = {
|
summary = {
|
||||||
totalPosition: totalPosition,
|
totalPosition: totalPosition,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue