no message
This commit is contained in:
parent
73deeaab66
commit
f612ecf0e2
1 changed files with 132 additions and 122 deletions
|
|
@ -823,79 +823,79 @@ export class PositionController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (posMaster.orgChild4Id != null) {
|
// if (posMaster.orgChild4Id != null) {
|
||||||
const chk_SName4 = await this.posMasterRepository.findOne({
|
const chk_SName4 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgChild4: { orgChild4ShortName: SName },
|
orgChild4: { orgChild4ShortName: SName },
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
id: Not(posMaster.id),
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chk_SName4 != null) {
|
if (chk_SName4 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// } else if (posMaster.orgChild3Id != null) {
|
// } else if (posMaster.orgChild3Id != null) {
|
||||||
const chk_SName3 = await this.posMasterRepository.findOne({
|
const chk_SName3 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgChild3: { orgChild3ShortName: SName },
|
orgChild3: { orgChild3ShortName: SName },
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
orgChild4Id: IsNull(),
|
orgChild4Id: IsNull(),
|
||||||
id: Not(posMaster.id),
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chk_SName3 != null) {
|
if (chk_SName3 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// } else if (posMaster.orgChild2Id != null) {
|
// } else if (posMaster.orgChild2Id != null) {
|
||||||
const chk_SName2 = await this.posMasterRepository.findOne({
|
const chk_SName2 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgChild2: { orgChild2ShortName: SName },
|
orgChild2: { orgChild2ShortName: SName },
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
orgChild3Id: IsNull(),
|
orgChild3Id: IsNull(),
|
||||||
id: Not(posMaster.id),
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chk_SName2 != null) {
|
if (chk_SName2 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// } else if (posMaster.orgChild1Id != null) {
|
// } else if (posMaster.orgChild1Id != null) {
|
||||||
const chk_SName1 = await this.posMasterRepository.findOne({
|
const chk_SName1 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgChild1: { orgChild1ShortName: SName },
|
orgChild1: { orgChild1ShortName: SName },
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
orgChild2Id: IsNull(),
|
orgChild2Id: IsNull(),
|
||||||
id: Not(posMaster.id),
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chk_SName1 != null) {
|
if (chk_SName1 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// } else if (posMaster.orgRootId != null) {
|
// } else if (posMaster.orgRootId != null) {
|
||||||
const chk_SName0 = await this.posMasterRepository.findOne({
|
const chk_SName0 = await this.posMasterRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRoot: { orgRootShortName: SName },
|
orgRoot: { orgRootShortName: SName },
|
||||||
posMasterNo: requestBody.posMasterNo,
|
posMasterNo: requestBody.posMasterNo,
|
||||||
orgChild1Id: IsNull(),
|
orgChild1Id: IsNull(),
|
||||||
id: Not(posMaster.id),
|
id: Not(posMaster.id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chk_SName0 != null) {
|
if (chk_SName0 != null) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
"ไม่สามารถแก้ไขชื่อตำแหน่งซ้ำกับข้อมูลที่มีอยู่แล้วได้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
|
|
@ -1198,8 +1198,8 @@ export class PositionController extends Controller {
|
||||||
posMasterId: posMaster.id,
|
posMasterId: posMaster.id,
|
||||||
},
|
},
|
||||||
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,26 +1754,26 @@ 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({
|
||||||
where: {
|
where: {
|
||||||
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,
|
||||||
`เลขที่ตำแหน่ง ${r.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
`เลขที่ตำแหน่ง ${r.orgRootShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||||
|
|
@ -1787,19 +1787,19 @@ 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({
|
||||||
where: {
|
where: {
|
||||||
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,
|
||||||
`เลขที่ตำแหน่ง ${c1.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
`เลขที่ตำแหน่ง ${c1.orgChild1ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||||
|
|
@ -1813,19 +1813,19 @@ 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({
|
||||||
where: {
|
where: {
|
||||||
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,
|
||||||
`เลขที่ตำแหน่ง ${c2.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
`เลขที่ตำแหน่ง ${c2.orgChild2ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||||
|
|
@ -1839,19 +1839,19 @@ 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({
|
||||||
where: {
|
where: {
|
||||||
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,
|
||||||
`เลขที่ตำแหน่ง ${c3.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
`เลขที่ตำแหน่ง ${c3.orgChild3ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||||
|
|
@ -1865,18 +1865,18 @@ 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,
|
||||||
`เลขที่ตำแหน่ง ${c4.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
`เลขที่ตำแหน่ง ${c4.orgChild4ShortName}${posMaster.posMasterNo} มีอยู่ในระบบอยู่แล้ว`,
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue