Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 58s

This commit is contained in:
Adisak 2025-12-15 17:33:56 +07:00
commit 8010a1ab85
3 changed files with 204 additions and 165 deletions

View file

@ -1021,12 +1021,12 @@ export class EmployeePositionController extends Controller {
let typeCondition: any = {};
let checkChildConditions: any = {};
let keywordAsInt: any;
let searchShortName = "";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName = "1=1";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`;
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_EMP");
if (body.type === 0) {
typeCondition = {
@ -1036,7 +1036,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = {
orgChild1Id: IsNull(),
};
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 1) {
@ -1047,7 +1047,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = {
orgChild2Id: IsNull(),
};
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 2) {
@ -1058,7 +1058,7 @@ export class EmployeePositionController extends Controller {
checkChildConditions = {
orgChild3Id: IsNull(),
};
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 3) {
@ -1069,14 +1069,14 @@ export class EmployeePositionController extends Controller {
checkChildConditions = {
orgChild4Id: IsNull(),
};
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 4) {
typeCondition = {
orgChild4Id: body.id,
};
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
}
let findPosition: any;
let masterId = new Array();
@ -1126,7 +1126,7 @@ export class EmployeePositionController extends Controller {
},
];
const [posMaster, total] = await AppDataSource.getRepository(EmployeePosMaster)
let query = AppDataSource.getRepository(EmployeePosMaster)
.createQueryBuilder("posMaster")
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
@ -1190,7 +1190,9 @@ export class EmployeePositionController extends Controller {
child4: _data.child4,
},
)
.orWhere(
if (body.keyword != null && body.keyword != "") {
query.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
@ -1204,51 +1206,54 @@ export class EmployeePositionController extends Controller {
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
}
let [posMaster, total] = await query
.orderBy("orgRoot.orgRootOrder", "ASC")
.addOrderBy("orgChild1.orgChild1Order", "ASC")
.addOrderBy("orgChild2.orgChild2Order", "ASC")
@ -1661,50 +1666,50 @@ export class EmployeePositionController extends Controller {
const type0LastPosMasterNo =
requestBody.type == 0
? await this.employeePosMasterRepository.find({
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
: [];
const type1LastPosMasterNo =
requestBody.type == 1
? await this.employeePosMasterRepository.find({
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
: [];
const type2LastPosMasterNo =
requestBody.type == 2
? await this.employeePosMasterRepository.find({
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
: [];
const type3LastPosMasterNo =
requestBody.type == 3
? await this.employeePosMasterRepository.find({
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
: [];
const type4LastPosMasterNo =
requestBody.type == 4
? await this.employeePosMasterRepository.find({
where: {
orgChild4Id: requestBody.id,
},
})
where: {
orgChild4Id: requestBody.id,
},
})
: [];
const allLastPosMasterNo = [

View file

@ -769,12 +769,12 @@ export class EmployeeTempPositionController extends Controller {
let typeCondition: any = {};
let checkChildConditions: any = {};
let keywordAsInt: any;
let searchShortName = "";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
let searchShortName = "1=1";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`;
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_TEMP");
if (body.type === 0) {
typeCondition = {
@ -784,7 +784,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild1Id: IsNull(),
};
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 1) {
@ -795,7 +795,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild2Id: IsNull(),
};
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 2) {
@ -806,7 +806,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild3Id: IsNull(),
};
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 3) {
@ -817,14 +817,14 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild4Id: IsNull(),
};
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 4) {
typeCondition = {
orgChild4Id: body.id,
};
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
}
let findPosition: any;
let masterId = new Array();
@ -873,8 +873,7 @@ export class EmployeeTempPositionController extends Controller {
: { posMasterNo: Like(`%${body.keyword}%`) })),
},
];
const [posMaster, total] = await AppDataSource.getRepository(EmployeeTempPosMaster)
let query = AppDataSource.getRepository(EmployeeTempPosMaster)
.createQueryBuilder("posMaster")
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
@ -938,7 +937,9 @@ export class EmployeeTempPositionController extends Controller {
child4: _data.child4,
},
)
.orWhere(
if (body.keyword != null && body.keyword != "") {
query.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
@ -952,51 +953,54 @@ export class EmployeeTempPositionController extends Controller {
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
}
let [posMaster, total] = await query
.orderBy("orgRoot.orgRootOrder", "ASC")
.addOrderBy("orgChild1.orgChild1Order", "ASC")
.addOrderBy("orgChild2.orgChild2Order", "ASC")
@ -1408,50 +1412,50 @@ export class EmployeeTempPositionController extends Controller {
const type0LastPosMasterNo =
requestBody.type == 0
? await this.employeeTempPosMasterRepository.find({
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
: [];
const type1LastPosMasterNo =
requestBody.type == 1
? await this.employeeTempPosMasterRepository.find({
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
: [];
const type2LastPosMasterNo =
requestBody.type == 2
? await this.employeeTempPosMasterRepository.find({
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
: [];
const type3LastPosMasterNo =
requestBody.type == 3
? await this.employeeTempPosMasterRepository.find({
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
: [];
const type4LastPosMasterNo =
requestBody.type == 4
? await this.employeeTempPosMasterRepository.find({
where: {
orgChild4Id: requestBody.id,
},
})
where: {
orgChild4Id: requestBody.id,
},
})
: [];
const allLastPosMasterNo = [

View file

@ -2389,6 +2389,36 @@ export class PositionController extends Controller {
: "1=1",
{ child1: _data.child1 }
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `posMaster.orgChild2Id IN (:...child2)`
: `posMaster.orgChild2Id is null`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `posMaster.orgChild3Id IN (:...child3)`
: `posMaster.orgChild3Id is null`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `posMaster.orgChild4Id IN (:...child4)`
: `posMaster.orgChild4Id is null`
: "1=1",
{
child4: _data.child4,
},
)
// .andWhere(checkChildConditions)
// .andWhere(typeCondition)
// .andWhere(revisionCondition);