บรรจุ
This commit is contained in:
parent
31b8116a6f
commit
d999c8050c
3 changed files with 379 additions and 34 deletions
|
|
@ -79,6 +79,12 @@ import { ProfileAssistance } from "../entities/ProfileAssistance";
|
|||
import { ProfileAssistanceHistory } from "../entities/ProfileAssistanceHistory";
|
||||
import { ProfileActposition } from "../entities/ProfileActposition";
|
||||
import { ProfileActpositionHistory } from "../entities/ProfileActpositionHistory";
|
||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
||||
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
||||
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
|
||||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
||||
|
||||
@Route("api/v1/org/command")
|
||||
@Tags("Command")
|
||||
|
|
@ -122,6 +128,12 @@ export class CommandController extends Controller {
|
|||
private assistanceHistoryRepository = AppDataSource.getRepository(ProfileAssistanceHistory);
|
||||
private actpositionRepository = AppDataSource.getRepository(ProfileActposition);
|
||||
private actpositionHistoryRepository = AppDataSource.getRepository(ProfileActpositionHistory);
|
||||
private profileFamilyCoupleRepo = AppDataSource.getRepository(ProfileFamilyCouple);
|
||||
private profileFamilyCoupleHistoryRepo = AppDataSource.getRepository(ProfileFamilyCoupleHistory);
|
||||
private profileFamilyMotherRepo = AppDataSource.getRepository(ProfileFamilyMother);
|
||||
private profileFamilyMotherHistoryRepo = AppDataSource.getRepository(ProfileFamilyMotherHistory);
|
||||
private profileFamilyFatherRepo = AppDataSource.getRepository(ProfileFamilyFather);
|
||||
private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory);
|
||||
|
||||
/**
|
||||
* API list รายการคำสั่ง
|
||||
|
|
@ -2121,7 +2133,7 @@ export class CommandController extends Controller {
|
|||
})
|
||||
.then(async (res) => {})
|
||||
.catch(() => {});
|
||||
let order =
|
||||
let order =
|
||||
command.commandRecives == null || command.commandRecives.length <= 0
|
||||
? 0
|
||||
: command.commandRecives[0].order;
|
||||
|
|
@ -2160,8 +2172,7 @@ export class CommandController extends Controller {
|
|||
commandRecive.amountSpecial =
|
||||
item.amountSpecial ?? (salaryData ? salaryData.amountSpecial : _setZero);
|
||||
commandRecive.positionSalaryAmount =
|
||||
item.positionSalaryAmount ??
|
||||
(salaryData ? salaryData.positionSalaryAmount : _setZero);
|
||||
item.positionSalaryAmount ?? (salaryData ? salaryData.positionSalaryAmount : _setZero);
|
||||
commandRecive.mouthSalaryAmount =
|
||||
item.mouthSalaryAmount ?? (salaryData ? salaryData.mouthSalaryAmount : _setZero);
|
||||
} else {
|
||||
|
|
@ -2171,8 +2182,7 @@ export class CommandController extends Controller {
|
|||
commandRecive.mouthSalaryAmount = _null;
|
||||
}
|
||||
|
||||
commandRecive.remarkVertical =
|
||||
item.remarkVertical == null ? _null : item.remarkVertical;
|
||||
commandRecive.remarkVertical = item.remarkVertical == null ? _null : item.remarkVertical;
|
||||
commandRecive.remarkHorizontal =
|
||||
item.remarkHorizontal == null ? _null : item.remarkHorizontal;
|
||||
commandRecive.order = order;
|
||||
|
|
@ -3288,7 +3298,17 @@ export class CommandController extends Controller {
|
|||
const checkUser = await getUserByUsername(profile.citizenId);
|
||||
//ถ้ายังไม่มี user keycloak ให้สร้างใหม่
|
||||
if (checkUser.length == 0) {
|
||||
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
let password = profile.citizenId;
|
||||
if (profile.birthDate != null) {
|
||||
const gregorianYear = profile.birthDate.getFullYear() + 543;
|
||||
|
||||
const formattedDate =
|
||||
profile.birthDate.toISOString().slice(8, 10) +
|
||||
profile.birthDate.toISOString().slice(5, 7) +
|
||||
gregorianYear;
|
||||
password = formattedDate;
|
||||
}
|
||||
userKeycloakId = await createUser(profile.citizenId, password, {
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
});
|
||||
|
|
@ -4746,6 +4766,28 @@ export class CommandController extends Controller {
|
|||
posmasterId: string;
|
||||
positionId: string;
|
||||
} | null;
|
||||
bodyMarry?: {
|
||||
marry?: boolean | null;
|
||||
marryPrefix?: string | null;
|
||||
marryFirstName?: string | null;
|
||||
marryLastName?: string | null;
|
||||
marryOccupation?: string | null;
|
||||
marryNationality?: string | null;
|
||||
} | null;
|
||||
bodyFather?: {
|
||||
fatherPrefix?: string | null;
|
||||
fatherFirstName?: string | null;
|
||||
fatherLastName?: string | null;
|
||||
fatherOccupation?: string | null;
|
||||
fatherNationality?: string | null;
|
||||
} | null;
|
||||
bodyMother?: {
|
||||
motherPrefix?: string | null;
|
||||
motherFirstName?: string | null;
|
||||
motherLastName?: string | null;
|
||||
motherOccupation?: string | null;
|
||||
motherNationality?: string | null;
|
||||
} | null;
|
||||
}[];
|
||||
},
|
||||
) {
|
||||
|
|
@ -4814,14 +4856,20 @@ export class CommandController extends Controller {
|
|||
let result: any;
|
||||
const checkUser = await getUserByUsername(item.bodyProfile.citizenId);
|
||||
if (checkUser.length == 0) {
|
||||
userKeycloakId = await createUser(
|
||||
item.bodyProfile.citizenId,
|
||||
item.bodyProfile.citizenId,
|
||||
{
|
||||
firstName: item.bodyProfile.firstName,
|
||||
lastName: item.bodyProfile.lastName,
|
||||
},
|
||||
);
|
||||
let password = item.bodyProfile.citizenId;
|
||||
if (item.bodyProfile.birthDate != null) {
|
||||
const gregorianYear = item.bodyProfile.birthDate.getFullYear() + 543;
|
||||
|
||||
const formattedDate =
|
||||
item.bodyProfile.birthDate.toISOString().slice(8, 10) +
|
||||
item.bodyProfile.birthDate.toISOString().slice(5, 7) +
|
||||
gregorianYear;
|
||||
password = formattedDate;
|
||||
}
|
||||
userKeycloakId = await createUser(item.bodyProfile.citizenId, password, {
|
||||
firstName: item.bodyProfile.firstName,
|
||||
lastName: item.bodyProfile.lastName,
|
||||
});
|
||||
result = await addUserRoles(
|
||||
userKeycloakId,
|
||||
list
|
||||
|
|
@ -4967,6 +5015,71 @@ export class CommandController extends Controller {
|
|||
}),
|
||||
);
|
||||
}
|
||||
|
||||
//FamilyCouple
|
||||
if (item.bodyMarry != null) {
|
||||
const profileCouple = new ProfileFamilyCouple();
|
||||
const data = {
|
||||
profileId: profile.id,
|
||||
couple: item.bodyMarry.marry,
|
||||
couplePrefix: item.bodyMarry.marryPrefix,
|
||||
coupleFirstName: item.bodyMarry.marryFirstName,
|
||||
coupleLastName: item.bodyMarry.marryLastName,
|
||||
coupleCareer: item.bodyMarry.marryOccupation,
|
||||
coupleLive: true,
|
||||
};
|
||||
Object.assign(profileCouple, { ...data, ...meta });
|
||||
const coupleHistory = new ProfileFamilyCoupleHistory();
|
||||
Object.assign(coupleHistory, { ...profileCouple, id: undefined });
|
||||
profileCouple.profileId = profile.id;
|
||||
await this.profileFamilyCoupleRepo.save(profileCouple, { data: req });
|
||||
setLogDataDiff(req, { before, after: profileCouple });
|
||||
coupleHistory.profileFamilyCoupleId = profileCouple.id;
|
||||
await this.profileFamilyCoupleHistoryRepo.save(coupleHistory, { data: req });
|
||||
}
|
||||
|
||||
//FamilyFather
|
||||
if (item.bodyFather != null) {
|
||||
const profileFather = new ProfileFamilyFather();
|
||||
const data = {
|
||||
profileId: profile.id,
|
||||
fatherPrefix: item.bodyFather.fatherPrefix,
|
||||
fatherFirstName: item.bodyFather.fatherFirstName,
|
||||
fatherLastName: item.bodyFather.fatherLastName,
|
||||
fatherCareer: item.bodyFather.fatherOccupation,
|
||||
fatherLive: true,
|
||||
};
|
||||
Object.assign(profileFather, { ...data, ...meta });
|
||||
const fatherHistory = new ProfileFamilyFatherHistory();
|
||||
Object.assign(fatherHistory, { ...profileFather, id: undefined });
|
||||
profileFather.profileId = profile.id;
|
||||
await this.profileFamilyFatherRepo.save(profileFather, { data: req });
|
||||
setLogDataDiff(req, { before, after: profileFather });
|
||||
fatherHistory.profileFamilyFatherId = profileFather.id;
|
||||
await this.profileFamilyFatherHistoryRepo.save(fatherHistory, { data: req });
|
||||
}
|
||||
|
||||
//FamilyMother
|
||||
if (item.bodyMother != null) {
|
||||
const profileMother = new ProfileFamilyMother();
|
||||
const data = {
|
||||
profileId: profile.id,
|
||||
motherPrefix: item.bodyMother.motherPrefix,
|
||||
motherFirstName: item.bodyMother.motherFirstName,
|
||||
motherLastName: item.bodyMother.motherLastName,
|
||||
motherCareer: item.bodyMother.motherOccupation,
|
||||
motherLive: true,
|
||||
};
|
||||
Object.assign(profileMother, { ...data, ...meta });
|
||||
const motherHistory = new ProfileFamilyMotherHistory();
|
||||
Object.assign(motherHistory, { ...profileMother, id: undefined });
|
||||
profileMother.profileId = profile.id;
|
||||
await this.profileFamilyMotherRepo.save(profileMother, { data: req });
|
||||
setLogDataDiff(req, { before, after: profileMother });
|
||||
motherHistory.profileFamilyMotherId = profileMother.id;
|
||||
await this.profileFamilyMotherHistoryRepo.save(motherHistory, { data: req });
|
||||
}
|
||||
|
||||
//Salary
|
||||
if (item.bodySalarys && item.bodySalarys != null) {
|
||||
const dest_item = await this.salaryRepo.findOne({
|
||||
|
|
@ -5293,7 +5406,17 @@ export class CommandController extends Controller {
|
|||
// Create Keycloak
|
||||
const checkUser = await getUserByUsername(profile.citizenId);
|
||||
if (checkUser.length == 0) {
|
||||
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
let password = profile.citizenId;
|
||||
if (profile.birthDate != null) {
|
||||
const gregorianYear = profile.birthDate.getFullYear() + 543;
|
||||
|
||||
const formattedDate =
|
||||
profile.birthDate.toISOString().slice(8, 10) +
|
||||
profile.birthDate.toISOString().slice(5, 7) +
|
||||
gregorianYear;
|
||||
password = formattedDate;
|
||||
}
|
||||
const userKeycloakId = await createUser(profile.citizenId, password, {
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
// email: profile.email,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue