diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 5c8e74a3..2538a59c 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -4765,18 +4765,25 @@ export class ImportDataController extends Controller { .orderBy("profileSalary.commandDateAffect", "ASC") .addOrderBy("profileSalary.order", "ASC") .getMany(); + // const _profiles = await this.salaryTempRepo + // .createQueryBuilder("profileSalaryTemp") + // .select("profileSalaryTemp.profileId", "profileId") + // .where("profileSalaryTemp.createdAt > :date", { date: "2025-06-24" }) + // .groupBy("profileSalaryTemp.profileId") + // .getRawMany(); const profiles = await this.profileRepo.find({ where: { id: In(_profiles.map((x) => x.id)), - profileSalary: { isEntry: true }, + // profileSalary: { isEntry: Not(true) }, statusCheckEdit: Not("EDITED"), }, order: { profileSalary: { commandDateAffect: "ASC", order: "ASC" } }, relations: ["profileSalary"], }); - // console.log(profiles.lengthisDelete) + console.log(profiles.length); for await (const item of profiles) { + console.log(item.id); // 2. จัดกลุ่มข้อมูลตามวันที่คำสั่งมีผล const groupedByDate = this.groupOrdersByDate(item.profileSalary); // 3. ประมวลผลแต่ละกลุ่ม @@ -4998,7 +5005,7 @@ export class ImportDataController extends Controller { // "c9639f3b-26d0-47fc-a53d-1a0e4926697e", // "e6d40cd6-c77b-4229-8e8d-a6df3f83394b", // ]), - isEntry: true, + // isEntry: true, }, relations: ["profile"], }); @@ -5023,7 +5030,7 @@ export class ImportDataController extends Controller { // ฟังก์ชันจัดกลุ่มตามวันที่ groupOrdersByDate(orders: ProfileSalary[]) { return orders.reduce((groups: any, order) => { - const date = order.commandDateAffect.toDateString(); // เปลี่ยนชื่อฟิลด์ตามจริง + const date = order?.commandDateAffect?.toDateString() || ""; // เปลี่ยนชื่อฟิลด์ตามจริง if (!groups[date]) { groups[date] = []; }