Job insert ข้อมูลราชการ&ลูกจ้าง #1406

This commit is contained in:
Bright 2025-08-27 18:21:04 +07:00
parent 52fca7813c
commit b5e534413a
3 changed files with 48 additions and 4 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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<string, any> }) {
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });