add entry

This commit is contained in:
mamoss 2025-07-08 23:27:41 +07:00
parent c6829ed14f
commit 30c785dc3c
5 changed files with 174 additions and 3 deletions

View file

@ -93,6 +93,8 @@ import { ProfileInsignias } from "../entities/ProfileInsignias";
import { ProfileLeave } from "../entities/ProfileLeave";
import { ProfileLeaves } from "../entities/ProfileLeaves";
import { ProfileSalaryTemp } from "../entities/ProfileSalaryTemp";
import { ProfileTraining } from "../entities/ProfileTraining";
import { ProfileTrainings } from "../entities/ProfileTrainings";
@Route("api/v1/org/upload")
@Tags("UPLOAD")
@Security("bearerAuth")
@ -185,6 +187,8 @@ export class ImportDataController extends Controller {
private LeaveSummaryRepo = AppDataSource.getRepository(ProfileLeave);
private ProfileInsigniasRepo = AppDataSource.getRepository(ProfileInsignias);
private InsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private ProfileTrainingsRepo = AppDataSource.getRepository(ProfileTrainings);
private TrainingRepo = AppDataSource.getRepository(ProfileTraining);
private salaryTempRepo = AppDataSource.getRepository(ProfileSalaryTemp);
/**
@ -4699,6 +4703,58 @@ export class ImportDataController extends Controller {
return new HttpSuccess();
}
/**
* @summary
*/
@Post("uploadProfileTraining-OfficerEntry")
async UploadFileSQLTrainingEntry(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let _null: any = null;
const existingProfile = await this.ProfileTrainingsRepo.find({
// order: {
// citizenId: "ASC",
// },
});
for await (const _item of existingProfile) {
const citizenId: any = _item.createdFullName ?? "";
const profiles = await this.profileRepo.find({
where: { citizenId: citizenId },
// order: {
// Order: "ASC",
// },
});
let order = 1;
for await (const item of profiles) {
rowCount++;
const profile: any = new ProfileTraining();
profile.profileId = item.id;
profile.startDate = _item.startDate;
profile.endDate = _item.endDate;
profile.numberOrder = _item.numberOrder;
profile.topic = _item.topic;
profile.place = _item.place;
profile.dateOrder = _item.dateOrder;
profile.department = _item.department;
profile.duration = _item.duration;
profile.name = _item.name;
profile.yearly = _item.yearly;
profile.isDate = _item.isDate;
profile.isEntry = true;
profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name;
profile.createdAt = new Date().toISOString().split("T")[0];
profile.lastUpdatedAt = new Date().toISOString().split("T")[0];
await this.TrainingRepo.save(profile);
console.log("profiles successfully written to Profile.csv: " + rowCount);
}
order = 1;
}
return new HttpSuccess();
}
/**
* @summary
*/