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