diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index bdb64d72..47a0e4ec 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3456,9 +3456,11 @@ export class CommandController extends Controller { }[]; }, ) { + console.log("xxxxxxoxxx"); const roleKeycloak = await this.roleKeycloakRepo.findOne({ where: { name: Like("USER") }, }); + console.log("xxxxixxxxx"); await Promise.all( body.data.map(async (item) => { const before = null; @@ -3470,6 +3472,7 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }; + console.log("xxxxxxuxxx"); const _null: any = null; if (item.bodyProfile.posLevelId === "") item.bodyProfile.posLevelId = null; if (item.bodyProfile.posTypeId === "") item.bodyProfile.posTypeId = null; @@ -3479,6 +3482,7 @@ export class CommandController extends Controller { ) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้"); } + console.log("xxxxxyxxxx"); if ( item.bodyProfile.posTypeId && !(await this.posTypeRepo.findOneBy({ id: item.bodyProfile.posTypeId })) @@ -3490,7 +3494,9 @@ export class CommandController extends Controller { where: { citizenId: item.bodyProfile.citizenId }, relations: ["roleKeycloaks"], }); + console.log("xxxxxxtxxx"); if (!profile) { + console.log("xxxrxxxxxx"); profile = Object.assign({ ...item.bodyProfile, ...meta }); profile.dateRetire = item.bodyProfile.birthDate == null @@ -3507,9 +3513,11 @@ export class CommandController extends Controller { // if (typeof userKeycloakId !== "string") { // throw new Error(userKeycloakId.errorMessage); // } + console.log("xxxexxxxxx"); const list = await getRoles(); if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server."); + console.log("xxxxwxxxxx"); const result = await addUserRoles( userKeycloakId, list @@ -3519,6 +3527,7 @@ export class CommandController extends Controller { name: x.name, })), ); + console.log("xxxxxqxxxx"); // if (!result) throw new Error("Failed. Cannot set user's role."); profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : ""; profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : []; @@ -3527,11 +3536,16 @@ export class CommandController extends Controller { profile.amount = item.bodyProfile.amount ?? null; profile.amountSpecial = item.bodyProfile.amountSpecial ?? null; await this.profileRepository.save(profile); + console.log("xxxx'xxxxx"); setLogDataDiff(req, { before, after: profile }); + console.log("xxxxx;xxxx"); } + console.log("xxxxlxxxxx"); if (profile && profile.id) { + console.log("xxxxkxxxxx"); //Educations if (item.bodyEducations && item.bodyEducations.length > 0) { + console.log("xxxxxjxxxx"); await Promise.all( item.bodyEducations.map(async (education) => { const profileEdu = new ProfileEducation(); @@ -3547,8 +3561,10 @@ export class CommandController extends Controller { ); } + console.log("xxxxxxhxxx"); //Certificates if (item.bodyCertificates && item.bodyCertificates.length > 0) { + console.log("xxxxxgxxxx"); await Promise.all( item.bodyCertificates.map(async (cer) => { const profileCer = new ProfileCertificate(); @@ -3563,8 +3579,10 @@ export class CommandController extends Controller { }), ); } + console.log("xxxxxfxxxx"); //Salary if (item.bodySalarys && item.bodySalarys != null) { + console.log("xxxxdxxxxx"); const dest_item = await this.salaryRepo.findOne({ where: { profileId: profile.id }, order: { order: "DESC" }, @@ -3585,14 +3603,17 @@ export class CommandController extends Controller { salaryHistory.profileSalaryId = profileSal.id; await this.salaryHistoryRepo.save(salaryHistory, { data: req }); } + console.log("xxxxxxsxxx"); //Position if (item.bodyPosition && item.bodyPosition != null) { + console.log("xxxxaxxxxx"); const posMaster = await this.posMasterRepository.findOne({ where: { id: item.bodyPosition.posmasterId }, }); if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); + console.log("xxxxx/xxxx"); const posMasterOld = await this.posMasterRepository.findOne({ where: { current_holderId: profile.id, @@ -3601,6 +3622,7 @@ export class CommandController extends Controller { }); if (posMasterOld != null) posMasterOld.current_holderId = null; + console.log("xxxx.xxxxx"); const positionOld = await this.positionRepository.findOne({ where: { posMasterId: posMasterOld?.id, @@ -3612,6 +3634,7 @@ export class CommandController extends Controller { await this.positionRepository.save(positionOld); } + console.log("xxxx,xxxxx"); const checkPosition = await this.positionRepository.find({ where: { posMasterId: item.bodyPosition.posmasterId, @@ -3626,6 +3649,7 @@ export class CommandController extends Controller { await this.positionRepository.save(clearPosition); } + console.log("xxxxxmxxxx"); posMaster.current_holderId = profile.id; if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld); await this.posMasterRepository.save(posMaster); @@ -3636,7 +3660,9 @@ export class CommandController extends Controller { posMasterId: item.bodyPosition.posmasterId, }, }); + console.log("xxxxxnxxxx"); if (positionNew != null) { + console.log("xxxxbxxxxx"); positionNew.positionIsSelected = true; profile.posLevelId = positionNew.posLevelId; profile.posTypeId = positionNew.posTypeId; @@ -3646,10 +3672,14 @@ export class CommandController extends Controller { setLogDataDiff(req, { before, after: profile }); await this.positionRepository.save(positionNew, { data: req }); } + console.log("xxxxxvxxxx"); } + console.log("xxxxxvxxxx"); } + console.log("xxxxcxxxxx"); }), ); + console.log("xxxxxxxxxx"); return new HttpSuccess(); } @@ -4069,7 +4099,7 @@ export class CommandController extends Controller { commandYear: number; templateDoc: string | null; amount: Double | null; - amountSpecial?: Double | null, + amountSpecial?: Double | null; positionSalaryAmount: Double | null; mouthSalaryAmount: Double | null; }[];