Merge branch 'develop' into develop-Bright
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m25s

This commit is contained in:
harid 2026-02-19 09:33:26 +07:00
commit cc6e61f4de
6 changed files with 574 additions and 482 deletions

View file

@ -7338,8 +7338,8 @@ export class CommandController extends Controller {
profile.employeeClass = "PERM";
const _null: any = null;
profile.employeeWage = item.amount == null ? _null : item.amount.toString();
profile.dateStart = new Date();
profile.dateAppoint = new Date();
profile.dateStart = _command ? _command.commandExcecuteDate : new Date();
profile.dateAppoint = _command ? _command.commandExcecuteDate : new Date();
profile.amount = item.amount == null ? _null : item.amount;
profile.amountSpecial = item.amountSpecial == null ? _null : item.amountSpecial;
_reqBody.push({

View file

@ -109,68 +109,143 @@ export class PosMasterActController extends Controller {
isAllRoot?: boolean;
page?: number;
pageSize?: number;
keyword?: string;
},
) {
await new permission().PermissionGet(request, "SYS_ACTING");
const {
page = 1,
pageSize = 100,
} = body
const { page = 1, pageSize = 100, keyword } = body;
const posMasterMain = await this.posMasterRepository.findOne({
where: { id: body.posmasterId },
relations: ["posMasterActs"],
});
if (posMasterMain == null) {
if (!posMasterMain) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
}
let posId: any = posMasterMain.posMasterActs.map((x) => x.posMasterChildId);
let posId: any[] = posMasterMain.posMasterActs.map(
(x) => x.posMasterChildId
);
posId.push(body.posmasterId);
let typeCondition: any = {};
const query = await AppDataSource.getRepository(PosMaster)
.createQueryBuilder("posMaster")
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType")
.where("posMaster.current_holderId IS NOT NULL")
.andWhere("posMaster.id NOT IN (:...posId)", { posId });
if (!body.isAllRoot) {
if (body.isAll == true) {
typeCondition = {
orgRootId: posMasterMain.orgRootId,
orgChild1Id: posMasterMain.orgChild1Id,
orgChild2Id: posMasterMain.orgChild2Id,
orgChild3Id: posMasterMain.orgChild3Id,
orgChild4Id: posMasterMain.orgChild4Id,
current_holderId: Not(IsNull()),
id: Not(In(posId)),
};
if (body.isAll) {
if (posMasterMain.orgChild4Id) {
query.andWhere("posMaster.orgChild4Id = :id", {
id: posMasterMain.orgChild4Id,
});
} else if (posMasterMain.orgChild3Id) {
query.andWhere("posMaster.orgChild3Id = :id", {
id: posMasterMain.orgChild3Id,
});
} else if (posMasterMain.orgChild2Id) {
query.andWhere("posMaster.orgChild2Id = :id", {
id: posMasterMain.orgChild2Id,
});
} else if (posMasterMain.orgChild1Id) {
query.andWhere("posMaster.orgChild1Id = :id", {
id: posMasterMain.orgChild1Id,
});
} else {
query.andWhere("posMaster.orgRootId = :id", {
id: posMasterMain.orgRootId,
});
}
} else {
typeCondition = {
orgRootId: posMasterMain.orgRootId == null ? IsNull() : posMasterMain.orgRootId,
orgChild1Id: posMasterMain.orgChild1Id == null ? IsNull() : posMasterMain.orgChild1Id,
orgChild2Id: posMasterMain.orgChild2Id == null ? IsNull() : posMasterMain.orgChild2Id,
orgChild3Id: posMasterMain.orgChild3Id == null ? IsNull() : posMasterMain.orgChild3Id,
orgChild4Id: posMasterMain.orgChild4Id == null ? IsNull() : posMasterMain.orgChild4Id,
current_holderId: Not(IsNull()),
id: Not(In(posId)),
};
query
.andWhere(
posMasterMain.orgRootId == null
? "posMaster.orgRootId IS NULL"
: "posMaster.orgRootId = :orgRootId",
{ orgRootId: posMasterMain.orgRootId }
)
.andWhere(
posMasterMain.orgChild1Id == null
? "posMaster.orgChild1Id IS NULL"
: "posMaster.orgChild1Id = :orgChild1Id",
{ orgChild1Id: posMasterMain.orgChild1Id }
)
.andWhere(
posMasterMain.orgChild2Id == null
? "posMaster.orgChild2Id IS NULL"
: "posMaster.orgChild2Id = :orgChild2Id",
{ orgChild2Id: posMasterMain.orgChild2Id }
)
.andWhere(
posMasterMain.orgChild3Id == null
? "posMaster.orgChild3Id IS NULL"
: "posMaster.orgChild3Id = :orgChild3Id",
{ orgChild3Id: posMasterMain.orgChild3Id }
)
.andWhere(
posMasterMain.orgChild4Id == null
? "posMaster.orgChild4Id IS NULL"
: "posMaster.orgChild4Id = :orgChild4Id",
{ orgChild4Id: posMasterMain.orgChild4Id }
);
}
} else {
typeCondition = {
query.andWhere("posMaster.orgRootId = :orgRootId", {
orgRootId: posMasterMain.orgRootId,
current_holderId: Not(IsNull()),
id: Not(In(posId)),
};
});
}
const [posMaster, total] = await this.posMasterRepository.findAndCount({
where: typeCondition,
relations: [
"orgRoot",
"orgChild1",
"orgChild2",
"orgChild3",
"orgChild4",
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
],
skip: (page - 1) * pageSize,
take: pageSize,
});
if (keyword) {
query.andWhere(
new Brackets((qb) => {
qb.where(
`CONCAT(current_holder.prefix, current_holder.firstName, ' ', current_holder.lastName) LIKE :keyword`,
{ keyword: `%${keyword}%` }
)
.orWhere(`current_holder.citizenId LIKE :keyword`, {
keyword: `%${keyword}%`,
})
.orWhere(
`CONCAT(
CASE
WHEN orgChild4.id IS NOT NULL THEN orgChild4.orgChild4ShortName
WHEN orgChild3.id IS NOT NULL THEN orgChild3.orgChild3ShortName
WHEN orgChild2.id IS NOT NULL THEN orgChild2.orgChild2ShortName
WHEN orgChild1.id IS NOT NULL THEN orgChild1.orgChild1ShortName
WHEN orgRoot.id IS NOT NULL THEN orgRoot.orgRootShortName
ELSE ''
END,
' ',
posMaster.posMasterNo
) LIKE :keyword`,
{ keyword: `%${keyword}%` }
)
.orWhere(`posLevel.posLevelName LIKE :keyword`, {
keyword: `%${keyword}%`,
})
.orWhere(`posType.posTypeName LIKE :keyword`, {
keyword: `%${keyword}%`,
})
.orWhere(`current_holder.position LIKE :keyword`, {
keyword: `%${keyword}%`,
})
})
);
}
query.skip((page - 1) * pageSize).take(pageSize);
const [posMaster, total] = await query.getManyAndCount();
const data = await Promise.all(
posMaster

File diff suppressed because it is too large Load diff

View file

@ -52,6 +52,9 @@ export class EmployeePosLevel extends EntityBase {
@OneToMany(() => ProfileEmployee, (profile) => profile.posLevel)
profiles: ProfileEmployee[];
@OneToMany(() => ProfileEmployee, (profile) => profile.posLevelTemp)
profilesTemp: ProfileEmployee[];
}
export class CreateEmployeePosLevel {

View file

@ -1,4 +1,4 @@
import { Entity, Column, OneToMany, ManyToOne, Double, ManyToMany, JoinTable } from "typeorm";
import { Entity, Column, OneToMany, ManyToOne, Double, ManyToMany, JoinTable, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosType } from "./EmployeePosType";
@ -792,6 +792,10 @@ export class ProfileEmployee extends EntityBase {
@ManyToOne(() => EmployeePosLevel, (v) => v.profiles)
posLevel: EmployeePosLevel;
@ManyToOne(() => EmployeePosLevel, (v) => v.profilesTemp)
@JoinColumn({ name: "posLevelIdTemp" })
posLevelTemp: EmployeePosLevel;
@ManyToOne(() => EmployeePosType, (v) => v.profiles)
posType: EmployeePosType;

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddRelationPosLevelTemp1771409869898 implements MigrationInterface {
name = 'AddRelationPosLevelTemp1771409869898'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD CONSTRAINT \`FK_49694ac4248a7bab7d12d4be280\` FOREIGN KEY (\`posLevelIdTemp\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP FOREIGN KEY \`FK_49694ac4248a7bab7d12d4be280\``);
}
}