fix bug
This commit is contained in:
parent
748c89294b
commit
c76473527f
1 changed files with 78 additions and 80 deletions
|
|
@ -621,17 +621,16 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||
SName = orgRoot.orgRootShortName;
|
||||
}
|
||||
// let fullPosMasterNo = String((requestBody.posMasterNoPrefix).trim() + (requestBody.posMasterNo) + (requestBody.posMasterNoSuffix).trim());
|
||||
// let searchShortName = `CONCAT(posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
|
||||
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,
|
||||
|
|
@ -702,84 +701,83 @@ export class PositionController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
let fullPosName = String((requestBody.posMasterNoPrefix).trim() + (requestBody.posMasterNo) + (requestBody.posMasterNoSuffix).trim());
|
||||
let filterName = `CONCAT(posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
|
||||
const chk_FullName0 = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.from("posMaster", "posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
.andWhere("posMaster.orgRootShortName = :orgRootShortName", { orgRootShortName: SName })
|
||||
.andWhere("posMaster.orgChild1Id IS NULL")
|
||||
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
if (chk_FullName0 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_FullName1 = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.from("posMaster", "posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
.andWhere("posMaster.orgChild1ShortName = :orgChild1ShortName", { orgChild1ShortName: SName })
|
||||
.andWhere("posMaster.orgChild2Id IS NULL")
|
||||
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
if (chk_FullName1 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_FullName2 = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.from("posMaster", "posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
.andWhere("posMaster.orgChild2ShortName = :orgChild2ShortName", { orgChild2ShortName: SName })
|
||||
.andWhere("posMaster.orgChild3Id IS NULL")
|
||||
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
if (chk_FullName2 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_FullName3 = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.from("posMaster", "posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
.andWhere("posMaster.orgChild3ShortName = :orgChild3ShortName", { orgChild3ShortName: SName })
|
||||
.andWhere("posMaster.orgChild4Id IS NULL")
|
||||
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
if (chk_FullName3 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const chk_FullName4 = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.from("posMaster", "posMaster")
|
||||
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
.andWhere("posMaster.orgChild4ShortName = :orgChild4ShortName", { orgChild4ShortName: SName })
|
||||
.andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
if (chk_FullName4 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
// let fullPosRootName = `CONCAT(posMaster.orgRootShortName).trim() + (requestBody.posMasterNo))`;
|
||||
// let filterRootName = `CONCAT(posMaster.orgRootShortName,posMaster.posMasterNo)`;
|
||||
|
||||
// const chk_FullName0 = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .from("posMaster", "posMaster")
|
||||
// .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
// .andWhere("posMaster.orgRootShortName = :orgRootShortName", { orgRootShortName: SName })
|
||||
// .andWhere("posMaster.orgChild1Id IS NULL")
|
||||
// .andWhere(`${filterRootName} = :fullPosRootName`, { fullPosRootName });
|
||||
|
||||
// if (chk_FullName0 != null) {
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
// "ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
// );
|
||||
// }
|
||||
|
||||
// const chk_FullName1 = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .from("posMaster", "posMaster")
|
||||
// .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
// .andWhere("posMaster.orgChild1ShortName = :orgChild1ShortName", { orgChild1ShortName: SName })
|
||||
// .andWhere("posMaster.orgChild2Id IS NULL")
|
||||
// .andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
// if (chk_FullName1 != null) {
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
// "ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
// );
|
||||
// }
|
||||
|
||||
// const chk_FullName2 = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .from("posMaster", "posMaster")
|
||||
// .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
// .andWhere("posMaster.orgChild2ShortName = :orgChild2ShortName", { orgChild2ShortName: SName })
|
||||
// .andWhere("posMaster.orgChild3Id IS NULL")
|
||||
// .andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
// if (chk_FullName2 != null) {
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
// "ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
// );
|
||||
// }
|
||||
|
||||
// const chk_FullName3 = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .from("posMaster", "posMaster")
|
||||
// .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
// .andWhere("posMaster.orgChild3ShortName = :orgChild3ShortName", { orgChild3ShortName: SName })
|
||||
// .andWhere("posMaster.orgChild4Id IS NULL")
|
||||
// .andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
// if (chk_FullName3 != null) {
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
// "ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
// );
|
||||
// }
|
||||
|
||||
// const chk_FullName4 = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .from("posMaster", "posMaster")
|
||||
// .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: posMaster.orgRevisionId })
|
||||
// .andWhere("posMaster.orgChild4ShortName = :orgChild4ShortName", { orgChild4ShortName: SName })
|
||||
// .andWhere(`${filterName} = :fullPosName`, { fullPosName });
|
||||
|
||||
// if (chk_FullName4 != null) {
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
// "ไม่สามารถเพิ่มชื่อตำแหน่งซ้ำกันได้",
|
||||
// );
|
||||
// }
|
||||
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -998,7 +996,7 @@ export class PositionController extends Controller {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue