edit data mis

This commit is contained in:
mamoss 2025-06-20 00:49:01 +07:00
parent 9eac11ff30
commit aab7736f64

View file

@ -4767,7 +4767,7 @@ export class ImportDataController extends Controller {
"3102101307867",
]),
},
order: { profileSalary: { commandDateAffect: "ASC" } },
order: { profileSalary: { commandDateAffect: "ASC", order: "ASC" } },
relations: ["profileSalary"],
});
for await (const item of profiles) {
@ -4802,11 +4802,24 @@ export class ImportDataController extends Controller {
let _orders = orders.filter((x: ProfileSalary) => !x.id.includes(_item1.id));
for (const _item of _orders) {
num = num + 1;
const chkEditCommandNo =
_item.commandName == "แก้ไขคำสั่ง"
? _item.remark.includes("แก้ไข ") || _item.remark.includes("แก้ไขคำสั่ง")
: !(_item.remark.includes("แก้ไข ") || _item.remark.includes("แก้ไขคำสั่ง"));
const chkCanCommandNo =
_item.commandName == "ยกเลิกคำสั่ง"
? _item.remark.includes("ยกเลิก")
: !_item.remark.includes("ยกเลิก");
_item.remark?.includes(_item1.commandNo + "/" + (_item1.commandYear + 543));
//ปี 4หลัก
const findCommandNo = _item.remark?.includes(
_item1.commandNo + "/" + (_item1.commandYear + 543),
);
if (findCommandNo) {
if (findCommandNo && chkEditCommandNo == true && chkCanCommandNo == true) {
_item.isDelete = true;
processedOrders.push(_item);
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
@ -4818,7 +4831,7 @@ export class ImportDataController extends Controller {
const _findCommandNo = _item.remark?.includes(
_item1.commandNo + "/" + (_item1.commandYear + 543).toString().slice(-2),
);
if (_findCommandNo) {
if (_findCommandNo && chkEditCommandNo == true && chkCanCommandNo == true) {
_item.isDelete = true;
processedOrders.push(_item);
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
@ -4829,13 +4842,14 @@ export class ImportDataController extends Controller {
}
for (const _item of orders) {
num = num + 1;
//หาแก้ไขคำสั่ง
//ปี 4หลัก
const chk1 = orderOrigi.filter(
(x) =>
x.remark.includes(_item.commandNo + "/" + (_item.commandYear + 543)) &&
(_item.commandName == "แก้ไขคำสั่ง"
? x.remark.includes("แก้ไขคำสั่ง")
: !x.remark.includes("แก้ไขคำสั่ง")),
? x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง")
: !(x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง"))),
);
if (chk1.length > 0) {
_item.isDelete = false;
@ -4852,8 +4866,8 @@ export class ImportDataController extends Controller {
_item.commandNo + "/" + (_item.commandYear + 543).toString().slice(-2),
) &&
(_item.commandName == "แก้ไขคำสั่ง"
? x.remark.includes("แก้ไขคำสั่ง")
: !x.remark.includes("แก้ไขคำสั่ง")),
? x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง")
: !(x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง"))),
);
if (chk2.length > 0) {
_item.isDelete = false;
@ -4862,6 +4876,41 @@ export class ImportDataController extends Controller {
processedOrders.push(_item);
continue;
}
//หายกเลิกคำสั่ง
//ปี 4หลัก
const chkCan1 = orderOrigi.filter(
(x) =>
x.remark.includes(_item.commandNo + "/" + (_item.commandYear + 543)) &&
(_item.commandName == "ยกเลิกคำสั่ง"
? x.remark.includes("ยกเลิก")
: !x.remark.includes("ยกเลิก")),
);
if (chkCan1.length > 0) {
_item.isDelete = false;
_item.remark = chkCan1[0].remark;
//commandName
processedOrders.push(_item);
continue;
}
//ปี 2หลัก
const chkCan2 = orderOrigi.filter(
(x) =>
x.remark.includes(
_item.commandNo + "/" + (_item.commandYear + 543).toString().slice(-2),
) &&
(_item.commandName == "ยกเลิกคำสั่ง"
? x.remark.includes("ยกเลิก")
: !x.remark.includes("ยกเลิก")),
);
if (chkCan2.length > 0) {
_item.isDelete = false;
_item.remark = chkCan2[0].remark;
//commandName
processedOrders.push(_item);
continue;
}
_item.isDelete = false;
processedOrders.push(_item);
}
@ -4881,6 +4930,51 @@ export class ImportDataController extends Controller {
}
return new HttpSuccess();
}
/**
* @summary entry
*/
@Post("tranferEntryToMainEdit")
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",
]),
isEntry: true,
isDelete: true,
},
});
for await (const item of profiles) {
const findAct = item.remark?.includes("รักษาการ");
if (findAct) {
item.commandName = "รักษาการในตำแหน่ง";
item.commandCode = "17";
item.isEdit = true;
await this.salaryTempRepo.save(item);
}
const findSalary =
(item.remark?.includes("เลื่อนขั้นเงินเดือน") ||
item.remark?.includes("เลื่อนเงินเดือน")) &&
!item.remark?.includes("แก้ไข") &&
item.commandDateAffect != null &&
((item.commandDateAffect.getMonth() == 3 && item.commandDateAffect.getDate() == 1) ||
(item.commandDateAffect.getMonth() == 9 && item.commandDateAffect.getDate() == 1));
if (findSalary) {
item.commandName = "เลื่อนเงินเดือน/ค่าจ้างตามปกติ";
item.commandCode = "5";
item.isEdit = true;
await this.salaryTempRepo.save(item);
}
}
return new HttpSuccess();
}
// ฟังก์ชันจัดกลุ่มตามวันที่
groupOrdersByDate(orders: ProfileSalary[]) {
return orders.reduce((groups: any, order) => {