เลขที่ตำแหน่งซ้ำ
This commit is contained in:
parent
b42af12a5f
commit
7eef964d48
1 changed files with 27 additions and 10 deletions
|
|
@ -413,35 +413,35 @@ 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.shortName;
|
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.shortName;
|
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.shortName;
|
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.shortName;
|
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.shortName;
|
SName = orgChild4.orgChild4ShortName;
|
||||||
if (!orgChild4) {
|
if (!orgChild4) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -696,35 +696,35 @@ 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.shortName;
|
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.shortName;
|
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.shortName;
|
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.shortName;
|
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.shortName;
|
SName = orgChild4.orgChild4ShortName;
|
||||||
if (!orgChild4) {
|
if (!orgChild4) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -758,6 +758,23 @@ export class PositionController extends Controller {
|
||||||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionId: posMaster.orgRevisionId,
|
||||||
|
orgRoot: { orgRootShortName: SName },
|
||||||
|
orgChild1Id: IsNull(),
|
||||||
|
posMasterNo: requestBody.posMasterNo,
|
||||||
|
id: Not(posMaster.id),
|
||||||
|
},
|
||||||
|
relations: ["orgRoot"],
|
||||||
|
});
|
||||||
|
if (chk_SName0 != null) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const chk_SName1 = await this.posMasterRepository.findOne({
|
const chk_SName1 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionId: posMaster.orgRevisionId,
|
orgRevisionId: posMaster.orgRevisionId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue