no message

This commit is contained in:
Kittapath 2024-04-29 16:01:47 +07:00
parent 73deeaab66
commit f612ecf0e2

View file

@ -1199,7 +1199,7 @@ export class PositionController extends Controller {
}, },
relations: ["posLevel", "posType", "posExecutive"], relations: ["posLevel", "posType", "posExecutive"],
order: { order: {
createdAt: "ASC" createdAt: "ASC",
}, },
}); });
@ -1589,7 +1589,7 @@ export class PositionController extends Controller {
]; ];
// let maxPosMasterNo = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterNo), 0); // let maxPosMasterNo = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterNo), 0);
let _shortName : string let _shortName: string;
let maxPosMasterOrder = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterOrder), 0); let maxPosMasterOrder = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterOrder), 0);
await Promise.all( await Promise.all(
posMasters.map(async (posMaster: any) => { posMasters.map(async (posMaster: any) => {
@ -1600,7 +1600,7 @@ export class PositionController extends Controller {
where: { id: requestBody.id }, where: { id: requestBody.id },
}); });
if (org != null) { if (org != null) {
_shortName = org.orgRootShortName _shortName = org.orgRootShortName;
const _posMaster = await this.posMasterRepository.findOne({ const _posMaster = await this.posMasterRepository.findOne({
where: { where: {
orgRootId: org.id, orgRootId: org.id,
@ -1634,7 +1634,7 @@ export class PositionController extends Controller {
where: { id: requestBody.id }, where: { id: requestBody.id },
}); });
if (org != null) { if (org != null) {
_shortName = org.orgChild1ShortName _shortName = org.orgChild1ShortName;
const _posMaster = await this.posMasterRepository.findOne({ const _posMaster = await this.posMasterRepository.findOne({
where: { where: {
orgChild1Id: org.id, orgChild1Id: org.id,
@ -1667,7 +1667,7 @@ export class PositionController extends Controller {
where: { id: requestBody.id }, where: { id: requestBody.id },
}); });
if (org != null) { if (org != null) {
_shortName = org.orgChild2ShortName _shortName = org.orgChild2ShortName;
const _posMaster = await this.posMasterRepository.findOne({ const _posMaster = await this.posMasterRepository.findOne({
where: { where: {
orgChild2Id: org.id, orgChild2Id: org.id,
@ -1699,7 +1699,7 @@ export class PositionController extends Controller {
where: { id: requestBody.id }, where: { id: requestBody.id },
}); });
if (org != null) { if (org != null) {
_shortName = org.orgChild3ShortName _shortName = org.orgChild3ShortName;
const _posMaster = await this.posMasterRepository.findOne({ const _posMaster = await this.posMasterRepository.findOne({
where: { where: {
orgChild3Id: org.id, orgChild3Id: org.id,
@ -1726,7 +1726,7 @@ export class PositionController extends Controller {
where: { id: requestBody.id }, where: { id: requestBody.id },
}); });
if (org != null) { if (org != null) {
_shortName = org.orgChild4ShortName _shortName = org.orgChild4ShortName;
const _posMaster = await this.posMasterRepository.findOne({ const _posMaster = await this.posMasterRepository.findOne({
where: { where: {
orgChild4Id: org.id, orgChild4Id: org.id,
@ -1754,15 +1754,15 @@ export class PositionController extends Controller {
where: { where: {
orgRevisionIsDraft: true, orgRevisionIsDraft: true,
orgRevisionIsCurrent: false, orgRevisionIsCurrent: false,
} },
}) });
const _orgRoot = await this.orgRootRepository.find({ const _orgRoot = await this.orgRootRepository.find({
where: { where: {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgRootShortName: _shortName, orgRootShortName: _shortName,
id: Not(requestBody.id), id: Not(requestBody.id),
} },
}) });
if (_orgRoot.length > 0) { if (_orgRoot.length > 0) {
for (const r of _orgRoot) { for (const r of _orgRoot) {
const _posMasterRoot = await this.posMasterRepository.findOne({ const _posMasterRoot = await this.posMasterRepository.findOne({
@ -1770,9 +1770,9 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgRootId: r.id, orgRootId: r.id,
orgChild1Id: IsNull() || "", orgChild1Id: IsNull() || "",
posMasterNo: posMaster.posMasterNo posMasterNo: posMaster.posMasterNo,
} },
}) });
if (_posMasterRoot != null) { if (_posMasterRoot != null) {
throw new HttpError( throw new HttpError(
HttpStatusCode.NOT_FOUND, HttpStatusCode.NOT_FOUND,
@ -1787,8 +1787,8 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild1ShortName: _shortName, orgChild1ShortName: _shortName,
id: Not(requestBody.id), id: Not(requestBody.id),
} },
}) });
if (_orgChild1.length > 0) { if (_orgChild1.length > 0) {
for (const c1 of _orgChild1) { for (const c1 of _orgChild1) {
const _posMasterChild1 = await this.posMasterRepository.findOne({ const _posMasterChild1 = await this.posMasterRepository.findOne({
@ -1796,9 +1796,9 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild1Id: c1.id, orgChild1Id: c1.id,
orgChild2Id: IsNull() || "", orgChild2Id: IsNull() || "",
posMasterNo: posMaster.posMasterNo posMasterNo: posMaster.posMasterNo,
} },
}) });
if (_posMasterChild1 != null) { if (_posMasterChild1 != null) {
throw new HttpError( throw new HttpError(
HttpStatusCode.NOT_FOUND, HttpStatusCode.NOT_FOUND,
@ -1813,8 +1813,8 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild2ShortName: _shortName, orgChild2ShortName: _shortName,
id: Not(requestBody.id), id: Not(requestBody.id),
} },
}) });
if (_orgChild2.length > 0) { if (_orgChild2.length > 0) {
for (const c2 of _orgChild2) { for (const c2 of _orgChild2) {
const _posMasterChild2 = await this.posMasterRepository.findOne({ const _posMasterChild2 = await this.posMasterRepository.findOne({
@ -1822,9 +1822,9 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild2Id: c2.id, orgChild2Id: c2.id,
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
posMasterNo: posMaster.posMasterNo posMasterNo: posMaster.posMasterNo,
} },
}) });
if (_posMasterChild2 != null) { if (_posMasterChild2 != null) {
throw new HttpError( throw new HttpError(
HttpStatusCode.NOT_FOUND, HttpStatusCode.NOT_FOUND,
@ -1839,8 +1839,8 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild3ShortName: _shortName, orgChild3ShortName: _shortName,
id: Not(requestBody.id), id: Not(requestBody.id),
} },
}) });
if (_orgChild3.length > 0) { if (_orgChild3.length > 0) {
for (const c3 of _orgChild3) { for (const c3 of _orgChild3) {
const _posMasterChild3 = await this.posMasterRepository.findOne({ const _posMasterChild3 = await this.posMasterRepository.findOne({
@ -1848,9 +1848,9 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild3Id: c3.id, orgChild3Id: c3.id,
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
posMasterNo: posMaster.posMasterNo posMasterNo: posMaster.posMasterNo,
} },
}) });
if (_posMasterChild3 != null) { if (_posMasterChild3 != null) {
throw new HttpError( throw new HttpError(
HttpStatusCode.NOT_FOUND, HttpStatusCode.NOT_FOUND,
@ -1865,17 +1865,17 @@ export class PositionController extends Controller {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild4ShortName: _shortName, orgChild4ShortName: _shortName,
id: Not(requestBody.id), id: Not(requestBody.id),
} },
}) });
if (_orgChild4.length > 0) { if (_orgChild4.length > 0) {
for (const c4 of _orgChild4) { for (const c4 of _orgChild4) {
const _posMasterChild4 = await this.posMasterRepository.findOne({ const _posMasterChild4 = await this.posMasterRepository.findOne({
where: { where: {
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
orgChild4Id: c4.id, orgChild4Id: c4.id,
posMasterNo: posMaster.posMasterNo posMasterNo: posMaster.posMasterNo,
} },
}) });
if (_posMasterChild4 != null) { if (_posMasterChild4 != null) {
throw new HttpError( throw new HttpError(
HttpStatusCode.NOT_FOUND, HttpStatusCode.NOT_FOUND,
@ -2462,7 +2462,17 @@ export class PositionController extends Controller {
* *
*/ */
@Post("placement/search") @Post("placement/search")
async searchPlacement(@Body() body: { node: number; nodeId: string; position: string }) { async searchPlacement(
@Body()
body: {
node: number;
nodeId: string;
position: string;
typeCommand: string;
posType: string;
posLevel: string;
},
) {
let typeCondition: any = {}; let typeCondition: any = {};
if (body.node === 0) { if (body.node === 0) {