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