Merge branch 'develop' into adiDev
This commit is contained in:
commit
de92ad520c
6 changed files with 2190 additions and 92 deletions
|
|
@ -92,6 +92,7 @@ import { ProfileEducations } from "../entities/ProfileEducations";
|
|||
import { ProfileInsignias } from "../entities/ProfileInsignias";
|
||||
import { ProfileLeave } from "../entities/ProfileLeave";
|
||||
import { ProfileLeaves } from "../entities/ProfileLeaves";
|
||||
import { ProfileSalaryTemp } from "../entities/ProfileSalaryTemp";
|
||||
@Route("api/v1/org/upload")
|
||||
@Tags("UPLOAD")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -184,6 +185,8 @@ export class ImportDataController extends Controller {
|
|||
private LeaveSummaryRepo = AppDataSource.getRepository(ProfileLeave);
|
||||
private ProfileInsigniasRepo = AppDataSource.getRepository(ProfileInsignias);
|
||||
private InsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
private salaryTempRepo = AppDataSource.getRepository(ProfileSalaryTemp);
|
||||
|
||||
/**
|
||||
* @summary ทะเบียนประวัติ ข้าราชการ
|
||||
*/
|
||||
|
|
@ -4746,4 +4749,241 @@ export class ImportDataController extends Controller {
|
|||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary รวม entry กับตัวหลัก
|
||||
*/
|
||||
@Post("tranferEntryToMain")
|
||||
async tranferEntryToMain(@Request() request: { user: Record<string, any> }) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: {
|
||||
citizenId: In([
|
||||
"3860700270466",
|
||||
"3909900758770",
|
||||
"3309900659891",
|
||||
"3100501312173",
|
||||
"3360200140185",
|
||||
"3101900524141",
|
||||
"3102101307867",
|
||||
]),
|
||||
},
|
||||
order: { profileSalary: { commandDateAffect: "ASC", order: "ASC" } },
|
||||
relations: ["profileSalary"],
|
||||
});
|
||||
for await (const item of profiles) {
|
||||
// 2. จัดกลุ่มข้อมูลตามวันที่คำสั่งมีผล
|
||||
const groupedByDate = this.groupOrdersByDate(item.profileSalary);
|
||||
// 3. ประมวลผลแต่ละกลุ่ม
|
||||
const processedOrders: any = [];
|
||||
let num = 0;
|
||||
for (let [date, orders] of Object.entries(groupedByDate) as any) {
|
||||
if (orders.length == 1) {
|
||||
num = num + 1;
|
||||
//save
|
||||
orders.isDelete = false;
|
||||
processedOrders.push(orders[0]);
|
||||
continue;
|
||||
}
|
||||
// หาแถวหลัก (ที่มีเลขที่คำสั่ง)
|
||||
const mainOrder: ProfileSalary[] = orders.filter((order: ProfileSalary) => order.commandNo);
|
||||
const orderOrigi: ProfileSalary[] = [];
|
||||
// ข้ามถ้าไม่มีแถวหลัก
|
||||
if (mainOrder.length == 0) {
|
||||
for await (const _item of orders) {
|
||||
num = num + 1;
|
||||
_item.isDelete = false;
|
||||
processedOrders.push(_item);
|
||||
//save
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const _item1 of mainOrder) {
|
||||
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 && chkEditCommandNo == true && chkCanCommandNo == true) {
|
||||
_item.isDelete = true;
|
||||
processedOrders.push(_item);
|
||||
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
|
||||
orderOrigi.push(_item);
|
||||
continue;
|
||||
}
|
||||
|
||||
//ปี 2หลัก
|
||||
const _findCommandNo = _item.remark?.includes(
|
||||
_item1.commandNo + "/" + (_item1.commandYear + 543).toString().slice(-2),
|
||||
);
|
||||
if (_findCommandNo && chkEditCommandNo == true && chkCanCommandNo == true) {
|
||||
_item.isDelete = true;
|
||||
processedOrders.push(_item);
|
||||
orders = orders.filter((x: ProfileSalary) => x.id != _item.id);
|
||||
orderOrigi.push(_item);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
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("แก้ไขคำสั่ง"))),
|
||||
);
|
||||
if (chk1.length > 0) {
|
||||
_item.isDelete = false;
|
||||
_item.remark = chk1[0].remark;
|
||||
//commandName
|
||||
processedOrders.push(_item);
|
||||
continue;
|
||||
}
|
||||
|
||||
//ปี 2หลัก
|
||||
const chk2 = orderOrigi.filter(
|
||||
(x) =>
|
||||
x.remark.includes(
|
||||
_item.commandNo + "/" + (_item.commandYear + 543).toString().slice(-2),
|
||||
) &&
|
||||
(_item.commandName == "แก้ไขคำสั่ง"
|
||||
? x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง")
|
||||
: !(x.remark.includes("แก้ไข ") || x.remark.includes("แก้ไขคำสั่ง"))),
|
||||
);
|
||||
if (chk2.length > 0) {
|
||||
_item.isDelete = false;
|
||||
_item.remark = chk2[0].remark;
|
||||
//commandName
|
||||
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);
|
||||
}
|
||||
}
|
||||
let salaryNew = processedOrders.map(({ id, ...rest }: ProfileSalary) => ({
|
||||
...rest,
|
||||
isEdit: false,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
}));
|
||||
await this.salaryTempRepo.save(salaryNew);
|
||||
// return new HttpSuccess(salaryNew.length);
|
||||
}
|
||||
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) => {
|
||||
const date = order.commandDateAffect.toDateString(); // เปลี่ยนชื่อฟิลด์ตามจริง
|
||||
if (!groups[date]) {
|
||||
groups[date] = [];
|
||||
}
|
||||
groups[date].push(order);
|
||||
return groups;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5608,6 +5608,13 @@ export class ProfileController extends Controller {
|
|||
// END LIKE :keyword
|
||||
// `;
|
||||
// }
|
||||
else if (searchField == "posNo") {
|
||||
queryLike = `
|
||||
CONCAT(profileSalary.posNoAbb, profileSalary.posNo) LIKE :keyword
|
||||
OR CONCAT(profileSalary.posNoAbb, " ", profileSalary.posNo) LIKE :keyword
|
||||
OR profileSalary.posNo LIKE :keyword
|
||||
`;
|
||||
}
|
||||
let nodeCondition = "1=1";
|
||||
let nodeAll = "";
|
||||
let orgRoot = null;
|
||||
|
|
@ -7649,6 +7656,7 @@ export class ProfileController extends Controller {
|
|||
"current_holders.orgChild4",
|
||||
"profileSalary",
|
||||
"profileEducations",
|
||||
"profileActpositions"
|
||||
],
|
||||
order: {
|
||||
// profileSalary: {
|
||||
|
|
@ -7657,6 +7665,9 @@ export class ProfileController extends Controller {
|
|||
profileEducations: {
|
||||
level: "ASC",
|
||||
},
|
||||
profileActpositions: {
|
||||
createdAt: "ASC"
|
||||
}
|
||||
},
|
||||
});
|
||||
if (!profile) {
|
||||
|
|
@ -7740,57 +7751,76 @@ export class ProfileController extends Controller {
|
|||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}`
|
||||
: null;
|
||||
const posMasterActs = await this.posMasterActRepository.find({
|
||||
relations: [
|
||||
"posMaster",
|
||||
"posMaster.orgRoot",
|
||||
"posMaster.orgChild1",
|
||||
"posMaster.orgChild2",
|
||||
"posMaster.orgChild3",
|
||||
"posMaster.orgChild4",
|
||||
"posMaster.current_holder",
|
||||
"posMaster.current_holder.posLevel",
|
||||
"posMaster.current_holder.posType",
|
||||
],
|
||||
where: {
|
||||
posMaster: {
|
||||
orgRevisionId: orgRevisionPublish.id,
|
||||
},
|
||||
posMasterChild: {
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
// const posMasterActs = await this.posMasterActRepository.find({
|
||||
// relations: [
|
||||
// "posMaster",
|
||||
// "posMaster.orgRoot",
|
||||
// "posMaster.orgChild1",
|
||||
// "posMaster.orgChild2",
|
||||
// "posMaster.orgChild3",
|
||||
// "posMaster.orgChild4",
|
||||
// "posMaster.current_holder",
|
||||
// "posMaster.current_holder.posLevel",
|
||||
// "posMaster.current_holder.posType",
|
||||
// ],
|
||||
// where: {
|
||||
// posMaster: {
|
||||
// orgRevisionId: orgRevisionPublish.id,
|
||||
// },
|
||||
// posMasterChild: {
|
||||
// current_holderId: profile.id,
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// const data = await Promise.all(
|
||||
// posMasterActs
|
||||
// .sort((a, b) => a.posMaster.posMasterOrder - b.posMaster.posMasterOrder)
|
||||
// .map((item) => {
|
||||
// const shortName =
|
||||
// item.posMaster != null && item.posMaster.orgChild4 != null
|
||||
// ? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}`
|
||||
// : item.posMaster != null && item.posMaster?.orgChild3 != null
|
||||
// ? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}`
|
||||
// : item.posMaster != null && item.posMaster?.orgChild2 != null
|
||||
// ? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}`
|
||||
// : item.posMaster != null && item.posMaster?.orgChild1 != null
|
||||
// ? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}`
|
||||
// : item.posMaster != null && item.posMaster?.orgRoot != null
|
||||
// ? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}`
|
||||
// : null;
|
||||
// return {
|
||||
// id: item.id,
|
||||
// posMasterOrder: item.posMasterOrder,
|
||||
// profileId: item.posMaster?.current_holder?.id ?? null,
|
||||
// citizenId: item.posMaster?.current_holder?.citizenId ?? null,
|
||||
// prefix: item.posMaster?.current_holder?.prefix ?? null,
|
||||
// firstName: item.posMaster?.current_holder?.firstName ?? null,
|
||||
// lastName: item.posMaster?.current_holder?.lastName ?? null,
|
||||
// posLevel: item.posMaster?.current_holder?.posLevel?.posLevelName ?? null,
|
||||
// posType: item.posMaster?.current_holder?.posType?.posTypeName ?? null,
|
||||
// position: item.posMaster?.current_holder?.position ?? null,
|
||||
// posNo: shortName,
|
||||
// };
|
||||
// }),
|
||||
// );
|
||||
const data = await Promise.all(
|
||||
posMasterActs
|
||||
.sort((a, b) => a.posMaster.posMasterOrder - b.posMaster.posMasterOrder)
|
||||
.map((item) => {
|
||||
const shortName =
|
||||
item.posMaster != null && item.posMaster.orgChild4 != null
|
||||
? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}`
|
||||
: item.posMaster != null && item.posMaster?.orgChild3 != null
|
||||
? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}`
|
||||
: item.posMaster != null && item.posMaster?.orgChild2 != null
|
||||
? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}`
|
||||
: item.posMaster != null && item.posMaster?.orgChild1 != null
|
||||
? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}`
|
||||
: item.posMaster != null && item.posMaster?.orgRoot != null
|
||||
? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}`
|
||||
: null;
|
||||
profile.profileActpositions
|
||||
.filter(x => x.status)
|
||||
.map((item, idx) => {
|
||||
return {
|
||||
id: item.id,
|
||||
posMasterOrder: item.posMasterOrder,
|
||||
profileId: item.posMaster?.current_holder?.id ?? null,
|
||||
citizenId: item.posMaster?.current_holder?.citizenId ?? null,
|
||||
prefix: item.posMaster?.current_holder?.prefix ?? null,
|
||||
firstName: item.posMaster?.current_holder?.firstName ?? null,
|
||||
lastName: item.posMaster?.current_holder?.lastName ?? null,
|
||||
posLevel: item.posMaster?.current_holder?.posLevel?.posLevelName ?? null,
|
||||
posType: item.posMaster?.current_holder?.posType?.posTypeName ?? null,
|
||||
position: item.posMaster?.current_holder?.position ?? null,
|
||||
posNo: shortName,
|
||||
};
|
||||
}),
|
||||
posMasterOrder: idx+1,
|
||||
profileId: item.profileId ?? null,
|
||||
citizenId: profile.citizenId ?? null,
|
||||
prefix: profile.prefix ?? null,
|
||||
firstName: profile.firstName ?? null,
|
||||
lastName: profile.lastName ?? null,
|
||||
posLevel: profile.posLevel.posLevelName ?? null,
|
||||
posType: profile.posType.posTypeName ?? null,
|
||||
position: item.position ?? null,
|
||||
posNo: item.posNo ?? null,
|
||||
}
|
||||
})
|
||||
);
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations: ["orgRootTree"],
|
||||
|
|
|
|||
|
|
@ -2640,6 +2640,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
// END LIKE :keyword
|
||||
// `;
|
||||
// }
|
||||
else if (searchField == "posNo") {
|
||||
queryLike = `
|
||||
CONCAT(profileSalary.posNoAbb, profileSalary.posNo) LIKE :keyword
|
||||
OR CONCAT(profileSalary.posNoAbb, " ", profileSalary.posNo) LIKE :keyword
|
||||
OR profileSalary.posNo LIKE :keyword
|
||||
`;
|
||||
}
|
||||
let nodeCondition = "1=1";
|
||||
let nodeAll = "";
|
||||
let orgRoot = null;
|
||||
|
|
|
|||
|
|
@ -1428,6 +1428,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Query() isRetire?: boolean,
|
||||
@Query() type?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_TEMP");
|
||||
let queryLike =
|
||||
"CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword";
|
||||
if (searchField == "citizenId") {
|
||||
|
|
@ -1435,7 +1436,6 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
} else if (searchField == "position") {
|
||||
queryLike = "profileEmployee.position LIKE :keyword";
|
||||
}
|
||||
let _data = await new permission().PermissionList(request, "SYS_REGISTRY_TEMP");
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
|
@ -1446,17 +1446,19 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("profileEmployee.current_holderTemps", "current_holderTemps")
|
||||
.leftJoinAndSelect("profileEmployee.profileEmployeeEmployment", "profileEmployeeEmployment")
|
||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("current_holderTemps.positions", "positions")
|
||||
.leftJoinAndSelect("current_holderTemps.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holderTemps.orgChild4", "orgChild4")
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? `current_holders.orgRootId IN (:...root)`
|
||||
? _data.root[0] != null
|
||||
? `current_holderTemps.orgRootId IN (:...root)`
|
||||
: `current_holderTemps.orgRootId is null`
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
|
|
@ -1464,7 +1466,9 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? `current_holders.orgChild1Id IN (:...child1)`
|
||||
? _data.child1[0] != null
|
||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||
: `current_holderTemps.orgChild1Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -1472,7 +1476,9 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? `current_holders.orgChild2Id IN (:...child2)`
|
||||
? _data.child2[0] != null
|
||||
? `current_holderTemps.orgChild2Id IN (:...child2)`
|
||||
: `current_holderTemps.orgChild2Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child2: _data.child2,
|
||||
|
|
@ -1480,7 +1486,9 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? `current_holders.orgChild3Id IN (:...child3)`
|
||||
? _data.child3[0] != null
|
||||
? `current_holderTemps.orgChild3Id IN (:...child3)`
|
||||
: `current_holderTemps.orgChild3Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child3: _data.child3,
|
||||
|
|
@ -1488,7 +1496,9 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? `current_holders.orgChild4Id IN (:...child4)`
|
||||
? _data.child4[0] != null
|
||||
? `current_holderTemps.orgChild4Id IN (:...child4)`
|
||||
: `current_holderTemps.orgChild4Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child4: _data.child4,
|
||||
|
|
@ -1518,19 +1528,19 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
keyword2: `${posLevel}`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
isProbation != undefined && isProbation != null
|
||||
? `profile.isProbation = ${isProbation}`
|
||||
: "1=1",
|
||||
)
|
||||
.andWhere(
|
||||
isRetire != undefined && isRetire != null
|
||||
? isRetire == true
|
||||
? `profile.dateRetire IS null`
|
||||
: `profile.dateRetire IS NOT NULL`
|
||||
: "1=1",
|
||||
)
|
||||
.andWhere("profileEmployee.employeeClass LIKE :type", {
|
||||
// .andWhere(
|
||||
// isProbation != undefined && isProbation != null
|
||||
// ? `profileEmployee.isProbation = ${isProbation}`
|
||||
// : "1=1",
|
||||
// )
|
||||
// .andWhere(
|
||||
// isRetire != undefined && isRetire != null
|
||||
// ? isRetire == true
|
||||
// ? `profileEmployee.dateRetire IS null`
|
||||
// : `profileEmployee.dateRetire IS NOT NULL`
|
||||
// : "1=1",
|
||||
// )
|
||||
.andWhere("profileEmployee.employeeClass = :type", {
|
||||
type: "TEMP",
|
||||
})
|
||||
.skip((page - 1) * pageSize)
|
||||
|
|
@ -1539,29 +1549,29 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
_data.current_holders.length == 0
|
||||
_data.current_holderTemps.length == 0
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild3 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
const dateEmployment =
|
||||
_data.profileEmployeeEmployment.length == 0
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ export class EntityBase {
|
|||
})
|
||||
lastUpdateUserId!: String;
|
||||
|
||||
@Column({ comment: "ชื่อ User ที่สร้างข้อมูล", length: 200, default: "string" })
|
||||
@Column({ comment: "ชื่อ User ที่สร้างข้อมูล", length: 200, default: "System Administrator" })
|
||||
createdFullName!: String;
|
||||
|
||||
@Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "string" })
|
||||
@Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "System Administrator" })
|
||||
lastUpdateFullName!: String;
|
||||
}
|
||||
|
|
|
|||
1811
src/migration/1750321011384-update30062025606.ts
Normal file
1811
src/migration/1750321011384-update30062025606.ts
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue