Merge branch 'develop' into develop-Bright

This commit is contained in:
harid 2026-05-26 13:20:22 +07:00
commit 136a4c562e
2 changed files with 37 additions and 6 deletions

View file

@ -350,6 +350,31 @@ export class ApiManageController extends Controller {
"next_holderId",
"current_holderId",
"ancestorDNA",
"leaveCommandId",
"posLevelId",
"posTypeId",
"posExecutiveId",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"isDelete",
"keycloak",
"statusCheckEdit",
"privacyCheckin",
"privacyUser",
"privacyMgt",
"dutyTimeId",
"dutyTimeEffectiveDate",
"profileId",
"profileEmployeeId",
"orgRevisionId",
"rank",
"isUpload",
"isDeleted",
"isEntry",
]; // ฟิลด์ที่ไม่ต้องการแสดงในผลลัพธ์
// การแทนที่ฟิลด์ ID ด้วยฟิลด์ Name สำหรับ Profile entity

View file

@ -3594,6 +3594,8 @@ export class CommandController extends Controller {
positionArea?: string | null;
positionType: string | null;
positionLevel: string | null;
positionTypeId?: string | null;
positionLevelId?: string | null;
posmasterId: string;
positionId: string;
posExecutiveId?: string | null;
@ -3815,6 +3817,10 @@ export class CommandController extends Controller {
let positionNew: Position | null = null;
// Resolve ID: ใช้ positionTypeId/positionLevelId ก่อน ถ้าไม่มี fallback เป็น positionType/positionLevel
const posTypeId = item.positionTypeId || item.positionType;
const posLevelId = item.positionLevelId || item.positionLevel;
// ═══════════════════════════════════════════════════════════
// CONDITION 1: เช็คจาก positionId ตรง
// ═══════════════════════════════════════════════════════════
@ -3835,13 +3841,13 @@ export class CommandController extends Controller {
// ═══════════════════════════════════════════════════════════
// CONDITION 2: Match 7 ฟิลด์ (ถ้า Condition 1 ไม่ match)
// ═══════════════════════════════════════════════════════════
if (!positionNew && item.positionName && item.positionType && item.positionLevel) {
if (!positionNew && item.positionName && posTypeId && posLevelId) {
// สร้าง where clause แบบ dynamic - ใส่เฉพาะฟิลด์ที่มีค่า
const whereCondition: any = {
posMasterId: posMaster.id,
positionName: item.positionName,
posTypeId: item.positionType, // positionType = posTypeId
posLevelId: item.positionLevel, // positionLevel = posLevelId
posTypeId: posTypeId,
posLevelId: posLevelId,
};
// เพิ่มเฉพาะฟิลด์ที่มีค่า (ไม่ใช่ null, undefined, หรือ string ว่าง)
@ -3872,13 +3878,13 @@ export class CommandController extends Controller {
// ═══════════════════════════════════════════════════════════
// CONDITION 3: Match 3 ฟิลด์ (ถ้า Condition 2 ไม่ match)
// ═══════════════════════════════════════════════════════════
if (!positionNew && item.positionName && item.positionType && item.positionLevel) {
if (!positionNew && item.positionName && posTypeId && posLevelId) {
const positionBy3Fields = await this.positionRepository.findOne({
where: {
posMasterId: posMaster.id,
positionName: item.positionName,
posTypeId: item.positionType,
posLevelId: item.positionLevel,
posTypeId: posTypeId,
posLevelId: posLevelId,
},
relations: ["posExecutive"],
order: { orderNo: "ASC" }