set null ตำแหน่งติดเงื่อนไข
This commit is contained in:
parent
f307484707
commit
dda4488409
4 changed files with 198 additions and 113 deletions
|
|
@ -4755,21 +4755,27 @@ export class ImportDataController extends Controller {
|
|||
*/
|
||||
@Post("tranferEntryToMain")
|
||||
async tranferEntryToMain(@Request() request: { user: Record<string, any> }) {
|
||||
const _profiles = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("profile.profileSalaryTemp", "profileSalaryTemp")
|
||||
.where("profileSalary.isEntry = :isEntry", { isEntry: true })
|
||||
.andWhere("profile.statusCheckEdit != :status", { status: "EDITED" })
|
||||
.andWhere("profileSalaryTemp.id IS NULL") // 💥 filter ให้ profileSalaryTemp ว่าง
|
||||
.orderBy("profileSalary.commandDateAffect", "ASC")
|
||||
.addOrderBy("profileSalary.order", "ASC")
|
||||
.getMany();
|
||||
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: {
|
||||
citizenId: In([
|
||||
"3860700270466",
|
||||
"3909900758770",
|
||||
"3309900659891",
|
||||
"3100501312173",
|
||||
"3360200140185",
|
||||
"3101900524141",
|
||||
"3102101307867",
|
||||
]),
|
||||
id: In(_profiles.map((x) => x.id)),
|
||||
profileSalary: { isEntry: true },
|
||||
statusCheckEdit: Not("EDITED"),
|
||||
},
|
||||
order: { profileSalary: { commandDateAffect: "ASC", order: "ASC" } },
|
||||
relations: ["profileSalary"],
|
||||
});
|
||||
// console.log(profiles.lengthisDelete)
|
||||
for await (const item of profiles) {
|
||||
// 2. จัดกลุ่มข้อมูลตามวันที่คำสั่งมีผล
|
||||
const groupedByDate = this.groupOrdersByDate(item.profileSalary);
|
||||
|
|
@ -4780,7 +4786,7 @@ export class ImportDataController extends Controller {
|
|||
if (orders.length == 1) {
|
||||
num = num + 1;
|
||||
//save
|
||||
orders.isDelete = false;
|
||||
orders[0].isDelete = false;
|
||||
processedOrders.push(orders[0]);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -4819,7 +4825,7 @@ export class ImportDataController extends Controller {
|
|||
const findCommandNo = _item.remark?.includes(
|
||||
_item1.commandNo + "/" + (_item1.commandYear + 543),
|
||||
);
|
||||
if (findCommandNo && chkEditCommandNo == true && chkCanCommandNo == true) {
|
||||
if (findCommandNo && (chkEditCommandNo == true || chkCanCommandNo == true)) {
|
||||
_item.isDelete = true;
|
||||
processedOrders.push(_item);
|
||||
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
|
||||
|
|
@ -4831,7 +4837,7 @@ export class ImportDataController extends Controller {
|
|||
const _findCommandNo = _item.remark?.includes(
|
||||
_item1.commandNo + "/" + (_item1.commandYear + 543).toString().slice(-2),
|
||||
);
|
||||
if (_findCommandNo && chkEditCommandNo == true && chkCanCommandNo == true) {
|
||||
if (_findCommandNo && (chkEditCommandNo == true || chkCanCommandNo == true)) {
|
||||
_item.isDelete = true;
|
||||
processedOrders.push(_item);
|
||||
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
|
||||
|
|
@ -4938,15 +4944,15 @@ export class ImportDataController extends Controller {
|
|||
async tranferEntryToMainEdit(@Request() request: { user: Record<string, any> }) {
|
||||
const profiles = await this.salaryTempRepo.find({
|
||||
where: {
|
||||
profileId: In([
|
||||
"529558c4-5c5d-431a-8b40-940cded51a41",
|
||||
"649f2d08-2a01-48b1-afcc-8a4c99091b17",
|
||||
"9ac31312-441a-4cdf-a778-974d9232ca55",
|
||||
"9c6b5005-ee8e-432f-a83d-cd41fb199e56",
|
||||
"c8c664de-e792-4fbd-85c1-fbeefdc860d4",
|
||||
"c9639f3b-26d0-47fc-a53d-1a0e4926697e",
|
||||
"e6d40cd6-c77b-4229-8e8d-a6df3f83394b",
|
||||
]),
|
||||
// profileId: In([
|
||||
// "529558c4-5c5d-431a-8b40-940cded51a41",
|
||||
// "649f2d08-2a01-48b1-afcc-8a4c99091b17",
|
||||
// "9ac31312-441a-4cdf-a778-974d9232ca55",
|
||||
// "9c6b5005-ee8e-432f-a83d-cd41fb199e56",
|
||||
// "c8c664de-e792-4fbd-85c1-fbeefdc860d4",
|
||||
// "c9639f3b-26d0-47fc-a53d-1a0e4926697e",
|
||||
// "e6d40cd6-c77b-4229-8e8d-a6df3f83394b",
|
||||
// ]),
|
||||
isEntry: true,
|
||||
isDelete: true,
|
||||
},
|
||||
|
|
@ -4975,6 +4981,45 @@ export class ImportDataController extends Controller {
|
|||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary รวม entry กับตัวหลัก
|
||||
*/
|
||||
@Post("tranferEntryToMainEditEntry")
|
||||
async tranferEntryToMainEditEntry(@Request() request: { user: Record<string, any> }) {
|
||||
const profiles = await this.salaryTempRepo.find({
|
||||
where: {
|
||||
// profileId: In([
|
||||
// "529558c4-5c5d-431a-8b40-940cded51a41",
|
||||
// "649f2d08-2a01-48b1-afcc-8a4c99091b17",
|
||||
// "9ac31312-441a-4cdf-a778-974d9232ca55",
|
||||
// "9c6b5005-ee8e-432f-a83d-cd41fb199e56",
|
||||
// "c8c664de-e792-4fbd-85c1-fbeefdc860d4",
|
||||
// "c9639f3b-26d0-47fc-a53d-1a0e4926697e",
|
||||
// "e6d40cd6-c77b-4229-8e8d-a6df3f83394b",
|
||||
// ]),
|
||||
isEntry: true,
|
||||
},
|
||||
relations: ["profile"],
|
||||
});
|
||||
let num = 1;
|
||||
for await (const item of profiles) {
|
||||
console.log(num);
|
||||
num += 1;
|
||||
const existingProfile = await this.ProfileSalariesRepo.createQueryBuilder("profile")
|
||||
.where("profile.posNo = :posNo", { posNo: item.profile.citizenId })
|
||||
.andWhere("CONCAT(profile.SalaryRef, ' ', profile.PositionName) = :remark", {
|
||||
remark: item.remark,
|
||||
})
|
||||
.getOne();
|
||||
|
||||
if (existingProfile) {
|
||||
item.remark = existingProfile.SalaryRef;
|
||||
await this.salaryTempRepo.save(item);
|
||||
}
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
// ฟังก์ชันจัดกลุ่มตามวันที่
|
||||
groupOrdersByDate(orders: ProfileSalary[]) {
|
||||
return orders.reduce((groups: any, order) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue