no message
This commit is contained in:
parent
6b2f1c99d8
commit
4ea60efd1a
1 changed files with 56 additions and 53 deletions
|
|
@ -413,35 +413,35 @@ export class PositionController extends Controller {
|
|||
orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
});
|
||||
SName = orgRoot.shortName;
|
||||
SName = orgRoot.shortName;
|
||||
if (!orgRoot) {
|
||||
let orgChild1: any = null;
|
||||
if (requestBody.orgChild1Id != null)
|
||||
orgChild1 = await this.child1Repository.findOne({
|
||||
where: { id: requestBody.orgChild1Id },
|
||||
});
|
||||
SName = orgChild1.shortName;
|
||||
SName = orgChild1.shortName;
|
||||
if (!orgChild1) {
|
||||
let orgChild2: any = null;
|
||||
if (requestBody.orgChild2Id != null)
|
||||
orgChild2 = await this.child2Repository.findOne({
|
||||
where: { id: requestBody.orgChild2Id },
|
||||
});
|
||||
SName = orgChild2.shortName;
|
||||
SName = orgChild2.shortName;
|
||||
if (!orgChild2) {
|
||||
let orgChild3: any = null;
|
||||
if (requestBody.orgChild3Id != null)
|
||||
orgChild3 = await this.child3Repository.findOne({
|
||||
where: { id: requestBody.orgChild3Id },
|
||||
});
|
||||
SName = orgChild3.shortName;
|
||||
SName = orgChild3.shortName;
|
||||
if (!orgChild3) {
|
||||
let orgChild4: any = null;
|
||||
if (requestBody.orgChild4Id != null)
|
||||
orgChild4 = await this.child4Repository.findOne({
|
||||
where: { id: requestBody.orgChild4Id },
|
||||
});
|
||||
SName = orgChild4.shortName;
|
||||
SName = orgChild4.shortName;
|
||||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||
} else {
|
||||
|
|
@ -607,9 +607,9 @@ export class PositionController extends Controller {
|
|||
orgChild1Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ['orgRoot'],
|
||||
relations: ["orgRoot"],
|
||||
});
|
||||
if (chk_SName0 != null){
|
||||
if (chk_SName0 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -623,9 +623,9 @@ export class PositionController extends Controller {
|
|||
orgChild2Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ['orgChild1'],
|
||||
relations: ["orgChild1"],
|
||||
});
|
||||
if (chk_SName1 != null){
|
||||
if (chk_SName1 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -639,9 +639,9 @@ export class PositionController extends Controller {
|
|||
orgChild3Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ['orgChild2'],
|
||||
relations: ["orgChild2"],
|
||||
});
|
||||
if (chk_SName2 != null){
|
||||
if (chk_SName2 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -655,9 +655,9 @@ export class PositionController extends Controller {
|
|||
orgChild4Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ['orgChild3'],
|
||||
relations: ["orgChild3"],
|
||||
});
|
||||
if (chk_SName3 != null){
|
||||
if (chk_SName3 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -670,9 +670,9 @@ export class PositionController extends Controller {
|
|||
orgChild4: { orgChild4ShortName: SName },
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
},
|
||||
relations: ['orgChild4'],
|
||||
relations: ["orgChild4"],
|
||||
});
|
||||
if (chk_SName4 != null){
|
||||
if (chk_SName4 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -689,9 +689,9 @@ export class PositionController extends Controller {
|
|||
const position = Object.assign(new Position());
|
||||
position.positionName = x.posDictName;
|
||||
position.positionField = x.posDictField;
|
||||
position.posTypeId = x.posTypeId;
|
||||
position.posLevelId = x.posLevelId;
|
||||
position.posExecutiveId = x.posExecutiveId;
|
||||
position.posTypeId = x.posTypeId == "" ? null : x.posTypeId;
|
||||
position.posLevelId = x.posLevelId == "" ? null : x.posLevelId;
|
||||
position.posExecutiveId = x.posExecutiveId == "" ? null : x.posExecutiveId;
|
||||
position.positionExecutiveField = x.posDictExecutiveField;
|
||||
position.positionArea = x.posDictArea;
|
||||
position.isSpecial = x.isSpecial;
|
||||
|
|
@ -761,35 +761,35 @@ export class PositionController extends Controller {
|
|||
orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
});
|
||||
SName = orgRoot.shortName;
|
||||
SName = orgRoot.shortName;
|
||||
if (!orgRoot) {
|
||||
let orgChild1: any = null;
|
||||
if (requestBody.orgChild1Id != null)
|
||||
orgChild1 = await this.child1Repository.findOne({
|
||||
where: { id: requestBody.orgChild1Id },
|
||||
});
|
||||
SName = orgChild1.shortName;
|
||||
SName = orgChild1.shortName;
|
||||
if (!orgChild1) {
|
||||
let orgChild2: any = null;
|
||||
if (requestBody.orgChild2Id != null)
|
||||
orgChild2 = await this.child2Repository.findOne({
|
||||
where: { id: requestBody.orgChild2Id },
|
||||
});
|
||||
SName = orgChild2.shortName;
|
||||
SName = orgChild2.shortName;
|
||||
if (!orgChild2) {
|
||||
let orgChild3: any = null;
|
||||
if (requestBody.orgChild3Id != null)
|
||||
orgChild3 = await this.child3Repository.findOne({
|
||||
where: { id: requestBody.orgChild3Id },
|
||||
});
|
||||
SName = orgChild3.shortName;
|
||||
SName = orgChild3.shortName;
|
||||
if (!orgChild3) {
|
||||
let orgChild4: any = null;
|
||||
if (requestBody.orgChild4Id != null)
|
||||
orgChild4 = await this.child4Repository.findOne({
|
||||
where: { id: requestBody.orgChild4Id },
|
||||
});
|
||||
SName = orgChild4.shortName;
|
||||
SName = orgChild4.shortName;
|
||||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||
} else {
|
||||
|
|
@ -909,11 +909,11 @@ export class PositionController extends Controller {
|
|||
orgChild1: { orgChild1ShortName: SName },
|
||||
orgChild2Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
id: Not(posMaster.id)
|
||||
id: Not(posMaster.id),
|
||||
},
|
||||
relations: ['orgChild1'],
|
||||
relations: ["orgChild1"],
|
||||
});
|
||||
if (chk_SName1 != null){
|
||||
if (chk_SName1 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -926,11 +926,11 @@ export class PositionController extends Controller {
|
|||
orgChild2: { orgChild2ShortName: SName },
|
||||
orgChild3Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
id: Not(posMaster.id)
|
||||
id: Not(posMaster.id),
|
||||
},
|
||||
relations: ['orgChild2'],
|
||||
relations: ["orgChild2"],
|
||||
});
|
||||
if (chk_SName2 != null){
|
||||
if (chk_SName2 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -943,11 +943,11 @@ export class PositionController extends Controller {
|
|||
orgChild3: { orgChild3ShortName: SName },
|
||||
orgChild4Id: IsNull(),
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
id: Not(posMaster.id)
|
||||
id: Not(posMaster.id),
|
||||
},
|
||||
relations: ['orgChild3'],
|
||||
relations: ["orgChild3"],
|
||||
});
|
||||
if (chk_SName3 != null){
|
||||
if (chk_SName3 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -959,11 +959,11 @@ export class PositionController extends Controller {
|
|||
orgRevisionId: posMaster.orgRevisionId,
|
||||
orgChild4: { orgChild4ShortName: SName },
|
||||
posMasterNo: requestBody.posMasterNo,
|
||||
id: Not(posMaster.id)
|
||||
id: Not(posMaster.id),
|
||||
},
|
||||
relations: ['orgChild4'],
|
||||
relations: ["orgChild4"],
|
||||
});
|
||||
if (chk_SName4 != null){
|
||||
if (chk_SName4 != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
|
|
@ -976,24 +976,27 @@ export class PositionController extends Controller {
|
|||
posMaster.lastUpdateFullName = request.user.name;
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
||||
requestBody.positions.forEach(async (x: any) => {
|
||||
const position = Object.assign(new Position());
|
||||
position.positionName = x.posDictName;
|
||||
position.positionField = x.posDictField;
|
||||
position.posTypeId = x.posTypeId;
|
||||
position.posLevelId = x.posLevelId;
|
||||
position.posExecutiveId = x.posExecutiveId;
|
||||
position.positionExecutiveField = x.posDictExecutiveField;
|
||||
position.positionArea = x.posDictArea;
|
||||
position.isSpecial = x.isSpecial;
|
||||
position.positionIsSelected = false;
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
await this.positionRepository.save(position);
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (x: any) => {
|
||||
const position = Object.assign(new Position());
|
||||
position.positionName = x.posDictName;
|
||||
position.positionField = x.posDictField;
|
||||
position.posTypeId = x.posTypeId == "" ? null : x.posTypeId;
|
||||
position.posLevelId = x.posLevelId == "" ? null : x.posLevelId;
|
||||
position.posExecutiveId = x.posExecutiveId == "" ? null : x.posExecutiveId;
|
||||
position.positionExecutiveField = x.posDictExecutiveField;
|
||||
position.positionArea = x.posDictArea;
|
||||
position.isSpecial = x.isSpecial;
|
||||
position.positionIsSelected = false;
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess(posMaster.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue