Merge branch 'main' into develop

This commit is contained in:
mamoss 2025-07-11 16:30:38 +07:00
commit 74691a2104
5 changed files with 174 additions and 3 deletions

View file

@ -89,6 +89,7 @@ import { OrgRoot } from "../entities/OrgRoot";
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
import { ProfileInsignia, CreateProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
import { Gender } from "../entities/Gender";
@Route("api/v1/org/command")
@Tags("Command")
@Security("bearerAuth")
@ -141,6 +142,7 @@ export class CommandController extends Controller {
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private insigniaHistoryRepo = AppDataSource.getRepository(ProfileInsigniaHistory);
private genderRepo = AppDataSource.getRepository(Gender);
/**
* API list
@ -7052,4 +7054,19 @@ export class CommandController extends Controller {
},
});
}
async cronjobTest(@Request() request?: RequestWithUser) {
const gender = {
name: "เพศทางเลือก",
code: "M",
isActive: true,
createdFullName: "system",
createdAt: new Date(),
updatedAt: new Date(),
};
await this.genderRepo.save(gender);
return new HttpSuccess();
}
}

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
*/