Merge branch 'develop'
* develop: fix issue #1831, #2086, #2126, #2146 fix ค้นหารายชื่อผู้ยื่นอุธรณ์/ร้องทุกข์ fix brother privilage #2139 fix log user API ตรวจสอบเช็คเลขบัตรประจำตัวประชาชน ทำไว้ให้ service อื่นๆ ภายในระบบ call มาตรวจสอบเลขบัตรประจำตัวประชาชน #2123 fix search #2119 เพิ่มฟิลด์ isSalary + api แก้ไขเงินเดือนทั้งกลุ่ม #2102 add permission brother
This commit is contained in:
commit
841fc648f6
15 changed files with 1056 additions and 646 deletions
|
|
@ -649,6 +649,54 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @summary API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Post("tab2/edit-salary")
|
||||
async EditSalary(
|
||||
@Body()
|
||||
requestBody: {
|
||||
id: string;
|
||||
mouthSalaryAmount?: Double | null;
|
||||
positionSalaryAmount?: Double | null;
|
||||
amount?: Double | null;
|
||||
amountSpecial?: Double | null;
|
||||
remarkVertical?: string | null;
|
||||
remarkHorizontal?: string | null;
|
||||
}[],
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
|
||||
if (!Array.isArray(requestBody)) {
|
||||
throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
for (const item of requestBody) {
|
||||
if (!item.id) continue;
|
||||
|
||||
const rec = await this.commandReciveRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
|
||||
if (!rec) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||
}
|
||||
|
||||
const updated = Object.assign(rec, item);
|
||||
updated.lastUpdateUserId = request.user.sub;
|
||||
updated.lastUpdateFullName = request.user.name;
|
||||
updated.lastUpdatedAt = new Date();
|
||||
|
||||
await this.commandReciveRepository.save(updated);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบรายการผู้ได้รับคำสั่ง
|
||||
*
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export class CommandTypeController extends Controller {
|
|||
"detailBody",
|
||||
"detailFooter",
|
||||
"subtitle",
|
||||
"isSalary",
|
||||
"isAttachment",
|
||||
"isUploadAttachment",
|
||||
"createdAt",
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -2036,7 +2036,7 @@ export class OrganizationController extends Controller {
|
|||
_data.child2 = [holder.orgChild2Id];
|
||||
_data.child3 = [holder.orgChild3Id];
|
||||
_data.child4 = [holder.orgChild4Id];
|
||||
} else if (_privilege.privilege == "CHILD") {
|
||||
} else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") {
|
||||
const holder = profile.current_holders.find((x) => x.orgRevisionId === id);
|
||||
if (!holder) return;
|
||||
_data.root = [holder.orgRootId];
|
||||
|
|
@ -6174,7 +6174,7 @@ export class OrganizationController extends Controller {
|
|||
_data.child2 = [holder.orgChild2Id];
|
||||
_data.child3 = [holder.orgChild3Id];
|
||||
_data.child4 = [holder.orgChild4Id];
|
||||
} else if (_privilege.privilege == "CHILD") {
|
||||
} else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") {
|
||||
const holder = profile.current_holders.find((x) => x.orgRevisionId === id);
|
||||
if (!holder) return;
|
||||
_data.root = [holder.orgRootId];
|
||||
|
|
|
|||
|
|
@ -57,6 +57,23 @@ export class OrganizationDotnetController extends Controller {
|
|||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
|
||||
/**
|
||||
* ทำไว้ให้ service อื่นๆ ภายในระบบ call มาตรวจสอบเลขบัตรประจำตัวประชาชน
|
||||
*
|
||||
* @summary API ตรวจสอบเช็คเลขบัตรประจำตัวประชาชน
|
||||
*
|
||||
*/
|
||||
@Post("check-citizen")
|
||||
public async CheckCitizen(
|
||||
@Body()
|
||||
body: {
|
||||
citizenId: string;
|
||||
},
|
||||
) {
|
||||
let citizen = Extension.CheckCitizen(body.citizenId)
|
||||
return new HttpSuccess(citizen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. API Search Profile
|
||||
*
|
||||
|
|
@ -101,6 +118,28 @@ export class OrganizationDotnetController extends Controller {
|
|||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "ROOT") {
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
|
|
@ -220,6 +259,28 @@ export class OrganizationDotnetController extends Controller {
|
|||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "ROOT") {
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
|
|
@ -439,7 +500,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild4?.id ?? null,
|
||||
};
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -465,7 +526,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -490,7 +551,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -515,7 +576,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -540,7 +601,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -935,8 +996,8 @@ export class OrganizationDotnetController extends Controller {
|
|||
|
||||
let positionLeaveName =
|
||||
profile.posType != null &&
|
||||
profile.posLevel != null &&
|
||||
(profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ")
|
||||
profile.posLevel != null &&
|
||||
(profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ")
|
||||
? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}`
|
||||
: profile.posLevel?.posLevelName ?? null;
|
||||
const _profileCurrent = profile?.current_holders?.find(
|
||||
|
|
@ -2528,26 +2589,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
profile.current_holders.length == 0
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
|
|
@ -2597,9 +2658,13 @@ export class OrganizationDotnetController extends Controller {
|
|||
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
@ -2827,26 +2892,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
profile.current_holders.length == 0
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
return {
|
||||
|
|
@ -3042,26 +3107,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
profile.current_holders.length == 0
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
return {
|
||||
|
|
@ -3298,7 +3363,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
||||
|
||||
|
|
@ -3358,41 +3423,41 @@ export class OrganizationDotnetController extends Controller {
|
|||
|
||||
const posMaster =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
||||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
|
||||
null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
||||
|
|
@ -3531,30 +3596,30 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot
|
||||
?.orgRootName;
|
||||
?.orgRootName;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
|
|
@ -3659,30 +3724,30 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot
|
||||
?.orgRootName;
|
||||
?.orgRootName;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
|
|
@ -3866,25 +3931,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -4045,25 +4110,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -4215,25 +4280,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -4399,7 +4464,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
if (body.role === "CHILD" || body.role === "PARENT") {
|
||||
if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
|
|
@ -4441,16 +4506,55 @@ export class OrganizationDotnetController extends Controller {
|
|||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (body.role === "PARENT") {
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "PARENT") {
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
orgChild1: Not(IsNull()),
|
||||
};
|
||||
}
|
||||
|
||||
} else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
switch (body.reqNode) {
|
||||
case 0:
|
||||
|
|
@ -4607,25 +4711,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -4773,25 +4877,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -4927,25 +5031,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -5005,7 +5109,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
if (body.role === "CHILD" || body.role === "PARENT") {
|
||||
if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
|
|
@ -5043,23 +5147,59 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
};
|
||||
break;
|
||||
case null:
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (body.role === "PARENT") {
|
||||
} else if (body.role === "PARENT") {
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
orgChild1: Not(IsNull()),
|
||||
};
|
||||
}
|
||||
|
||||
} else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
switch (body.reqNode) {
|
||||
case 0:
|
||||
|
|
@ -5216,25 +5356,25 @@ export class OrganizationDotnetController extends Controller {
|
|||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild3 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
|
||||
: null;
|
||||
const Oc =
|
||||
|
|
@ -5515,16 +5655,16 @@ export class OrganizationDotnetController extends Controller {
|
|||
currentAddress:
|
||||
profile && profile.currentAddress
|
||||
? profile.currentAddress +
|
||||
(profile.currentSubDistrict && profile.currentSubDistrict.name
|
||||
? " ตำบล/แขวง " + profile.currentSubDistrict.name
|
||||
: "") +
|
||||
(profile.currentDistrict && profile.currentDistrict.name
|
||||
? " อำเภอ/เขต " + profile.currentDistrict.name
|
||||
: "") +
|
||||
(profile.currentProvince && profile.currentProvince.name
|
||||
? " จังหวัด " + profile.currentProvince.name
|
||||
: "") +
|
||||
profile.currentZipCode
|
||||
(profile.currentSubDistrict && profile.currentSubDistrict.name
|
||||
? " ตำบล/แขวง " + profile.currentSubDistrict.name
|
||||
: "") +
|
||||
(profile.currentDistrict && profile.currentDistrict.name
|
||||
? " อำเภอ/เขต " + profile.currentDistrict.name
|
||||
: "") +
|
||||
(profile.currentProvince && profile.currentProvince.name
|
||||
? " จังหวัด " + profile.currentProvince.name
|
||||
: "") +
|
||||
profile.currentZipCode
|
||||
: "-",
|
||||
oc: oc ?? "-",
|
||||
root:
|
||||
|
|
@ -5560,26 +5700,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
positions:
|
||||
_position && _position.length > 0
|
||||
? _position.slice(0, -1).map((x: any, idx: number) => ({
|
||||
positionName: x.positionName,
|
||||
dateStart: x.commandDateAffect ?? null,
|
||||
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
|
||||
positionType: x.positionType,
|
||||
positionLevel: x.positionLevel,
|
||||
orgRoot: x.orgRoot,
|
||||
orgChild1: x.orgChild1,
|
||||
orgChild2: x.orgChild2,
|
||||
orgChild3: x.orgChild3,
|
||||
orgChild4: x.orgChild4,
|
||||
}))
|
||||
positionName: x.positionName,
|
||||
dateStart: x.commandDateAffect ?? null,
|
||||
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
|
||||
positionType: x.positionType,
|
||||
positionLevel: x.positionLevel,
|
||||
orgRoot: x.orgRoot,
|
||||
orgChild1: x.orgChild1,
|
||||
orgChild2: x.orgChild2,
|
||||
orgChild3: x.orgChild3,
|
||||
orgChild4: x.orgChild4,
|
||||
}))
|
||||
: [],
|
||||
educations:
|
||||
profile.profileEducations && profile.profileEducations.length > 0
|
||||
? profile.profileEducations.map((x) => ({
|
||||
educationLevel: x.educationLevel,
|
||||
institute: x.institute ?? "-",
|
||||
country: x.country ?? "-",
|
||||
finishDate: x.finishDate,
|
||||
}))
|
||||
educationLevel: x.educationLevel,
|
||||
institute: x.institute ?? "-",
|
||||
country: x.country ?? "-",
|
||||
finishDate: x.finishDate,
|
||||
}))
|
||||
: [],
|
||||
};
|
||||
return new HttpSuccess(mapEmpProfile);
|
||||
|
|
@ -5629,16 +5769,16 @@ export class OrganizationDotnetController extends Controller {
|
|||
currentAddress:
|
||||
profile && profile.currentAddress
|
||||
? profile.currentAddress +
|
||||
(profile.currentSubDistrict && profile.currentSubDistrict.name
|
||||
? " ตำบล/แขวง " + profile.currentSubDistrict.name
|
||||
: "") +
|
||||
(profile.currentDistrict && profile.currentDistrict.name
|
||||
? " อำเภอ/เขต " + profile.currentDistrict.name
|
||||
: "") +
|
||||
(profile.currentProvince && profile.currentProvince.name
|
||||
? " จังหวัด " + profile.currentProvince.name
|
||||
: "") +
|
||||
profile.currentZipCode
|
||||
(profile.currentSubDistrict && profile.currentSubDistrict.name
|
||||
? " ตำบล/แขวง " + profile.currentSubDistrict.name
|
||||
: "") +
|
||||
(profile.currentDistrict && profile.currentDistrict.name
|
||||
? " อำเภอ/เขต " + profile.currentDistrict.name
|
||||
: "") +
|
||||
(profile.currentProvince && profile.currentProvince.name
|
||||
? " จังหวัด " + profile.currentProvince.name
|
||||
: "") +
|
||||
profile.currentZipCode
|
||||
: "-",
|
||||
oc: oc ?? "-",
|
||||
root:
|
||||
|
|
@ -5674,26 +5814,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
positions:
|
||||
_position && _position.length > 0
|
||||
? _position.slice(0, -1).map((x: any, idx: number) => ({
|
||||
positionName: x.positionName,
|
||||
dateStart: x.commandDateAffect ?? null,
|
||||
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
|
||||
positionType: x.positionType,
|
||||
positionLevel: x.positionLevel,
|
||||
orgRoot: x.orgRoot,
|
||||
orgChild1: x.orgChild1,
|
||||
orgChild2: x.orgChild2,
|
||||
orgChild3: x.orgChild3,
|
||||
orgChild4: x.orgChild4,
|
||||
}))
|
||||
positionName: x.positionName,
|
||||
dateStart: x.commandDateAffect ?? null,
|
||||
dateEnd: _position[idx + 1]?.commandDateAffect ?? null,
|
||||
positionType: x.positionType,
|
||||
positionLevel: x.positionLevel,
|
||||
orgRoot: x.orgRoot,
|
||||
orgChild1: x.orgChild1,
|
||||
orgChild2: x.orgChild2,
|
||||
orgChild3: x.orgChild3,
|
||||
orgChild4: x.orgChild4,
|
||||
}))
|
||||
: [],
|
||||
educations:
|
||||
profile.profileEducations && profile.profileEducations.length > 0
|
||||
? profile.profileEducations.map((x) => ({
|
||||
educationLevel: x.educationLevel,
|
||||
institute: x.institute ?? "-",
|
||||
country: x.country ?? "-",
|
||||
finishDate: x.finishDate,
|
||||
}))
|
||||
educationLevel: x.educationLevel,
|
||||
institute: x.institute ?? "-",
|
||||
country: x.country ?? "-",
|
||||
finishDate: x.finishDate,
|
||||
}))
|
||||
: [],
|
||||
};
|
||||
return new HttpSuccess(mapProfile);
|
||||
|
|
|
|||
|
|
@ -1664,9 +1664,13 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
|
|||
|
|
@ -748,6 +748,14 @@ export class PermissionController extends Controller {
|
|||
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
};
|
||||
} else if (privilege == "BROTHER") {
|
||||
data = {
|
||||
// root: node >= 0 ? null : null,
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 2 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 3 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 4 ? [x.orgChild3Id] : null,
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
|
|
|
|||
|
|
@ -2240,7 +2240,129 @@ export class PositionController extends Controller {
|
|||
},
|
||||
];
|
||||
|
||||
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||
//Old
|
||||
// let [posMaster, total] = 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("posMaster.next_holder", "next_holder")
|
||||
// .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
||||
// .where(conditions)
|
||||
// .andWhere(
|
||||
// _data.root != undefined && _data.root != null
|
||||
// ? _data.root[0] != null
|
||||
// ? `posMaster.orgRootId IN (:...root)`
|
||||
// : `posMaster.orgRootId is null`
|
||||
// : "1=1",
|
||||
// {
|
||||
// root: _data.root,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// _data.child1 != undefined && _data.child1 != null
|
||||
// ? _data.child1[0] != null
|
||||
// ? `posMaster.orgChild1Id IN (:...child1)`
|
||||
// : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
// : "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(
|
||||
// new Brackets((qb) => {
|
||||
// qb.orWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(
|
||||
// body.keyword != null && body.keyword != ""
|
||||
// ? body.isAll == false
|
||||
// ? searchShortName
|
||||
// : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||
// : "1=1",
|
||||
// )
|
||||
// .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);
|
||||
// }),
|
||||
// );
|
||||
// }),
|
||||
// )
|
||||
// .orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
// .addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
// .addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
// .addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||
// .addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||
// .addOrderBy("posMaster.posMasterOrder", "ASC")
|
||||
// .addOrderBy("posMaster.posMasterCreatedAt", "ASC")
|
||||
// .skip((body.page - 1) * body.pageSize)
|
||||
// .take(body.pageSize)
|
||||
// .getManyAndCount();
|
||||
|
||||
//New
|
||||
let query = AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||
|
|
@ -2254,22 +2376,18 @@ export class PositionController extends Controller {
|
|||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `posMaster.orgRootId IN (:...root)`
|
||||
: `posMaster.orgRootId is null`
|
||||
? "posMaster.orgRootId IN (:...root)"
|
||||
: "posMaster.orgRootId is null"
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
},
|
||||
{ root: _data.root }
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `posMaster.orgChild1Id IN (:...child1)`
|
||||
? "posMaster.orgChild1Id IN (:...child1)"
|
||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
},
|
||||
{ child1: _data.child1 }
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
|
|
@ -2301,54 +2419,58 @@ export class PositionController extends Controller {
|
|||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
// .andWhere(checkChildConditions)
|
||||
// .andWhere(typeCondition)
|
||||
// .andWhere(revisionCondition);
|
||||
|
||||
if (body.keyword != null && body.keyword != "") {
|
||||
query.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? body.isAll == false
|
||||
? searchShortName
|
||||
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? body.isAll == false
|
||||
? searchShortName
|
||||
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.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);
|
||||
}),
|
||||
);
|
||||
.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);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
let [posMaster, total] = await query
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
|
|
@ -2525,7 +2647,11 @@ export class PositionController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||
if (
|
||||
_data.privilege === "NORMAL" ||
|
||||
_data.privilege === "CHILD" ||
|
||||
_data.privilege === "BROTHER"
|
||||
) {
|
||||
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap: any = {
|
||||
//เอาไวเช็ค CHILD ถัดไป
|
||||
|
|
@ -2539,7 +2665,7 @@ export class PositionController extends Controller {
|
|||
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
} else if (_data.privilege === "CHILD") {
|
||||
} else if (_data.privilege === "CHILD" || _data.privilege === "BROTHER") {
|
||||
const higherChildChecks = [
|
||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||
|
|
@ -2820,50 +2946,50 @@ export class PositionController extends Controller {
|
|||
const type0LastPosMasterNo =
|
||||
requestBody.type == 0
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo =
|
||||
requestBody.type == 1
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo =
|
||||
requestBody.type == 2
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo =
|
||||
requestBody.type == 3
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo =
|
||||
requestBody.type == 4
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
|
|
|
|||
|
|
@ -10800,67 +10800,20 @@ export class ProfileController extends Controller {
|
|||
*/
|
||||
@Post("search-personal-no-keycloak")
|
||||
async getProfileBySearchKeywordNoKeyCloak(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Body()
|
||||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
let findProfile: any;
|
||||
let total: any;
|
||||
const skip = (page - 1) * pageSize;
|
||||
const take = pageSize;
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
citizenId: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||
let _system: string = "SYS_REGISTRY_OFFICER";
|
||||
if (body.system) _system = body.system;
|
||||
let _data = await new permission().PermissionOrgList(request, _system);
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
|
@ -10868,45 +10821,124 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "fullName":
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "firstName":
|
||||
queryLike = "profile.firstName LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "lastName":
|
||||
queryLike = "profile.lastName LIKE :keyword";
|
||||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.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")
|
||||
.where("profile.keycloak IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
);
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
let shortName = null;
|
||||
let root = null;
|
||||
let posMasterNo = null;
|
||||
if (item.isLeave == false) {
|
||||
shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
root = root == null ? null : root.orgRootName;
|
||||
posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
}
|
||||
else {
|
||||
const profileSalary = await this.salaryRepo
|
||||
.createQueryBuilder("s")
|
||||
.where("s.profileId = :profileId", { profileId: item.id })
|
||||
.andWhere("s.commandCode IN (:...codes)", {
|
||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||
})
|
||||
.orderBy("s.order", "DESC")
|
||||
.addOrderBy("s.createdAt", "DESC")
|
||||
.take(2)
|
||||
.getMany();
|
||||
if (profileSalary.length > 0) {
|
||||
shortName = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||
posMasterNo = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.posNo
|
||||
: profileSalary[0]?.posNo
|
||||
: profileSalary[0]?.posNo;
|
||||
root = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot;
|
||||
}
|
||||
}
|
||||
|
||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||
where: { profileId: item.id },
|
||||
|
|
@ -10930,7 +10962,7 @@ export class ProfileController extends Controller {
|
|||
positionType: item.posTypeId,
|
||||
positionTypeName: item.posType?.posTypeName,
|
||||
posNo: shortName,
|
||||
organization: root == null ? null : root.orgRootName,
|
||||
organization: root,
|
||||
salary: item.amount,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
|
|
|
|||
|
|
@ -5726,111 +5726,136 @@ export class ProfileEmployeeController extends Controller {
|
|||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
let findProfile: any;
|
||||
let total: any;
|
||||
const skip = (page - 1) * pageSize;
|
||||
const take = pageSize;
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
citizenId: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "fullName":
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "firstName":
|
||||
queryLike = "profile.firstName LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "lastName":
|
||||
queryLike = "profile.lastName LIKE :keyword";
|
||||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.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")
|
||||
.where("profile.keycloak IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
);
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: ProfileEmployee) => {
|
||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
let shortName = null;
|
||||
let root = null;
|
||||
let posMasterNo = null;
|
||||
if (item.isLeave == false) {
|
||||
shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
root = root == null ? null : root.orgRootName;
|
||||
posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
}
|
||||
else {
|
||||
const profileSalary = await this.salaryRepo
|
||||
.createQueryBuilder("s")
|
||||
.where("s.profileEmployeeId = :profileId", { profileId: item.id })
|
||||
.andWhere("s.commandCode IN (:...codes)", {
|
||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||
})
|
||||
.orderBy("s.order", "DESC")
|
||||
.addOrderBy("s.createdAt", "DESC")
|
||||
.take(2)
|
||||
.getMany();
|
||||
if (profileSalary.length > 0) {
|
||||
shortName = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||
posMasterNo = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.posNo
|
||||
: profileSalary[0]?.posNo
|
||||
: profileSalary[0]?.posNo;
|
||||
root = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||
where: { profileEmployeeId: item.id },
|
||||
|
|
@ -5854,7 +5879,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
positionType: item.posTypeId,
|
||||
positionTypeName: item.posType?.posTypeName,
|
||||
posNo: shortName,
|
||||
organization: root == null ? null : root.orgRootName,
|
||||
organization: root,
|
||||
salary: item.amount,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
|
|
|
|||
|
|
@ -1030,7 +1030,7 @@ export class WorkflowController extends Controller {
|
|||
: data.map((x: any) => ({
|
||||
...x,
|
||||
posExecutiveNameOrg:
|
||||
x.posExecutiveName +
|
||||
x.posExecutiveName ?? "" +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
}));
|
||||
|
||||
|
|
@ -1227,7 +1227,7 @@ export class WorkflowController extends Controller {
|
|||
const processedData = data.map((x: any) => ({
|
||||
...x,
|
||||
posExecutiveNameOrg:
|
||||
x.posExecutiveName +
|
||||
x.posExecutiveName ?? "" +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -251,8 +251,11 @@ class Extension {
|
|||
|
||||
public static CheckCitizen(value: string) {
|
||||
let citizen = value;
|
||||
if (citizen == null || citizen == "") {
|
||||
return citizen;
|
||||
if (citizen == null || citizen == "" || citizen == undefined) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชน",
|
||||
);
|
||||
}
|
||||
if (citizen.length !== 13) {
|
||||
throw new HttpError(
|
||||
|
|
@ -277,9 +280,12 @@ class Extension {
|
|||
const calStp2 = cal % 11;
|
||||
const chkDigit = (11 - calStp2) % 10;
|
||||
|
||||
// if (citizenIdDigits[12] !== chkDigit) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
// }
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"
|
||||
);
|
||||
}
|
||||
return citizen;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,15 @@ class CheckAuth {
|
|||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
privilege: "CHILD",
|
||||
};
|
||||
} else if (privilege == "BROTHER") {
|
||||
data = {
|
||||
// root: node >= 0 ? [x.orgRootId] : null,
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 2 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 3 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 4 ? [x.orgChild3Id] : null,
|
||||
privilege: "BROTHER",
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
if (req.url.startsWith("/api/v1/org/apiKey/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/api-manage/")) system = "admin";
|
||||
|
||||
if (req.url.startsWith("/api/v1/org/keycloak/")) system = "registry";
|
||||
|
||||
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
|
||||
const profileByKeycloak = await repoProfile.findOne({
|
||||
where: { keycloak: req.app.locals.logData.userId },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue