no message
This commit is contained in:
parent
971c611c5d
commit
1de27691f8
2 changed files with 416 additions and 79 deletions
|
|
@ -685,18 +685,29 @@ export class PositionController extends Controller {
|
|||
select: ["posMasterId"],
|
||||
});
|
||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||
// let keywordAsInt: any;
|
||||
// keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
|
||||
// if (isNaN(keywordAsInt)) {
|
||||
// keywordAsInt = "";
|
||||
// }
|
||||
let keywordAsInt: any;
|
||||
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
|
||||
if (isNaN(keywordAsInt)) {
|
||||
keywordAsInt = "";
|
||||
}
|
||||
masterId = [...new Set(masterId)];
|
||||
const posMaster = await this.posMasterRepository.find({
|
||||
where: {
|
||||
...typeCondition,
|
||||
...checkChildConditions,
|
||||
// posMasterNo: Like(`%${keywordAsInt}%`),
|
||||
id: In(masterId),
|
||||
},
|
||||
where: [
|
||||
{
|
||||
...checkChildConditions,
|
||||
...typeCondition,
|
||||
},
|
||||
{
|
||||
...checkChildConditions,
|
||||
...typeCondition,
|
||||
id: In(masterId),
|
||||
},
|
||||
{
|
||||
...checkChildConditions,
|
||||
...typeCondition,
|
||||
posMasterNo: Like(`%${keywordAsInt}%`),
|
||||
},
|
||||
],
|
||||
order: { posMasterOrder: "ASC" },
|
||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
|
||||
skip: (body.page - 1) * body.pageSize,
|
||||
|
|
@ -715,6 +726,11 @@ export class PositionController extends Controller {
|
|||
|
||||
return {
|
||||
id: posMaster.id,
|
||||
orgRootId: posMaster.orgRootId,
|
||||
orgChild1Id: posMaster.orgChild1Id,
|
||||
orgChild2Id: posMaster.orgChild2Id,
|
||||
orgChild3Id: posMaster.orgChild3Id,
|
||||
orgChild4Id: posMaster.orgChild4Id,
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
|
|
@ -1052,11 +1068,8 @@ export class PositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("summary")
|
||||
async PositionSummary(
|
||||
@Body() requestBody: { id: string; type: number },
|
||||
) {
|
||||
async PositionSummary(@Body() requestBody: { id: string; type: number }) {
|
||||
try {
|
||||
|
||||
let summary: any;
|
||||
let totalPosition: any;
|
||||
let totalPositionCurrentUse: any;
|
||||
|
|
@ -1064,34 +1077,39 @@ export class PositionController extends Controller {
|
|||
let totalPositionNextUse: any;
|
||||
let totalPositionNextVacant: any;
|
||||
|
||||
switch(requestBody.type){
|
||||
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({
|
||||
const NodeId = await this.posMasterRepository.findOne({
|
||||
where: { orgRootId: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
if (!NodeId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id,
|
||||
);
|
||||
}
|
||||
totalPosition = await this.posMasterRepository.count({
|
||||
where: { orgRootId: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
profileIdCurrentHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
profileIdCurrentHolder: IsNull() && "",
|
||||
},
|
||||
});
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
profileIdNextHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
profileIdNextHolder: IsNull() && "",
|
||||
|
|
@ -1100,32 +1118,37 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
case 1: {
|
||||
const NodeId = await this.posMasterRepository.findOne({where: {orgChild1Id: requestBody.id}});
|
||||
if(!NodeId){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id);
|
||||
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: { orgChild1Id: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
profileIdCurrentHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
profileIdCurrentHolder: IsNull() && "",
|
||||
},
|
||||
});
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
profileIdNextHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
profileIdNextHolder: IsNull() && "",
|
||||
|
|
@ -1134,32 +1157,37 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
case 2: {
|
||||
const NodeId = await this.posMasterRepository.findOne({where: {orgChild2Id: requestBody.id}});
|
||||
if(!NodeId){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id);
|
||||
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: { orgChild2Id: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
profileIdCurrentHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
profileIdCurrentHolder: IsNull() && "",
|
||||
},
|
||||
});
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
profileIdNextHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
profileIdNextHolder: IsNull() && "",
|
||||
|
|
@ -1168,32 +1196,37 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
case 3: {
|
||||
const NodeId = await this.posMasterRepository.findOne({where: {orgChild3Id: requestBody.id}});
|
||||
if(!NodeId){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id);
|
||||
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: { orgChild3Id: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
profileIdCurrentHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
profileIdCurrentHolder: IsNull() && "",
|
||||
},
|
||||
});
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
profileIdNextHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
profileIdNextHolder: IsNull() && "",
|
||||
|
|
@ -1202,32 +1235,37 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
case 4: {
|
||||
const NodeId = await this.posMasterRepository.findOne({where: {orgChild4Id: requestBody.id}});
|
||||
if(!NodeId){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตามไอดีนี้ : " + requestBody.id);
|
||||
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: { orgChild4Id: requestBody.id },
|
||||
});
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
totalPositionCurrentUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
profileIdCurrentHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
totalPositionCurrentVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
profileIdCurrentHolder: IsNull() && "",
|
||||
},
|
||||
});
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
totalPositionNextUse = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
profileIdNextHolder: Not(IsNull()) && Not(""),
|
||||
},
|
||||
});
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
totalPositionNextVacant = await this.posMasterRepository.count({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
profileIdNextHolder: IsNull() && "",
|
||||
|
|
@ -1239,15 +1277,14 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
summary = {
|
||||
summary = {
|
||||
totalPosition: totalPosition,
|
||||
totalPositionCurrentUse: totalPositionCurrentUse,
|
||||
totalPositionCurrentVacant: totalPositionCurrentVacant,
|
||||
totalPositionNextUse: totalPositionNextUse,
|
||||
totalPositionNextVacant: totalPositionNextVacant
|
||||
}
|
||||
totalPositionNextVacant: totalPositionNextVacant,
|
||||
};
|
||||
return new HttpSuccess(summary);
|
||||
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue