เพิ่มฟิว isretire
This commit is contained in:
parent
d45f957214
commit
b53176ed05
3 changed files with 180 additions and 188 deletions
|
|
@ -33,181 +33,181 @@ import { PosMaster } from "../entities/PosMaster";
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class OrganizationUnauthorizeController extends Controller {
|
export class OrganizationUnauthorizeController extends Controller {
|
||||||
|
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
||||||
*
|
*
|
||||||
* @summary ORG_072 - รายชื่อราชการที่เลื่อนเงินเดือน #76 (unauthorize)
|
* @summary ORG_072 - รายชื่อราชการที่เลื่อนเงินเดือน #76 (unauthorize)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("salary/gen")
|
@Post("salary/gen")
|
||||||
async salaryGen(
|
async salaryGen(
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
page: number;
|
page: number;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const findRevision = await this.orgRevisionRepository.findOne({
|
const findRevision = await this.orgRevisionRepository.findOne({
|
||||||
where: { orgRevisionIsCurrent: true },
|
where: { orgRevisionIsCurrent: true },
|
||||||
});
|
});
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [findPosMaster, total] = await AppDataSource.getRepository(PosMaster)
|
|
||||||
.createQueryBuilder("posMaster")
|
|
||||||
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
|
||||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
|
||||||
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
|
||||||
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
|
||||||
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
|
||||||
.leftJoinAndSelect("posMaster.positions", "positions")
|
|
||||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
|
||||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
|
||||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
|
||||||
.where({
|
|
||||||
orgRevisionId: findRevision?.id,
|
|
||||||
current_holderId: Not(IsNull()),
|
|
||||||
})
|
|
||||||
.andWhere(
|
|
||||||
new Brackets((qb) => {
|
|
||||||
qb.where(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "current_holder.prefix LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "current_holder.firstName LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "current_holder.lastName LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "current_holder.position LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "current_holder.citizenId LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "posType.posTypeName LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "posLevel.posLevelName LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.skip((body.page - 1) * body.pageSize)
|
|
||||||
.take(body.pageSize)
|
|
||||||
.getManyAndCount();
|
|
||||||
if (!findPosMaster) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedData = findPosMaster.map((item) => {
|
const [findPosMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
let orgShortName = "";
|
.createQueryBuilder("posMaster")
|
||||||
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
if (item.orgChild1Id === null) {
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
orgShortName = item.orgRoot?.orgRootShortName;
|
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
} else if (item.orgChild2Id === null) {
|
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
||||||
orgShortName = item.orgChild1?.orgChild1ShortName;
|
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
||||||
} else if (item.orgChild3Id === null) {
|
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||||
orgShortName = item.orgChild2?.orgChild2ShortName;
|
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||||
} else if (item.orgChild4Id === null) {
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
orgShortName = item.orgChild3?.orgChild3ShortName;
|
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||||
} else {
|
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||||
orgShortName = item.orgChild4?.orgChild4ShortName;
|
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||||
}
|
.where({
|
||||||
const posExecutive =
|
orgRevisionId: findRevision?.id,
|
||||||
item.positions == null ||
|
current_holderId: Not(IsNull()),
|
||||||
item.positions?.find((position) => position.positionIsSelected == true) == null ||
|
})
|
||||||
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
.andWhere(
|
||||||
null ||
|
new Brackets((qb) => {
|
||||||
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
qb.where(
|
||||||
?.posExecutiveName == null
|
body.keyword != null && body.keyword != ""
|
||||||
? null
|
? "current_holder.prefix LIKE :keyword"
|
||||||
: item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
: "1=1",
|
||||||
.posExecutiveName;
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
const amount =
|
},
|
||||||
item.current_holder == null || item.current_holder.profileSalary.length == 0
|
)
|
||||||
? null
|
.orWhere(
|
||||||
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "current_holder.firstName LIKE :keyword"
|
||||||
return {
|
: "1=1",
|
||||||
prefix: item.current_holder.prefix,
|
{
|
||||||
firstName: item.current_holder.firstName,
|
keyword: `%${body.keyword}%`,
|
||||||
lastName: item.current_holder.lastName,
|
},
|
||||||
citizenId: item.current_holder.citizenId,
|
)
|
||||||
posMasterNoPrefix: item.posMasterNoPrefix,
|
.orWhere(
|
||||||
posMasterNo: item.posMasterNo,
|
body.keyword != null && body.keyword != ""
|
||||||
posMasterNoSuffix: item.posMasterNoSuffix,
|
? "current_holder.lastName LIKE :keyword"
|
||||||
orgShortName: orgShortName,
|
: "1=1",
|
||||||
position: item.current_holder.position,
|
{
|
||||||
posType: item.current_holder.posType.posTypeName,
|
keyword: `%${body.keyword}%`,
|
||||||
posLevel: item.current_holder.posLevel.posLevelName,
|
},
|
||||||
posExecutive: posExecutive,
|
)
|
||||||
amount: amount?amount:0,
|
.orWhere(
|
||||||
rootId: item.orgRootId,
|
body.keyword != null && body.keyword != ""
|
||||||
root: item.orgRoot?.orgRootName?item.orgRoot.orgRootName:null,
|
? "current_holder.position LIKE :keyword"
|
||||||
child1Id: item.orgChild1Id,
|
: "1=1",
|
||||||
child1: item.orgChild1?.orgChild1Name?item.orgChild1.orgChild1Name:null,
|
{
|
||||||
child2Id: item.orgChild2Id,
|
keyword: `%${body.keyword}%`,
|
||||||
child2: item.orgChild2?.orgChild2Name?item.orgChild2.orgChild2Name:null,
|
},
|
||||||
child3Id: item.orgChild3Id,
|
)
|
||||||
child3: item.orgChild3?.orgChild3Name?item.orgChild3.orgChild3Name:null,
|
|
||||||
child4Id: item.orgChild4Id,
|
.orWhere(
|
||||||
child4: item.orgChild4?.orgChild4Name?item.orgChild4.orgChild4Name:null,
|
body.keyword != null && body.keyword != ""
|
||||||
isResult: true,
|
? "current_holder.citizenId LIKE :keyword"
|
||||||
isDuration: false,
|
: "1=1",
|
||||||
isPunish: true,
|
{
|
||||||
isRetired: false,
|
keyword: `%${body.keyword}%`,
|
||||||
isRetired2: true,
|
},
|
||||||
};
|
)
|
||||||
});
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
return new HttpSuccess({data:formattedData,total:total});
|
? "posType.posTypeName LIKE :keyword"
|
||||||
}
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "posLevel.posLevelName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
if (!findPosMaster) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
|
||||||
|
}
|
||||||
|
|
||||||
|
const formattedData = findPosMaster.map((item) => {
|
||||||
|
let orgShortName = "";
|
||||||
|
|
||||||
|
if (item.orgChild1Id === null) {
|
||||||
|
orgShortName = item.orgRoot?.orgRootShortName;
|
||||||
|
} else if (item.orgChild2Id === null) {
|
||||||
|
orgShortName = item.orgChild1?.orgChild1ShortName;
|
||||||
|
} else if (item.orgChild3Id === null) {
|
||||||
|
orgShortName = item.orgChild2?.orgChild2ShortName;
|
||||||
|
} else if (item.orgChild4Id === null) {
|
||||||
|
orgShortName = item.orgChild3?.orgChild3ShortName;
|
||||||
|
} else {
|
||||||
|
orgShortName = item.orgChild4?.orgChild4ShortName;
|
||||||
|
}
|
||||||
|
const posExecutive =
|
||||||
|
item.positions == null ||
|
||||||
|
item.positions?.find((position) => position.positionIsSelected == true) == null ||
|
||||||
|
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
||||||
|
null ||
|
||||||
|
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
|
?.posExecutiveName == null
|
||||||
|
? null
|
||||||
|
: item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
|
.posExecutiveName;
|
||||||
|
|
||||||
|
const amount =
|
||||||
|
item.current_holder == null || item.current_holder.profileSalary.length == 0
|
||||||
|
? null
|
||||||
|
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
|
||||||
|
|
||||||
|
return {
|
||||||
|
prefix: item.current_holder.prefix,
|
||||||
|
firstName: item.current_holder.firstName,
|
||||||
|
lastName: item.current_holder.lastName,
|
||||||
|
citizenId: item.current_holder.citizenId,
|
||||||
|
posMasterNoPrefix: item.posMasterNoPrefix,
|
||||||
|
posMasterNo: item.posMasterNo,
|
||||||
|
posMasterNoSuffix: item.posMasterNoSuffix,
|
||||||
|
orgShortName: orgShortName,
|
||||||
|
position: item.current_holder.position,
|
||||||
|
posType: item.current_holder.posType.posTypeName,
|
||||||
|
posLevel: item.current_holder.posLevel.posLevelName,
|
||||||
|
posExecutive: posExecutive,
|
||||||
|
amount: amount ? amount : 0,
|
||||||
|
rootId: item.orgRootId,
|
||||||
|
root: item.orgRoot?.orgRootName ? item.orgRoot.orgRootName : null,
|
||||||
|
child1Id: item.orgChild1Id,
|
||||||
|
child1: item.orgChild1?.orgChild1Name ? item.orgChild1.orgChild1Name : null,
|
||||||
|
child2Id: item.orgChild2Id,
|
||||||
|
child2: item.orgChild2?.orgChild2Name ? item.orgChild2.orgChild2Name : null,
|
||||||
|
child3Id: item.orgChild3Id,
|
||||||
|
child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null,
|
||||||
|
child4Id: item.orgChild4Id,
|
||||||
|
child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null,
|
||||||
|
result: null,
|
||||||
|
duration: null,
|
||||||
|
punish: null,
|
||||||
|
retired: null,
|
||||||
|
retired2: null,
|
||||||
|
isRetired: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: formattedData, total: total });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API หาสำนักทั้งหมด (unauthorize)
|
* API หาสำนักทั้งหมด (unauthorize)
|
||||||
|
|
|
||||||
|
|
@ -397,35 +397,30 @@ export class PositionController extends Controller {
|
||||||
orgRoot = await this.orgRootRepository.findOne({
|
orgRoot = await this.orgRootRepository.findOne({
|
||||||
where: { id: requestBody.orgRootId },
|
where: { id: requestBody.orgRootId },
|
||||||
});
|
});
|
||||||
SName = orgRoot.orgRootShortName;
|
|
||||||
if (!orgRoot) {
|
if (!orgRoot) {
|
||||||
let orgChild1: any = null;
|
let orgChild1: any = null;
|
||||||
if (requestBody.orgChild1Id != null)
|
if (requestBody.orgChild1Id != null)
|
||||||
orgChild1 = await this.child1Repository.findOne({
|
orgChild1 = await this.child1Repository.findOne({
|
||||||
where: { id: requestBody.orgChild1Id },
|
where: { id: requestBody.orgChild1Id },
|
||||||
});
|
});
|
||||||
SName = orgChild1.orgChild1ShortName;
|
|
||||||
if (!orgChild1) {
|
if (!orgChild1) {
|
||||||
let orgChild2: any = null;
|
let orgChild2: any = null;
|
||||||
if (requestBody.orgChild2Id != null)
|
if (requestBody.orgChild2Id != null)
|
||||||
orgChild2 = await this.child2Repository.findOne({
|
orgChild2 = await this.child2Repository.findOne({
|
||||||
where: { id: requestBody.orgChild2Id },
|
where: { id: requestBody.orgChild2Id },
|
||||||
});
|
});
|
||||||
SName = orgChild2.orgChild2ShortName;
|
|
||||||
if (!orgChild2) {
|
if (!orgChild2) {
|
||||||
let orgChild3: any = null;
|
let orgChild3: any = null;
|
||||||
if (requestBody.orgChild3Id != null)
|
if (requestBody.orgChild3Id != null)
|
||||||
orgChild3 = await this.child3Repository.findOne({
|
orgChild3 = await this.child3Repository.findOne({
|
||||||
where: { id: requestBody.orgChild3Id },
|
where: { id: requestBody.orgChild3Id },
|
||||||
});
|
});
|
||||||
SName = orgChild3.orgChild3ShortName;
|
|
||||||
if (!orgChild3) {
|
if (!orgChild3) {
|
||||||
let orgChild4: any = null;
|
let orgChild4: any = null;
|
||||||
if (requestBody.orgChild4Id != null)
|
if (requestBody.orgChild4Id != null)
|
||||||
orgChild4 = await this.child4Repository.findOne({
|
orgChild4 = await this.child4Repository.findOne({
|
||||||
where: { id: requestBody.orgChild4Id },
|
where: { id: requestBody.orgChild4Id },
|
||||||
});
|
});
|
||||||
SName = orgChild4.orgChild4ShortName;
|
|
||||||
if (!orgChild4) {
|
if (!orgChild4) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -445,6 +440,7 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgChild3Id = orgChild4.orgChild3Id;
|
posMaster.orgChild3Id = orgChild4.orgChild3Id;
|
||||||
posMaster.orgChild4Id = orgChild4.id;
|
posMaster.orgChild4Id = orgChild4.id;
|
||||||
posMaster.orgRevisionId = orgChild4.orgRevisionId;
|
posMaster.orgRevisionId = orgChild4.orgRevisionId;
|
||||||
|
SName = orgChild4.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const order: any = await this.posMasterRepository.findOne({
|
const order: any = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -463,6 +459,7 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgChild2Id = orgChild3.orgChild2Id;
|
posMaster.orgChild2Id = orgChild3.orgChild2Id;
|
||||||
posMaster.orgChild3Id = orgChild3.id;
|
posMaster.orgChild3Id = orgChild3.id;
|
||||||
posMaster.orgRevisionId = orgChild3.orgRevisionId;
|
posMaster.orgRevisionId = orgChild3.orgRevisionId;
|
||||||
|
SName = orgChild3.orgChild3ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const order: any = await this.posMasterRepository.findOne({
|
const order: any = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -481,6 +478,7 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgChild1Id = orgChild2.orgChild1Id;
|
posMaster.orgChild1Id = orgChild2.orgChild1Id;
|
||||||
posMaster.orgChild2Id = orgChild2.id;
|
posMaster.orgChild2Id = orgChild2.id;
|
||||||
posMaster.orgRevisionId = orgChild2.orgRevisionId;
|
posMaster.orgRevisionId = orgChild2.orgRevisionId;
|
||||||
|
SName = orgChild2.orgChild2ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const order: any = await this.posMasterRepository.findOne({
|
const order: any = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -499,6 +497,7 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgRootId = orgChild1.orgRootId;
|
posMaster.orgRootId = orgChild1.orgRootId;
|
||||||
posMaster.orgChild1Id = orgChild1.id;
|
posMaster.orgChild1Id = orgChild1.id;
|
||||||
posMaster.orgRevisionId = orgChild1.orgRevisionId;
|
posMaster.orgRevisionId = orgChild1.orgRevisionId;
|
||||||
|
SName = orgChild1.orgChild1ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const order: any = await this.posMasterRepository.findOne({
|
const order: any = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -517,6 +516,7 @@ export class PositionController extends Controller {
|
||||||
: 1;
|
: 1;
|
||||||
posMaster.orgRootId = orgRoot.id;
|
posMaster.orgRootId = orgRoot.id;
|
||||||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||||
|
SName = orgRoot.orgRootShortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -680,35 +680,30 @@ export class PositionController extends Controller {
|
||||||
orgRoot = await this.orgRootRepository.findOne({
|
orgRoot = await this.orgRootRepository.findOne({
|
||||||
where: { id: requestBody.orgRootId },
|
where: { id: requestBody.orgRootId },
|
||||||
});
|
});
|
||||||
SName = orgRoot.orgRootShortName;
|
|
||||||
if (!orgRoot) {
|
if (!orgRoot) {
|
||||||
let orgChild1: any = null;
|
let orgChild1: any = null;
|
||||||
if (requestBody.orgChild1Id != null)
|
if (requestBody.orgChild1Id != null)
|
||||||
orgChild1 = await this.child1Repository.findOne({
|
orgChild1 = await this.child1Repository.findOne({
|
||||||
where: { id: requestBody.orgChild1Id },
|
where: { id: requestBody.orgChild1Id },
|
||||||
});
|
});
|
||||||
SName = orgChild1.orgChild1ShortName;
|
|
||||||
if (!orgChild1) {
|
if (!orgChild1) {
|
||||||
let orgChild2: any = null;
|
let orgChild2: any = null;
|
||||||
if (requestBody.orgChild2Id != null)
|
if (requestBody.orgChild2Id != null)
|
||||||
orgChild2 = await this.child2Repository.findOne({
|
orgChild2 = await this.child2Repository.findOne({
|
||||||
where: { id: requestBody.orgChild2Id },
|
where: { id: requestBody.orgChild2Id },
|
||||||
});
|
});
|
||||||
SName = orgChild2.orgChild2ShortName;
|
|
||||||
if (!orgChild2) {
|
if (!orgChild2) {
|
||||||
let orgChild3: any = null;
|
let orgChild3: any = null;
|
||||||
if (requestBody.orgChild3Id != null)
|
if (requestBody.orgChild3Id != null)
|
||||||
orgChild3 = await this.child3Repository.findOne({
|
orgChild3 = await this.child3Repository.findOne({
|
||||||
where: { id: requestBody.orgChild3Id },
|
where: { id: requestBody.orgChild3Id },
|
||||||
});
|
});
|
||||||
SName = orgChild3.orgChild3ShortName;
|
|
||||||
if (!orgChild3) {
|
if (!orgChild3) {
|
||||||
let orgChild4: any = null;
|
let orgChild4: any = null;
|
||||||
if (requestBody.orgChild4Id != null)
|
if (requestBody.orgChild4Id != null)
|
||||||
orgChild4 = await this.child4Repository.findOne({
|
orgChild4 = await this.child4Repository.findOne({
|
||||||
where: { id: requestBody.orgChild4Id },
|
where: { id: requestBody.orgChild4Id },
|
||||||
});
|
});
|
||||||
SName = orgChild4.orgChild4ShortName;
|
|
||||||
if (!orgChild4) {
|
if (!orgChild4) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -718,6 +713,7 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgChild3Id = orgChild4.orgChild3Id;
|
posMaster.orgChild3Id = orgChild4.orgChild3Id;
|
||||||
posMaster.orgChild4Id = orgChild4.id;
|
posMaster.orgChild4Id = orgChild4.id;
|
||||||
posMaster.orgRevisionId = orgChild4.orgRevisionId;
|
posMaster.orgRevisionId = orgChild4.orgRevisionId;
|
||||||
|
SName = orgChild4.orgChild4ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
posMaster.orgRootId = orgChild3.orgRootId;
|
posMaster.orgRootId = orgChild3.orgRootId;
|
||||||
|
|
@ -725,21 +721,25 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgChild2Id = orgChild3.orgChild2Id;
|
posMaster.orgChild2Id = orgChild3.orgChild2Id;
|
||||||
posMaster.orgChild3Id = orgChild3.id;
|
posMaster.orgChild3Id = orgChild3.id;
|
||||||
posMaster.orgRevisionId = orgChild3.orgRevisionId;
|
posMaster.orgRevisionId = orgChild3.orgRevisionId;
|
||||||
|
SName = orgChild3.orgChild3ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
posMaster.orgRootId = orgChild2.orgRootId;
|
posMaster.orgRootId = orgChild2.orgRootId;
|
||||||
posMaster.orgChild1Id = orgChild2.orgChild1Id;
|
posMaster.orgChild1Id = orgChild2.orgChild1Id;
|
||||||
posMaster.orgChild2Id = orgChild2.id;
|
posMaster.orgChild2Id = orgChild2.id;
|
||||||
posMaster.orgRevisionId = orgChild2.orgRevisionId;
|
posMaster.orgRevisionId = orgChild2.orgRevisionId;
|
||||||
|
SName = orgChild2.orgChild2ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
posMaster.orgRootId = orgChild1.orgRootId;
|
posMaster.orgRootId = orgChild1.orgRootId;
|
||||||
posMaster.orgChild1Id = orgChild1.id;
|
posMaster.orgChild1Id = orgChild1.id;
|
||||||
posMaster.orgRevisionId = orgChild1.orgRevisionId;
|
posMaster.orgRevisionId = orgChild1.orgRevisionId;
|
||||||
|
SName = orgChild1.orgChild1ShortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
posMaster.orgRootId = orgRoot.id;
|
posMaster.orgRootId = orgRoot.id;
|
||||||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||||
|
SName = orgRoot.orgRootShortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -1968,10 +1968,7 @@ export class PositionController extends Controller {
|
||||||
relations: ["positions"],
|
relations: ["positions"],
|
||||||
});
|
});
|
||||||
if (!dataMaster) {
|
if (!dataMaster) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลตำแหน่งนี้"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
dataMaster.positions.forEach(async (position) => {
|
dataMaster.positions.forEach(async (position) => {
|
||||||
if (position.id === requestBody.position) {
|
if (position.id === requestBody.position) {
|
||||||
|
|
@ -2042,10 +2039,7 @@ export class PositionController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!dataPublish) {
|
if (!dataPublish) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลตำแหน่งนี้",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataDraft = await this.posMasterRepository.findOne({
|
const dataDraft = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -2054,10 +2048,7 @@ export class PositionController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!dataDraft) {
|
if (!dataDraft) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลตำแหน่งนี้"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.posMasterRepository.update(
|
await this.posMasterRepository.update(
|
||||||
|
|
|
||||||
|
|
@ -1060,6 +1060,7 @@ export class ProfileController extends Controller {
|
||||||
punish: null,
|
punish: null,
|
||||||
retired: null,
|
retired: null,
|
||||||
retired2: null,
|
retired2: null,
|
||||||
|
isRetired: null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue