Merge branch 'adiDev' into develop

This commit is contained in:
AdisakKanthawilang 2025-05-13 14:50:37 +07:00
commit 00de87822a

View file

@ -4,7 +4,7 @@ import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import { Brackets, In, IsNull, Not } from "typeorm"; import { Brackets, In, IsNull, MoreThanOrEqual, Not } from "typeorm";
import { OrgRoot } from "../entities/OrgRoot"; import { OrgRoot } from "../entities/OrgRoot";
import { PosMaster } from "../entities/PosMaster"; import { PosMaster } from "../entities/PosMaster";
import { calculateRetireDate } from "../interfaces/utils"; import { calculateRetireDate } from "../interfaces/utils";
@ -317,13 +317,21 @@ export class OrganizationUnauthorizeController extends Controller {
if (!findRevision) { if (!findRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
} }
// const rootIds = [
// "d7e98989-b5ce-47d6-93c3-ab63ed486348",
// "e0545eca-5d0a-4a1c-8bbd-e3e25c2521db",
// "26989ffa-d5ab-4bbd-ac97-130646cd1da6",
// "6f9b30e1-757a-40d5-b053-61eb1b91c0f0",
// "eaf65f33-25e9-4956-9dba-5d909f5eb595",
// "a3efed2c-3f4b-476d-95e6-9f7e0585ae25",
// ];
const rootIds = [ const rootIds = [
"d7e98989-b5ce-47d6-93c3-ab63ed486348", "b89a4467-7ee3-4706-8db7-f366555f826c",
"e0545eca-5d0a-4a1c-8bbd-e3e25c2521db", "585648a9-e634-43fc-9360-5fd4189136ab",
"26989ffa-d5ab-4bbd-ac97-130646cd1da6", "d6e3daa0-284a-428f-aa43-0750fa74e974",
"6f9b30e1-757a-40d5-b053-61eb1b91c0f0", "ed3ddcfb-f882-4499-817b-aff73e5be87c",
"eaf65f33-25e9-4956-9dba-5d909f5eb595", "f8ce98ca-a691-4c89-abde-875f559afb3a",
"a3efed2c-3f4b-476d-95e6-9f7e0585ae25",
]; ];
const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster) const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster)
@ -399,6 +407,17 @@ export class OrganizationUnauthorizeController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
} }
const profileAssessment = await this.profileAssessmentRepo.findOne(
{
where:{
profileId: In(findPosMaster.map((item) => item.current_holderId)),
year: body.year.toString(),
pointSum: MoreThanOrEqual(90),
period: body.period.toLocaleUpperCase(),
}
}
);
const formattedData = findPosMaster.map((item) => { const formattedData = findPosMaster.map((item) => {
let orgShortName = ""; let orgShortName = "";
@ -503,7 +522,8 @@ export class OrganizationUnauthorizeController extends Controller {
calculateRetireDate(item.birthDate).getFullYear() != body.year calculateRetireDate(item.birthDate).getFullYear() != body.year
? false ? false
: true, : true,
// isSpecial: isSpecial, // isSpecial: isSpecial,
isGood: profileAssessment?.profileId.includes(item.current_holderId) ? true : false,
}; };
}); });
return new HttpSuccess({ data: formattedData, total: total }); return new HttpSuccess({ data: formattedData, total: total });
@ -753,13 +773,20 @@ export class OrganizationUnauthorizeController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
} }
// const rootIds = [
// "d7e98989-b5ce-47d6-93c3-ab63ed486348",
// "e0545eca-5d0a-4a1c-8bbd-e3e25c2521db",
// "26989ffa-d5ab-4bbd-ac97-130646cd1da6",
// "6f9b30e1-757a-40d5-b053-61eb1b91c0f0",
// "eaf65f33-25e9-4956-9dba-5d909f5eb595",
// "a3efed2c-3f4b-476d-95e6-9f7e0585ae25",
// ];
const rootIds = [ const rootIds = [
"d7e98989-b5ce-47d6-93c3-ab63ed486348", "b89a4467-7ee3-4706-8db7-f366555f826c",
"e0545eca-5d0a-4a1c-8bbd-e3e25c2521db", "585648a9-e634-43fc-9360-5fd4189136ab",
"26989ffa-d5ab-4bbd-ac97-130646cd1da6", "d6e3daa0-284a-428f-aa43-0750fa74e974",
"6f9b30e1-757a-40d5-b053-61eb1b91c0f0", "ed3ddcfb-f882-4499-817b-aff73e5be87c",
"eaf65f33-25e9-4956-9dba-5d909f5eb595", "f8ce98ca-a691-4c89-abde-875f559afb3a",
"a3efed2c-3f4b-476d-95e6-9f7e0585ae25",
]; ];
const [findPosMaster, total] = await AppDataSource.getRepository(viewEmployeePosMaster) const [findPosMaster, total] = await AppDataSource.getRepository(viewEmployeePosMaster)
@ -813,7 +840,7 @@ export class OrganizationUnauthorizeController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "posType.posTypeName LIKE :keyword" ? "posTypeName LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -821,7 +848,7 @@ export class OrganizationUnauthorizeController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "posLevel.posLevelName LIKE :keyword" ? "posLevelName LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -837,6 +864,17 @@ export class OrganizationUnauthorizeController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
} }
const profileAssessment = await this.profileAssessmentRepo.findOne(
{
where:{
profileEmployeeId: In(findPosMaster.map((item) => item.current_holderId)),
year: body.year.toString(),
pointSum: MoreThanOrEqual(90),
period: body.period.toLocaleUpperCase(),
}
}
);
const formattedData = findPosMaster.map((item) => { const formattedData = findPosMaster.map((item) => {
let orgShortName = ""; let orgShortName = "";
@ -936,6 +974,7 @@ export class OrganizationUnauthorizeController extends Controller {
calculateRetireDate(item.birthDate).getFullYear() != body.year calculateRetireDate(item.birthDate).getFullYear() != body.year
? false ? false
: true, : true,
isGood: profileAssessment?.profileId.includes(item.current_holderId) ? true : false,
}; };
}); });
return new HttpSuccess({ data: formattedData, total: total }); return new HttpSuccess({ data: formattedData, total: total });