บัญชี2 ยังไม่เสร็จ

This commit is contained in:
Kittapath 2024-02-02 15:49:08 +07:00
parent f6bf6ef536
commit a157089097
2 changed files with 116 additions and 21 deletions

View file

@ -725,16 +725,16 @@ export class OrganizationController extends Controller {
where: { orgRootId: orgRoot.id },
}),
totalPositionCurrentUse: await this.posMasterRepository.count({
where: { orgRootId: orgRoot.id, profileIdCurrentHolder: Not(IsNull()) && Not("") },
where: { orgRootId: orgRoot.id, profileIdCurrentHolder: Not(IsNull()) || Not("") },
}),
totalPositionCurrentVacant: await this.posMasterRepository.count({
where: { orgRootId: orgRoot.id, profileIdCurrentHolder: IsNull() && "" },
where: { orgRootId: orgRoot.id, profileIdCurrentHolder: IsNull() || "" },
}),
totalPositionNextUse: await this.posMasterRepository.count({
where: { orgRootId: orgRoot.id, profileIdNextHolder: Not(IsNull()) && Not("") },
where: { orgRootId: orgRoot.id, profileIdNextHolder: Not(IsNull()) || Not("") },
}),
totalPositionNextVacant: await this.posMasterRepository.count({
where: { orgRootId: orgRoot.id, profileIdNextHolder: IsNull() && "" },
where: { orgRootId: orgRoot.id, profileIdNextHolder: IsNull() || "" },
}),
children: await Promise.all(
@ -763,20 +763,20 @@ export class OrganizationController extends Controller {
totalPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgChild1Id: orgChild1.id,
profileIdCurrentHolder: Not(IsNull()) && Not(""),
profileIdCurrentHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionCurrentVacant: await this.posMasterRepository.count({
where: { orgChild1Id: orgChild1.id, profileIdCurrentHolder: IsNull() && "" },
where: { orgChild1Id: orgChild1.id, profileIdCurrentHolder: IsNull() || "" },
}),
totalPositionNextUse: await this.posMasterRepository.count({
where: {
orgChild1Id: orgChild1.id,
profileIdNextHolder: Not(IsNull()) && Not(""),
profileIdNextHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionNextVacant: await this.posMasterRepository.count({
where: { orgChild1Id: orgChild1.id, profileIdNextHolder: IsNull() && "" },
where: { orgChild1Id: orgChild1.id, profileIdNextHolder: IsNull() || "" },
}),
children: await Promise.all(
orgChild2Data
@ -804,23 +804,23 @@ export class OrganizationController extends Controller {
totalPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgChild2Id: orgChild2.id,
profileIdCurrentHolder: Not(IsNull()) && Not(""),
profileIdCurrentHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgChild2Id: orgChild2.id,
profileIdCurrentHolder: IsNull() && "",
profileIdCurrentHolder: IsNull() || "",
},
}),
totalPositionNextUse: await this.posMasterRepository.count({
where: {
orgChild2Id: orgChild2.id,
profileIdNextHolder: Not(IsNull()) && Not(""),
profileIdNextHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionNextVacant: await this.posMasterRepository.count({
where: { orgChild2Id: orgChild2.id, profileIdNextHolder: IsNull() && "" },
where: { orgChild2Id: orgChild2.id, profileIdNextHolder: IsNull() || "" },
}),
children: await Promise.all(
orgChild3Data
@ -848,25 +848,25 @@ export class OrganizationController extends Controller {
totalPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgChild3Id: orgChild3.id,
profileIdCurrentHolder: Not(IsNull()) && Not(""),
profileIdCurrentHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgChild3Id: orgChild3.id,
profileIdCurrentHolder: IsNull() && "",
profileIdCurrentHolder: IsNull() || "",
},
}),
totalPositionNextUse: await this.posMasterRepository.count({
where: {
orgChild3Id: orgChild3.id,
profileIdNextHolder: Not(IsNull()) && Not(""),
profileIdNextHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionNextVacant: await this.posMasterRepository.count({
where: {
orgChild3Id: orgChild3.id,
profileIdNextHolder: IsNull() && "",
profileIdNextHolder: IsNull() || "",
},
}),
children: await Promise.all(
@ -895,26 +895,26 @@ export class OrganizationController extends Controller {
totalPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgChild4Id: orgChild4.id,
profileIdCurrentHolder: Not(IsNull()) && Not(""),
profileIdCurrentHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionCurrentVacant:
await this.posMasterRepository.count({
where: {
orgChild4Id: orgChild4.id,
profileIdCurrentHolder: IsNull() && "",
profileIdCurrentHolder: IsNull() || "",
},
}),
totalPositionNextUse: await this.posMasterRepository.count({
where: {
orgChild4Id: orgChild4.id,
profileIdNextHolder: Not(IsNull()) && Not(""),
profileIdNextHolder: Not(IsNull()) || Not(""),
},
}),
totalPositionNextVacant: await this.posMasterRepository.count({
where: {
orgChild4Id: orgChild4.id,
profileIdNextHolder: IsNull() && "",
profileIdNextHolder: IsNull() || "",
},
}),
})),
@ -1254,7 +1254,7 @@ export class OrganizationController extends Controller {
.createQueryBuilder("orgRevision")
.where("orgRevision.orgRevisionIsDraft = true")
.andWhere("orgRevision.orgRevisionIsCurrent = false")
.andWhere("DATE(orgRevision.orgPublishDate) = :today", { today })
// .andWhere("DATE(orgRevision.orgPublishDate) = :today", { today })
.getOne();
if (!orgRevisionDraft) {
return new HttpSuccess();

View file

@ -0,0 +1,95 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Patch,
Route,
Security,
Tags,
Body,
Path,
Request,
Example,
SuccessResponse,
Response,
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import { PosExecutive } from "../entities/PosExecutive";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import { CreatePosDict, PosDict } from "../entities/PosDict";
import HttpError from "../interfaces/http-error";
import { Equal, ILike, In, IsNull, Like, Not } from "typeorm";
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
import { OrgChild1 } from "../entities/OrgChild1";
import { OrgChild2 } from "../entities/OrgChild2";
import { OrgChild3 } from "../entities/OrgChild3";
import { OrgChild4 } from "../entities/OrgChild4";
import { Position } from "../entities/Position";
import { Brackets } from "typeorm/browser";
@Route("api/v1/org/report")
@Tags("Position")
@Security("bearerAuth")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class ReportController extends Controller {
private posExecutiveRepository = AppDataSource.getRepository(PosExecutive);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
private posDictRepository = AppDataSource.getRepository(PosDict);
private posMasterRepository = AppDataSource.getRepository(PosMaster);
private positionRepository = AppDataSource.getRepository(Position);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
private child2Repository = AppDataSource.getRepository(OrgChild2);
private child3Repository = AppDataSource.getRepository(OrgChild3);
private child4Repository = AppDataSource.getRepository(OrgChild4);
/**
* API
*
* @summary ORG_029 - (ADMIN) #32
*
*/
@Get("position")
async findPosition() {
try {
// const getPosType = await this.posTypeRepository.findOne({
// select: ["id", "posTypeName", "posTypeRank"],
// relations: ["posLevels"],
// where: { id: id },
// });
// if (!getPosType) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
// }
// const mapGetPosType = {
// id: getPosType.id,
// posTypeName: getPosType.posTypeName,
// posTypeRank: getPosType.posTypeRank,
// posLevels: getPosType.posLevels.map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// };
return new HttpSuccess();
} catch (error) {
return error;
}
}
}