checkpoint

This commit is contained in:
AdisakKanthawilang 2025-04-18 11:15:53 +07:00
parent 41ebcee967
commit 2f0d86ed58
2 changed files with 19 additions and 11 deletions

View file

@ -2496,25 +2496,25 @@ export class SalaryPeriodController extends Controller {
await this.salaryProfileEmployeeRepository.remove(salaryProfileEmployee, { data: request });
await this.salaryOrgEmployeeRepository.remove(salaryOrgEmployee, { data: request });
let orgs = await new CallAPI().GetData(request, "/org/unauthorize/active/root/id");
let total = 10000;
let total = 1000;
// let _orgProfiles = await new CallAPI().PostData(request, "/org/unauthorize/salary/gen", {
let _orgProfiles = await new CallAPI().PostData(request, "/org/unauthorize/new-salary/gen", {
page: 1,
pageSize: 10000,
pageSize: 1000,
keyword: "",
year: salaryPeriod.year,
period: salaryPeriod.period,
});
let orgProfiles = _orgProfiles.data;
total = _orgProfiles.total;
if (total > 10000) {
const page = Math.ceil(total / 10000);
if (total > 1000) {
const page = Math.ceil(total / 1000);
for (let index = 2; index <= page; index++) {
await new CallAPI()
// .PostData(request, "/org/unauthorize/salary/gen", {
.PostData(request, "/org/unauthorize/new-salary/gen", {
page: index,
pageSize: 10000,
pageSize: 1000,
keyword: "",
year: salaryPeriod.year,
period: salaryPeriod.period,
@ -2524,7 +2524,7 @@ export class SalaryPeriodController extends Controller {
});
}
}
total = 10000;
total = 1000;
let orgProfileEmployees: any;
let _orgProfileEmployees = await new CallAPI().PostData(
request,
@ -2532,7 +2532,7 @@ export class SalaryPeriodController extends Controller {
"/org/unauthorize/new-salary/employee/gen",
{
page: 1,
pageSize: 10000,
pageSize: 1000,
keyword: "",
year: salaryPeriod.year,
period: salaryPeriod.period,
@ -2540,14 +2540,14 @@ export class SalaryPeriodController extends Controller {
);
orgProfileEmployees = _orgProfileEmployees.data;
total = _orgProfileEmployees.total;
if (total > 10000) {
const page = Math.ceil(total / 10000);
if (total > 1000) {
const page = Math.ceil(total / 1000);
for (let index = 2; index <= page; index++) {
await new CallAPI()
// .PostData(request, "/org/unauthorize/salary/employee/gen", {
.PostData(request, "/org/unauthorize/new-salary/employee/gen", {
page: index,
pageSize: 10000,
pageSize: 1000,
keyword: "",
year: salaryPeriod.year,
period: salaryPeriod.period,
@ -2630,6 +2630,7 @@ export class SalaryPeriodController extends Controller {
}),
);
if (salaryPeriod.period != "SPECIAL") {
console.log(`step1`)
await Promise.all(
orgProfiles.map(async (profile: any) => {
let group = "GROUP1";
@ -2643,6 +2644,7 @@ export class SalaryPeriodController extends Controller {
) {
group = "GROUP2";
}
console.log(`step2`)
const salaryOrgNew = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriod.id,
@ -2651,8 +2653,9 @@ export class SalaryPeriodController extends Controller {
group: group,
},
});
console.log(`step3`)
if (salaryOrgNew != null) {
console.log(`step4`)
let salaryProfileNew = Object.assign(new SalaryProfile(), profile);
delete salaryProfileNew.id;
@ -2668,6 +2671,7 @@ export class SalaryPeriodController extends Controller {
salaryProfileNew.lastUpdatedAt = new Date();
if (snapshot == "SNAP2") {
console.log(`step5`)
const salaryOrgOld = await this.salaryOrgRepository.find({
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
});
@ -2688,6 +2692,7 @@ export class SalaryPeriodController extends Controller {
salaryProfileNew.isReserve = salaryOld == null ? false : salaryOld.isReserve;
salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired;
}
console.log(`step6`)
await this.salaryProfileRepository.save(salaryProfileNew, { data: request });
setLogDataDiff(request, { before: beforeSalaryProfileNew, after: salaryProfileNew });
console.log(`✅ [SNAP: ${snapshot}] บันทึก SalaryProfile: ${salaryProfileNew.citizenId} (${salaryProfileNew.fullName ?? "-"})`);