Merge branch 'develop' into dev
This commit is contained in:
commit
261d05f88d
1 changed files with 73 additions and 73 deletions
|
|
@ -2822,87 +2822,87 @@ export class SalaryPeriodController extends Controller {
|
||||||
console.time("⏱ SalaryProfileEmployee - Total Time");
|
console.time("⏱ SalaryProfileEmployee - Total Time");
|
||||||
console.time("⏱ Step5: Process ProfileEmps");
|
console.time("⏱ Step5: Process ProfileEmps");
|
||||||
for (const profile of orgProfileEmployees) {
|
for (const profile of orgProfileEmployees) {
|
||||||
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
salaryPeriodId: salaryPeriod.id,
|
salaryPeriodId: salaryPeriod.id,
|
||||||
rootId: profile.rootId,
|
rootId: profile.rootId,
|
||||||
snapshot: snapshot,
|
snapshot: snapshot,
|
||||||
group: "GROUP1",
|
group: "GROUP1",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
//console.log(`step7`);
|
//console.log(`step7`);
|
||||||
if (salaryOrgNew != null) {
|
if (salaryOrgNew != null) {
|
||||||
//console.log(`step8`);
|
//console.log(`step8`);
|
||||||
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), profile);
|
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), profile);
|
||||||
delete salaryProfileNew.id;
|
delete salaryProfileNew.id;
|
||||||
// const beforeSalaryProfileNew = structuredClone(salaryProfileNew);
|
// const beforeSalaryProfileNew = structuredClone(salaryProfileNew);
|
||||||
|
|
||||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||||
salaryProfileNew.createdUserId = request.user.sub;
|
salaryProfileNew.createdUserId = request.user.sub;
|
||||||
salaryProfileNew.createdFullName = request.user.name;
|
salaryProfileNew.createdFullName = request.user.name;
|
||||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||||
salaryProfileNew.createdAt = new Date();
|
salaryProfileNew.createdAt = new Date();
|
||||||
salaryProfileNew.lastUpdatedAt = new Date();
|
salaryProfileNew.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
if (snapshot == "SNAP2") {
|
if (snapshot == "SNAP2") {
|
||||||
//console.log(`step9`);
|
//console.log(`step9`);
|
||||||
const salaryOrgOld = await this.salaryOrgEmployeeRepository.find({
|
const salaryOrgOld = await this.salaryOrgEmployeeRepository.find({
|
||||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||||
});
|
});
|
||||||
const salaryOld = await this.salaryProfileEmployeeRepository.findOne({
|
const salaryOld = await this.salaryProfileEmployeeRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
citizenId: salaryProfileNew.citizenId,
|
citizenId: salaryProfileNew.citizenId,
|
||||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
||||||
// salaryProfileNew.salaryLevel = salaryOld && salaryOld.salaryLevelNew ? salaryOld.salaryLevelNew : salaryOld?.salaryLevel;
|
// salaryProfileNew.salaryLevel = salaryOld && salaryOld.salaryLevelNew ? salaryOld.salaryLevelNew : salaryOld?.salaryLevel;
|
||||||
// salaryProfileNew.group = salaryOld && salaryOld.groupNew ? salaryOld.groupNew : salaryOld?.group;
|
// salaryProfileNew.group = salaryOld && salaryOld.groupNew ? salaryOld.groupNew : salaryOld?.group;
|
||||||
salaryProfileNew.salaryLevelNew =
|
salaryProfileNew.salaryLevelNew =
|
||||||
salaryOld && salaryOld.salaryLevelNew ? salaryOld.salaryLevelNew : null;
|
salaryOld && salaryOld.salaryLevelNew ? salaryOld.salaryLevelNew : null;
|
||||||
salaryProfileNew.groupNew =
|
salaryProfileNew.groupNew =
|
||||||
salaryOld && salaryOld.groupNew ? salaryOld.groupNew : null;
|
salaryOld && salaryOld.groupNew ? salaryOld.groupNew : null;
|
||||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||||
salaryProfileNew.positionSalaryAmount =
|
salaryProfileNew.positionSalaryAmount =
|
||||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||||
salaryProfileNew.positionSalaryDayAmount =
|
salaryProfileNew.positionSalaryDayAmount =
|
||||||
salaryOld == null ? 0 : salaryOld.positionSalaryDayAmount;
|
salaryOld == null ? 0 : salaryOld.positionSalaryDayAmount;
|
||||||
salaryProfileNew.positionSalaryAmountPer =
|
salaryProfileNew.positionSalaryAmountPer =
|
||||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmountPer;
|
salaryOld == null ? 0 : salaryOld.positionSalaryAmountPer;
|
||||||
salaryProfileNew.remark = salaryOld == null ? null : salaryOld.remark;
|
salaryProfileNew.remark = salaryOld == null ? null : salaryOld.remark;
|
||||||
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||||
salaryProfileNew.isSpecial = salaryOld == null ? false : salaryOld.isSpecial;
|
salaryProfileNew.isSpecial = salaryOld == null ? false : salaryOld.isSpecial;
|
||||||
salaryProfileNew.isReserve = salaryOld == null ? false : salaryOld.isReserve;
|
salaryProfileNew.isReserve = salaryOld == null ? false : salaryOld.isReserve;
|
||||||
salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired;
|
salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired;
|
||||||
salaryProfileNew.isGood = salaryOld == null ? false : salaryOld.isGood;
|
salaryProfileNew.isGood = salaryOld == null ? false : salaryOld.isGood;
|
||||||
}
|
}
|
||||||
profilesEmpToSave.push(salaryProfileNew);
|
profilesEmpToSave.push(salaryProfileNew);
|
||||||
await this.salaryProfileEmployeeRepository
|
await this.salaryProfileEmployeeRepository
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.insert()
|
.insert()
|
||||||
.into(SalaryProfileEmployee)
|
.into(SalaryProfileEmployee)
|
||||||
.values(profilesEmpToSave)
|
.values(profilesEmpToSave)
|
||||||
.orIgnore()
|
.orIgnore()
|
||||||
.execute();
|
.execute();
|
||||||
//console.log(`step10`);
|
//console.log(`step10`);
|
||||||
// console.log(
|
// console.log(
|
||||||
// `✅ [SNAP: ${snapshot}] Push SalaryProfileEmployee: ${salaryProfileNew.citizenId} (${salaryProfileNew.fullName ?? "-"})`,
|
// `✅ [SNAP: ${snapshot}] Push SalaryProfileEmployee: ${salaryProfileNew.citizenId} (${salaryProfileNew.fullName ?? "-"})`,
|
||||||
// );
|
// );
|
||||||
// await this.salaryProfileEmployeeRepository.save(salaryProfileNew, { data: request });
|
// await this.salaryProfileEmployeeRepository.save(salaryProfileNew, { data: request });
|
||||||
// await this.salaryProfileEmployeeRepository.save(profilesEmpToSave, { chunk: 100, data: request });
|
// await this.salaryProfileEmployeeRepository.save(profilesEmpToSave, { chunk: 100, data: request });
|
||||||
// setLogDataDiff(request, { before: beforeSalaryProfileNew, after: salaryProfileNew });
|
// setLogDataDiff(request, { before: beforeSalaryProfileNew, after: salaryProfileNew });
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
`⚠️ [SNAP: ${snapshot}] ไม่พบ salaryOrgEmployee สำหรับ rootId: ${profile.rootId}`,
|
`⚠️ [SNAP: ${snapshot}] ไม่พบ salaryOrgEmployee สำหรับ rootId: ${profile.rootId}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
console.timeEnd("⏱ SalaryProfileEmployee - Total Time");
|
console.timeEnd("⏱ SalaryProfileEmployee - Total Time");
|
||||||
}
|
}
|
||||||
|
|
||||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue