แก้ไขเก็บประวัติ

This commit is contained in:
kittapath 2024-09-04 21:20:50 +07:00
parent 88920d92e6
commit 4056a2aa7f
6 changed files with 19 additions and 58 deletions

View file

@ -94,7 +94,7 @@ export class ProfileAddressController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,
@ -135,7 +135,7 @@ export class ProfileAddressController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,

View file

@ -98,7 +98,7 @@ export class ProfileAddressEmployeeController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,
@ -139,7 +139,7 @@ export class ProfileAddressEmployeeController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,

View file

@ -98,7 +98,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,
@ -139,7 +139,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
"currentDistrict", "currentDistrict",
"currentSubDistrict", "currentSubDistrict",
], ],
order: { createdAt: "ASC" }, order: { createdAt: "DESC" },
}); });
const _record = record.map((item) => ({ const _record = record.map((item) => ({
id: item.id, id: item.id,

View file

@ -2389,11 +2389,12 @@ export class ProfileController extends Controller {
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
Object.assign(record, body); Object.assign(record, body);
record.createdUserId = request.user.sub;
record.createdFullName = request.user.name;
record.createdAt = new Date();
record.lastUpdateUserId = request.user.sub; record.lastUpdateUserId = request.user.sub;
record.lastUpdateFullName = request.user.name; record.lastUpdateFullName = request.user.name;
record.lastUpdatedAt = new Date(); record.lastUpdatedAt = new Date();
record.dateRetire = calculateRetireDate(record.birthDate);
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileHistory(), { Object.assign(new ProfileHistory(), {
...record, ...record,

View file

@ -62,11 +62,9 @@ import {
} from "../entities/ProfileEmployeeEmployment"; } from "../entities/ProfileEmployeeEmployment";
import { ProfileEmployeeEmploymentHistory } from "../entities/ProfileEmployeeEmploymentHistory"; import { ProfileEmployeeEmploymentHistory } from "../entities/ProfileEmployeeEmploymentHistory";
import CallAPI from "../interfaces/call-api"; import CallAPI from "../interfaces/call-api";
import { EmployeePosition } from "../entities/EmployeePosition";
import { ProfileInsignia } from "../entities/ProfileInsignia"; import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { request } from "axios";
@Route("api/v1/org/profile-employee") @Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee") @Tags("ProfileEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -82,7 +80,6 @@ export class ProfileEmployeeController extends Controller {
private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory); private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory);
private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel); private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel);
private posTypeRepo = AppDataSource.getRepository(EmployeePosType); private posTypeRepo = AppDataSource.getRepository(EmployeePosType);
private positionRepository = AppDataSource.getRepository(EmployeePosition);
private provinceRepository = AppDataSource.getRepository(Province); private provinceRepository = AppDataSource.getRepository(Province);
private districtRepository = AppDataSource.getRepository(District); private districtRepository = AppDataSource.getRepository(District);
private subDistrict = AppDataSource.getRepository(SubDistrict); private subDistrict = AppDataSource.getRepository(SubDistrict);
@ -673,13 +670,12 @@ export class ProfileEmployeeController extends Controller {
} }
Object.assign(record, body); Object.assign(record, body);
record.createdUserId = request.user.sub;
record.createdFullName = request.user.name;
record.createdAt = new Date();
record.lastUpdateUserId = request.user.sub; record.lastUpdateUserId = request.user.sub;
record.lastUpdateFullName = request.user.name; record.lastUpdateFullName = request.user.name;
record.lastUpdatedAt = new Date(); record.lastUpdatedAt = new Date();
record.dateRetire = calculateRetireDate(record.birthDate);
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
record.citizenId = Extension.CheckCitizen(record.citizenId);
record.employeeClass = record.employeeClass.toLocaleUpperCase();
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileEmployeeHistory(), { Object.assign(new ProfileEmployeeHistory(), {
...record, ...record,
@ -2798,18 +2794,6 @@ export class ProfileEmployeeController extends Controller {
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
? null ? null
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id); : item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
const position =
posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null ||
item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length ==
0 ||
item.current_holders
.find((x) => x.orgRevisionId == findRevision.id)
?.positions?.find((position) => position.positionIsSelected == true) == null
? null
: item.current_holders
.find((x) => x.orgRevisionId == findRevision.id)
?.positions?.find((position) => position.positionIsSelected == true);
// const posExecutive = // const posExecutive =
// position == null || // position == null ||
// item.current_holders // item.current_holders
@ -2978,11 +2962,6 @@ export class ProfileEmployeeController extends Controller {
} }
await this.profileRepo.save(profile); await this.profileRepo.save(profile);
const profileSalary = await this.salaryRepository.findOne({
where: { profileEmployeeId: id },
order: { createdAt: "DESC" },
});
return new HttpSuccess(); return new HttpSuccess();
} }
@ -3333,7 +3312,7 @@ export class ProfileEmployeeController extends Controller {
refCommandNo: v.refCommandNo, refCommandNo: v.refCommandNo,
templateDoc: v.templateDoc, templateDoc: v.templateDoc,
}) })
.then(async (x) => { .then(async () => {
profile.statusTemp = "DONE"; profile.statusTemp = "DONE";
profile.employeeClass = "PERM"; profile.employeeClass = "PERM";
const _null: any = null; const _null: any = null;
@ -3346,7 +3325,7 @@ export class ProfileEmployeeController extends Controller {
positionId: profile.positionIdTemp, positionId: profile.positionIdTemp,
profileId: profile.id, profileId: profile.id,
}) })
.then(async (x) => {}); .then(async () => {});
} }
}), }),
); );

View file

@ -81,7 +81,6 @@ export class ProfileEmployeeTempController extends Controller {
private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory); private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory);
private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel); private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel);
private posTypeRepo = AppDataSource.getRepository(EmployeePosType); private posTypeRepo = AppDataSource.getRepository(EmployeePosType);
private positionRepository = AppDataSource.getRepository(EmployeePosition);
private provinceRepository = AppDataSource.getRepository(Province); private provinceRepository = AppDataSource.getRepository(Province);
private districtRepository = AppDataSource.getRepository(District); private districtRepository = AppDataSource.getRepository(District);
private subDistrict = AppDataSource.getRepository(SubDistrict); private subDistrict = AppDataSource.getRepository(SubDistrict);
@ -670,13 +669,12 @@ export class ProfileEmployeeTempController extends Controller {
} }
Object.assign(record, body); Object.assign(record, body);
record.createdUserId = request.user.sub;
record.createdFullName = request.user.name;
record.createdAt = new Date();
record.lastUpdateUserId = request.user.sub; record.lastUpdateUserId = request.user.sub;
record.lastUpdateFullName = request.user.name; record.lastUpdateFullName = request.user.name;
record.lastUpdatedAt = new Date(); record.lastUpdatedAt = new Date();
record.dateRetire = calculateRetireDate(record.birthDate);
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
record.citizenId = Extension.CheckCitizen(record.citizenId);
record.employeeClass = record.employeeClass.toLocaleUpperCase();
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileEmployeeHistory(), { Object.assign(new ProfileEmployeeHistory(), {
...record, ...record,
@ -2703,18 +2701,6 @@ export class ProfileEmployeeTempController extends Controller {
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
? null ? null
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id); : item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
const position =
posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null ||
item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length ==
0 ||
item.current_holders
.find((x) => x.orgRevisionId == findRevision.id)
?.positions?.find((position) => position.positionIsSelected == true) == null
? null
: item.current_holders
.find((x) => x.orgRevisionId == findRevision.id)
?.positions?.find((position) => position.positionIsSelected == true);
// const posExecutive = // const posExecutive =
// position == null || // position == null ||
// item.current_holders // item.current_holders
@ -2883,11 +2869,6 @@ export class ProfileEmployeeTempController extends Controller {
} }
await this.profileRepo.save(profile); await this.profileRepo.save(profile);
const profileSalary = await this.salaryRepository.findOne({
where: { profileEmployeeId: id },
order: { createdAt: "DESC" },
});
return new HttpSuccess(); return new HttpSuccess();
} }
@ -3206,7 +3187,7 @@ export class ProfileEmployeeTempController extends Controller {
refCommandNo: v.refCommandNo, refCommandNo: v.refCommandNo,
templateDoc: v.templateDoc, templateDoc: v.templateDoc,
}) })
.then(async (x) => { .then(async () => {
profile.statusTemp = "DONE"; profile.statusTemp = "DONE";
profile.employeeClass = "PERM"; profile.employeeClass = "PERM";
const _null: any = null; const _null: any = null;
@ -3219,7 +3200,7 @@ export class ProfileEmployeeTempController extends Controller {
positionId: profile.positionIdTemp, positionId: profile.positionIdTemp,
profileId: profile.id, profileId: profile.id,
}) })
.then(async (x) => {}); .then(async () => {});
} }
}), }),
); );