From b5e534413aa92e10f840cc548ecd38cec5cd2487 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 27 Aug 2025 18:21:04 +0700 Subject: [PATCH] =?UTF-8?q?Job=20insert=20=E0=B8=82=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3&=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87=20#1406?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 2 + src/controllers/ProfileInsigniaController.ts | 3 +- src/controllers/ProfileSalaryController.ts | 47 +++++++++++++++++++- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/app.ts b/src/app.ts index 565cb46f..236fb105 100644 --- a/src/app.ts +++ b/src/app.ts @@ -81,6 +81,8 @@ async function main() { await profileSalaryController.cronjobTenureExecutivePositionOfficer(); await profileSalaryController.cronjobTenurePositionEmployee(); await profileSalaryController.cronjobTenureLevelEmployee(); + await profileSalaryController.Registry(); + await profileSalaryController.RegistryEmployee(); } catch (error) { console.error("Error executing function from controller:", error); } diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index f71f1601..93c792f5 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -326,8 +326,7 @@ export class ProfileInsigniaController extends Controller { child4: x.orgChild4, age: age, amount: x.amount, - remark: x.remark, - commandCode: x.commandCode + remark: x.remark }; }); return new HttpSuccess(mapData); diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index f99c96bd..e40c8b0e 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -33,7 +33,10 @@ import { OrgRoot } from "../entities/OrgRoot"; import { OrgRevision } from "../entities/OrgRevision"; import { Position } from "../entities/Position"; import Extension from "../interfaces/extension"; - +import { viewRegistryOfficer } from "../entities/view/viewRegistryOfficer"; +import { viewRegistryEmployee } from "../entities/view/viewRegistryEmployee"; +import { Registry } from "../entities/Registry"; +import { RegistryEmployee } from "../entities/RegistryEmployee"; @Route("api/v1/org/profile/salary") @Tags("ProfileSalary") @Security("bearerAuth") @@ -51,7 +54,9 @@ export class ProfileSalaryController extends Controller { private orgRootRepository = AppDataSource.getRepository(OrgRoot); private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); private positionRepo = AppDataSource.getRepository(Position); - + private registryRepo = AppDataSource.getRepository(Registry); + private registryEmployeeRepo = AppDataSource.getRepository(RegistryEmployee); + @Get("TenurePositionOfficer") public async cronjobTenurePositionOfficer() { let data: any = []; @@ -332,6 +337,44 @@ export class ProfileSalaryController extends Controller { return new HttpSuccess(); } + @Get("Registry") + public async Registry() { + await this.registryRepo.clear(); + const profile = await this.profileRepo.find(); + for await (const x of profile) { + const _regis = await AppDataSource.getRepository(viewRegistryOfficer) + .createQueryBuilder("registryOfficer") + .where("registryOfficer.profileId IN (:id)", { id: x.id }) + .getMany(); + + const mapData = _regis.map(x => ({ + ...x, + Educations: x.Educations ? JSON.stringify(x.Educations) : "", + })); + await this.registryRepo.save(mapData); + } + return new HttpSuccess(); + } + + @Get("RegistryEmployee") + public async RegistryEmployee() { + await this.registryEmployeeRepo.clear(); + const profileEmp = await this.profileEmployeeRepo.find(); + for await (const x of profileEmp) { + const _regisEmp = await AppDataSource.getRepository(viewRegistryEmployee) + .createQueryBuilder("registryEmployee") + .where("registryEmployee.profileEmployeeId IN (:id)", { id: x.id }) + .getMany(); + + const mapData = _regisEmp.map(x => ({ + ...x, + Educations: x.Educations ? JSON.stringify(x.Educations) : "", + })); + await this.registryEmployeeRepo.save(mapData); + } + return new HttpSuccess(); + } + @Get("user") public async getSalaryUser(@Request() request: { user: Record }) { const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });