restore edit
This commit is contained in:
parent
72ac021b16
commit
45c9ed549e
1 changed files with 41 additions and 98 deletions
|
|
@ -774,97 +774,15 @@ export class PositionController extends Controller {
|
||||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||||
posMaster.reason = requestBody.reason == null ? "" : requestBody.reason;
|
posMaster.reason = requestBody.reason == null ? "" : requestBody.reason;
|
||||||
|
|
||||||
let orgRoot: any = null;
|
if (posMaster.orgChild4Id != null) {
|
||||||
let SName: any = null;
|
const chk_SName4 = await this.posMasterRepository.findOne({
|
||||||
if (requestBody.orgRootId != null)
|
|
||||||
orgRoot = await this.orgRootRepository.findOne({
|
|
||||||
where: { id: requestBody.orgRootId },
|
|
||||||
});
|
|
||||||
if (!orgRoot) {
|
|
||||||
let orgChild1: any = null;
|
|
||||||
if (requestBody.orgChild1Id != null)
|
|
||||||
orgChild1 = await this.child1Repository.findOne({
|
|
||||||
where: { id: requestBody.orgChild1Id },
|
|
||||||
});
|
|
||||||
if (!orgChild1) {
|
|
||||||
let orgChild2: any = null;
|
|
||||||
if (requestBody.orgChild2Id != null)
|
|
||||||
orgChild2 = await this.child2Repository.findOne({
|
|
||||||
where: { id: requestBody.orgChild2Id },
|
|
||||||
});
|
|
||||||
if (!orgChild2) {
|
|
||||||
let orgChild3: any = null;
|
|
||||||
if (requestBody.orgChild3Id != null)
|
|
||||||
orgChild3 = await this.child3Repository.findOne({
|
|
||||||
where: { id: requestBody.orgChild3Id },
|
|
||||||
});
|
|
||||||
if (!orgChild3) {
|
|
||||||
let orgChild4: any = null;
|
|
||||||
if (requestBody.orgChild4Id != null)
|
|
||||||
orgChild4 = await this.child4Repository.findOne({
|
|
||||||
where: { id: requestBody.orgChild4Id },
|
|
||||||
});
|
|
||||||
if (!orgChild4) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
|
||||||
} else {
|
|
||||||
SName = orgChild4.orgChild4ShortName;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SName = orgChild3.orgChild3ShortName;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SName = orgChild2.orgChild2ShortName;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SName = orgChild1.orgChild1ShortName;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SName = orgRoot.orgRootShortName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posMaster.orgRootId != null) {
|
|
||||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
orgChild4Id: posMaster.orgChild4Id,
|
||||||
orgRoot: { orgRootShortName: SName },
|
|
||||||
orgChild1Id: IsNull(),
|
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
relations: ["orgRoot"],
|
|
||||||
});
|
});
|
||||||
if (chk_SName0 != null) {
|
if (chk_SName4 != null) {
|
||||||
throw new HttpError(
|
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (posMaster.orgChild1Id != null) {
|
|
||||||
const chk_SName1 = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
orgChild1: { orgChild1ShortName: SName },
|
|
||||||
orgChild2Id: IsNull(),
|
|
||||||
posMasterNo: requestBody.posMasterNo,
|
|
||||||
},
|
|
||||||
relations: ["orgChild1"],
|
|
||||||
});
|
|
||||||
if (chk_SName1 != null) {
|
|
||||||
throw new HttpError(
|
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (posMaster.orgChild2Id != null) {
|
|
||||||
const chk_SName2 = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
|
||||||
orgChild2: { orgChild2ShortName: SName },
|
|
||||||
orgChild3Id: IsNull(),
|
|
||||||
posMasterNo: requestBody.posMasterNo,
|
|
||||||
},
|
|
||||||
relations: ["orgChild2"],
|
|
||||||
});
|
|
||||||
if (chk_SName2 != null) {
|
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
|
|
@ -873,12 +791,10 @@ export class PositionController extends Controller {
|
||||||
} else if (posMaster.orgChild3Id != null) {
|
} else if (posMaster.orgChild3Id != null) {
|
||||||
const chk_SName3 = await this.posMasterRepository.findOne({
|
const chk_SName3 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
orgChild3Id: posMaster.orgChild3Id,
|
||||||
orgChild3: { orgChild3ShortName: SName },
|
|
||||||
orgChild4Id: IsNull(),
|
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
relations: ["orgChild3"],
|
|
||||||
});
|
});
|
||||||
if (chk_SName3 != null) {
|
if (chk_SName3 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -886,16 +802,43 @@ export class PositionController extends Controller {
|
||||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (posMaster.orgChild4Id != null) {
|
} else if (posMaster.orgChild2Id != null) {
|
||||||
const chk_SName4 = await this.posMasterRepository.findOne({
|
const chk_SName2 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
orgChild2Id: posMaster.orgChild2Id,
|
||||||
orgChild4: { orgChild4ShortName: SName },
|
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
relations: ["orgChild4"],
|
|
||||||
});
|
});
|
||||||
if (chk_SName4 != null) {
|
if (chk_SName2 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (posMaster.orgChild1Id != null) {
|
||||||
|
const chk_SName1 = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgChild1Id: posMaster.orgChild1Id,
|
||||||
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (chk_SName1 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (posMaster.orgRootId != null) {
|
||||||
|
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRootId: posMaster.orgRootId,
|
||||||
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (chk_SName0 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue