Merge branch 'develop' into feat/org-move-draf-current
* develop: Fix Script #2292 Fix Script #2292 comment ห้ามลบเจ้าหน้าที่ลำดับที่ 1 #2220 optimize sort #2260
This commit is contained in:
commit
c344804936
3 changed files with 177 additions and 78 deletions
|
|
@ -187,13 +187,13 @@ export class CommandOperatorController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบเจ้าหน้าที่ดำเนินการ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบเจ้าหน้าที่ดำเนินการ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. ห้ามลบ orderNo = 1
|
// // 2. ห้ามลบ orderNo = 1
|
||||||
if (operator.orderNo === 1) {
|
// if (operator.orderNo === 1) {
|
||||||
throw new HttpError(
|
// throw new HttpError(
|
||||||
HttpStatusCode.BAD_REQUEST,
|
// HttpStatusCode.BAD_REQUEST,
|
||||||
"ไม่สามารถลบเจ้าหน้าที่ลำดับที่ 1 ได้"
|
// "ไม่สามารถลบเจ้าหน้าที่ลำดับที่ 1 ได้"
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
const removedOrderNo = operator.orderNo;
|
const removedOrderNo = operator.orderNo;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7151,75 +7151,174 @@ export class OrganizationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("root/search/sort")
|
@Get("root/search/sort")
|
||||||
async searchSortRootLevelType(@Request() request: RequestWithUser) {
|
async searchSortRootLevelType(@Request() request: RequestWithUser) {
|
||||||
const root1 = await this.orgRootRepository.find({
|
// const root1 = await this.orgRootRepository.find({
|
||||||
where: {
|
// where: {
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
DEPARTMENT_CODE: Not("50"),
|
// DEPARTMENT_CODE: Not("50"),
|
||||||
},
|
// },
|
||||||
order: { isDeputy: "DESC", orgRootOrder: "ASC" },
|
// order: { isDeputy: "DESC", orgRootOrder: "ASC" },
|
||||||
select: ["orgRootName"],
|
// select: ["orgRootName"],
|
||||||
});
|
// });
|
||||||
const root2 = await this.orgRootRepository.find({
|
// const root2 = await this.orgRootRepository.find({
|
||||||
where: {
|
// where: {
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
DEPARTMENT_CODE: "50",
|
// DEPARTMENT_CODE: "50",
|
||||||
},
|
// },
|
||||||
order: { orgRootName: "ASC" },
|
// order: { orgRootName: "ASC" },
|
||||||
select: ["orgRootName"],
|
// select: ["orgRootName"],
|
||||||
});
|
// });
|
||||||
const root = [...root1, ...root2];
|
// const root = [...root1, ...root2];
|
||||||
|
|
||||||
|
// const child1 = await this.child1Repository.find({
|
||||||
|
// where: {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// },
|
||||||
|
// order: { orgChild1Order: "ASC" },
|
||||||
|
// select: ["orgChild1Name"],
|
||||||
|
// });
|
||||||
|
// const child2 = await this.child2Repository.find({
|
||||||
|
// where: {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// },
|
||||||
|
// order: { orgChild2Order: "ASC" },
|
||||||
|
// select: ["orgChild2Name"],
|
||||||
|
// });
|
||||||
|
// const child3 = await this.child3Repository.find({
|
||||||
|
// where: {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// },
|
||||||
|
// order: { orgChild3Order: "ASC" },
|
||||||
|
// select: ["orgChild3Name"],
|
||||||
|
// });
|
||||||
|
// const child4 = await this.child4Repository.find({
|
||||||
|
// where: {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// },
|
||||||
|
// order: { orgChild4Order: "ASC" },
|
||||||
|
// select: ["orgChild4Name"],
|
||||||
|
// });
|
||||||
|
// const hospital = await this.child1Repository.find({
|
||||||
|
// where: [
|
||||||
|
// {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// orgRoot: { isDeputy: true },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
// orgChild1RankSub: "HOSPITAL",
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// select: ["orgChild1Name"],
|
||||||
|
// });
|
||||||
|
// const posType = await this.posTypeRepository.find({
|
||||||
|
// order: { posTypeRank: "DESC" },
|
||||||
|
// select: ["posTypeName"],
|
||||||
|
// });
|
||||||
|
// const posLevel = await this.posLevelRepository.find({
|
||||||
|
// order: { posLevelRank: "DESC" },
|
||||||
|
// select: ["posLevelName"],
|
||||||
|
// });
|
||||||
|
|
||||||
|
const [
|
||||||
|
roots,
|
||||||
|
child1,
|
||||||
|
child2,
|
||||||
|
child3,
|
||||||
|
child4,
|
||||||
|
hospital,
|
||||||
|
posType,
|
||||||
|
posLevel,
|
||||||
|
] = await Promise.all([
|
||||||
|
|
||||||
|
// ===== ROOT =====
|
||||||
|
this.orgRootRepository
|
||||||
|
.createQueryBuilder("root")
|
||||||
|
.innerJoin("root.orgRevision", "rev")
|
||||||
|
.select([
|
||||||
|
"root.orgRootName AS orgRootName",
|
||||||
|
])
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.orderBy(
|
||||||
|
"CASE WHEN root.DEPARTMENT_CODE = '50' THEN 1 ELSE 0 END",
|
||||||
|
"ASC",
|
||||||
|
)
|
||||||
|
.addOrderBy("root.isDeputy", "DESC")
|
||||||
|
.addOrderBy("root.orgRootOrder", "ASC")
|
||||||
|
.addOrderBy("root.orgRootName", "ASC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== CHILD 1 =====
|
||||||
|
this.child1Repository
|
||||||
|
.createQueryBuilder("c1")
|
||||||
|
.innerJoin("c1.orgRevision", "rev")
|
||||||
|
.select("c1.orgChild1Name", "orgChild1Name")
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.orderBy("c1.orgChild1Order", "ASC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== CHILD 2 =====
|
||||||
|
this.child2Repository
|
||||||
|
.createQueryBuilder("c2")
|
||||||
|
.innerJoin("c2.orgRevision", "rev")
|
||||||
|
.select("c2.orgChild2Name", "orgChild2Name")
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.orderBy("c2.orgChild2Order", "ASC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== CHILD 3 =====
|
||||||
|
this.child3Repository
|
||||||
|
.createQueryBuilder("c3")
|
||||||
|
.innerJoin("c3.orgRevision", "rev")
|
||||||
|
.select("c3.orgChild3Name", "orgChild3Name")
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.orderBy("c3.orgChild3Order", "ASC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== CHILD 4 =====
|
||||||
|
this.child4Repository
|
||||||
|
.createQueryBuilder("c4")
|
||||||
|
.innerJoin("c4.orgRevision", "rev")
|
||||||
|
.select("c4.orgChild4Name", "orgChild4Name")
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.orderBy("c4.orgChild4Order", "ASC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== HOSPITAL =====
|
||||||
|
this.child1Repository
|
||||||
|
.createQueryBuilder("c1")
|
||||||
|
.innerJoin("c1.orgRevision", "rev")
|
||||||
|
.leftJoin("c1.orgRoot", "root")
|
||||||
|
.select("c1.orgChild1Name", "orgChild1Name")
|
||||||
|
.where("rev.orgRevisionIsDraft = false")
|
||||||
|
.andWhere("rev.orgRevisionIsCurrent = true")
|
||||||
|
.andWhere(
|
||||||
|
"(root.isDeputy = true OR c1.orgChild1RankSub = :rank)",
|
||||||
|
{ rank: "HOSPITAL" },
|
||||||
|
)
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== POSITION TYPE =====
|
||||||
|
this.posTypeRepository
|
||||||
|
.createQueryBuilder("pt")
|
||||||
|
.select("pt.posTypeName", "posTypeName")
|
||||||
|
.orderBy("pt.posTypeRank", "DESC")
|
||||||
|
.getRawMany(),
|
||||||
|
|
||||||
|
// ===== POSITION LEVEL =====
|
||||||
|
this.posLevelRepository
|
||||||
|
.createQueryBuilder("pl")
|
||||||
|
.select("pl.posLevelName", "posLevelName")
|
||||||
|
.orderBy("pl.posLevelRank", "DESC")
|
||||||
|
.getRawMany(),
|
||||||
|
]);
|
||||||
|
|
||||||
const child1 = await this.child1Repository.find({
|
|
||||||
where: {
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
},
|
|
||||||
order: { orgChild1Order: "ASC" },
|
|
||||||
select: ["orgChild1Name"],
|
|
||||||
});
|
|
||||||
const child2 = await this.child2Repository.find({
|
|
||||||
where: {
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
},
|
|
||||||
order: { orgChild2Order: "ASC" },
|
|
||||||
select: ["orgChild2Name"],
|
|
||||||
});
|
|
||||||
const child3 = await this.child3Repository.find({
|
|
||||||
where: {
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
},
|
|
||||||
order: { orgChild3Order: "ASC" },
|
|
||||||
select: ["orgChild3Name"],
|
|
||||||
});
|
|
||||||
const child4 = await this.child4Repository.find({
|
|
||||||
where: {
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
},
|
|
||||||
order: { orgChild4Order: "ASC" },
|
|
||||||
select: ["orgChild4Name"],
|
|
||||||
});
|
|
||||||
const hospital = await this.child1Repository.find({
|
|
||||||
where: [
|
|
||||||
{
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
orgRoot: { isDeputy: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
orgChild1RankSub: "HOSPITAL",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
select: ["orgChild1Name"],
|
|
||||||
});
|
|
||||||
const posType = await this.posTypeRepository.find({
|
|
||||||
order: { posTypeRank: "DESC" },
|
|
||||||
select: ["posTypeName"],
|
|
||||||
});
|
|
||||||
const posLevel = await this.posLevelRepository.find({
|
|
||||||
order: { posLevelRank: "DESC" },
|
|
||||||
select: ["posLevelName"],
|
|
||||||
});
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
root: root.map((x) => x.orgRootName),
|
root: roots.map((x) => x.orgRootName),
|
||||||
child1: child1.map((x) => x.orgChild1Name),
|
child1: child1.map((x) => x.orgChild1Name),
|
||||||
child2: child2.map((x) => x.orgChild2Name),
|
child2: child2.map((x) => x.orgChild2Name),
|
||||||
child3: child3.map((x) => x.orgChild3Name),
|
child3: child3.map((x) => x.orgChild3Name),
|
||||||
|
|
|
||||||
|
|
@ -1431,10 +1431,10 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
profileEmployeeId: x.profileEmployeeId,
|
profileEmployeeId: x.profileEmployeeId,
|
||||||
dateStart: x.commandDateAffect,
|
dateStart: x.commandDateAffect,
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
posNo: x.posNo,
|
posNo: `${x.posNoAbb} ${x.posNo}`,
|
||||||
position: x.positionName,
|
position: x.positionName,
|
||||||
commandId: x.commandId,
|
commandId: x.commandId,
|
||||||
refCommandNo: x.commandNo,
|
refCommandNo: `${x.commandNo}/${x.commandYear}`,
|
||||||
refCommandDate: x.commandDateAffect,
|
refCommandDate: x.commandDateAffect,
|
||||||
status: false,
|
status: false,
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
|
|
@ -1454,8 +1454,8 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
dateStart: x.commandDateAffect,
|
dateStart: x.commandDateAffect,
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
commandId: x.commandId,
|
commandId: x.commandId,
|
||||||
commandNo: x.commandNo,
|
commandNo: `${x.commandNo}/${x.commandYear}`,
|
||||||
commandName: x.commandName,
|
commandName: x.commandName ?? "ให้ช่วยราชการ",
|
||||||
refCommandDate: x.commandDateSign,
|
refCommandDate: x.commandDateSign,
|
||||||
refId: x.refId,
|
refId: x.refId,
|
||||||
status: "DONE",
|
status: "DONE",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue