From 66a2d998261d4639b422394ac3a53f1bd491f58b Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Tue, 6 May 2025 17:38:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B8=A5?= =?UTF-8?q?=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=9B?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3=20=E0=B8=A5=E0=B8=9A?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B9=82?= =?UTF-8?q?=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 32 +++++++++++++++++++++++++ src/controllers/ImportDataController.ts | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 4ee8c004..6ca63a7e 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -86,6 +86,7 @@ import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHisto import { ProfileFamilyMother } from "../entities/ProfileFamilyMother"; import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory"; import { OrgRoot } from "../entities/OrgRoot"; +import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster"; @Route("api/v1/org/command") @Tags("Command") @Security("bearerAuth") @@ -108,6 +109,7 @@ export class CommandController extends Controller { private posMasterRepository = AppDataSource.getRepository(PosMaster); private positionRepository = AppDataSource.getRepository(Position); private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster); + private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster); private employeePositionRepository = AppDataSource.getRepository(EmployeePosition); private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline); private disciplineHistoryRepository = AppDataSource.getRepository(ProfileDisciplineHistory); @@ -5923,6 +5925,36 @@ export class CommandController extends Controller { if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld); await this.employeePosMasterRepository.save(posMaster); + const clsTempPosmaster = await this.employeeTempPosMasterRepository.find({ + where: { + current_holderId: profile.id, + orgRevisionId: posMaster.orgRevisionId, + }, + }); + + if (clsTempPosmaster.length > 0) { + const clearTempPosmaster = clsTempPosmaster.map((posMasterTemp) => ({ + ...posMasterTemp, + current_holderId: null, + next_holderId: null, + })); + await this.employeeTempPosMasterRepository.save(clearTempPosmaster); + + const checkTempPosition = await this.employeePositionRepository.find({ + where: { + posMasterTempId: In(clearTempPosmaster.map((x) => x.id)), + positionIsSelected: true, + }, + }); + if (checkTempPosition.length > 0) { + const clearTempPosition = checkTempPosition.map((positions) => ({ + ...positions, + positionIsSelected: false, + })); + await this.employeePositionRepository.save(clearTempPosition); + } + } + const positionNew = await this.employeePositionRepository.findOne({ where: { id: profile.positionIdTemp, diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index c8ea9bbf..ccaefbf2 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -3272,12 +3272,13 @@ export class ImportDataController extends Controller { // // .take(1000) // .getManyAndCount(); const profiles = await this.profileRepo.find({ - where: { profileSalary: { isEntry: Not(true) } }, + where: { profileSalary: { isEntry: false } }, order: { citizenId: "ASC", }, select: ["citizenId", "id"], }); + // return new HttpSuccess(profiles.length); // const filePath = path.join(__dirname, "salaryProfile1.csv"); // CSV Header // let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId","isEntry"\n`;