fix
This commit is contained in:
parent
404f4afb61
commit
72ac021b16
1 changed files with 83 additions and 81 deletions
|
|
@ -621,7 +621,7 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||
SName = orgRoot.orgRootShortName;
|
||||
}
|
||||
|
||||
|
||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
|
|
@ -700,7 +700,7 @@ export class PositionController extends Controller {
|
|||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -773,7 +773,7 @@ export class PositionController extends Controller {
|
|||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
posMaster.reason = requestBody.reason == null ? "" : requestBody.reason;
|
||||
|
||||
|
||||
let orgRoot: any = null;
|
||||
let SName: any = null;
|
||||
if (requestBody.orgRootId != null)
|
||||
|
|
@ -821,84 +821,86 @@ export class PositionController extends Controller {
|
|||
} else {
|
||||
SName = orgRoot.orgRootShortName;
|
||||
}
|
||||
|
||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgRoot: { orgRootShortName: SName },
|
||||
orgChild1Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgRoot"],
|
||||
});
|
||||
if (chk_SName0 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_SName3 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgChild3: { orgChild3ShortName: SName },
|
||||
orgChild4Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgChild3"],
|
||||
});
|
||||
if (chk_SName3 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_SName4 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgChild4: { orgChild4ShortName: SName },
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgChild4"],
|
||||
});
|
||||
if (chk_SName4 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
if (posMaster.orgRootId != null) {
|
||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgRoot: { orgRootShortName: SName },
|
||||
orgChild1Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgRoot"],
|
||||
});
|
||||
if (chk_SName0 != 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(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
} else if (posMaster.orgChild3Id != null) {
|
||||
const chk_SName3 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgChild3: { orgChild3ShortName: SName },
|
||||
orgChild4Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgChild3"],
|
||||
});
|
||||
if (chk_SName3 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
} else if (posMaster.orgChild4Id != null) {
|
||||
const chk_SName4 = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgChild4: { orgChild4ShortName: SName },
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ["orgChild4"],
|
||||
});
|
||||
if (chk_SName4 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
|
|
@ -1065,7 +1067,7 @@ export class PositionController extends Controller {
|
|||
orgChild3Id: body.id,
|
||||
};
|
||||
if (!body.isAll) {
|
||||
checkChildConditions = {
|
||||
checkChildConditions = {
|
||||
orgChild4Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue